@@ -1770,6 +1770,24 @@ WC_RNG* wc_rng_new(byte* nonce, word32 nonceSz, void* heap)
17701770}
17711771
17721772
1773+ WOLFSSL_ABI
1774+ WC_RNG * wc_rng_new_ex (byte * nonce , word32 nonceSz , void * heap , int devId )
1775+ {
1776+ WC_RNG * rng ;
1777+
1778+ rng = (WC_RNG * )XMALLOC (sizeof (WC_RNG ), heap , DYNAMIC_TYPE_RNG );
1779+ if (rng ) {
1780+ int error = _InitRng (rng , nonce , nonceSz , heap , devId ) != 0 ;
1781+ if (error ) {
1782+ XFREE (rng , heap , DYNAMIC_TYPE_RNG );
1783+ rng = NULL ;
1784+ }
1785+ }
1786+
1787+ return rng ;
1788+ }
1789+
1790+
17731791WOLFSSL_ABI
17741792void wc_rng_free (WC_RNG * rng )
17751793{
@@ -3777,6 +3795,28 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
37773795
37783796#elif defined(NO_DEV_RANDOM )
37793797
3798+ /* Allow bare-metal targets to use cryptoCb as seed provider */
3799+ #if defined(WOLF_CRYPTO_CB )
3800+
3801+ int wc_GenerateSeed (OS_Seed * os , byte * output , word32 sz )
3802+ {
3803+ int ret = WC_HW_E ;
3804+
3805+ #ifndef WOLF_CRYPTO_CB_FIND
3806+ if (os -> devId != INVALID_DEVID )
3807+ #endif
3808+ {
3809+ ret = wc_CryptoCb_RandomSeed (os , output , sz );
3810+ if (ret == CRYPTOCB_UNAVAILABLE ) {
3811+ ret = WC_HW_E ;
3812+ }
3813+ }
3814+
3815+ return ret ;
3816+ }
3817+
3818+ #else /* defined(WOLF_CRYPTO_CB)*/
3819+
37803820 #error "you need to write an os specific wc_GenerateSeed() here"
37813821
37823822 /*
@@ -3786,6 +3826,8 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
37863826 }
37873827 */
37883828
3829+ #endif /* !defined(WOLF_CRYPTO_CB) */
3830+
37893831#else
37903832
37913833 /* may block */
0 commit comments