Skip to content

Commit be1428d

Browse files
committed
Validate AF_ALG RSA inputs
Require the ciphertext length to match the RSA modulus before copying into the AF_ALG Xilinx stack buffer, preventing oversized inputs from overflowing the aligned scratch space.
1 parent 11d2f48 commit be1428d

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

wolfcrypt/src/rsa.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2237,6 +2237,11 @@ static int wc_RsaFunctionSync(const byte* in, word32 inLen, byte* out,
22372237
ERROR_OUT(BAD_FUNC_ARG);
22382238
}
22392239

2240+
if (inLen != keyLen) {
2241+
WOLFSSL_MSG("Expected that inLen equals RSA key length");
2242+
ERROR_OUT(BAD_FUNC_ARG);
2243+
}
2244+
22402245
if ((keyBuf = (byte*)XMALLOC(keyLen * 2, key->heap, DYNAMIC_TYPE_KEY))
22412246
== NULL) {
22422247
ERROR_OUT(MEMORY_E);

0 commit comments

Comments
 (0)