mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Crypto: Fix one bug when use kernel ecdsa algorithm
@ 2023-05-10  7:51 yangmengfei1394
  2023-05-19  8:33 ` Herbert Xu
  2023-05-22  3:30 ` [PATCH] Crypto module : rearrange the default functions of akcipher yangmengfei1394
  0 siblings, 2 replies; 4+ messages in thread
From: yangmengfei1394 @ 2023-05-10  7:51 UTC (permalink / raw)
  To: herbert, davem; +Cc: linux-crypto, linux-kernel, ymf

From: ymf <yangmengfei1394@phytium.com.cn>

We are trying to use kernel ecdsa algorithm to sign something.
When we call the crypto_akcipher_set_priv_key function, the
system collapses because it comes to NULL pointer.We find out
kerenl ecdsa algorithm has not offered the set_priv_key function.
So we think it might be necessary to check whether set_priv_key is
available when crypto_akcipher_set_priv_key is called.

Signed-off-by: ymf <yangmengfei1394@phytium.com.cn>
---
 include/crypto/akcipher.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/crypto/akcipher.h b/include/crypto/akcipher.h
index f35fd653e4e5..a68f0e23bf89 100644
--- a/include/crypto/akcipher.h
+++ b/include/crypto/akcipher.h
@@ -459,7 +459,9 @@ static inline int crypto_akcipher_set_priv_key(struct crypto_akcipher *tfm,
 					       unsigned int keylen)
 {
 	struct akcipher_alg *alg = crypto_akcipher_alg(tfm);
-
-	return alg->set_priv_key(tfm, key, keylen);
+	if (likely(alg->set_priv_key != NULL))
+		return alg->set_priv_key(tfm, key, keylen);
+	else
+		return -EPERM;
 }
 #endif
-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-06-02 10:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH] Crypto module : rearrange the default functions of akcipher yangmengfei1394
2023-06-02 10:19   ` Herbert Xu

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®