From 6bfb53f084a25198835a50796eca83f463a0e7be Mon Sep 17 00:00:00 2001 From: Ruby Martin Date: Mon, 8 Jun 2026 17:22:23 -0600 Subject: [PATCH] Add pubKeySize check for SM3-with-SM2 --- wolfcrypt/src/asn.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 00be607506..664d7862f5 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -23380,6 +23380,10 @@ int ParseCertRelative(DecodedCert* cert, int type, int verify, void* cm, if (cert->extSubjKeyIdSet == 0 && cert->publicKey != NULL && cert->pubKeySize > 0) { if (cert->signatureOID == CTC_SM3wSM2) { + if (cert->pubKeySize < 65) { + WOLFSSL_ERROR_VERBOSE(BUFFER_E); + return BUFFER_E; + } /* TODO: GmSSL creates IDs this way but whole public key info * block should be hashed. */ ret = CalcHashId_ex(cert->publicKey + cert->pubKeySize - 65, 65,