Merge pull request #7039 from embhorn/zd17127

Check for neg size in fp_read_unsigned_bin
This commit is contained in:
Sean Parkinson 2023-12-08 07:44:09 +10:00 committed by GitHub
commit 61b0efce4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -4051,12 +4051,16 @@ int fp_read_unsigned_bin(fp_int *a, const unsigned char *b, int c)
/* zero the int */
fp_zero (a);
if (c < 0) {
return FP_VAL;
}
if (c == 0) {
return FP_OKAY;
}
/* if input b excess max, then truncate */
if (c > 0 && (word32)c > maxC) {
if ((word32)c > maxC) {
int excess = (c - maxC);
c -= excess;
b += excess;

View File

@ -16930,7 +16930,7 @@ static wc_test_ret_t rsa_decode_test(RsaKey* keyPub)
goto done;
}
ret = wc_RsaPublicKeyDecodeRaw(n, (word32)-1, e, sizeof(e), keyPub);
#if !defined(WOLFSSL_SP_MATH) & !defined(WOLFSSL_SP_MATH_ALL)
#if defined(USE_INTEGER_HEAP_MATH)
if (ret != 0)
#else
if (ret != ASN_GETINT_E)
@ -16944,11 +16944,12 @@ static wc_test_ret_t rsa_decode_test(RsaKey* keyPub)
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ret = wc_RsaPublicKeyDecodeRaw(n, sizeof(n), e, (word32)-1, keyPub);
#if !defined(WOLFSSL_SP_MATH) & !defined(WOLFSSL_SP_MATH_ALL)
if (ret != 0) {
#if defined(USE_INTEGER_HEAP_MATH)
if (ret != 0)
#else
if (ret != ASN_GETINT_E) {
if (ret != ASN_GETINT_E)
#endif
{
ret = WC_TEST_RET_ENC_EC(ret);
goto done;
}