From e252b1014880b1a49f5fd85b8932e204e324f1fd Mon Sep 17 00:00:00 2001 From: cyliangtw Date: Thu, 9 Nov 2017 16:01:14 +0800 Subject: [PATCH] [M487/NUC472] zeroize random data on the stack memory --- targets/TARGET_NUVOTON/TARGET_M480/trng_api.c | 2 +- targets/TARGET_NUVOTON/TARGET_NUC472/trng_api.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/targets/TARGET_NUVOTON/TARGET_M480/trng_api.c b/targets/TARGET_NUVOTON/TARGET_M480/trng_api.c index 82e5227d46..87f124801b 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/trng_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M480/trng_api.c @@ -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; diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/trng_api.c b/targets/TARGET_NUVOTON/TARGET_NUC472/trng_api.c index a8a9498284..a4210e2910 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/trng_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/trng_api.c @@ -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;