mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 20:24:39 +02:00
Merge pull request #3818 from dgarske/zd11760
Fix for InTime RTOS v5 random
This commit is contained in:
@@ -2236,19 +2236,35 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
|||||||
#elif defined(INTIME_RTOS)
|
#elif defined(INTIME_RTOS)
|
||||||
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
uint32_t randval;
|
||||||
|
word32 len;
|
||||||
(void)os;
|
|
||||||
|
|
||||||
if (output == NULL) {
|
if (output == NULL) {
|
||||||
return BUFFER_E;
|
return BUFFER_E;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Note: Investigate better solution */
|
#ifdef INTIMEVER
|
||||||
/* no return to check */
|
/* If INTIMEVER exists then it is INTIME RTOS v6 or later */
|
||||||
arc4random_buf(output, sz);
|
#define INTIME_RAND_FUNC arc4random
|
||||||
|
len = 4;
|
||||||
|
#else
|
||||||
|
/* v5 and older */
|
||||||
|
#define INTIME_RAND_FUNC rand
|
||||||
|
srand(time(0));
|
||||||
|
len = 2; /* don't use all 31 returned bits */
|
||||||
|
#endif
|
||||||
|
|
||||||
return ret;
|
while (sz > 0) {
|
||||||
|
if (sz < len)
|
||||||
|
len = sz;
|
||||||
|
randval = INTIME_RAND_FUNC();
|
||||||
|
XMEMCPY(output, &randval, len);
|
||||||
|
output += len;
|
||||||
|
sz -= len;
|
||||||
|
}
|
||||||
|
(void)os;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(WOLFSSL_WICED)
|
#elif defined(WOLFSSL_WICED)
|
||||||
|
Reference in New Issue
Block a user