mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 12:14:38 +02:00
wolfSSL_RAND_set_rand_method: Code review feedback
This commit is contained in:
11
src/ssl.c
11
src/ssl.c
@@ -13244,6 +13244,11 @@ int wolfSSL_Cleanup(void)
|
|||||||
|
|
||||||
#ifdef OPENSSL_EXTRA
|
#ifdef OPENSSL_EXTRA
|
||||||
wolfSSL_RAND_Cleanup();
|
wolfSSL_RAND_Cleanup();
|
||||||
|
|
||||||
|
if (wc_FreeMutex(&gRandMethodMutex) != 0)
|
||||||
|
ret = BAD_MUTEX_E;
|
||||||
|
else
|
||||||
|
gRandMethodsInit = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (wolfCrypt_Cleanup() != 0) {
|
if (wolfCrypt_Cleanup() != 0) {
|
||||||
@@ -17843,11 +17848,12 @@ size_t wolfSSL_get_client_random(const WOLFSSL* ssl, unsigned char* out,
|
|||||||
if (wolfSSL_RAND_InitMutex() == 0 && wc_LockMutex(&gRandMethodMutex) == 0) {
|
if (wolfSSL_RAND_InitMutex() == 0 && wc_LockMutex(&gRandMethodMutex) == 0) {
|
||||||
gRandMethods = methods;
|
gRandMethods = methods;
|
||||||
wc_UnLockMutex(&gRandMethodMutex);
|
wc_UnLockMutex(&gRandMethodMutex);
|
||||||
|
return WOLFSSL_SUCCESS;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
(void)methods;
|
(void)methods;
|
||||||
#endif
|
#endif
|
||||||
return WOLFSSL_SUCCESS;
|
return WOLFSSL_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns WOLFSSL_SUCCESS if the RNG has been seeded with enough data */
|
/* Returns WOLFSSL_SUCCESS if the RNG has been seeded with enough data */
|
||||||
@@ -17860,6 +17866,9 @@ size_t wolfSSL_get_client_random(const WOLFSSL* ssl, unsigned char* out,
|
|||||||
ret = gRandMethods->status();
|
ret = gRandMethods->status();
|
||||||
wc_UnLockMutex(&gRandMethodMutex);
|
wc_UnLockMutex(&gRandMethodMutex);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
ret = WOLFSSL_FAILURE;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
/* wolfCrypt provides enough seed internally, so return success */
|
/* wolfCrypt provides enough seed internally, so return success */
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user