Skip to content

Commit

Permalink
Added PKCS7 PEM support: "-----BEGIN PKCS7-----" and "-----END PKCS7-…
Browse files Browse the repository at this point in the history
…----"
  • Loading branch information
aidan garske committed Jul 2, 2024
1 parent 3206637 commit c065e4a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion wolfcrypt/src/asn.c
Original file line number Diff line number Diff line change
Expand Up @@ -24414,6 +24414,10 @@ wcchar END_ENC_PRIV_KEY = "-----END ENCRYPTED PRIVATE KEY-----";
wcchar END_EC_PARAM = "-----END EC PARAMETERS-----";
#endif
#endif
#ifdef HAVE_PKCS7
wcchar BEGIN_PKCS7 = "-----BEGIN PKCS7-----";
wcchar END_PKCS7 = "-----END PKCS7-----";
#endif
#if defined(HAVE_ECC) || defined(HAVE_ED25519) || defined(HAVE_ED448) || \
!defined(NO_DSA)
wcchar BEGIN_DSA_PRIV = "-----BEGIN DSA PRIVATE KEY-----";
Expand Down Expand Up @@ -24521,6 +24525,13 @@ int wc_PemGetHeaderFooter(int type, const char** header, const char** footer)
ret = 0;
break;
#endif
#ifdef HAVE_PKCS7
case PKCS7_TYPE:
if (header) *header = BEGIN_PKCS7;
if (footer) *footer = END_PKCS7;
ret = 0;
break;
#endif
#ifndef NO_DSA
case DSA_TYPE:
case DSA_PRIVATEKEY_TYPE:
Expand Down Expand Up @@ -25558,7 +25569,7 @@ int wc_CertPemToDer(const unsigned char* pem, int pemSz,
}

if (type != CERT_TYPE && type != CHAIN_CERT_TYPE && type != CA_TYPE &&
type != CERTREQ_TYPE) {
type != CERTREQ_TYPE && type != PKCS7_TYPE) {
WOLFSSL_MSG("Bad cert type");
return BAD_FUNC_ARG;
}
Expand Down
3 changes: 2 additions & 1 deletion wolfssl/wolfcrypt/asn_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ enum CertType {
SPHINCS_SMALL_LEVEL3_TYPE,
SPHINCS_SMALL_LEVEL5_TYPE,
ECC_PARAM_TYPE,
CHAIN_CERT_TYPE
CHAIN_CERT_TYPE,
PKCS7_TYPE
};


Expand Down

0 comments on commit c065e4a

Please sign in to comment.