mirror of https://github.com/wolfSSL/wolfssl.git
add full support to wolfcrypt tests for random.c cryptocbs
parent
aa444c1b2c
commit
1a5064cf8c
|
@ -1770,6 +1770,24 @@ WC_RNG* wc_rng_new(byte* nonce, word32 nonceSz, void* heap)
|
|||
}
|
||||
|
||||
|
||||
WOLFSSL_ABI
|
||||
WC_RNG* wc_rng_new_ex(byte* nonce, word32 nonceSz, void* heap, int devId)
|
||||
{
|
||||
WC_RNG* rng;
|
||||
|
||||
rng = (WC_RNG*)XMALLOC(sizeof(WC_RNG), heap, DYNAMIC_TYPE_RNG);
|
||||
if (rng) {
|
||||
int error = _InitRng(rng, nonce, nonceSz, heap, devId) != 0;
|
||||
if (error) {
|
||||
XFREE(rng, heap, DYNAMIC_TYPE_RNG);
|
||||
rng = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return rng;
|
||||
}
|
||||
|
||||
|
||||
WOLFSSL_ABI
|
||||
void wc_rng_free(WC_RNG* rng)
|
||||
{
|
||||
|
@ -3777,6 +3795,28 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
|||
|
||||
#elif defined(NO_DEV_RANDOM)
|
||||
|
||||
/* Allow bare-metal targets to use cryptoCb as seed provider */
|
||||
#if defined(WOLF_CRYPTO_CB)
|
||||
|
||||
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
||||
{
|
||||
int ret = WC_HW_E;
|
||||
|
||||
#ifndef WOLF_CRYPTO_CB_FIND
|
||||
if (os->devId != INVALID_DEVID)
|
||||
#endif
|
||||
{
|
||||
ret = wc_CryptoCb_RandomSeed(os, output, sz);
|
||||
if (ret == CRYPTOCB_UNAVAILABLE) {
|
||||
ret = WC_HW_E;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#else /* defined(WOLF_CRYPTO_CB)*/
|
||||
|
||||
#error "you need to write an os specific wc_GenerateSeed() here"
|
||||
|
||||
/*
|
||||
|
@ -3786,6 +3826,8 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
|||
}
|
||||
*/
|
||||
|
||||
#endif /* !defined(WOLF_CRYPTO_CB) */
|
||||
|
||||
#else
|
||||
|
||||
/* may block */
|
||||
|
|
|
@ -15282,7 +15282,7 @@ static wc_test_ret_t random_rng_test(void)
|
|||
{
|
||||
byte nonce[8] = { 0 };
|
||||
/* Test dynamic RNG. */
|
||||
rng = wc_rng_new(nonce, (word32)sizeof(nonce), HEAP_HINT);
|
||||
rng = wc_rng_new_ex(nonce, (word32)sizeof(nonce), HEAP_HINT, devId);
|
||||
if (rng == NULL)
|
||||
return WC_TEST_RET_ENC_ERRNO;
|
||||
|
||||
|
|
|
@ -206,6 +206,7 @@ WOLFSSL_API int wc_GenerateSeed(OS_Seed* os, byte* seed, word32 sz);
|
|||
|
||||
|
||||
WOLFSSL_ABI WOLFSSL_API WC_RNG* wc_rng_new(byte* nonce, word32 nonceSz, void* heap);
|
||||
WOLFSSL_ABI WOLFSSL_API WC_RNG* wc_rng_new_ex(byte* nonce, word32 nonceSz, void* heap, int devId);
|
||||
WOLFSSL_ABI WOLFSSL_API void wc_rng_free(WC_RNG* rng);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue