wolfSSL 3.11.1 for TLS1.3 beta
Fork of wolfSSL by
wolfssl/wolfcrypt/asn_public.h@11:cee25a834751, 2017-05-30 (annotated)
- Committer:
- wolfSSL
- Date:
- Tue May 30 01:44:10 2017 +0000
- Revision:
- 11:cee25a834751
wolfSSL 3.11.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wolfSSL | 11:cee25a834751 | 1 | /* asn_public.h |
wolfSSL | 11:cee25a834751 | 2 | * |
wolfSSL | 11:cee25a834751 | 3 | * Copyright (C) 2006-2016 wolfSSL Inc. |
wolfSSL | 11:cee25a834751 | 4 | * |
wolfSSL | 11:cee25a834751 | 5 | * This file is part of wolfSSL. |
wolfSSL | 11:cee25a834751 | 6 | * |
wolfSSL | 11:cee25a834751 | 7 | * wolfSSL is free software; you can redistribute it and/or modify |
wolfSSL | 11:cee25a834751 | 8 | * it under the terms of the GNU General Public License as published by |
wolfSSL | 11:cee25a834751 | 9 | * the Free Software Foundation; either version 2 of the License, or |
wolfSSL | 11:cee25a834751 | 10 | * (at your option) any later version. |
wolfSSL | 11:cee25a834751 | 11 | * |
wolfSSL | 11:cee25a834751 | 12 | * wolfSSL is distributed in the hope that it will be useful, |
wolfSSL | 11:cee25a834751 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
wolfSSL | 11:cee25a834751 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
wolfSSL | 11:cee25a834751 | 15 | * GNU General Public License for more details. |
wolfSSL | 11:cee25a834751 | 16 | * |
wolfSSL | 11:cee25a834751 | 17 | * You should have received a copy of the GNU General Public License |
wolfSSL | 11:cee25a834751 | 18 | * along with this program; if not, write to the Free Software |
wolfSSL | 11:cee25a834751 | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA |
wolfSSL | 11:cee25a834751 | 20 | */ |
wolfSSL | 11:cee25a834751 | 21 | |
wolfSSL | 11:cee25a834751 | 22 | |
wolfSSL | 11:cee25a834751 | 23 | |
wolfSSL | 11:cee25a834751 | 24 | #ifndef WOLF_CRYPT_ASN_PUBLIC_H |
wolfSSL | 11:cee25a834751 | 25 | #define WOLF_CRYPT_ASN_PUBLIC_H |
wolfSSL | 11:cee25a834751 | 26 | |
wolfSSL | 11:cee25a834751 | 27 | #include <wolfssl/wolfcrypt/types.h> |
wolfSSL | 11:cee25a834751 | 28 | |
wolfSSL | 11:cee25a834751 | 29 | #ifdef __cplusplus |
wolfSSL | 11:cee25a834751 | 30 | extern "C" { |
wolfSSL | 11:cee25a834751 | 31 | #endif |
wolfSSL | 11:cee25a834751 | 32 | |
wolfSSL | 11:cee25a834751 | 33 | /* guard on redeclaration */ |
wolfSSL | 11:cee25a834751 | 34 | #ifndef WC_ECCKEY_TYPE_DEFINED |
wolfSSL | 11:cee25a834751 | 35 | typedef struct ecc_key ecc_key; |
wolfSSL | 11:cee25a834751 | 36 | #define WC_ECCKEY_TYPE_DEFINED |
wolfSSL | 11:cee25a834751 | 37 | #endif |
wolfSSL | 11:cee25a834751 | 38 | #ifndef WC_RSAKEY_TYPE_DEFINED |
wolfSSL | 11:cee25a834751 | 39 | typedef struct RsaKey RsaKey; |
wolfSSL | 11:cee25a834751 | 40 | #define WC_RSAKEY_TYPE_DEFINED |
wolfSSL | 11:cee25a834751 | 41 | #endif |
wolfSSL | 11:cee25a834751 | 42 | #ifndef WC_RNG_TYPE_DEFINED |
wolfSSL | 11:cee25a834751 | 43 | typedef struct WC_RNG WC_RNG; |
wolfSSL | 11:cee25a834751 | 44 | #define WC_RNG_TYPE_DEFINED |
wolfSSL | 11:cee25a834751 | 45 | #endif |
wolfSSL | 11:cee25a834751 | 46 | |
wolfSSL | 11:cee25a834751 | 47 | /* Certificate file Type */ |
wolfSSL | 11:cee25a834751 | 48 | enum CertType { |
wolfSSL | 11:cee25a834751 | 49 | CERT_TYPE = 0, |
wolfSSL | 11:cee25a834751 | 50 | PRIVATEKEY_TYPE, |
wolfSSL | 11:cee25a834751 | 51 | DH_PARAM_TYPE, |
wolfSSL | 11:cee25a834751 | 52 | DSA_PARAM_TYPE, |
wolfSSL | 11:cee25a834751 | 53 | CRL_TYPE, |
wolfSSL | 11:cee25a834751 | 54 | CA_TYPE, |
wolfSSL | 11:cee25a834751 | 55 | ECC_PRIVATEKEY_TYPE, |
wolfSSL | 11:cee25a834751 | 56 | DSA_PRIVATEKEY_TYPE, |
wolfSSL | 11:cee25a834751 | 57 | CERTREQ_TYPE, |
wolfSSL | 11:cee25a834751 | 58 | DSA_TYPE, |
wolfSSL | 11:cee25a834751 | 59 | ECC_TYPE, |
wolfSSL | 11:cee25a834751 | 60 | RSA_TYPE, |
wolfSSL | 11:cee25a834751 | 61 | PUBLICKEY_TYPE, |
wolfSSL | 11:cee25a834751 | 62 | RSA_PUBLICKEY_TYPE, |
wolfSSL | 11:cee25a834751 | 63 | ECC_PUBLICKEY_TYPE, |
wolfSSL | 11:cee25a834751 | 64 | TRUSTED_PEER_TYPE |
wolfSSL | 11:cee25a834751 | 65 | }; |
wolfSSL | 11:cee25a834751 | 66 | |
wolfSSL | 11:cee25a834751 | 67 | |
wolfSSL | 11:cee25a834751 | 68 | /* Signature type, by OID sum */ |
wolfSSL | 11:cee25a834751 | 69 | enum Ctc_SigType { |
wolfSSL | 11:cee25a834751 | 70 | CTC_SHAwDSA = 517, |
wolfSSL | 11:cee25a834751 | 71 | CTC_MD2wRSA = 646, |
wolfSSL | 11:cee25a834751 | 72 | CTC_MD5wRSA = 648, |
wolfSSL | 11:cee25a834751 | 73 | CTC_SHAwRSA = 649, |
wolfSSL | 11:cee25a834751 | 74 | CTC_SHAwECDSA = 520, |
wolfSSL | 11:cee25a834751 | 75 | CTC_SHA224wRSA = 658, |
wolfSSL | 11:cee25a834751 | 76 | CTC_SHA224wECDSA = 527, |
wolfSSL | 11:cee25a834751 | 77 | CTC_SHA256wRSA = 655, |
wolfSSL | 11:cee25a834751 | 78 | CTC_SHA256wECDSA = 524, |
wolfSSL | 11:cee25a834751 | 79 | CTC_SHA384wRSA = 656, |
wolfSSL | 11:cee25a834751 | 80 | CTC_SHA384wECDSA = 525, |
wolfSSL | 11:cee25a834751 | 81 | CTC_SHA512wRSA = 657, |
wolfSSL | 11:cee25a834751 | 82 | CTC_SHA512wECDSA = 526 |
wolfSSL | 11:cee25a834751 | 83 | }; |
wolfSSL | 11:cee25a834751 | 84 | |
wolfSSL | 11:cee25a834751 | 85 | enum Ctc_Encoding { |
wolfSSL | 11:cee25a834751 | 86 | CTC_UTF8 = 0x0c, /* utf8 */ |
wolfSSL | 11:cee25a834751 | 87 | CTC_PRINTABLE = 0x13 /* printable */ |
wolfSSL | 11:cee25a834751 | 88 | }; |
wolfSSL | 11:cee25a834751 | 89 | |
wolfSSL | 11:cee25a834751 | 90 | enum Ctc_Misc { |
wolfSSL | 11:cee25a834751 | 91 | CTC_COUNTRY_SIZE = 2, |
wolfSSL | 11:cee25a834751 | 92 | CTC_NAME_SIZE = 64, |
wolfSSL | 11:cee25a834751 | 93 | CTC_DATE_SIZE = 32, |
wolfSSL | 11:cee25a834751 | 94 | CTC_MAX_ALT_SIZE = 16384, /* may be huge */ |
wolfSSL | 11:cee25a834751 | 95 | CTC_SERIAL_SIZE = 8, |
wolfSSL | 11:cee25a834751 | 96 | #ifdef WOLFSSL_CERT_EXT |
wolfSSL | 11:cee25a834751 | 97 | /* AKID could contains: hash + (Option) AuthCertIssuer,AuthCertSerialNum |
wolfSSL | 11:cee25a834751 | 98 | * We support only hash */ |
wolfSSL | 11:cee25a834751 | 99 | CTC_MAX_SKID_SIZE = 32, /* SHA256_DIGEST_SIZE */ |
wolfSSL | 11:cee25a834751 | 100 | CTC_MAX_AKID_SIZE = 32, /* SHA256_DIGEST_SIZE */ |
wolfSSL | 11:cee25a834751 | 101 | CTC_MAX_CERTPOL_SZ = 64, |
wolfSSL | 11:cee25a834751 | 102 | CTC_MAX_CERTPOL_NB = 2 /* Max number of Certificate Policy */ |
wolfSSL | 11:cee25a834751 | 103 | #endif /* WOLFSSL_CERT_EXT */ |
wolfSSL | 11:cee25a834751 | 104 | }; |
wolfSSL | 11:cee25a834751 | 105 | |
wolfSSL | 11:cee25a834751 | 106 | |
wolfSSL | 11:cee25a834751 | 107 | #ifdef WOLFSSL_CERT_GEN |
wolfSSL | 11:cee25a834751 | 108 | |
wolfSSL | 11:cee25a834751 | 109 | typedef struct CertName { |
wolfSSL | 11:cee25a834751 | 110 | char country[CTC_NAME_SIZE]; |
wolfSSL | 11:cee25a834751 | 111 | char countryEnc; |
wolfSSL | 11:cee25a834751 | 112 | char state[CTC_NAME_SIZE]; |
wolfSSL | 11:cee25a834751 | 113 | char stateEnc; |
wolfSSL | 11:cee25a834751 | 114 | char locality[CTC_NAME_SIZE]; |
wolfSSL | 11:cee25a834751 | 115 | char localityEnc; |
wolfSSL | 11:cee25a834751 | 116 | char sur[CTC_NAME_SIZE]; |
wolfSSL | 11:cee25a834751 | 117 | char surEnc; |
wolfSSL | 11:cee25a834751 | 118 | char org[CTC_NAME_SIZE]; |
wolfSSL | 11:cee25a834751 | 119 | char orgEnc; |
wolfSSL | 11:cee25a834751 | 120 | char unit[CTC_NAME_SIZE]; |
wolfSSL | 11:cee25a834751 | 121 | char unitEnc; |
wolfSSL | 11:cee25a834751 | 122 | char commonName[CTC_NAME_SIZE]; |
wolfSSL | 11:cee25a834751 | 123 | char commonNameEnc; |
wolfSSL | 11:cee25a834751 | 124 | char email[CTC_NAME_SIZE]; /* !!!! email has to be last !!!! */ |
wolfSSL | 11:cee25a834751 | 125 | } CertName; |
wolfSSL | 11:cee25a834751 | 126 | |
wolfSSL | 11:cee25a834751 | 127 | |
wolfSSL | 11:cee25a834751 | 128 | /* for user to fill for certificate generation */ |
wolfSSL | 11:cee25a834751 | 129 | typedef struct Cert { |
wolfSSL | 11:cee25a834751 | 130 | int version; /* x509 version */ |
wolfSSL | 11:cee25a834751 | 131 | byte serial[CTC_SERIAL_SIZE]; /* serial number */ |
wolfSSL | 11:cee25a834751 | 132 | int sigType; /* signature algo type */ |
wolfSSL | 11:cee25a834751 | 133 | CertName issuer; /* issuer info */ |
wolfSSL | 11:cee25a834751 | 134 | int daysValid; /* validity days */ |
wolfSSL | 11:cee25a834751 | 135 | int selfSigned; /* self signed flag */ |
wolfSSL | 11:cee25a834751 | 136 | CertName subject; /* subject info */ |
wolfSSL | 11:cee25a834751 | 137 | int isCA; /* is this going to be a CA */ |
wolfSSL | 11:cee25a834751 | 138 | /* internal use only */ |
wolfSSL | 11:cee25a834751 | 139 | int bodySz; /* pre sign total size */ |
wolfSSL | 11:cee25a834751 | 140 | int keyType; /* public key type of subject */ |
wolfSSL | 11:cee25a834751 | 141 | #ifdef WOLFSSL_ALT_NAMES |
wolfSSL | 11:cee25a834751 | 142 | byte altNames[CTC_MAX_ALT_SIZE]; /* altNames copy */ |
wolfSSL | 11:cee25a834751 | 143 | int altNamesSz; /* altNames size in bytes */ |
wolfSSL | 11:cee25a834751 | 144 | byte beforeDate[CTC_DATE_SIZE]; /* before date copy */ |
wolfSSL | 11:cee25a834751 | 145 | int beforeDateSz; /* size of copy */ |
wolfSSL | 11:cee25a834751 | 146 | byte afterDate[CTC_DATE_SIZE]; /* after date copy */ |
wolfSSL | 11:cee25a834751 | 147 | int afterDateSz; /* size of copy */ |
wolfSSL | 11:cee25a834751 | 148 | #endif |
wolfSSL | 11:cee25a834751 | 149 | #ifdef WOLFSSL_CERT_EXT |
wolfSSL | 11:cee25a834751 | 150 | byte skid[CTC_MAX_SKID_SIZE]; /* Subject Key Identifier */ |
wolfSSL | 11:cee25a834751 | 151 | int skidSz; /* SKID size in bytes */ |
wolfSSL | 11:cee25a834751 | 152 | byte akid[CTC_MAX_AKID_SIZE]; /* Authority Key Identifier */ |
wolfSSL | 11:cee25a834751 | 153 | int akidSz; /* AKID size in bytes */ |
wolfSSL | 11:cee25a834751 | 154 | word16 keyUsage; /* Key Usage */ |
wolfSSL | 11:cee25a834751 | 155 | char certPolicies[CTC_MAX_CERTPOL_NB][CTC_MAX_CERTPOL_SZ]; |
wolfSSL | 11:cee25a834751 | 156 | word16 certPoliciesNb; /* Number of Cert Policy */ |
wolfSSL | 11:cee25a834751 | 157 | #endif |
wolfSSL | 11:cee25a834751 | 158 | #ifdef WOLFSSL_CERT_REQ |
wolfSSL | 11:cee25a834751 | 159 | char challengePw[CTC_NAME_SIZE]; |
wolfSSL | 11:cee25a834751 | 160 | #endif |
wolfSSL | 11:cee25a834751 | 161 | void* heap; /* heap hint */ |
wolfSSL | 11:cee25a834751 | 162 | } Cert; |
wolfSSL | 11:cee25a834751 | 163 | |
wolfSSL | 11:cee25a834751 | 164 | |
wolfSSL | 11:cee25a834751 | 165 | /* Initialize and Set Certificate defaults: |
wolfSSL | 11:cee25a834751 | 166 | version = 3 (0x2) |
wolfSSL | 11:cee25a834751 | 167 | serial = 0 (Will be randomly generated) |
wolfSSL | 11:cee25a834751 | 168 | sigType = SHA_WITH_RSA |
wolfSSL | 11:cee25a834751 | 169 | issuer = blank |
wolfSSL | 11:cee25a834751 | 170 | daysValid = 500 |
wolfSSL | 11:cee25a834751 | 171 | selfSigned = 1 (true) use subject as issuer |
wolfSSL | 11:cee25a834751 | 172 | subject = blank |
wolfSSL | 11:cee25a834751 | 173 | isCA = 0 (false) |
wolfSSL | 11:cee25a834751 | 174 | keyType = RSA_KEY (default) |
wolfSSL | 11:cee25a834751 | 175 | */ |
wolfSSL | 11:cee25a834751 | 176 | WOLFSSL_API void wc_InitCert(Cert*); |
wolfSSL | 11:cee25a834751 | 177 | WOLFSSL_API int wc_MakeCert(Cert*, byte* derBuffer, word32 derSz, RsaKey*, |
wolfSSL | 11:cee25a834751 | 178 | ecc_key*, WC_RNG*); |
wolfSSL | 11:cee25a834751 | 179 | #ifdef WOLFSSL_CERT_REQ |
wolfSSL | 11:cee25a834751 | 180 | WOLFSSL_API int wc_MakeCertReq(Cert*, byte* derBuffer, word32 derSz, |
wolfSSL | 11:cee25a834751 | 181 | RsaKey*, ecc_key*); |
wolfSSL | 11:cee25a834751 | 182 | #endif |
wolfSSL | 11:cee25a834751 | 183 | WOLFSSL_API int wc_SignCert(int requestSz, int sigType, byte* derBuffer, |
wolfSSL | 11:cee25a834751 | 184 | word32 derSz, RsaKey*, ecc_key*, WC_RNG*); |
wolfSSL | 11:cee25a834751 | 185 | WOLFSSL_API int wc_MakeSelfCert(Cert*, byte* derBuffer, word32 derSz, RsaKey*, |
wolfSSL | 11:cee25a834751 | 186 | WC_RNG*); |
wolfSSL | 11:cee25a834751 | 187 | WOLFSSL_API int wc_SetIssuer(Cert*, const char*); |
wolfSSL | 11:cee25a834751 | 188 | WOLFSSL_API int wc_SetSubject(Cert*, const char*); |
wolfSSL | 11:cee25a834751 | 189 | #ifdef WOLFSSL_ALT_NAMES |
wolfSSL | 11:cee25a834751 | 190 | WOLFSSL_API int wc_SetAltNames(Cert*, const char*); |
wolfSSL | 11:cee25a834751 | 191 | #endif |
wolfSSL | 11:cee25a834751 | 192 | WOLFSSL_API int wc_SetIssuerBuffer(Cert*, const byte*, int); |
wolfSSL | 11:cee25a834751 | 193 | WOLFSSL_API int wc_SetSubjectBuffer(Cert*, const byte*, int); |
wolfSSL | 11:cee25a834751 | 194 | WOLFSSL_API int wc_SetAltNamesBuffer(Cert*, const byte*, int); |
wolfSSL | 11:cee25a834751 | 195 | WOLFSSL_API int wc_SetDatesBuffer(Cert*, const byte*, int); |
wolfSSL | 11:cee25a834751 | 196 | |
wolfSSL | 11:cee25a834751 | 197 | #ifdef WOLFSSL_CERT_EXT |
wolfSSL | 11:cee25a834751 | 198 | WOLFSSL_API int wc_SetAuthKeyIdFromPublicKey(Cert *cert, RsaKey *rsakey, |
wolfSSL | 11:cee25a834751 | 199 | ecc_key *eckey); |
wolfSSL | 11:cee25a834751 | 200 | WOLFSSL_API int wc_SetAuthKeyIdFromCert(Cert *cert, const byte *der, int derSz); |
wolfSSL | 11:cee25a834751 | 201 | WOLFSSL_API int wc_SetAuthKeyId(Cert *cert, const char* file); |
wolfSSL | 11:cee25a834751 | 202 | WOLFSSL_API int wc_SetSubjectKeyIdFromPublicKey(Cert *cert, RsaKey *rsakey, |
wolfSSL | 11:cee25a834751 | 203 | ecc_key *eckey); |
wolfSSL | 11:cee25a834751 | 204 | WOLFSSL_API int wc_SetSubjectKeyId(Cert *cert, const char* file); |
wolfSSL | 11:cee25a834751 | 205 | |
wolfSSL | 11:cee25a834751 | 206 | #ifdef HAVE_NTRU |
wolfSSL | 11:cee25a834751 | 207 | WOLFSSL_API int wc_SetSubjectKeyIdFromNtruPublicKey(Cert *cert, byte *ntruKey, |
wolfSSL | 11:cee25a834751 | 208 | word16 ntruKeySz); |
wolfSSL | 11:cee25a834751 | 209 | #endif |
wolfSSL | 11:cee25a834751 | 210 | |
wolfSSL | 11:cee25a834751 | 211 | /* Set the KeyUsage. |
wolfSSL | 11:cee25a834751 | 212 | * Value is a string separated tokens with ','. Accepted tokens are : |
wolfSSL | 11:cee25a834751 | 213 | * digitalSignature,nonRepudiation,contentCommitment,keyCertSign,cRLSign, |
wolfSSL | 11:cee25a834751 | 214 | * dataEncipherment,keyAgreement,keyEncipherment,encipherOnly and decipherOnly. |
wolfSSL | 11:cee25a834751 | 215 | * |
wolfSSL | 11:cee25a834751 | 216 | * nonRepudiation and contentCommitment are for the same usage. |
wolfSSL | 11:cee25a834751 | 217 | */ |
wolfSSL | 11:cee25a834751 | 218 | WOLFSSL_API int wc_SetKeyUsage(Cert *cert, const char *value); |
wolfSSL | 11:cee25a834751 | 219 | |
wolfSSL | 11:cee25a834751 | 220 | #endif /* WOLFSSL_CERT_EXT */ |
wolfSSL | 11:cee25a834751 | 221 | |
wolfSSL | 11:cee25a834751 | 222 | #ifdef HAVE_NTRU |
wolfSSL | 11:cee25a834751 | 223 | WOLFSSL_API int wc_MakeNtruCert(Cert*, byte* derBuffer, word32 derSz, |
wolfSSL | 11:cee25a834751 | 224 | const byte* ntruKey, word16 keySz, |
wolfSSL | 11:cee25a834751 | 225 | WC_RNG*); |
wolfSSL | 11:cee25a834751 | 226 | #endif |
wolfSSL | 11:cee25a834751 | 227 | |
wolfSSL | 11:cee25a834751 | 228 | #endif /* WOLFSSL_CERT_GEN */ |
wolfSSL | 11:cee25a834751 | 229 | |
wolfSSL | 11:cee25a834751 | 230 | #if defined(WOLFSSL_CERT_EXT) || defined(WOLFSSL_PUB_PEM_TO_DER) |
wolfSSL | 11:cee25a834751 | 231 | #ifndef WOLFSSL_PEMPUBKEY_TODER_DEFINED |
wolfSSL | 11:cee25a834751 | 232 | #ifndef NO_FILESYSTEM |
wolfSSL | 11:cee25a834751 | 233 | /* forward from wolfssl */ |
wolfSSL | 11:cee25a834751 | 234 | WOLFSSL_API int wolfSSL_PemPubKeyToDer(const char* fileName, |
wolfSSL | 11:cee25a834751 | 235 | unsigned char* derBuf, int derSz); |
wolfSSL | 11:cee25a834751 | 236 | #endif |
wolfSSL | 11:cee25a834751 | 237 | |
wolfSSL | 11:cee25a834751 | 238 | /* forward from wolfssl */ |
wolfSSL | 11:cee25a834751 | 239 | WOLFSSL_API int wolfSSL_PubKeyPemToDer(const unsigned char*, int, |
wolfSSL | 11:cee25a834751 | 240 | unsigned char*, int); |
wolfSSL | 11:cee25a834751 | 241 | #define WOLFSSL_PEMPUBKEY_TODER_DEFINED |
wolfSSL | 11:cee25a834751 | 242 | #endif /* WOLFSSL_PEMPUBKEY_TODER_DEFINED */ |
wolfSSL | 11:cee25a834751 | 243 | #endif /* WOLFSSL_CERT_EXT || WOLFSSL_PUB_PEM_TO_DER */ |
wolfSSL | 11:cee25a834751 | 244 | |
wolfSSL | 11:cee25a834751 | 245 | #if defined(WOLFSSL_KEY_GEN) || defined(WOLFSSL_CERT_GEN) || !defined(NO_DSA) \ |
wolfSSL | 11:cee25a834751 | 246 | || defined(OPENSSL_EXTRA) |
wolfSSL | 11:cee25a834751 | 247 | WOLFSSL_API int wc_DerToPem(const byte* der, word32 derSz, byte* output, |
wolfSSL | 11:cee25a834751 | 248 | word32 outputSz, int type); |
wolfSSL | 11:cee25a834751 | 249 | WOLFSSL_API int wc_DerToPemEx(const byte* der, word32 derSz, byte* output, |
wolfSSL | 11:cee25a834751 | 250 | word32 outputSz, byte *cipherIno, int type); |
wolfSSL | 11:cee25a834751 | 251 | #endif |
wolfSSL | 11:cee25a834751 | 252 | |
wolfSSL | 11:cee25a834751 | 253 | #ifdef HAVE_ECC |
wolfSSL | 11:cee25a834751 | 254 | /* private key helpers */ |
wolfSSL | 11:cee25a834751 | 255 | WOLFSSL_API int wc_EccPrivateKeyDecode(const byte*, word32*, |
wolfSSL | 11:cee25a834751 | 256 | ecc_key*, word32); |
wolfSSL | 11:cee25a834751 | 257 | WOLFSSL_API int wc_EccKeyToDer(ecc_key*, byte* output, word32 inLen); |
wolfSSL | 11:cee25a834751 | 258 | WOLFSSL_API int wc_EccPrivateKeyToDer(ecc_key* key, byte* output, |
wolfSSL | 11:cee25a834751 | 259 | word32 inLen); |
wolfSSL | 11:cee25a834751 | 260 | |
wolfSSL | 11:cee25a834751 | 261 | /* public key helper */ |
wolfSSL | 11:cee25a834751 | 262 | WOLFSSL_API int wc_EccPublicKeyDecode(const byte*, word32*, |
wolfSSL | 11:cee25a834751 | 263 | ecc_key*, word32); |
wolfSSL | 11:cee25a834751 | 264 | #if (defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_KEY_GEN)) |
wolfSSL | 11:cee25a834751 | 265 | WOLFSSL_API int wc_EccPublicKeyToDer(ecc_key*, byte* output, |
wolfSSL | 11:cee25a834751 | 266 | word32 inLen, int with_AlgCurve); |
wolfSSL | 11:cee25a834751 | 267 | #endif |
wolfSSL | 11:cee25a834751 | 268 | #endif |
wolfSSL | 11:cee25a834751 | 269 | |
wolfSSL | 11:cee25a834751 | 270 | /* DER encode signature */ |
wolfSSL | 11:cee25a834751 | 271 | WOLFSSL_API word32 wc_EncodeSignature(byte* out, const byte* digest, |
wolfSSL | 11:cee25a834751 | 272 | word32 digSz, int hashOID); |
wolfSSL | 11:cee25a834751 | 273 | WOLFSSL_API int wc_GetCTC_HashOID(int type); |
wolfSSL | 11:cee25a834751 | 274 | |
wolfSSL | 11:cee25a834751 | 275 | WOLFSSL_API int wc_GetPkcs8TraditionalOffset(byte* input, |
wolfSSL | 11:cee25a834751 | 276 | word32* inOutIdx, word32 sz); |
wolfSSL | 11:cee25a834751 | 277 | WOLFSSL_API int wc_CreatePKCS8Key(byte* out, word32* outSz, |
wolfSSL | 11:cee25a834751 | 278 | byte* key, word32 keySz, int algoID, const byte* curveOID, word32 oidSz); |
wolfSSL | 11:cee25a834751 | 279 | |
wolfSSL | 11:cee25a834751 | 280 | /* Time */ |
wolfSSL | 11:cee25a834751 | 281 | /* Returns seconds (Epoch/UTC) |
wolfSSL | 11:cee25a834751 | 282 | * timePtr: is "time_t", which is typically "long" |
wolfSSL | 11:cee25a834751 | 283 | * Example: |
wolfSSL | 11:cee25a834751 | 284 | long lTime; |
wolfSSL | 11:cee25a834751 | 285 | rc = wc_GetTime(&lTime, (word32)sizeof(lTime)); |
wolfSSL | 11:cee25a834751 | 286 | */ |
wolfSSL | 11:cee25a834751 | 287 | WOLFSSL_API int wc_GetTime(void* timePtr, word32 timeSize); |
wolfSSL | 11:cee25a834751 | 288 | |
wolfSSL | 11:cee25a834751 | 289 | #ifdef __cplusplus |
wolfSSL | 11:cee25a834751 | 290 | } /* extern "C" */ |
wolfSSL | 11:cee25a834751 | 291 | #endif |
wolfSSL | 11:cee25a834751 | 292 | |
wolfSSL | 11:cee25a834751 | 293 | #endif /* WOLF_CRYPT_ASN_PUBLIC_H */ |
wolfSSL | 11:cee25a834751 | 294 | |
wolfSSL | 11:cee25a834751 | 295 |