Skip to content

Commit fca3028

Browse files
advance index past recipent set in non stream case too
1 parent 4e92920 commit fca3028

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

wolfcrypt/src/pkcs7.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12412,9 +12412,8 @@ int wc_PKCS7_DecodeEnvelopedData(wc_PKCS7* pkcs7, byte* in,
1241212412
int recipFound = 0;
1241312413
int ret, length = 0;
1241412414
word32 idx = 0;
12415-
#ifndef NO_PKCS7_STREAM
1241612415
word32 tmpIdx = 0;
12417-
#endif
12416+
word32 recipientSetSz = 0;
1241812417
word32 contentType = 0, encOID = 0;
1241912418
word32 decryptedKeySz = MAX_ENCRYPTED_KEY_SZ;
1242012419

@@ -12473,11 +12472,12 @@ int wc_PKCS7_DecodeEnvelopedData(wc_PKCS7* pkcs7, byte* in,
1247312472
if (decryptedKey == NULL)
1247412473
return MEMORY_E;
1247512474
wc_PKCS7_ChangeState(pkcs7, WC_PKCS7_ENV_2);
12476-
#ifndef NO_PKCS7_STREAM
1247712475
tmpIdx = idx;
12476+
recipientSetSz = (word32)ret;
12477+
#ifndef NO_PKCS7_STREAM
1247812478
pkcs7->stream->aad = decryptedKey;
1247912479
/* get the full recipient set */
12480-
pkcs7->stream->expected = (word32)ret;
12480+
pkcs7->stream->expected = recipientSetSz;
1248112481
pkcs7->stream->recipientSz = ret;
1248212482
#endif
1248312483
FALL_THROUGH;
@@ -12532,6 +12532,8 @@ int wc_PKCS7_DecodeEnvelopedData(wc_PKCS7* pkcs7, byte* in,
1253212532
pkcs7->stream->aadSz = decryptedKeySz;
1253312533
pkcs7->stream->expected = MAX_LENGTH_SZ + MAX_VERSION_SZ +
1253412534
ASN_TAG_SZ + MAX_LENGTH_SZ;
12535+
#else
12536+
idx = tmpIdx + recipientSetSz;
1253512537
#endif
1253612538
wc_PKCS7_ChangeState(pkcs7, WC_PKCS7_ENV_3);
1253712539
FALL_THROUGH;

0 commit comments

Comments
 (0)