Skip to content

Commit fe932b8

Browse files
committed
fixup! csrv2multi: pending ca list
1 parent 9222cb1 commit fe932b8

9 files changed

Lines changed: 26 additions & 32 deletions

File tree

src/internal.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14130,7 +14130,7 @@ PRAGMA_GCC_DIAG_POP
1413014130
}
1413114131
#endif
1413214132
/* Parse Certificate */
14133-
ret = ParseCertRelativeEx(args->dCert, certType, verify, SSL_CM(ssl), extraSigners);
14133+
ret = ParseCertRelative(args->dCert, certType, verify, SSL_CM(ssl), extraSigners);
1413414134

1413514135
#if defined(HAVE_RPK)
1413614136
/* if cert type has negotiated with peer, confirm the cert received has
@@ -14961,6 +14961,7 @@ int ProcessPeerCerts(WOLFSSL* ssl, byte* input, word32* inOutIdx,
1496114961
s = MakeSigner(SSL_CM(ssl)->heap);
1496214962
if (s == NULL) {
1496314963
FreeDecodedCert(&dCertAdd);
14964+
FreeDer(&derBuffer);
1496414965
ret = MEMORY_E;
1496514966
goto exit_ppc;
1496614967
}
@@ -23254,7 +23255,7 @@ static int CreateOcspRequest(WOLFSSL* ssl, OcspRequest* request,
2325423255

2325523256
InitDecodedCert(cert, certData, length, ssl->heap);
2325623257
/* TODO: Setup async support here */
23257-
ret = ParseCertRelative(cert, CERT_TYPE, VERIFY, SSL_CM(ssl));
23258+
ret = ParseCertRelative(cert, CERT_TYPE, VERIFY, SSL_CM(ssl), NULL);
2325823259
if (ret != 0) {
2325923260
WOLFSSL_MSG("ParseCert failed");
2326023261
}

src/ocsp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ WOLFSSL_OCSP_CERTID* wolfSSL_OCSP_cert_to_id(
802802

803803
InitDecodedCert(cert, subject->derCert->buffer,
804804
subject->derCert->length, NULL);
805-
if (ParseCertRelative(cert, CERT_TYPE, VERIFY_OCSP, cm) != 0) {
805+
if (ParseCertRelative(cert, CERT_TYPE, VERIFY_OCSP, cm, NULL) != 0) {
806806
FreeDecodedCert(cert);
807807
goto out;
808808
}
@@ -892,7 +892,7 @@ int wolfSSL_OCSP_basic_verify(WOLFSSL_OCSP_BASICRESP *bs,
892892

893893
InitDecodedCert(cert, bs->cert, bs->certSz, NULL);
894894
certInit = 1;
895-
if (ParseCertRelative(cert, CERT_TYPE, VERIFY, st->cm) < 0)
895+
if (ParseCertRelative(cert, CERT_TYPE, VERIFY, st->cm, NULL) < 0)
896896
goto out;
897897

898898
if (!(flags & OCSP_NOCHECKS)) {

src/ssl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6211,7 +6211,7 @@ static int check_cert_key(DerBuffer* cert, DerBuffer* key, DerBuffer* altKey,
62116211
size = cert->length;
62126212
buff = cert->buffer;
62136213
InitDecodedCert_ex(der, buff, size, heap, devId);
6214-
if (ParseCertRelative(der, CERT_TYPE, NO_VERIFY, NULL) != 0) {
6214+
if (ParseCertRelative(der, CERT_TYPE, NO_VERIFY, NULL, NULL) != 0) {
62156215
FreeDecodedCert(der);
62166216
#ifdef WOLFSSL_SMALL_STACK
62176217
XFREE(der, heap, DYNAMIC_TYPE_DCERT);
@@ -13313,7 +13313,7 @@ size_t wolfSSL_get_client_random(const WOLFSSL* ssl, unsigned char* out,
1331313313
/* Create a DecodedCert object and copy fields into WOLFSSL_X509 object.
1331413314
*/
1331513315
InitDecodedCert(cert, (byte*)in, (word32)len, NULL);
13316-
if ((ret = ParseCertRelative(cert, CERT_TYPE, 0, NULL)) == 0) {
13316+
if ((ret = ParseCertRelative(cert, CERT_TYPE, 0, NULL, NULL)) == 0) {
1331713317
/* Check if x509 was not previously initialized by wolfSSL_X509_new() */
1331813318
if (x509->dynamicMemory != TRUE)
1331913319
InitX509(x509, 0, NULL);
@@ -17756,7 +17756,7 @@ WOLFSSL_X509* wolfSSL_get_chain_X509(WOLFSSL_X509_CHAIN* chain, int idx)
1775617756
InitDecodedCert(cert, chain->certs[idx].buffer,
1775717757
chain->certs[idx].length, NULL);
1775817758

17759-
if ((ret = ParseCertRelative(cert, CERT_TYPE, 0, NULL)) != 0) {
17759+
if ((ret = ParseCertRelative(cert, CERT_TYPE, 0, NULL, NULL)) != 0) {
1776017760
WOLFSSL_MSG("Failed to parse cert");
1776117761
}
1776217762
else {

src/ssl_certman.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ int CM_VerifyBuffer_ex(WOLFSSL_CERT_MANAGER* cm, const unsigned char* buff,
698698

699699
/* Parse DER into decoded certificate fields and verify signature
700700
* against a known CA. */
701-
ret = ParseCertRelative(cert, CERT_TYPE, VERIFY, cm);
701+
ret = ParseCertRelative(cert, CERT_TYPE, VERIFY, cm, NULL);
702702
}
703703

704704
#ifdef HAVE_CRL
@@ -1817,7 +1817,7 @@ int wolfSSL_CertManagerCheckCRL(WOLFSSL_CERT_MANAGER* cm,
18171817
InitDecodedCert(cert, der, (word32)sz, NULL);
18181818

18191819
/* Parse certificate and perform CRL checks. */
1820-
ret = ParseCertRelative(cert, CERT_TYPE, VERIFY_CRL, cm);
1820+
ret = ParseCertRelative(cert, CERT_TYPE, VERIFY_CRL, cm, NULL);
18211821
if (ret != 0) {
18221822
WOLFSSL_MSG("ParseCert failed");
18231823
}
@@ -2289,7 +2289,7 @@ int wolfSSL_CertManagerCheckOCSP(WOLFSSL_CERT_MANAGER* cm,
22892289
InitDecodedCert(cert, der, (word32)sz, NULL);
22902290

22912291
/* Parse certificate and perform CRL checks. */
2292-
ret = ParseCertRelative(cert, CERT_TYPE, VERIFY_OCSP, cm);
2292+
ret = ParseCertRelative(cert, CERT_TYPE, VERIFY_OCSP, cm, NULL);
22932293
if (ret != 0) {
22942294
WOLFSSL_MSG("ParseCert failed");
22952295
}

src/ssl_p7p12.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,7 +1932,7 @@ int wolfSSL_PKCS12_parse(WC_PKCS12* pkcs12, const char* psw,
19321932
DYNAMIC_TYPE_X509);
19331933
InitX509(x509, 1, heap);
19341934
InitDecodedCert(DeCert, current->buffer, current->bufferSz, heap);
1935-
if (ParseCertRelative(DeCert, CERT_TYPE, NO_VERIFY, NULL) != 0) {
1935+
if (ParseCertRelative(DeCert, CERT_TYPE, NO_VERIFY, NULL, NULL) != 0) {
19361936
WOLFSSL_MSG("Issue with parsing certificate");
19371937
FreeDecodedCert(DeCert);
19381938
wolfSSL_X509_free(x509);
@@ -2009,7 +2009,7 @@ int wolfSSL_PKCS12_parse(WC_PKCS12* pkcs12, const char* psw,
20092009
}
20102010
InitX509(*cert, 1, heap);
20112011
InitDecodedCert(DeCert, certData, certDataSz, heap);
2012-
if (ParseCertRelative(DeCert, CERT_TYPE, NO_VERIFY, NULL) != 0) {
2012+
if (ParseCertRelative(DeCert, CERT_TYPE, NO_VERIFY, NULL, NULL) != 0) {
20132013
WOLFSSL_MSG("Issue with parsing certificate");
20142014
}
20152015
if (CopyDecodedToX509(*cert, DeCert) != 0) {

src/x509.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3612,7 +3612,7 @@ static WOLFSSL_X509* d2i_X509orX509REQ(WOLFSSL_X509** x509,
36123612
#ifdef WOLFSSL_CERT_REQ
36133613
cert->isCSR = (byte)req;
36143614
#endif
3615-
if (ParseCertRelative(cert, type, 0, NULL) == 0) {
3615+
if (ParseCertRelative(cert, type, 0, NULL, NULL) == 0) {
36163616
newX509 = wolfSSL_X509_new_ex(heap);
36173617
if (newX509 != NULL) {
36183618
if (CopyDecodedToX509(newX509, cert) != 0) {
@@ -5254,7 +5254,7 @@ static WOLFSSL_X509* loadX509orX509REQFromBuffer(
52545254
#endif
52555255
{
52565256
InitDecodedCert(cert, der->buffer, der->length, NULL);
5257-
ret = ParseCertRelative(cert, type, 0, NULL);
5257+
ret = ParseCertRelative(cert, type, 0, NULL, NULL);
52585258
if (ret == 0) {
52595259
x509 = (WOLFSSL_X509*)XMALLOC(sizeof(WOLFSSL_X509), NULL,
52605260
DYNAMIC_TYPE_X509);
@@ -13403,7 +13403,7 @@ int wolfSSL_X509_check_host(WOLFSSL_X509 *x, const char *chk, size_t chklen,
1340313403
#endif
1340413404

1340513405
InitDecodedCert(dCert, x->derCert->buffer, x->derCert->length, NULL);
13406-
ret = ParseCertRelative(dCert, CERT_TYPE, 0, NULL);
13406+
ret = ParseCertRelative(dCert, CERT_TYPE, 0, NULL, NULL);
1340713407
if (ret != 0) {
1340813408
goto out;
1340913409
}
@@ -13474,7 +13474,7 @@ int wolfSSL_X509_check_ip_asc(WOLFSSL_X509 *x, const char *ipasc,
1347413474

1347513475
if (ret == WOLFSSL_SUCCESS) {
1347613476
InitDecodedCert(dCert, x->derCert->buffer, x->derCert->length, NULL);
13477-
ret = ParseCertRelative(dCert, CERT_TYPE, 0, NULL);
13477+
ret = ParseCertRelative(dCert, CERT_TYPE, 0, NULL, NULL);
1347813478
if (ret != 0) {
1347913479
ret = WOLFSSL_FAILURE;
1348013480
}
@@ -13613,7 +13613,7 @@ static int x509GetIssuerFromCM(WOLFSSL_X509 **issuer, WOLFSSL_CERT_MANAGER* cm,
1361313613

1361413614
/* Use existing CA retrieval APIs that use DecodedCert. */
1361513615
InitDecodedCert(cert, x->derCert->buffer, x->derCert->length, cm->heap);
13616-
if (ParseCertRelative(cert, CERT_TYPE, 0, NULL) == 0
13616+
if (ParseCertRelative(cert, CERT_TYPE, 0, NULL, NULL) == 0
1361713617
&& !cert->selfSigned) {
1361813618
#ifndef NO_SKID
1361913619
if (cert->extAuthKeyIdSet)

wolfcrypt/src/asn.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22501,7 +22501,7 @@ int ParseCert(DecodedCert* cert, int type, int verify, void* cm)
2250122501
char* ptr;
2250222502
#endif
2250322503

22504-
ret = ParseCertRelative(cert, type, verify, cm);
22504+
ret = ParseCertRelative(cert, type, verify, cm, NULL);
2250522505
if (ret < 0)
2250622506
return ret;
2250722507

@@ -23399,7 +23399,7 @@ Signer* findSignerByName(Signer *list, byte *hash)
2339923399
return NULL;
2340023400
}
2340123401

23402-
int ParseCertRelativeEx(DecodedCert* cert, int type, int verify, void* cm, Signer *extraCAList)
23402+
int ParseCertRelative(DecodedCert* cert, int type, int verify, void* cm, Signer *extraCAList)
2340323403
{
2340423404
int ret = 0;
2340523405
#ifndef WOLFSSL_ASN_TEMPLATE
@@ -24056,11 +24056,6 @@ int ParseCertRelativeEx(DecodedCert* cert, int type, int verify, void* cm, Signe
2405624056
return ret;
2405724057
}
2405824058

24059-
int ParseCertRelative(DecodedCert* cert, int type, int verify, void* cm)
24060-
{
24061-
return ParseCertRelativeEx(cert, type, verify, cm, NULL);
24062-
}
24063-
2406424059
int FillSigner(Signer* signer, DecodedCert* cert, int type, DerBuffer *der)
2406524060
{
2406624061
int ret = 0;
@@ -26681,7 +26676,7 @@ static int wc_SetCert_LoadDer(Cert* cert, const byte* der, word32 derSz,
2668126676
InitDecodedCert_ex((DecodedCert*)cert->decodedCert, der, derSz,
2668226677
cert->heap, devId);
2668326678
ret = ParseCertRelative((DecodedCert*)cert->decodedCert,
26684-
CERT_TYPE, 0, NULL);
26679+
CERT_TYPE, 0, NULL, NULL);
2668526680
if (ret >= 0) {
2668626681
cert->der = (byte*)der;
2668726682
}
@@ -32425,7 +32420,7 @@ static int SetAltNamesFromCert(Cert* cert, const byte* der, int derSz,
3242532420
#endif
3242632421

3242732422
InitDecodedCert_ex(decoded, der, (word32)derSz, NULL, devId);
32428-
ret = ParseCertRelative(decoded, CA_TYPE, NO_VERIFY, 0);
32423+
ret = ParseCertRelative(decoded, CA_TYPE, NO_VERIFY, 0, NULL);
3242932424

3243032425
if (ret < 0) {
3243132426
WOLFSSL_MSG("ParseCertRelative error");
@@ -32624,7 +32619,7 @@ static int SetNameFromCert(CertName* cn, const byte* der, int derSz, int devId)
3262432619
#endif
3262532620

3262632621
InitDecodedCert_ex(decoded, der, (word32)derSz, NULL, devId);
32627-
ret = ParseCertRelative(decoded, CA_TYPE, NO_VERIFY, 0);
32622+
ret = ParseCertRelative(decoded, CA_TYPE, NO_VERIFY, 0, NULL);
3262832623

3262932624
if (ret < 0) {
3263032625
WOLFSSL_MSG("ParseCertRelative error");
@@ -36561,7 +36556,7 @@ static int DecodeBasicOcspResponse(byte* source, word32* ioIndex,
3656136556
cert_inited = 1;
3656236557

3656336558
/* Don't verify if we don't have access to Cert Manager. */
36564-
ret = ParseCertRelativeEx(cert, CERT_TYPE,
36559+
ret = ParseCertRelative(cert, CERT_TYPE,
3656536560
noVerify ? NO_VERIFY : VERIFY_OCSP_CERT,
3656636561
cm, resp->pendingCAs);
3656736562
if (ret < 0) {
@@ -36723,7 +36718,7 @@ static int DecodeBasicOcspResponse(byte* source, word32* ioIndex,
3672336718
certInit = 1;
3672436719
/* Parse the certificate and don't verify if we don't have access to
3672536720
* Cert Manager. */
36726-
ret = ParseCertRelativeEx(cert, CERT_TYPE, noVerify ? NO_VERIFY : VERIFY,
36721+
ret = ParseCertRelative(cert, CERT_TYPE, noVerify ? NO_VERIFY : VERIFY,
3672736722
cm, resp->pendingCAs);
3672836723
if (ret < 0) {
3672936724
WOLFSSL_MSG("\tOCSP Responder certificate parsing failed");

wolfcrypt/src/pkcs12.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ static WARN_UNUSED_RESULT int freeDecCertList(WC_DerCertList** list,
11261126
while (current != NULL) {
11271127

11281128
InitDecodedCert(DeCert, current->buffer, current->bufferSz, heap);
1129-
if (ParseCertRelative(DeCert, CERT_TYPE, NO_VERIFY, NULL) == 0) {
1129+
if (ParseCertRelative(DeCert, CERT_TYPE, NO_VERIFY, NULL, NULL) == 0) {
11301130
if (wc_CheckPrivateKeyCert(*pkey, *pkeySz, DeCert, 0) == 1) {
11311131
WOLFSSL_MSG("Key Pair found");
11321132
*cert = current->buffer;

wolfssl/wolfcrypt/asn.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2187,8 +2187,6 @@ WOLFSSL_LOCAL int CheckCSRSignaturePubKey(const byte* cert, word32 certSz,
21872187
WOLFSSL_ASN_API int AddSignature(byte* buf, int bodySz, const byte* sig, int sigSz,
21882188
int sigAlgoType);
21892189
WOLFSSL_LOCAL int ParseCertRelative(DecodedCert* cert, int type, int verify,
2190-
void* cm);
2191-
WOLFSSL_LOCAL int ParseCertRelativeEx(DecodedCert* cert, int type, int verify,
21922190
void* cm, Signer *extraCa);
21932191
WOLFSSL_LOCAL int DecodeToKey(DecodedCert* cert, int verify);
21942192
#ifdef WOLFSSL_ASN_TEMPLATE

0 commit comments

Comments
 (0)