Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions wolfcrypt/src/aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -4101,10 +4101,16 @@ static WARN_UNUSED_RESULT int wc_AesDecrypt(
int wc_AesSetKey(Aes* aes, const byte* userKey, word32 keylen,
const byte* iv, int dir)
{
if (aes == NULL || userKey == NULL) {
return BAD_FUNC_ARG;
}
if (keylen > sizeof(aes->key)) {
return BAD_FUNC_ARG;
}

return wc_AesSetKeyLocal(aes, userKey, keylen, iv, dir, 1);
}


int wc_AesSetKeyDirect(Aes* aes, const byte* userKey, word32 keylen,
const byte* iv, int dir)
{
Expand Down Expand Up @@ -5282,7 +5288,7 @@ int wc_AesSetIV(Aes* aes, const byte* iv)
{
int ret;

if (aes == NULL)
if (aes == NULL || out == NULL || in == NULL)
return BAD_FUNC_ARG;
VECTOR_REGISTERS_PUSH;
ret = wc_AesEncrypt(aes, in, out);
Expand Down
8 changes: 7 additions & 1 deletion wolfcrypt/src/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -752,12 +752,18 @@ int wc_RNG_TestSeed(const byte* seed, word32 seedSz)

/* Check the seed for duplicate words. */
word32 seedIdx = 0;
word32 scratchSz = min(SEED_BLOCK_SZ, seedSz - SEED_BLOCK_SZ);
word32 scratchSz = 0;

if (seed == NULL || seedSz < SEED_BLOCK_SZ)
return BAD_FUNC_ARG;

scratchSz = min(SEED_BLOCK_SZ, seedSz - SEED_BLOCK_SZ);

while (seedIdx < seedSz - SEED_BLOCK_SZ) {
if (ConstantCompare(seed + seedIdx,
seed + seedIdx + scratchSz,
(int)scratchSz) == 0) {

ret = DRBG_CONT_FAILURE;
}
seedIdx += SEED_BLOCK_SZ;
Expand Down