From: Weili Qian qianweili@huawei.com
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 821cb78..2f78a37 100644 --- a/src/uadk_rsa.c +++ b/src/uadk_rsa.c @@ -141,6 +141,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) @@ -1111,10 +1113,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; }