Skip to content

Commit 11ddec3

Browse files
authored
Merge pull request #9681 from tmael/wfb1_
Fix cert SW issues in Aes and rng
2 parents e1e7c4d + 1c3816d commit 11ddec3

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

wolfcrypt/src/aes.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4101,10 +4101,16 @@ static WARN_UNUSED_RESULT int wc_AesDecrypt(
41014101
int wc_AesSetKey(Aes* aes, const byte* userKey, word32 keylen,
41024102
const byte* iv, int dir)
41034103
{
4104+
if (aes == NULL || userKey == NULL) {
4105+
return BAD_FUNC_ARG;
4106+
}
4107+
if (keylen > sizeof(aes->key)) {
4108+
return BAD_FUNC_ARG;
4109+
}
4110+
41044111
return wc_AesSetKeyLocal(aes, userKey, keylen, iv, dir, 1);
41054112
}
41064113

4107-
41084114
int wc_AesSetKeyDirect(Aes* aes, const byte* userKey, word32 keylen,
41094115
const byte* iv, int dir)
41104116
{
@@ -5282,7 +5288,7 @@ int wc_AesSetIV(Aes* aes, const byte* iv)
52825288
{
52835289
int ret;
52845290

5285-
if (aes == NULL)
5291+
if (aes == NULL || out == NULL || in == NULL)
52865292
return BAD_FUNC_ARG;
52875293
VECTOR_REGISTERS_PUSH;
52885294
ret = wc_AesEncrypt(aes, in, out);

wolfcrypt/src/random.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,12 +752,18 @@ int wc_RNG_TestSeed(const byte* seed, word32 seedSz)
752752

753753
/* Check the seed for duplicate words. */
754754
word32 seedIdx = 0;
755-
word32 scratchSz = min(SEED_BLOCK_SZ, seedSz - SEED_BLOCK_SZ);
755+
word32 scratchSz = 0;
756+
757+
if (seed == NULL || seedSz < SEED_BLOCK_SZ)
758+
return BAD_FUNC_ARG;
759+
760+
scratchSz = min(SEED_BLOCK_SZ, seedSz - SEED_BLOCK_SZ);
756761

757762
while (seedIdx < seedSz - SEED_BLOCK_SZ) {
758763
if (ConstantCompare(seed + seedIdx,
759764
seed + seedIdx + scratchSz,
760765
(int)scratchSz) == 0) {
766+
761767
ret = DRBG_CONT_FAILURE;
762768
}
763769
seedIdx += SEED_BLOCK_SZ;

0 commit comments

Comments
 (0)