asn_public.h
1 
22 WOLFSSL_API int wc_InitCert(Cert*);
23 
67 WOLFSSL_API int wc_MakeCert(Cert*, byte* derBuffer, word32 derSz, RsaKey*,
68  ecc_key*, WC_RNG*);
69 
114 WOLFSSL_API int wc_MakeCertReq(Cert*, byte* derBuffer, word32 derSz,
115  RsaKey*, ecc_key*);
116 
167 WOLFSSL_API int wc_SignCert(int requestSz, int sigType, byte* derBuffer,
168  word32 derSz, RsaKey*, ecc_key*, WC_RNG*);
169 
213 WOLFSSL_API int wc_MakeSelfCert(Cert*, byte* derBuffer, word32 derSz, RsaKey*,
214  WC_RNG*);
215 
277 WOLFSSL_API int wc_SetIssuer(Cert*, const char*);
278 
336 WOLFSSL_API int wc_SetSubject(Cert*, const char*);
337 
338 
403 WOLFSSL_API int wc_SetSubjectRaw(Cert* cert, const byte* der, int derSz);
404 
431 WOLFSSL_API int wc_GetSubjectRaw(byte **subjectRaw, Cert *cert);
432 
492 WOLFSSL_API int wc_SetAltNames(Cert*, const char*);
493 
558 WOLFSSL_API int wc_SetIssuerBuffer(Cert*, const byte*, int);
559 
624 WOLFSSL_API int wc_SetIssuerRaw(Cert* cert, const byte* der, int derSz);
625 
689 WOLFSSL_API int wc_SetSubjectBuffer(Cert*, const byte*, int);
690 
757 WOLFSSL_API int wc_SetAltNamesBuffer(Cert*, const byte*, int);
758 
822 WOLFSSL_API int wc_SetDatesBuffer(Cert*, const byte*, int);
823 
856 WOLFSSL_API int wc_SetAuthKeyIdFromPublicKey(Cert *cert, RsaKey *rsakey,
857  ecc_key *eckey);
858 
887 WOLFSSL_API int wc_SetAuthKeyIdFromCert(Cert *cert, const byte *der, int derSz);
888 
916 WOLFSSL_API int wc_SetAuthKeyId(Cert *cert, const char* file);
917 
948 WOLFSSL_API int wc_SetSubjectKeyIdFromPublicKey(Cert *cert, RsaKey *rsakey,
949  ecc_key *eckey);
950 
980 WOLFSSL_API int wc_SetSubjectKeyId(Cert *cert, const char* file);
981 
1012 WOLFSSL_API int wc_SetSubjectKeyIdFromNtruPublicKey(Cert *cert, byte *ntruKey,
1013  word16 ntruKeySz);
1014 
1047 WOLFSSL_API int wc_SetKeyUsage(Cert *cert, const char *value);
1048 
1096 WOLFSSL_API int wc_MakeNtruCert(Cert*, byte* derBuffer, word32 derSz,
1097  const byte* ntruKey, word16 keySz,
1098  WC_RNG*);
1099 
1128 WOLFSSL_API int wc_PemPubKeyToDer(const char* fileName,
1129  unsigned char* derBuf, int derSz);
1130 
1160 WOLFSSL_API int wc_PubKeyPemToDer(const unsigned char*, int,
1161  unsigned char*, int);
1162 
1195 WOLFSSL_API
1196 int wc_PemCertToDer(const char* fileName, unsigned char* derBuf, int derSz);
1197 
1238 WOLFSSL_API int wc_DerToPem(const byte* der, word32 derSz, byte* output,
1239  word32 outputSz, int type);
1240 
1283 WOLFSSL_API int wc_DerToPemEx(const byte* der, word32 derSz, byte* output,
1284  word32 outputSz, byte *cipherIno, int type);
1285 
1321 WOLFSSL_API int wc_KeyPemToDer(const unsigned char*, int,
1322  unsigned char*, int, const char*);
1323 
1353 WOLFSSL_API int wc_CertPemToDer(const unsigned char*, int,
1354  unsigned char*, int, int);
1355 
1413 WOLFSSL_API int wc_EccPrivateKeyDecode(const byte*, word32*,
1414  ecc_key*, word32);
1415 
1458 WOLFSSL_API int wc_EccKeyToDer(ecc_key*, byte* output, word32 inLen);
1459 
1492 WOLFSSL_API int wc_EccPublicKeyDecode(const byte*, word32*,
1493  ecc_key*, word32);
1494 
1533 WOLFSSL_API int wc_EccPublicKeyToDer(ecc_key*, byte* output,
1534  word32 inLen, int with_AlgCurve);
1535 
1569 WOLFSSL_API word32 wc_EncodeSignature(byte* out, const byte* digest,
1570  word32 digSz, int hashOID);
1571 
1599 WOLFSSL_API int wc_GetCTC_HashOID(int type);
1600 
1630 WOLFSSL_API void wc_SetCert_Free(Cert* cert);
1631 
WOLFSSL_API int wc_EccPublicKeyToDer(ecc_key *, byte *output, word32 inLen, int with_AlgCurve)
This function converts the ECC public key to DER format. It returns the size of buffer used...
Definition: asn.c:11565
WOLFSSL_API int wc_MakeNtruCert(Cert *, byte *derBuffer, word32 derSz, const byte *ntruKey, word16 keySz, WC_RNG *)
Used to make CA signed certs. Called after the subject information has been entered. This function makes an NTRU Certificate from a cert input. It then writes this cert to derBuffer. It takes in an ntruKey and a rng to generate the certificate. The certificate must be initialized with wc_InitCert before this method is called.
Definition: asn.c:13440
WOLFSSL_API int wc_PemCertToDer(const char *fileName, unsigned char *derBuf, int derSz)
This function converts a pem certificate to a der certificate, and places the resulting certificate i...
Definition: asn.c:10776
WOLFSSL_API word32 wc_EncodeSignature(byte *out, const byte *digest, word32 digSz, int hashOID)
This function encodes a digital signature into the output buffer, and returns the size of the encoded...
Definition: asn.c:6852
WOLFSSL_API int wc_CertPemToDer(const unsigned char *, int, unsigned char *, int, int)
This function converts a PEM formatted certificate to DER format. Calls OpenSSL function PemToDer...
Definition: asn.c:10692
WOLFSSL_API int wc_MakeCert(Cert *, byte *derBuffer, word32 derSz, RsaKey *, ecc_key *, WC_RNG *)
Used to make CA signed certs. Called after the subject information has been entered. This function makes an x509 Certificate v3 RSA or ECC from a cert input. It then writes this cert to derBuffer. It takes in either an rsaKey or an eccKey to generate the certificate. The certificate must be initialized with wc_InitCert before this method is called.
Definition: asn.c:13430
WOLFSSL_API int wc_KeyPemToDer(const unsigned char *, int, unsigned char *, int, const char *)
Converts a key in PEM format to DER format.
Definition: asn.c:10636
WOLFSSL_API int wc_GetSubjectRaw(byte **subjectRaw, Cert *cert)
This function gets the raw subject from the certificate structure.
Definition: asn.c:13943
WOLFSSL_API int wc_MakeCertReq(Cert *, byte *derBuffer, word32 derSz, RsaKey *, ecc_key *)
This function makes a certificate signing request using the input certificate and writes the output t...
Definition: asn.c:13810
WOLFSSL_API int wc_SetSubjectKeyId(Cert *cert, const char *file)
Set SKID from public key file in PEM format. Both arguments are required.
Definition: asn.c:14097
WOLFSSL_API int wc_SetSubjectKeyIdFromPublicKey(Cert *cert, RsaKey *rsakey, ecc_key *eckey)
Set SKID from RSA or ECC public key.
Definition: asn.c:14050
WOLFSSL_API int wc_SetSubjectKeyIdFromNtruPublicKey(Cert *cert, byte *ntruKey, word16 ntruKeySz)
Set SKID from NTRU public key.
Definition: asn.c:14058
WOLFSSL_API int wc_SetIssuer(Cert *, const char *)
This function sets the issuer for a certificate to the issuer in the provided pem issuerFile...
Definition: asn.c:14701
WOLFSSL_API int wc_SetAuthKeyIdFromPublicKey(Cert *cert, RsaKey *rsakey, ecc_key *eckey)
Set AKID from either an RSA or ECC public key. note: Only set one of rsakey or eckey, not both.
Definition: asn.c:14087
WOLFSSL_API int wc_SetDatesBuffer(Cert *, const byte *, int)
This function sets the dates for a certificate from the date range in the provided der buffer...
Definition: asn.c:14925
WOLFSSL_API int wc_SetAltNamesBuffer(Cert *, const byte *, int)
This function sets the alternate names for a certificate from the alternate names in the provided der...
Definition: asn.c:14899
WOLFSSL_API int wc_DerToPemEx(const byte *der, word32 derSz, byte *output, word32 outputSz, byte *cipherIno, int type)
This function converts a der formatted input certificate, contained in the der buffer, into a pem formatted output certificate, contained in the output buffer. It should be noted that this is not an in place conversion, and a separate buffer must be utilized to store the pem formatted output. Allows setting cipher info.
Definition: asn.c:10173
WOLFSSL_API int wc_GetCTC_HashOID(int type)
This function returns the hash OID that corresponds to a hashing type. For example, when given the type: SHA512, this function returns the identifier corresponding to a SHA512 hash, SHA512h.
Definition: asn.c:6874
WOLFSSL_API int wc_SetSubjectRaw(Cert *cert, const byte *der, int derSz)
This function sets the raw subject for a certificate from the subject in the provided der buffer...
Definition: asn.c:14833
WOLFSSL_API int wc_SetAuthKeyId(Cert *cert, const char *file)
Set AKID from certificate file in PEM format.
Definition: asn.c:14250
WOLFSSL_API int wc_SetSubject(Cert *, const char *)
This function sets the subject for a certificate to the subject in the provided pem subjectFile...
Definition: asn.c:14726
WOLFSSL_API int wc_SetIssuerBuffer(Cert *, const byte *, int)
This function sets the issuer for a certificate from the issuer in the provided der buffer...
Definition: asn.c:14779
WOLFSSL_API int wc_SetAuthKeyIdFromCert(Cert *cert, const byte *der, int derSz)
Set AKID from from DER encoded certificate.
Definition: asn.c:14221
Definition: ecc.h:357
WOLFSSL_API int wc_EccPublicKeyDecode(const byte *, word32 *, ecc_key *, word32)
Decodes an ECC public key from an input buffer. It will parse an ASN sequence to retrieve the ECC key...
Definition: asn.c:15369
WOLFSSL_API int wc_SignCert(int requestSz, int sigType, byte *derBuffer, word32 derSz, RsaKey *, ecc_key *, WC_RNG *)
This function signs buffer and adds the signature to the end of buffer. It takes in a signature type...
Definition: asn.c:13918
Definition: random.h:153
WOLFSSL_API int wc_EccPrivateKeyDecode(const byte *, word32 *, ecc_key *, word32)
This function reads in an ECC private key from the input buffer, input, parses the private key...
Definition: asn.c:15166
WOLFSSL_API int wc_SetSubjectBuffer(Cert *, const byte *, int)
This function sets the subject for a certificate from the subject in the provided der buffer...
Definition: asn.c:14807
WOLFSSL_API int wc_SetKeyUsage(Cert *cert, const char *value)
This function allows you to set the key usage using a comma delimited string of tokens. Accepted tokens are: digitalSignature, nonRepudiation, contentCommitment, keyCertSign, cRLSign, dataEncipherment, keyAgreement, keyEncipherment, encipherOnly, decipherOnly. Example: "digitalSignature,nonRepudiation" nonRepudiation and contentCommitment are for the same usage.
Definition: asn.c:14281
WOLFSSL_API int wc_InitCert(Cert *)
This function initializes a default cert, with the default options: version = 3 (0x2), serial = 0, sigType = SHA_WITH_RSA, issuer = blank, daysValid = 500, selfSigned = 1 (true) use subject as issuer, subject = blank.
Definition: asn.c:11273
WOLFSSL_API int wc_SetIssuerRaw(Cert *cert, const byte *der, int derSz)
This function sets the raw issuer for a certificate from the issuer in the provided der buffer...
Definition: asn.c:14865
WOLFSSL_API int wc_SetAltNames(Cert *, const char *)
This function sets the alternate names for a certificate to the alternate names in the provided pem f...
Definition: asn.c:14752
WOLFSSL_API int wc_PemPubKeyToDer(const char *fileName, unsigned char *derBuf, int derSz)
Loads a PEM key from a file and converts to a DER encoded buffer.
Definition: asn.c:10856
Definition: asn_public.h:293
Definition: user_rsa.h:60
WOLFSSL_API int wc_MakeSelfCert(Cert *, byte *derBuffer, word32 derSz, RsaKey *, WC_RNG *)
This function is a combination of the previous two functions, wc_MakeCert and wc_SignCert for self si...
Definition: asn.c:13925
WOLFSSL_API int wc_EccKeyToDer(ecc_key *, byte *output, word32 inLen)
This function writes a private ECC key to der format.
Definition: asn.c:15685
WOLFSSL_API int wc_DerToPem(const byte *der, word32 derSz, byte *output, word32 outputSz, int type)
This function converts a der formatted input certificate, contained in the der buffer, into a pem formatted output certificate, contained in the output buffer. It should be noted that this is not an in place conversion, and a separate buffer must be utilized to store the pem formatted output.
Definition: asn.c:10165
WOLFSSL_API void wc_SetCert_Free(Cert *cert)
This function cleans up memory and resources used by the certificate structure's decoded cert cache...
WOLFSSL_API int wc_PubKeyPemToDer(const unsigned char *, int, unsigned char *, int)
Convert a PEM encoded public key to DER. Returns the number of bytes written to the buffer or a negat...
Definition: asn.c:10738