Skip to content

Commit 63c0775

Browse files
siemen11nasahlpa
authored andcommitted
[crypto/aes_kwp] Max size for exp_pad
The aes_kwp checks that the padding length is above half a block size and then creates a variable length buffer exp_pad. Make that buffer the max size instead of a user chosen length. Signed-off-by: Siemen Dhooghe <sdhooghe@google.com>
1 parent 2dbfb16 commit 63c0775

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

sw/device/lib/crypto/impl/aes_kwp/aes_kwp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ status_t aes_kwp_unwrap(const aes_key_t kek, const uint32_t *ciphertext,
168168
// the prefix check. Otherwise it could expose a padding oracle, because
169169
// memcmp is not constant-time.
170170
if (pad_len != 0) {
171-
uint8_t exp_pad[pad_len];
172-
memset(exp_pad, 0, pad_len);
171+
uint8_t exp_pad[kSemiblockBytes];
172+
memset(exp_pad, 0, kSemiblockBytes);
173173
unsigned char *pad_start = ((unsigned char *)r) + plaintext_len;
174174
if (memcmp(pad_start, exp_pad, pad_len) != 0) {
175175
*success = kHardenedBoolFalse;

0 commit comments

Comments
 (0)