@@ -1770,6 +1770,26 @@ WC_RNG* wc_rng_new(byte* nonce, word32 nonceSz, void* heap)
17701770}
17711771
17721772
1773+ int wc_rng_new_ex (WC_RNG * * rng , byte * nonce , word32 nonceSz ,
1774+ void * heap , int devId )
1775+ {
1776+ int ret ;
1777+
1778+ * rng = (WC_RNG * )XMALLOC (sizeof (WC_RNG ), heap , DYNAMIC_TYPE_RNG );
1779+ if (* rng == NULL ) {
1780+ return MEMORY_E ;
1781+ }
1782+
1783+ ret = _InitRng (* rng , nonce , nonceSz , heap , devId );
1784+ if (ret != 0 ) {
1785+ XFREE (* rng , heap , DYNAMIC_TYPE_RNG );
1786+ * rng = NULL ;
1787+ }
1788+
1789+ return ret ;
1790+ }
1791+
1792+
17731793WOLFSSL_ABI
17741794void wc_rng_free (WC_RNG * rng )
17751795{
@@ -3777,6 +3797,28 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
37773797
37783798#elif defined(NO_DEV_RANDOM )
37793799
3800+ /* Allow bare-metal targets to use cryptoCb as seed provider */
3801+ #if defined(WOLF_CRYPTO_CB )
3802+
3803+ int wc_GenerateSeed (OS_Seed * os , byte * output , word32 sz )
3804+ {
3805+ int ret = WC_HW_E ;
3806+
3807+ #ifndef WOLF_CRYPTO_CB_FIND
3808+ if (os -> devId != INVALID_DEVID )
3809+ #endif
3810+ {
3811+ ret = wc_CryptoCb_RandomSeed (os , output , sz );
3812+ if (ret == CRYPTOCB_UNAVAILABLE ) {
3813+ ret = WC_HW_E ;
3814+ }
3815+ }
3816+
3817+ return ret ;
3818+ }
3819+
3820+ #else /* defined(WOLF_CRYPTO_CB)*/
3821+
37803822 #error "you need to write an os specific wc_GenerateSeed() here"
37813823
37823824 /*
@@ -3786,6 +3828,8 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
37863828 }
37873829 */
37883830
3831+ #endif /* !defined(WOLF_CRYPTO_CB) */
3832+
37893833#else
37903834
37913835 /* may block */
0 commit comments