Skip to content

Commit 871dc9c

Browse files
committed
Implement peer review feedback
1 parent a1645d6 commit 871dc9c

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

wolfcrypt/src/aes.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10643,11 +10643,6 @@ static WARN_UNUSED_RESULT int roll_auth(
1064310643
word32 remainder;
1064410644
int ret;
1064510645

10646-
/* Sanity check on authIn to prevent segfault in xorbuf() where
10647-
* variable 'in' is dereferenced as the mask 'm' in misc.c */
10648-
if (in == NULL)
10649-
return BAD_FUNC_ARG;
10650-
1065110646
/* encode the length in */
1065210647
if (inSz <= 0xFEFF) {
1065310648
authLenSz = 2;
@@ -10766,6 +10761,11 @@ int wc_AesCcmEncrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
1076610761
authTagSz > AES_BLOCK_SIZE)
1076710762
return BAD_FUNC_ARG;
1076810763

10764+
/* Sanity check on authIn to prevent segfault in xorbuf() where
10765+
* variable 'in' is dereferenced as the mask 'm' in misc.c */
10766+
if (authIn == NULL && authInSz > 0)
10767+
return BAD_FUNC_ARG;
10768+
1076910769
/* sanity check on tag size */
1077010770
if (wc_AesCcmCheckTagSize((int)authTagSz) != 0) {
1077110771
return BAD_FUNC_ARG;
@@ -10908,6 +10908,12 @@ int wc_AesCcmDecrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
1090810908
authTagSz > AES_BLOCK_SIZE)
1090910909
return BAD_FUNC_ARG;
1091010910

10911+
/* Sanity check on authIn to prevent segfault in xorbuf() where
10912+
* variable 'in' is dereferenced as the mask 'm' in misc.c */
10913+
if (authIn == NULL && authInSz > 0)
10914+
return BAD_FUNC_ARG;
10915+
10916+
1091110917
/* sanity check on tag size */
1091210918
if (wc_AesCcmCheckTagSize((int)authTagSz) != 0) {
1091310919
return BAD_FUNC_ARG;

0 commit comments

Comments
 (0)