Skip to content

Commit 7128932

Browse files
avoid attempt of key decode and free buffer if incorrect recipient found
1 parent fca3028 commit 7128932

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

wolfcrypt/src/pkcs7.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10488,6 +10488,14 @@ static int wc_PKCS7_DecryptKtri(wc_PKCS7* pkcs7, byte* in, word32 inSz,
1048810488
XMEMCPY(encryptedKey, &pkiMsg[*idx], (word32)encryptedKeySz);
1048910489
*idx += (word32)encryptedKeySz;
1049010490

10491+
/* If this is not the correct recipient then do not try to decode
10492+
* the encrypted key */
10493+
if (*recipFound == 0) {
10494+
XFREE(encryptedKey, pkcs7->heap, DYNAMIC_TYPE_WOLF_BIGINT);
10495+
ret = PKCS7_RECIP_E;
10496+
break;
10497+
}
10498+
1049110499
/* load private key */
1049210500
#ifdef WOLFSSL_SMALL_STACK
1049310501
privKey = (RsaKey*)XMALLOC(sizeof(RsaKey), pkcs7->heap,

0 commit comments

Comments
 (0)