Check that we don't run out of space for the RID structure

This commit is contained in:
Josh Holtrop
2025-07-24 15:52:34 -04:00
parent 71bd9e2f6e
commit 1226dedeb8

View File

@@ -18313,6 +18313,8 @@ static int test_wc_PKCS7_GetEnvelopedDataKariRid(void)
#if defined(HAVE_PKCS7)
#if defined(HAVE_ECC) && (!defined(NO_AES) || (!defined(NO_SHA) || \
!defined(NO_SHA256) || defined(WOLFSSL_SHA512)))
/* The kari-keyid-cms.msg generated by openssl has a 68 byte RID structure.
* Reserve a bit more than that in case it might grow. */
byte rid[256];
byte cms[1024];
XFILE cmsFile = XBADFILE;
@@ -18342,6 +18344,7 @@ static int test_wc_PKCS7_GetEnvelopedDataKariRid(void)
ret = wc_PKCS7_GetEnvelopedDataKariRid(cms, cmsSz, rid, &ridSz);
}
ExpectIntEQ(ret, 0);
ExpectIntLT(ridSz, sizeof(rid));
ExpectIntGT(ridSz, ridKeyIdentifierOffset);
/* The Subject Key Identifier hex file should have 2 hex characters for each
* byte of the key identifier in the returned recipient ID (rid), plus a