Update some patch for uadk_engine from mainline. Signed-off-by: Yang Shen <shenyang39@huawei.com> (cherry picked from commit 6ae4d8c0999343eddb153c4e4e879a6b66ef528f)
53 lines
1.4 KiB
Diff
53 lines
1.4 KiB
Diff
From 623c8687b64381b0dc454ea2d2c81ee5f6bfdbc7 Mon Sep 17 00:00:00 2001
|
|
From: Weili Qian <qianweili@huawei.com>
|
|
Date: Tue, 26 Jul 2022 10:39:01 +0800
|
|
Subject: [PATCH 55/57] rsa: modify the default algorithm of keygen soft
|
|
algorithm
|
|
|
|
When the hardware algorithm execution fails, the engine needs to
|
|
switch to the soft algorithm execution, and the callback needs to
|
|
be modified to the soft algorithm to prevent it from being
|
|
re-transferred to the hardware interface.
|
|
|
|
Signed-off-by: Weili Qian <qianweili@huawei.com>
|
|
---
|
|
src/uadk_rsa.c | 11 +++++++++++
|
|
1 file changed, 11 insertions(+)
|
|
|
|
diff --git a/src/uadk_rsa.c b/src/uadk_rsa.c
|
|
index 7983bc0..03f2ce5 100644
|
|
--- a/src/uadk_rsa.c
|
|
+++ b/src/uadk_rsa.c
|
|
@@ -140,6 +140,8 @@ enum {
|
|
MAX_CODE,
|
|
};
|
|
|
|
+static int uadk_e_rsa_keygen(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
|
|
+
|
|
static int rsa_check_bit_useful(const int bits, int flen)
|
|
{
|
|
if (flen > bits)
|
|
@@ -1100,10 +1102,19 @@ err:
|
|
|
|
static int uadk_e_soft_rsa_keygen(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb)
|
|
{
|
|
+ const RSA_METHOD *default_meth = RSA_PKCS1_OpenSSL();
|
|
int ret;
|
|
|
|
+ if (!default_meth) {
|
|
+ fprintf(stderr, "failed to get soft method.\n");
|
|
+ return UADK_E_FAIL;
|
|
+ }
|
|
+
|
|
UNUSED(cb);
|
|
+ (void)RSA_meth_set_keygen(rsa_hw_meth,
|
|
+ RSA_meth_get_keygen(default_meth));
|
|
ret = RSA_generate_key_ex(rsa, bits, e, NULL);
|
|
+ (void)RSA_meth_set_keygen(rsa_hw_meth, uadk_e_rsa_keygen);
|
|
|
|
return ret;
|
|
}
|
|
--
|
|
2.27.0
|
|
|