mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 04:04:39 +02:00
update random.c for better entropy with VXWORKS
This commit is contained in:
@@ -1271,20 +1271,10 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
|||||||
|
|
||||||
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) {
|
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) {
|
||||||
STATUS status;
|
STATUS status;
|
||||||
unsigned char seed[1024];
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
for (i = 0; i < sizeof(seed); i++) {
|
|
||||||
seed[i] = i * 3 % 256;
|
|
||||||
}
|
|
||||||
/* build entropy */
|
|
||||||
(void) randAdd(seed, 0, 0);
|
|
||||||
for (i = 4; i <= sizeof(seed); i*=2) {
|
|
||||||
(void) randAdd (seed, i - 1, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
status = randBytes (output, sz);
|
status = randBytes (output, sz);
|
||||||
if (status == ERROR) {
|
if (status == ERROR) {
|
||||||
|
printf("Random seed failed! Enable RANDOM ENTROPY INJECT.");
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user