fix ed25519 sing msg test failure

better random number handling
This commit is contained in:
Hideki Miyazaki
2019-06-24 15:27:29 +09:00
parent f4548945f7
commit 1d9d9e2955
2 changed files with 13 additions and 4 deletions

View File

@ -2175,10 +2175,16 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
{
int i;
for (i = 0; i< sz; i++) {
output[i] = esp_random( );
word32 rand;
while (sz > 0) {
word32 len = sizeof(rand);
if (sz < len)
len = sz;
/* Get one random 32-bit word from hw RNG */
rand = esp_random( );
XMEMCPY(output, &rand, sz);
output += len;
sz -= len;
}
return 0;

View File

@ -752,6 +752,9 @@ static WC_INLINE int Sha512Final(wc_Sha512* sha512)
defined(NO_WOLFSSL_ESP32WROOM32_CRYPT_HASH)
ret = Transform_Sha512(sha512);
#else
if(sha512->ctx.mode == ESP32_SHA_INIT) {
esp_sha_try_hw_lock(&sha512->ctx);
}
ret = esp_sha512_process(sha512);
if(ret == 0 && sha512->ctx.mode == ESP32_SHA_SW){
ret = Transform_Sha512(sha512);