Data Structures | Typedefs | Enumerations | Functions | Variables
asn_public.h File Reference

Go to the source code of this file.

Data Structures

struct  DerBuffer
 
struct  WOLFSSL_ASN1_TIME
 
struct  EncryptedInfo
 
struct  WOLFSSL_ASN1_INTEGER
 
struct  NameAttrib
 
struct  CertName
 
struct  Cert
 
struct  _wc_CertPIV
 

Typedefs

typedef struct ed25519_key ed25519_key
 
typedef struct ed448_key ed448_key
 
typedef struct RsaKey RsaKey
 
typedef struct WC_RNG WC_RNG
 
typedef struct DerBuffer DerBuffer
 
typedef struct WOLFSSL_ASN1_TIME WOLFSSL_ASN1_TIME
 
typedef int() pem_password_cb(char *passwd, int sz, int rw, void *userdata)
 
typedef struct EncryptedInfo EncryptedInfo
 
typedef struct WOLFSSL_ASN1_INTEGER WOLFSSL_ASN1_INTEGER
 
typedef struct NameAttrib NameAttrib
 
typedef struct CertName CertName
 
typedef struct Cert Cert
 
typedef struct _wc_CertPIV wc_CertPIV
 

Enumerations

enum  Ecc_Sum {
  ECC_SECP112R1_OID = 182, ECC_SECP112R2_OID = 183, ECC_SECP128R1_OID = 204, ECC_SECP128R2_OID = 205,
  ECC_SECP160R1_OID = 184, ECC_SECP160R2_OID = 206, ECC_SECP160K1_OID = 185, ECC_BRAINPOOLP160R1_OID = 98,
  ECC_SECP192R1_OID = 520, ECC_PRIME192V2_OID = 521, ECC_PRIME192V3_OID = 522, ECC_SECP192K1_OID = 207,
  ECC_BRAINPOOLP192R1_OID = 100, ECC_SECP224R1_OID = 209, ECC_SECP224K1_OID = 208, ECC_BRAINPOOLP224R1_OID = 102,
  ECC_PRIME239V1_OID = 523, ECC_PRIME239V2_OID = 524, ECC_PRIME239V3_OID = 525, ECC_SECP256R1_OID = 526,
  ECC_SECP256K1_OID = 186, ECC_BRAINPOOLP256R1_OID = 104, ECC_X25519_OID = 365, ECC_ED25519_OID = 256,
  ECC_BRAINPOOLP320R1_OID = 106, ECC_X448_OID = 362, ECC_ED448_OID = 257, ECC_SECP384R1_OID = 210,
  ECC_BRAINPOOLP384R1_OID = 108, ECC_BRAINPOOLP512R1_OID = 110, ECC_SECP521R1_OID = 211
}
 
enum  CertType {
  CERT_TYPE = 0, PRIVATEKEY_TYPE, DH_PARAM_TYPE, DSA_PARAM_TYPE,
  CRL_TYPE, CA_TYPE, ECC_PRIVATEKEY_TYPE, DSA_PRIVATEKEY_TYPE,
  CERTREQ_TYPE, DSA_TYPE, ECC_TYPE, RSA_TYPE,
  PUBLICKEY_TYPE, RSA_PUBLICKEY_TYPE, ECC_PUBLICKEY_TYPE, TRUSTED_PEER_TYPE,
  EDDSA_PRIVATEKEY_TYPE, ED25519_TYPE, ED448_TYPE, PKCS12_TYPE,
  PKCS8_PRIVATEKEY_TYPE, PKCS8_ENC_PRIVATEKEY_TYPE, DETECT_CERT_TYPE, DH_PRIVATEKEY_TYPE
}
 
enum  Ctc_SigType {
  CTC_SHAwDSA = 517, CTC_MD2wRSA = 646, CTC_MD5wRSA = 648, CTC_SHAwRSA = 649,
  CTC_SHAwECDSA = 520, CTC_SHA224wRSA = 658, CTC_SHA224wECDSA = 523, CTC_SHA256wRSA = 655,
  CTC_SHA256wECDSA = 524, CTC_SHA384wRSA = 656, CTC_SHA384wECDSA = 525, CTC_SHA512wRSA = 657,
  CTC_SHA512wECDSA = 526, CTC_ED25519 = 256, CTC_ED448 = 257
}
 
enum  Ctc_Encoding { CTC_UTF8 = 0x0c, CTC_PRINTABLE = 0x13 }
 
enum  Ctc_Misc {
  CTC_COUNTRY_SIZE = 2, CTC_NAME_SIZE = WC_CTC_NAME_SIZE, CTC_DATE_SIZE = 32, CTC_MAX_ALT_SIZE = WC_CTC_MAX_ALT_SIZE,
  CTC_SERIAL_SIZE = 20, CTC_GEN_SERIAL_SZ = 16, CTC_MAX_SKID_SIZE = 32, CTC_MAX_AKID_SIZE = 32,
  CTC_MAX_CERTPOL_SZ = 64, CTC_MAX_CERTPOL_NB
}
 
enum  { IV_SZ = 32, NAME_SZ = 80, PEM_PASS_READ = 0, PEM_PASS_WRITE = 1 }
 

Functions

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. More...
 
WOLFSSL_API int wc_MakeCert_ex (Cert *cert, byte *derBuffer, word32 derSz, int keyType, void *key, WC_RNG *rng)
 
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. More...
 
WOLFSSL_API int wc_MakeCertReq_ex (Cert *, byte *derBuffer, word32 derSz, int, void *)
 
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 to derBuffer. It takes in either an rsaKey or an eccKey to generate the certificate request. wc_SignCert() will need to be called after this function to sign the certificate request. Please see the wolfCrypt test application (./wolfcrypt/test/test.c) for an example usage of this function. More...
 
WOLFSSL_API int wc_SignCert_ex (int requestSz, int sType, byte *buffer, word32 buffSz, int keyType, void *key, WC_RNG *rng)
 
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. Must be called after wc_MakeCert() or wc_MakeCertReq() if creating a CA signed cert. More...
 
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 signing (the previous functions may be used for CA requests). It makes a certificate, and then signs it, generating a self-signed certificate. More...
 
WOLFSSL_API int wc_SetIssuer (Cert *, const char *)
 This function sets the issuer for a certificate to the issuer in the provided pem issuerFile. It also changes the certificate’s self-signed attribute to false. The issuer specified in issuerFile is verified prior to setting the cert issuer. This method is used to set fields prior to signing. More...
 
WOLFSSL_API int wc_SetSubject (Cert *, const char *)
 This function sets the subject for a certificate to the subject in the provided pem subjectFile. This method is used to set fields prior to signing. More...
 
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 file. This is useful in the case that one wishes to secure multiple domains with the same certificate. This method is used to set fields prior to signing. More...
 
WOLFSSL_API void wc_SetCert_Free (Cert *cert)
 
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. It also changes the certificate’s self-signed attribute to false. This method is used to set fields prior to signing. More...
 
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. This method is used to set fields prior to signing. More...
 
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 buffer. This is useful in the case that one wishes to secure multiple domains with the same certificate. This method is used to set fields prior to signing. More...
 
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. This method is used to set fields prior to signing. More...
 
WOLFSSL_API int wc_GetCertDates (Cert *cert, struct tm *before, struct tm *after)
 
WOLFSSL_API int wc_SetAuthKeyIdFromPublicKey_ex (Cert *cert, int keyType, void *key)
 
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. More...
 
WOLFSSL_API int wc_SetAuthKeyIdFromCert (Cert *cert, const byte *der, int derSz)
 Set AKID from from DER encoded certificate. More...
 
WOLFSSL_API int wc_SetAuthKeyId (Cert *cert, const char *file)
 Set AKID from certificate file in PEM format. More...
 
WOLFSSL_API int wc_SetSubjectKeyIdFromPublicKey_ex (Cert *cert, int keyType, void *key)
 
WOLFSSL_API int wc_SetSubjectKeyIdFromPublicKey (Cert *cert, RsaKey *rsakey, ecc_key *eckey)
 Set SKID from RSA or ECC public key. More...
 
WOLFSSL_API int wc_SetSubjectKeyId (Cert *cert, const char *file)
 Set SKID from public key file in PEM format. Both arguments are required. More...
 
WOLFSSL_API int wc_GetSubjectRaw (byte **subjectRaw, Cert *cert)
 This function gets the raw subject from the certificate structure. More...
 
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. This method is used to set the raw subject field prior to signing. More...
 
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. This method is used to set the raw issuer field prior to signing. More...
 
WOLFSSL_API int wc_SetSubjectKeyIdFromNtruPublicKey (Cert *cert, byte *ntruKey, word16 ntruKeySz)
 Set SKID from NTRU public key. More...
 
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. More...
 
WOLFSSL_API int wc_SetExtKeyUsage (Cert *cert, const char *value)
 
WOLFSSL_API int wc_SetExtKeyUsageOID (Cert *cert, const char *oid, word32 sz, byte idx, void *heap)
 
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. More...
 
WOLFSSL_API int wc_GetDateInfo (const byte *certDate, int certDateSz, const byte **date, byte *format, int *length)
 
WOLFSSL_API int wc_GetDateAsCalendarTime (const byte *date, int length, byte format, struct tm *time)
 
WOLFSSL_API int wc_PemGetHeaderFooter (int type, const char **header, const char **footer)
 
WOLFSSL_API int wc_AllocDer (DerBuffer **pDer, word32 length, int type, void *heap)
 
WOLFSSL_API void wc_FreeDer (DerBuffer **pDer)
 
WOLFSSL_API int wc_PemToDer (const unsigned char *buff, long longSz, int type, DerBuffer **pDer, void *heap, EncryptedInfo *info, int *eccKey)
 
WOLFSSL_API int wc_KeyPemToDer (const unsigned char *, int, unsigned char *, int, const char *)
 Converts a key in PEM format to DER format. More...
 
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. More...
 
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. More...
 
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 negative value for an error. More...
 
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 in the derBuf buffer provided. More...
 
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. More...
 
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. More...
 
WOLFSSL_API int wc_RsaPublicKeyDecode_ex (const byte *input, word32 *inOutIdx, word32 inSz, const byte **n, word32 *nSz, const byte **e, word32 *eSz)
 
WOLFSSL_API int wc_RsaPublicKeyDerSize (RsaKey *key, int with_header)
 
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, and uses it to generate an ecc_key object, which it stores in key. More...
 
WOLFSSL_API int wc_EccKeyToDer (ecc_key *, byte *output, word32 inLen)
 This function writes a private ECC key to der format. More...
 
WOLFSSL_API int wc_EccPrivateKeyToDer (ecc_key *key, byte *output, word32 inLen)
 
WOLFSSL_API int wc_EccPrivateKeyToPKCS8 (ecc_key *key, byte *output, word32 *outLen)
 
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. More...
 
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. The public ECC key in DER format is stored in output buffer. with_AlgCurve is a flag for when to include a header that has the Algorithm and Curve information. More...
 
WOLFSSL_API int wc_EccPublicKeyDerSize (ecc_key *, int with_AlgCurve)
 
WOLFSSL_API int wc_Ed25519PrivateKeyDecode (const byte *, word32 *, ed25519_key *, word32)
 
WOLFSSL_API int wc_Ed25519KeyToDer (ed25519_key *key, byte *output, word32 inLen)
 
WOLFSSL_API int wc_Ed25519PrivateKeyToDer (ed25519_key *key, byte *output, word32 inLen)
 
WOLFSSL_API int wc_Ed25519PublicKeyDecode (const byte *, word32 *, ed25519_key *, word32)
 
WOLFSSL_API int wc_Ed25519PublicKeyToDer (ed25519_key *, byte *output, word32 inLen, int with_AlgCurve)
 
WOLFSSL_API int wc_Ed448PrivateKeyDecode (const byte *, word32 *, ed448_key *, word32)
 
WOLFSSL_API int wc_Ed448KeyToDer (ed448_key *key, byte *output, word32 inLen)
 
WOLFSSL_API int wc_Ed448PrivateKeyToDer (ed448_key *key, byte *output, word32 inLen)
 
WOLFSSL_API int wc_Ed448PublicKeyDecode (const byte *, word32 *, ed448_key *, word32)
 
WOLFSSL_API int wc_Ed448PublicKeyToDer (ed448_key *, byte *output, word32 inLen, int with_AlgCurve)
 
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 signature created. More...
 
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. More...
 
WOLFSSL_API int wc_GetPkcs8TraditionalOffset (byte *input, word32 *inOutIdx, word32 sz)
 
WOLFSSL_API int wc_CreatePKCS8Key (byte *out, word32 *outSz, byte *key, word32 keySz, int algoID, const byte *curveOID, word32 oidSz)
 
WOLFSSL_API int wc_GetTime (void *timePtr, word32 timeSize)
 
WOLFSSL_API int wc_EncryptedInfoGet (EncryptedInfo *info, const char *cipherInfo)
 
WOLFSSL_API int wc_ParseCertPIV (wc_CertPIV *cert, const byte *buf, word32 totalSz)
 

Variables

 C
 

Variable Documentation

◆ C

C
Initial value:
{
#endif
#ifndef WC_ECCKEY_TYPE_DEFINED
typedef struct ecc_key ecc_key