diff --git a/wolfcrypt/src/tfm.c b/wolfcrypt/src/tfm.c index 6e3d2fe8b..373c9e85c 100644 --- a/wolfcrypt/src/tfm.c +++ b/wolfcrypt/src/tfm.c @@ -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; diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 534dedc43..6b802e356 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -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; }