forked from wolfSSL/wolfssl
Check for neg size in fp_read_unsigned_bin
This commit is contained in:
@ -4051,12 +4051,16 @@ int fp_read_unsigned_bin(fp_int *a, const unsigned char *b, int c)
|
|||||||
/* zero the int */
|
/* zero the int */
|
||||||
fp_zero (a);
|
fp_zero (a);
|
||||||
|
|
||||||
|
if (c < 0) {
|
||||||
|
return FP_VAL;
|
||||||
|
}
|
||||||
|
|
||||||
if (c == 0) {
|
if (c == 0) {
|
||||||
return FP_OKAY;
|
return FP_OKAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if input b excess max, then truncate */
|
/* if input b excess max, then truncate */
|
||||||
if (c > 0 && (word32)c > maxC) {
|
if ((word32)c > maxC) {
|
||||||
int excess = (c - maxC);
|
int excess = (c - maxC);
|
||||||
c -= excess;
|
c -= excess;
|
||||||
b += excess;
|
b += excess;
|
||||||
|
@ -16930,7 +16930,7 @@ static wc_test_ret_t rsa_decode_test(RsaKey* keyPub)
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
ret = wc_RsaPublicKeyDecodeRaw(n, (word32)-1, e, sizeof(e), keyPub);
|
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)
|
if (ret != 0)
|
||||||
#else
|
#else
|
||||||
if (ret != ASN_GETINT_E)
|
if (ret != ASN_GETINT_E)
|
||||||
@ -16944,11 +16944,12 @@ static wc_test_ret_t rsa_decode_test(RsaKey* keyPub)
|
|||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return WC_TEST_RET_ENC_EC(ret);
|
return WC_TEST_RET_ENC_EC(ret);
|
||||||
ret = wc_RsaPublicKeyDecodeRaw(n, sizeof(n), e, (word32)-1, keyPub);
|
ret = wc_RsaPublicKeyDecodeRaw(n, sizeof(n), e, (word32)-1, keyPub);
|
||||||
#if !defined(WOLFSSL_SP_MATH) & !defined(WOLFSSL_SP_MATH_ALL)
|
#if defined(USE_INTEGER_HEAP_MATH)
|
||||||
if (ret != 0) {
|
if (ret != 0)
|
||||||
#else
|
#else
|
||||||
if (ret != ASN_GETINT_E) {
|
if (ret != ASN_GETINT_E)
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
ret = WC_TEST_RET_ENC_EC(ret);
|
ret = WC_TEST_RET_ENC_EC(ret);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user