From: Weili Qian qianweili@huawei.com
In asynchronous scenarios, if random numbers are obtained using uadk provider cipher, deadlocks may occur. Therefore, random numbers are obtained using default provider cipher.
logs like: 20808E99FFFF0000:error:1C8000B6:Provider routines:ossl_drbg_lock_parent: parent locking not enabled:providers/implementations/rands/drbg.c:70: 20808E99FFFF0000:error:1C8000C9:Provider routines:get_parent_strength: unable to lock parent:providers/implementations/rands/drbg.c:97: 20808E99FFFF0000:error:1C8000BD:Provider routines: ossl_prov_drbg_instantiate: error retrieving entropy: providers/implementations/rands/drbg.c:456: 20808E99FFFF0000:error:1C8000C0:Provider routines:ossl_prov_drbg_generate: in error state:providers/implementations/rands/drbg.c:630: 20808E99FFFF0000:error:030000D6:digital envelope routines: evp_rand_generate_locked:generate error:crypto/evp/evp_rand.c:560:
Signed-off-by: Weili Qian qianweili@huawei.com --- src/uadk_prov_init.c | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/src/uadk_prov_init.c b/src/uadk_prov_init.c index 9a2baeb..8616931 100644 --- a/src/uadk_prov_init.c +++ b/src/uadk_prov_init.c @@ -25,6 +25,7 @@ #include <openssl/crypto.h> #include <openssl/evp.h> #include <openssl/provider.h> +#include <openssl/rand.h>
#include "uadk_async.h" #include "uadk_prov.h" @@ -212,6 +213,14 @@ static const OSSL_ALGORITHM *uadk_query(void *provctx, int operation_id, * and overwrite the openssl.cnf property. */ EVP_set_default_properties(NULL, "?provider=uadk_provider"); + + /* + * In asynchronous scenarios, if random numbers are obtained using + * uadk provider cipher, deadlocks may occur. Therefore, random numbers are + * obtained using default provider cipher. + */ + (void)RAND_set_DRBG_type(prov_libctx_of(provctx), NULL, + "provider=default", NULL, NULL); }
*no_cache = 0;