From 4834e2d5cfd68ad6b6c8cd1eabfcdaee6022f01a Mon Sep 17 00:00:00 2001 From: lchristina26 Date: Mon, 4 Jan 2016 14:33:30 -0700 Subject: [PATCH] updates for VxWorks simulator entropy --- wolfcrypt/src/random.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c index 6456825b7..5c9f3579f 100644 --- a/wolfcrypt/src/random.c +++ b/wolfcrypt/src/random.c @@ -1265,17 +1265,29 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) return 0; } -#elif defined(WOLFSSL_VXWORKS) +#elif defined(WOLFSSL_VXWORKS) && defined(VXWORKS_SIM) #include int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) { STATUS status; + unsigned char seed[1024]; + int i = 0; + + /* cannot generate true entropy with VxWorks simulator */ + #warning "VxWorks simulator for testing purposes only!" + + 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); + } - /* RANDOM ENTORPY INJECT component must be enabled in VSB project */ status = randBytes (output, sz); if (status == ERROR) { - WOLFSSL_MSG("Random seed failed! Enable RANDOM ENTROPY INJECT."); return RNG_FAILURE_E; }