From fca302839501cd793ebd0b4252827bcb62af3486 Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Fri, 3 Oct 2025 15:52:30 -0600 Subject: [PATCH] advance index past recipent set in non stream case too --- wolfcrypt/src/pkcs7.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/wolfcrypt/src/pkcs7.c b/wolfcrypt/src/pkcs7.c index b8ceb3ce9..2ca132181 100644 --- a/wolfcrypt/src/pkcs7.c +++ b/wolfcrypt/src/pkcs7.c @@ -12412,9 +12412,8 @@ int wc_PKCS7_DecodeEnvelopedData(wc_PKCS7* pkcs7, byte* in, int recipFound = 0; int ret, length = 0; word32 idx = 0; -#ifndef NO_PKCS7_STREAM word32 tmpIdx = 0; -#endif + word32 recipientSetSz = 0; word32 contentType = 0, encOID = 0; word32 decryptedKeySz = MAX_ENCRYPTED_KEY_SZ; @@ -12473,11 +12472,12 @@ int wc_PKCS7_DecodeEnvelopedData(wc_PKCS7* pkcs7, byte* in, if (decryptedKey == NULL) return MEMORY_E; wc_PKCS7_ChangeState(pkcs7, WC_PKCS7_ENV_2); - #ifndef NO_PKCS7_STREAM tmpIdx = idx; + recipientSetSz = (word32)ret; + #ifndef NO_PKCS7_STREAM pkcs7->stream->aad = decryptedKey; /* get the full recipient set */ - pkcs7->stream->expected = (word32)ret; + pkcs7->stream->expected = recipientSetSz; pkcs7->stream->recipientSz = ret; #endif FALL_THROUGH; @@ -12532,6 +12532,8 @@ int wc_PKCS7_DecodeEnvelopedData(wc_PKCS7* pkcs7, byte* in, pkcs7->stream->aadSz = decryptedKeySz; pkcs7->stream->expected = MAX_LENGTH_SZ + MAX_VERSION_SZ + ASN_TAG_SZ + MAX_LENGTH_SZ; + #else + idx = tmpIdx + recipientSetSz; #endif wc_PKCS7_ChangeState(pkcs7, WC_PKCS7_ENV_3); FALL_THROUGH;