[M487/NUC472] zeroize random data on the stack memory

pull/5454/head
cyliangtw 2017-11-09 16:01:14 +08:00
parent 76c2c19853
commit e252b10148
2 changed files with 2 additions and 2 deletions

View File

@ -92,10 +92,10 @@ int trng_get_bytes(trng_t *obj, uint8_t *output, size_t length, size_t *output_l
output += 32;
}
if( length > *output_length ) {
trng_zeroize(tmpBuff, sizeof(tmpBuff));
trng_get(tmpBuff);
memcpy(output, &tmpBuff, (length - *output_length));
*output_length = length;
trng_zeroize(tmpBuff, sizeof(tmpBuff));
}
return 0;

View File

@ -97,10 +97,10 @@ int trng_get_bytes(trng_t *obj, uint8_t *output, size_t length, size_t *output_l
output += 32;
}
if( length > *output_length ) {
trng_zeroize(tmpBuff, sizeof(tmpBuff));
trng_get(tmpBuff);
memcpy(output, &tmpBuff, (length - *output_length));
*output_length = length;
trng_zeroize(tmpBuff, sizeof(tmpBuff));
}
return 0;