Validate NULL parameters in wc_AesCbcEncryptWithKey (F-1376)

wc_AesCbcEncryptWithKey did not check out/in/key/iv for NULL before calling
wc_AesSetKey/wc_AesCbcEncrypt, unlike its counterpart wc_AesCbcDecryptWithKey.
A NULL key can reach wc_AesSetKey implementations that XMEMCPY userKey without
a NULL guard (e.g. the STM32 path), causing a crash at the API boundary.

Add the same NULL guard wc_AesCbcDecryptWithKey uses.
This commit is contained in:
Juliusz Sosinowicz
2026-07-22 13:30:22 +02:00
parent e566531ff0
commit fb8efa4ec8
+4
View File
@@ -74,6 +74,10 @@ int wc_AesCbcEncryptWithKey(byte* out, const byte* in, word32 inSz,
int ret = 0;
WC_DECLARE_VAR(aes, Aes, 1, 0);
if (out == NULL || in == NULL || key == NULL || iv == NULL) {
return BAD_FUNC_ARG;
}
WC_ALLOC_VAR_EX(aes, Aes, 1, NULL, DYNAMIC_TYPE_TMP_BUFFER,
return MEMORY_E);