Skip to content

Commit 026c4bc

Browse files
Merge pull request #6902 from dgarske/various_20231020
Fixes for PKCS w/out RSA and Cert/CSR signing with unknown OID
2 parents a3ea84d + cf1dcdf commit 026c4bc

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

tests/api.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27647,6 +27647,7 @@ static int test_wc_PKCS7_EncodeDecodeEnvelopedData(void)
2764727647
tmpBytePtr = pkcs7->singleCert;
2764827648
pkcs7->singleCert = NULL;
2764927649
}
27650+
#ifndef NO_RSA
2765027651
#if defined(NO_PKCS7_STREAM)
2765127652
/* when none streaming mode is used and PKCS7 is in bad state buffer error
2765227653
* is returned from kari parse which gets set to bad func arg */
@@ -27658,6 +27659,7 @@ static int test_wc_PKCS7_EncodeDecodeEnvelopedData(void)
2765827659
(word32)sizeof(output), decoded, (word32)sizeof(decoded)),
2765927660
ASN_PARSE_E);
2766027661
#endif
27662+
#endif /* !NO_RSA */
2766127663
if (pkcs7 != NULL) {
2766227664
pkcs7->singleCert = tmpBytePtr;
2766327665
}

wolfcrypt/src/asn.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29007,6 +29007,12 @@ int AddSignature(byte* buf, int bodySz, const byte* sig, int sigSz,
2900729007
/* Set signature OID and signature data. */
2900829008
SetASN_OID(&dataASN[SIGASN_IDX_SIGALGO_OID], (word32)sigAlgoType,
2900929009
oidSigType);
29010+
if (dataASN[SIGASN_IDX_SIGALGO_OID].data.buffer.data == NULL) {
29011+
/* The OID was not found or compiled in! */
29012+
ret = ASN_UNKNOWN_OID_E;
29013+
}
29014+
}
29015+
if (ret == 0) {
2901029016
if (IsSigAlgoECC((word32)sigAlgoType)) {
2901129017
/* ECDSA and EdDSA doesn't have NULL tagged item. */
2901229018
dataASN[SIGASN_IDX_SIGALGO_NULL].noOut = 1;

0 commit comments

Comments
 (0)