forked from wolfSSL/wolfssl
aesccm_test(): test for (and require) BAD_FUNC_ARG when in or out pointer to wc_AesCcm{En,De}crypt() is null and inSz > 0.
This commit is contained in:
@@ -7985,8 +7985,8 @@ int wc_AesCcmDecrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
|
|||||||
const word32 wordSz = (word32)sizeof(word32);
|
const word32 wordSz = (word32)sizeof(word32);
|
||||||
|
|
||||||
/* sanity check on arguments */
|
/* sanity check on arguments */
|
||||||
if (aes == NULL || (inSz != 0 && (in == NULL || out == NULL)) || nonce == NULL
|
if (aes == NULL || (inSz != 0 && (in == NULL || out == NULL)) ||
|
||||||
|| authTag == NULL || nonceSz < 7 || nonceSz > 13 ||
|
nonce == NULL || authTag == NULL || nonceSz < 7 || nonceSz > 13 ||
|
||||||
authTagSz > AES_BLOCK_SIZE)
|
authTagSz > AES_BLOCK_SIZE)
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
|
|
||||||
|
@@ -10350,8 +10350,30 @@ WOLFSSL_TEST_SUBROUTINE int aesccm_test(void)
|
|||||||
if (XMEMCMP(pl, pl2, sizeof(pl2)))
|
if (XMEMCMP(pl, pl2, sizeof(pl2)))
|
||||||
ERROR_OUT(-6520, out);
|
ERROR_OUT(-6520, out);
|
||||||
|
|
||||||
/* test empty message as null input and output --
|
/* test empty message as null input or output with nonzero inSz. */
|
||||||
* must work, or fail early with BAD_FUNC_ARG.
|
result = wc_AesCcmEncrypt(enc, pl2 /* out */, NULL /* in */, 1 /* inSz */,
|
||||||
|
iv, sizeof(iv), t_empty2, sizeof(t_empty2),
|
||||||
|
a, sizeof(a));
|
||||||
|
if (result != BAD_FUNC_ARG)
|
||||||
|
ERROR_OUT(-6527, out);
|
||||||
|
result = wc_AesCcmEncrypt(enc, NULL /* out */, (const byte *)"" /* in */, 1 /* inSz */,
|
||||||
|
iv, sizeof(iv), t_empty2, sizeof(t_empty2),
|
||||||
|
a, sizeof(a));
|
||||||
|
if (result != BAD_FUNC_ARG)
|
||||||
|
ERROR_OUT(-6528, out);
|
||||||
|
result = wc_AesCcmDecrypt(enc, pl2, NULL /* in */, 1 /* inSz */,
|
||||||
|
iv, sizeof(iv), t_empty2, sizeof(t_empty2), a,
|
||||||
|
sizeof(a));
|
||||||
|
if (result != BAD_FUNC_ARG)
|
||||||
|
ERROR_OUT(-6529, out);
|
||||||
|
result = wc_AesCcmDecrypt(enc, NULL /* out */, (const byte *)"" /* in */, 1 /* inSz */,
|
||||||
|
iv, sizeof(iv), t_empty2, sizeof(t_empty2), a,
|
||||||
|
sizeof(a));
|
||||||
|
if (result != BAD_FUNC_ARG)
|
||||||
|
ERROR_OUT(-6530, out);
|
||||||
|
|
||||||
|
/* test empty message as null input and output with zero inSz --
|
||||||
|
* must either succeed, or fail early with BAD_FUNC_ARG.
|
||||||
*/
|
*/
|
||||||
result = wc_AesCcmEncrypt(enc, NULL /* out */, NULL /* in */, 0 /* inSz */,
|
result = wc_AesCcmEncrypt(enc, NULL /* out */, NULL /* in */, 0 /* inSz */,
|
||||||
iv, sizeof(iv), t_empty2, sizeof(t_empty2),
|
iv, sizeof(iv), t_empty2, sizeof(t_empty2),
|
||||||
|
Reference in New Issue
Block a user