forked from wolfSSL/wolfssl
Support for more cert subject OIDs and raw subject access (#1734)
* Add businessCategory OID * Raw subject support methods * Support for jurisdiction OIDs * Wrap in WOLFSSL_CERT_EXT * Adding tests
This commit is contained in:
committed by
David Garske
parent
6d10efe79c
commit
bb574d28b2
@@ -335,6 +335,101 @@ WOLFSSL_API int wc_SetIssuer(Cert*, const char*);
|
||||
*/
|
||||
WOLFSSL_API int wc_SetSubject(Cert*, const char*);
|
||||
|
||||
|
||||
/*!
|
||||
\ingroup ASN
|
||||
|
||||
\brief This function sets the raw subject for a certificate from the
|
||||
subject in the provided der buffer. This method is used to set the raw
|
||||
subject field prior to signing.
|
||||
|
||||
\return 0 Returned on successfully setting the subject for the certificate
|
||||
\return MEMORY_E Returned if there is an error allocating memory
|
||||
with XMALLOC
|
||||
\return ASN_PARSE_E Returned if there is an error parsing the cert
|
||||
header file
|
||||
\return ASN_OBJECT_ID_E Returned if there is an error parsing the
|
||||
encryption type from the cert
|
||||
\return ASN_EXPECT_0_E Returned if there is a formatting error in the
|
||||
encryption specification of the cert file
|
||||
\return ASN_BEFORE_DATE_E Returned if the date is before the certificate
|
||||
start date
|
||||
\return ASN_AFTER_DATE_E Returned if the date is after the certificate
|
||||
expiration date
|
||||
\return ASN_BITSTR_E Returned if there is an error parsing a bit string
|
||||
from the certificate
|
||||
\return ASN_NTRU_KEY_E Returned if there is an error parsing the NTRU key
|
||||
from the certificate
|
||||
\return ECC_CURVE_OID_E Returned if there is an error parsing the ECC key
|
||||
from the certificate
|
||||
\return ASN_UNKNOWN_OID_E Returned if the certificate is using an unknown
|
||||
key object id
|
||||
\return ASN_VERSION_E Returned if the ALLOW_V1_EXTENSIONS option is not
|
||||
defined and the certificate is a V1 or V2 certificate
|
||||
\return BAD_FUNC_ARG Returned if there is an error processing the
|
||||
certificate extension
|
||||
\return ASN_CRIT_EXT_E Returned if an unfamiliar critical extension is
|
||||
encountered in processing the certificate
|
||||
\return ASN_SIG_OID_E Returned if the signature encryption type is not
|
||||
the same as the encryption type of the certificate in the provided file
|
||||
\return ASN_SIG_CONFIRM_E Returned if confirming the certification
|
||||
signature fails
|
||||
\return ASN_NAME_INVALID_E Returned if the certificate’s name is not
|
||||
permitted by the CA name constraints
|
||||
\return ASN_NO_SIGNER_E Returned if there is no CA signer to verify the
|
||||
certificate’s authenticity
|
||||
|
||||
\param cert pointer to the cert for which to set the raw subject
|
||||
\param der pointer to the buffer containing the der formatted certificate
|
||||
from which to grab the subject
|
||||
\param derSz size of the buffer containing the der formatted certificate
|
||||
from which to grab the subject
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Cert myCert;
|
||||
// initialize myCert
|
||||
byte* der;
|
||||
der = (byte*)malloc(FOURK_BUF);
|
||||
// initialize der
|
||||
if(wc_SetSubjectRaw(&myCert, der, FOURK_BUF) != 0) {
|
||||
// error setting subject
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_InitCert
|
||||
\sa wc_SetSubject
|
||||
*/
|
||||
WOLFSSL_API int wc_SetSubjectRaw(Cert* cert, const byte* der, int derSz);
|
||||
|
||||
/*!
|
||||
\ingroup ASN
|
||||
|
||||
\brief This function gets the raw subject from the certificate structure.
|
||||
|
||||
\return 0 Returned on successfully getting the subject from the certificate
|
||||
\return BAD_FUNC_ARG Returned if there is an error processing the
|
||||
certificate extension
|
||||
|
||||
\param subjectRaw pointer-pointer to the raw subject upon successful return
|
||||
\param cert pointer to the cert from which to get the raw subject
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Cert myCert;
|
||||
byte *subjRaw;
|
||||
// initialize myCert
|
||||
|
||||
if(wc_GetSubjectRaw(&subjRaw, &myCert) != 0) {
|
||||
// error setting subject
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_InitCert
|
||||
\sa wc_SetSubjectRaw
|
||||
*/
|
||||
WOLFSSL_API int wc_GetSubjectRaw(byte **subjectRaw, Cert *cert);
|
||||
|
||||
/*!
|
||||
\ingroup ASN
|
||||
|
||||
|
Reference in New Issue
Block a user