From 9c4ef7cd30a4a2ce47045df2680f93f958875eb4 Mon Sep 17 00:00:00 2001 From: Eric Blankenhorn Date: Mon, 20 Jan 2025 08:40:36 -0600 Subject: [PATCH] Use BUFFER_E instead of ASN_PARSE_E when buffer is too small --- tests/api.c | 4 ++-- wolfcrypt/src/asn.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/api.c b/tests/api.c index 05ad9486fa..f29417c39e 100644 --- a/tests/api.c +++ b/tests/api.c @@ -26522,9 +26522,9 @@ static int test_wc_ecc_rs_to_sig(void) WC_NO_ERR_TRACE(ECC_BAD_ARG_E)); #if !defined(HAVE_SELFTEST) && !defined(HAVE_FIPS) ExpectIntEQ(wc_ecc_sig_to_rs(sig, siglen, r, &zeroLen, s, &slen), - WC_NO_ERR_TRACE(ASN_PARSE_E)); + WC_NO_ERR_TRACE(BUFFER_E)); ExpectIntEQ(wc_ecc_sig_to_rs(sig, siglen, r, &rlen, s, &zeroLen), - WC_NO_ERR_TRACE(ASN_PARSE_E)); + WC_NO_ERR_TRACE(BUFFER_E)); #endif #endif return EXPECT_RESULT(); diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 2f8b6b9116..63fb174ffc 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -1300,7 +1300,7 @@ static int GetASN_StoreData(const ASNItem* asn, ASNGetData* data, WOLFSSL_MSG_VSNPRINTF("Buffer too small for data: %d %d", len, *data->data.buffer.length); #endif - return ASN_PARSE_E; + return BUFFER_E; } /* Copy in data and record actual length seen. */ XMEMCPY(data->data.buffer.data, input + idx, (size_t)len); @@ -33784,7 +33784,7 @@ int DecodeECC_DSA_Sig_Bin(const byte* sig, word32 sigLen, byte* r, word32* rLen, *rLen = (word32)len; else { /* Buffer too small to hold r value */ - return ASN_PARSE_E; + return BUFFER_E; } } if (r) @@ -33798,8 +33798,8 @@ int DecodeECC_DSA_Sig_Bin(const byte* sig, word32 sigLen, byte* r, word32* rLen, if (*sLen >= (word32)len) *sLen = (word32)len; else { - /* Buffer too small to hold r value */ - return ASN_PARSE_E; + /* Buffer too small to hold s value */ + return BUFFER_E; } } if (s)