Skip to content

Commit e252b10

Browse files
committed
[M487/NUC472] zeroize random data on the stack memory
1 parent 76c2c19 commit e252b10

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

targets/TARGET_NUVOTON/TARGET_M480/trng_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ int trng_get_bytes(trng_t *obj, uint8_t *output, size_t length, size_t *output_l
9292
output += 32;
9393
}
9494
if( length > *output_length ) {
95-
trng_zeroize(tmpBuff, sizeof(tmpBuff));
9695
trng_get(tmpBuff);
9796
memcpy(output, &tmpBuff, (length - *output_length));
9897
*output_length = length;
98+
trng_zeroize(tmpBuff, sizeof(tmpBuff));
9999
}
100100

101101
return 0;

targets/TARGET_NUVOTON/TARGET_NUC472/trng_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ int trng_get_bytes(trng_t *obj, uint8_t *output, size_t length, size_t *output_l
9797
output += 32;
9898
}
9999
if( length > *output_length ) {
100-
trng_zeroize(tmpBuff, sizeof(tmpBuff));
101100
trng_get(tmpBuff);
102101
memcpy(output, &tmpBuff, (length - *output_length));
103102
*output_length = length;
103+
trng_zeroize(tmpBuff, sizeof(tmpBuff));
104104
}
105105

106106
return 0;

0 commit comments

Comments
 (0)