From: yangmengfei1394 <yangmengfei1394@phytium.com.cn>
To: herbert@gondor.apana.org.au, davem@davemloft.net
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
yangmengfei1394 <yangmengfei1394@phytium.com.cn>
Subject: [PATCH] Crypto module : rearrange the default functions of akcipher
Date: Mon, 22 May 2023 11:30:27 +0800 [thread overview]
Message-ID: <20230522033027.989-1-yangmengfei1394@phytium.com.cn> (raw)
In-Reply-To: <20230510075142.1638-1-yangmengfei1394@phytium.com.cn>
According to your last email, we rearrange the default functions,
move the code that sets the default functions from
crypto_register_akcipher into akcipher_prepare_alg,
add the set_pub_key function check at the same time.
Signed-off-by: yangmengfei1394 <yangmengfei1394@phytium.com.cn>
---
crypto/akcipher.c | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/crypto/akcipher.c b/crypto/akcipher.c
index 7960ceb528c3..45502446b231 100644
--- a/crypto/akcipher.c
+++ b/crypto/akcipher.c
@@ -126,19 +126,6 @@ struct crypto_akcipher *crypto_alloc_akcipher(const char *alg_name, u32 type,
}
EXPORT_SYMBOL_GPL(crypto_alloc_akcipher);
-static void akcipher_prepare_alg(struct akcipher_alg *alg)
-{
- struct crypto_istat_akcipher *istat = akcipher_get_stat(alg);
- struct crypto_alg *base = &alg->base;
-
- base->cra_type = &crypto_akcipher_type;
- base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK;
- base->cra_flags |= CRYPTO_ALG_TYPE_AKCIPHER;
-
- if (IS_ENABLED(CONFIG_CRYPTO_STATS))
- memset(istat, 0, sizeof(*istat));
-}
-
static int akcipher_default_op(struct akcipher_request *req)
{
return -ENOSYS;
@@ -150,8 +137,9 @@ static int akcipher_default_set_key(struct crypto_akcipher *tfm,
return -ENOSYS;
}
-int crypto_register_akcipher(struct akcipher_alg *alg)
+static void akcipher_prepare_alg(struct akcipher_alg *alg)
{
+ struct crypto_istat_akcipher *istat = akcipher_get_stat(alg);
struct crypto_alg *base = &alg->base;
if (!alg->sign)
@@ -164,6 +152,20 @@ int crypto_register_akcipher(struct akcipher_alg *alg)
alg->decrypt = akcipher_default_op;
if (!alg->set_priv_key)
alg->set_priv_key = akcipher_default_set_key;
+ if (!alg->set_pub_key)
+ alg->set_pub_key = akcipher_default_set_key;
+
+ base->cra_type = &crypto_akcipher_type;
+ base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK;
+ base->cra_flags |= CRYPTO_ALG_TYPE_AKCIPHER;
+
+ if (IS_ENABLED(CONFIG_CRYPTO_STATS))
+ memset(istat, 0, sizeof(*istat));
+}
+
+int crypto_register_akcipher(struct akcipher_alg *alg)
+{
+ struct crypto_alg *base = &alg->base;
akcipher_prepare_alg(alg);
return crypto_register_alg(base);
--
2.35.1.windows.2
next prev parent reply other threads:[~2023-05-22 3:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-10 7:51 [PATCH] Crypto: Fix one bug when use kernel ecdsa algorithm yangmengfei1394
2023-05-19 8:33 ` Herbert Xu
2023-05-22 3:30 ` yangmengfei1394 [this message]
2023-06-02 10:19 ` [PATCH] Crypto module : rearrange the default functions of akcipher Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230522033027.989-1-yangmengfei1394@phytium.com.cn \
--to=yangmengfei1394@phytium.com.cn \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®