From 1786cebf8c84861ea274642203b9d29bd1d52b52 Mon Sep 17 00:00:00 2001 From: Ruby Martin Date: Tue, 9 Jun 2026 10:43:33 -0600 Subject: [PATCH] add negative value check after wc_HashGetDigestSize --- wolfcrypt/src/asn.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 664d7862f5..910a318a5d 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -30236,11 +30236,16 @@ static int SetAuthKeyIdFromDcert(Cert* cert, DecodedCert* decoded) #if defined(WOLFSSL_SM2) && defined(WOLFSSL_SM3) cert->akidSz = wc_HashGetDigestSize(wc_HashTypeConvert(HashIdAlg( cert->sigType))); + if (cert->akidSz <= 0) { + ret = HASH_TYPE_E; + } #else cert->akidSz = KEYID_SIZE; #endif - /* Put the SKID of CA to AKID of certificate */ - XMEMCPY(cert->akid, decoded->extSubjKeyId, (size_t)cert->akidSz); + if (ret == 0) { + /* Put the SKID of CA to AKID of certificate */ + XMEMCPY(cert->akid, decoded->extSubjKeyId, (size_t)cert->akidSz); + } } return ret;