26 #ifndef WOLF_CRYPT_ASN_H 27 #define WOLF_CRYPT_ASN_H 34 #if !defined(NO_ASN_TIME) && defined(NO_TIME_H) 38 #include <wolfssl/wolfcrypt/integer.h> 41 #if defined(HAVE_FIPS) && !defined(NO_RSA) && \ 42 (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)) 43 #include <cyassl/ctaocrypt/rsa.h> 61 #if defined(NO_SHA) && defined(NO_SHA256) 62 #define WC_SHA256_DIGEST_SIZE 32 69 #ifndef EXTERNAL_SERIAL_SIZE 70 #define EXTERNAL_SERIAL_SIZE 32 86 ASN_BIT_STRING = 0x03,
87 ASN_OCTET_STRING = 0x04,
90 ASN_ENUMERATED = 0x0a,
91 ASN_UTF8STRING = 0x0c,
94 ASN_PRINTABLE_STRING = 0x13,
96 ASN_OTHER_TYPE = 0x00,
97 ASN_RFC822_TYPE = 0x01,
102 ASN_GENERALIZED_TIME = 0x18,
103 CRL_EXTENSIONS = 0xa0,
104 ASN_EXTENSIONS = 0xa3,
105 ASN_LONG_LENGTH = 0x80,
106 ASN_INDEF_LENGTH = 0x80,
109 ASN_CONSTRUCTED = 0x20,
110 ASN_APPLICATION = 0x40,
111 ASN_CONTEXT_SPECIFIC = 0x80,
114 #define ASN_UTC_TIME_SIZE 14 115 #define ASN_GENERALIZED_TIME_SIZE 16 116 #define ASN_GENERALIZED_TIME_MAX 68 120 ASN_COMMON_NAME = 0x03,
122 ASN_SERIAL_NUMBER = 0x05,
123 ASN_COUNTRY_NAME = 0x06,
124 ASN_LOCALITY_NAME = 0x07,
125 ASN_STATE_NAME = 0x08,
127 ASN_ORGUNIT_NAME = 0x0b,
129 ASN_EMAIL_NAME = 0x98,
134 ASN_DOMAIN_COMPONENT = 0x19
137 #if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL) 145 extern const size_t wolfssl_object_info_sz;
150 #define WOLFSSL_COMMON_NAME "/CN=" 151 #define WOLFSSL_LN_COMMON_NAME "/commonName=" 152 #define WOLFSSL_SUR_NAME "/SN=" 153 #define WOLFSSL_SERIAL_NUMBER "/serialNumber=" 154 #define WOLFSSL_COUNTRY_NAME "/C=" 155 #define WOLFSSL_LN_COUNTRY_NAME "/countryName=" 156 #define WOLFSSL_LOCALITY_NAME "/L=" 157 #define WOLFSSL_LN_LOCALITY_NAME "/localityName=" 158 #define WOLFSSL_STATE_NAME "/ST=" 159 #define WOLFSSL_LN_STATE_NAME "/stateOrProvinceName=" 160 #define WOLFSSL_ORG_NAME "/O=" 161 #define WOLFSSL_LN_ORG_NAME "/organizationName=" 162 #define WOLFSSL_ORGUNIT_NAME "/OU=" 163 #define WOLFSSL_LN_ORGUNIT_NAME "/organizationalUnitName=" 164 #define WOLFSSL_DOMAIN_COMPONENT "/DC=" 165 #define WOLFSSL_LN_DOMAIN_COMPONENT "/domainComponent=" 166 #define WOLFSSL_BUS_CAT "/businessCategory=" 167 #define WOLFSSL_JOI_C "/jurisdictionC=" 168 #define WOLFSSL_JOI_ST "/jurisdictionST=" 169 #define WOLFSSL_EMAIL_ADDR "/emailAddress=" 171 #define WOLFSSL_USER_ID "/UID=" 172 #define WOLFSSL_DOMAIN_COMPONENT "/DC=" 174 #if defined(WOLFSSL_APACHE_HTTPD) 176 #define WOLFSSL_SN_MS_UPN "msUPN" 177 #define WOLFSSL_LN_MS_UPN "Microsoft User Principal Name" 178 #define WOLFSSL_MS_UPN_SUM 265 179 #define WOLFSSL_SN_DNS_SRV "id-on-dnsSRV" 180 #define WOLFSSL_LN_DNS_SRV "SRVName" 182 #define WOLFSSL_SN_TLS_FEATURE "tlsfeature" 183 #define WOLFSSL_LN_TLS_FEATURE "TLS Feature" 184 #define WOLFSSL_TLS_FEATURE_SUM 92 191 NID_netscape_cert_type = NID_undef,
197 NID_hw_name_oid = 73,
198 NID_id_pkix_OCSP_basic = 74,
200 NID_anyExtendedKeyUsage = 76,
204 NID_description = 107,
205 NID_basic_constraints = 133,
207 NID_ext_key_usage = 151,
208 NID_subject_key_identifier = 128,
209 NID_authority_key_identifier = 149,
210 NID_private_key_usage_period = 130,
211 NID_subject_alt_name = 131,
212 NID_issuer_alt_name = 132,
213 NID_info_access = 69,
214 NID_sinfo_access = 79,
215 NID_name_constraints = 144,
216 NID_crl_distribution_points = 145,
217 NID_certificate_policies = 146,
218 NID_policy_mappings = 147,
219 NID_policy_constraints = 150,
220 NID_inhibit_any_policy = 168,
221 NID_tlsfeature = 1020,
222 NID_commonName = 0x03,
226 NID_serialNumber = 0x05,
227 NID_countryName = 0x06,
228 NID_localityName = 0x07,
229 NID_stateOrProvinceName = 0x08,
230 NID_organizationName = 0x0a,
231 NID_organizationalUnitName = 0x0b,
232 NID_jurisdictionCountryName = 0xc,
233 NID_jurisdictionStateOrProvinceName = 0xd,
234 NID_businessCategory = ASN_BUS_CAT,
235 NID_domainComponent = ASN_DOMAIN_COMPONENT,
236 NID_emailAddress = 0x30,
237 NID_id_on_dnsSRV = 82,
240 NID_X9_62_prime_field = 406
249 #ifdef WOLFSSL_CERT_PIV 252 ASN_PIV_NONCE = 0x0B,
253 ASN_PIV_SIGNED_NONCE = 0x0C,
255 ASN_PIV_TAG_CERT = 0x70,
256 ASN_PIV_TAG_CERT_INFO = 0x71,
257 ASN_PIV_TAG_MSCUID = 0x72,
258 ASN_PIV_TAG_ERR_DET = 0xFE,
261 ASN_PIV_CERT_INFO_COMPRESSED = 0x03,
262 ASN_PIV_CERT_INFO_ISX509 = 0x04,
267 #define ASN_JOI_PREFIX_SZ 10 268 #define ASN_JOI_PREFIX "\x2b\x06\x01\x04\x01\x82\x37\x3c\x02\x01" 269 #define ASN_JOI_C 0x3 270 #define ASN_JOI_ST 0x2 272 #ifndef WC_ASN_NAME_MAX 274 #define WC_ASN_NAME_MAX 300 276 #define WC_ASN_NAME_MAX 256 279 #define ASN_NAME_MAX WC_ASN_NAME_MAX 285 ASN_ECC_HEADER_SZ = 2,
286 ASN_ECC_CONTEXT_SZ = 2,
288 KEYID_SIZE = WC_SHA256_DIGEST_SIZE,
290 KEYID_SIZE = WC_SHA_DIGEST_SIZE,
296 ASN_GEN_TIME_SZ = 15,
298 MAX_ENCODED_SIG_SZ = 512,
299 #elif defined(HAVE_ECC) 300 MAX_ENCODED_SIG_SZ = 140,
301 #elif defined(HAVE_CURVE448) 302 MAX_ENCODED_SIG_SZ = 114,
304 MAX_ENCODED_SIG_SZ = 64,
311 MAX_OCTET_STR_SZ = 5,
315 MAX_ENCODED_DIG_ASN_SZ= 9,
316 MAX_ENCODED_DIG_SZ = 64 + MAX_ENCODED_DIG_ASN_SZ,
317 MAX_RSA_INT_SZ = 517,
318 MAX_DSA_INT_SZ = 261,
319 MAX_NTRU_KEY_SZ = 610,
320 MAX_NTRU_ENC_SZ = 628,
325 MAX_DER_DIGEST_SZ = MAX_ENCODED_DIG_SZ + MAX_ALGO_SZ + MAX_SEQ_SZ,
327 MAX_DER_DIGEST_ASN_SZ = MAX_ENCODED_DIG_ASN_SZ + MAX_ALGO_SZ + MAX_SEQ_SZ,
329 #ifdef WOLFSSL_CERT_GEN 330 #ifdef WOLFSSL_CERT_REQ 332 MAX_ATTRIB_SZ = MAX_SEQ_SZ * 3 + (11 + MAX_SEQ_SZ) * 2 +
333 MAX_PRSTR_SZ + CTC_NAME_SIZE,
335 #
if defined(WOLFSSL_ALT_NAMES) || defined(WOLFSSL_CERT_EXT)
336 MAX_EXTENSIONS_SZ = 1 + MAX_LENGTH_SZ + CTC_MAX_ALT_SIZE,
338 MAX_EXTENSIONS_SZ = 1 + MAX_LENGTH_SZ + MAX_CA_SZ,
342 #if defined(WOLFSSL_CERT_EXT) || defined(OPENSSL_EXTRA) || defined(HAVE_PKCS7) 344 MAX_OID_STRING_SZ = 64,
346 #ifdef WOLFSSL_CERT_EXT 348 MAX_KEYUSAGE_SZ = 18,
349 MAX_EXTKEYUSAGE_SZ = 12 + (6 * (8 + 2)) +
353 MAX_CERTPOL_NB = CTC_MAX_CERTPOL_NB,
354 MAX_CERTPOL_SZ = CTC_MAX_CERTPOL_SZ,
357 MAX_NAME_ENTRIES = 5,
358 OCSP_NONCE_EXT_SZ = 35,
359 MAX_OCSP_EXT_SZ = 58,
360 MAX_OCSP_NONCE_SZ = 16,
362 MAX_PUBLIC_KEY_SZ = MAX_NTRU_ENC_SZ + MAX_ALGO_SZ + MAX_SEQ_SZ * 2,
364 #ifdef WOLFSSL_ENCRYPTED_KEYS 365 HEADER_ENCRYPTED_KEY_SIZE = 88,
367 HEADER_ENCRYPTED_KEY_SIZE = 0,
372 #if defined(OPENSSL_ALL) || defined(WOLFSSL_MYSQL_COMPATIBLE) || \ 373 defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) || \ 374 defined(OPENSSL_EXTRA) || defined(HAVE_PKCS7) 375 MAX_TIME_STRING_SZ = 25,
392 oidCertAuthInfoType = 7,
393 oidCertPolicyType = 8,
394 oidCertAltNameType = 9,
395 oidCertKeyUseType = 10,
398 oidCmsKeyAgreeType = 13,
401 oidCompressType = 16,
402 oidCertNameType = 17,
424 #if !defined(NO_DES3) || !defined(NO_AES) 426 #ifdef WOLFSSL_AES_128 431 #ifdef WOLFSSL_AES_192 436 #ifdef WOLFSSL_AES_256 459 #if !defined(NO_AES) || defined(HAVE_PKCS7) 461 #ifdef WOLFSSL_AES_128 464 #ifdef WOLFSSL_AES_192 467 #ifdef WOLFSSL_AES_256 477 dhSinglePass_stdDH_sha1kdf_scheme = 464,
478 dhSinglePass_stdDH_sha224kdf_scheme = 188,
479 dhSinglePass_stdDH_sha256kdf_scheme = 189,
480 dhSinglePass_stdDH_sha384kdf_scheme = 190,
481 dhSinglePass_stdDH_sha512kdf_scheme = 191,
492 HMAC_SHA224_OID = 652,
493 HMAC_SHA256_OID = 653,
494 HMAC_SHA384_OID = 654,
495 HMAC_SHA512_OID = 655,
496 HMAC_SHA3_224_OID = 426,
497 HMAC_SHA3_256_OID = 427,
498 HMAC_SHA3_384_OID = 428,
499 HMAC_SHA3_512_OID = 429
503 enum Extensions_Sum {
510 CERT_POLICY_OID = 146,
512 INHIBIT_ANY_OID = 168,
513 EXT_KEY_USAGE_OID = 151,
515 PRIV_KEY_USAGE_PERIOD_OID = 130,
516 SUBJECT_INFO_ACCESS = 79,
517 POLICY_MAP_OID = 147,
518 POLICY_CONST_OID = 150,
519 ISSUE_ALT_NAMES_OID = 132,
520 TLS_FEATURE_OID = 92,
521 NETSCAPE_CT_OID = 753
524 enum CertificatePolicy_Sum {
528 enum SepHardwareName_Sum {
534 AIA_CA_ISSUER_OID = 117
537 enum ExtKeyUsage_Sum {
539 EKU_SERVER_AUTH_OID = 71,
540 EKU_CLIENT_AUTH_OID = 72,
541 EKU_CODESIGNING_OID = 73,
542 EKU_EMAILPROTECT_OID = 74,
543 EKU_TIMESTAMP_OID = 78,
544 EKU_OCSP_SIGN_OID = 79
548 enum CompressAlg_Sum {
559 VERIFY_SKIP_DATE = 5,
562 #ifdef WOLFSSL_CERT_EXT 570 #define KEYUSE_DIGITAL_SIG 0x0080 571 #define KEYUSE_CONTENT_COMMIT 0x0040 572 #define KEYUSE_KEY_ENCIPHER 0x0020 573 #define KEYUSE_DATA_ENCIPHER 0x0010 574 #define KEYUSE_KEY_AGREE 0x0008 575 #define KEYUSE_KEY_CERT_SIGN 0x0004 576 #define KEYUSE_CRL_SIGN 0x0002 577 #define KEYUSE_ENCIPHER_ONLY 0x0001 578 #define KEYUSE_DECIPHER_ONLY 0x8000 581 #define EXTKEYUSE_USER 0x80 582 #define EXTKEYUSE_OCSP_SIGN 0x40 583 #define EXTKEYUSE_TIMESTAMP 0x20 584 #define EXTKEYUSE_EMAILPROT 0x10 585 #define EXTKEYUSE_CODESIGN 0x08 586 #define EXTKEYUSE_CLIENT_AUTH 0x04 587 #define EXTKEYUSE_SERVER_AUTH 0x02 588 #define EXTKEYUSE_ANY 0x01 609 #define DOMAIN_COMPONENT_MAX 10 610 #define DN_NAMES_MAX 9 636 #ifdef WOLFSSL_CERT_EXT 654 int dcIdx[DOMAIN_COMPONENT_MAX];
655 int dcLen[DOMAIN_COMPONENT_MAX];
658 #if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL) 663 int loc[DOMAIN_COMPONENT_MAX + DN_NAMES_MAX];
668 enum SignatureState {
677 #ifdef HAVE_PK_CALLBACKS 679 typedef int (*wc_CallbackEccVerify)(
680 const unsigned char* sig,
unsigned int sigSz,
681 const unsigned char* hash,
unsigned int hashSz,
682 const unsigned char* keyDer,
unsigned int keySz,
683 int* result,
void* ctx);
686 typedef int (*wc_CallbackRsaVerify)(
687 unsigned char* sig,
unsigned int sigSz,
689 const unsigned char* keyDer,
unsigned int keySz,
701 #if defined(HAVE_ECC) || defined(HAVE_ED25519) || defined(HAVE_ED448) 724 #ifdef WOLFSSL_ASYNC_CRYPT 725 WC_ASYNC_DEV* asyncDev;
729 #ifdef HAVE_PK_CALLBACKS 731 wc_CallbackEccVerify pkCbEcc;
735 wc_CallbackRsaVerify pkCbRsa;
740 #ifdef WOLFSSL_RENESAS_TSIP_TLS 743 word32 pubkey_n_start;
745 word32 pubkey_e_start;
752 CERTSIGN_STATE_BEGIN,
753 CERTSIGN_STATE_DIGEST,
754 CERTSIGN_STATE_ENCODE,
768 #ifndef WOLFSSL_MAX_PATH_LEN 780 #define WOLFSSL_MAX_PATH_LEN 127 786 #ifdef WOLFSSL_TRUST_PEER_CERT 794 const byte* publicKey;
804 #ifndef IGNORE_NAME_CONSTRAINTS 809 byte subjectHash[KEYID_SIZE];
810 byte issuerHash[KEYID_SIZE];
812 byte subjectKeyHash[KEYID_SIZE];
813 byte issuerKeyHash[KEYID_SIZE];
815 const byte* signature;
819 char issuer[ASN_NAME_MAX];
820 char subject[ASN_NAME_MAX];
826 byte serial[EXTERNAL_SERIAL_SIZE];
828 const byte* extensions;
830 word32 extensionsIdx;
831 const byte* extAuthInfo;
833 #if defined(OPENSSL_ALL) || defined(WOLFSSL_QT) 834 const byte* extAuthInfoCaIssuer;
835 int extAuthInfoCaIssuerSz;
837 const byte* extCrlInfo;
839 byte extSubjKeyId[KEYID_SIZE];
840 byte extAuthKeyId[KEYID_SIZE];
848 #if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL) 849 const byte* extExtKeyUsageSrc;
850 word32 extExtKeyUsageSz;
851 word32 extExtKeyUsageCount;
852 const byte* extAuthKeyIdSrc;
853 word32 extAuthKeyIdSz;
854 const byte* extSubjKeyIdSrc;
855 word32 extSubjKeyIdSz;
858 #if defined(HAVE_ECC) || defined(HAVE_ED25519) || defined(HAVE_ED448) 861 const byte* beforeDate;
863 const byte* afterDate;
865 #if defined(HAVE_PKCS7) || defined(WOLFSSL_CERT_EXT) 866 const byte* issuerRaw;
869 #if !defined(IGNORE_NAME_CONSTRAINTS) || defined(WOLFSSL_CERT_EXT) 870 const byte* subjectRaw;
873 #if defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_EXT) 896 #ifdef WOLFSSL_CERT_EXT 910 #if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL) 922 #ifdef WOLFSSL_CERT_EXT 923 char extCertPolicies[MAX_CERTPOL_NB][MAX_CERTPOL_SZ];
924 int extCertPoliciesNb;
931 #ifdef WOLFSSL_RENESAS_TSIP 932 byte* tsip_encRsaKeyIdx;
939 byte subjectCNStored : 1;
940 byte extSubjKeyIdSet : 1;
941 byte extAuthKeyIdSet : 1;
942 #ifndef IGNORE_NAME_CONSTRAINTS 943 byte extNameConstraintSet : 1;
946 byte pathLengthSet : 1;
947 byte weOwnAltNames : 1;
948 byte extKeyUsageSet : 1;
949 byte extExtKeyUsageSet : 1;
950 byte extCRLdistSet : 1;
951 byte extAuthInfoSet : 1;
952 byte extBasicConstSet : 1;
953 byte extSubjAltNameSet : 1;
954 byte inhibitAnyOidSet : 1;
956 #if defined(WOLFSSL_SEP) || defined(WOLFSSL_QT) 957 byte extCertPolicySet : 1;
959 #if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL) 960 byte extCRLdistCrit : 1;
961 byte extAuthInfoCrit : 1;
962 byte extBasicConstCrit : 1;
963 byte extSubjAltNameCrit : 1;
964 byte extAuthKeyIdCrit : 1;
965 #ifndef IGNORE_NAME_CONSTRAINTS 966 byte extNameConstraintCrit : 1;
968 byte extSubjKeyIdCrit : 1;
969 byte extKeyUsageCrit : 1;
970 byte extExtKeyUsageCrit : 1;
972 #if defined(WOLFSSL_SEP) || defined(WOLFSSL_QT) 973 byte extCertPolicyCrit : 1;
980 #define SIGNER_DIGEST_SIZE WC_SHA256_DIGEST_SIZE 982 #define SIGNER_DIGEST_SIZE WC_SHA_DIGEST_SIZE 993 byte pathLengthSet : 1;
995 const byte* publicKey;
998 #ifndef IGNORE_NAME_CONSTRAINTS 1002 byte subjectNameHash[SIGNER_DIGEST_SIZE];
1005 byte subjectKeyIdHash[SIGNER_DIGEST_SIZE];
1009 byte subjectKeyHash[KEYID_SIZE];
1011 #ifdef WOLFSSL_SIGNER_DER_CERT 1014 #ifdef WOLFSSL_RENESAS_TSIP_TLS 1021 #ifdef WOLFSSL_TRUST_PEER_CERT 1026 #ifndef IGNORE_NAME_CONSTRAINTS 1030 byte subjectNameHash[SIGNER_DIGEST_SIZE];
1033 byte subjectKeyIdHash[SIGNER_DIGEST_SIZE];
1044 #if defined(WOLFSSL_TEST_CERT) || defined(OPENSSL_EXTRA) || \ 1045 defined(OPENSSL_EXTRA_X509_SMALL) 1046 #define WOLFSSL_ASN_API WOLFSSL_API 1048 #define WOLFSSL_ASN_API WOLFSSL_LOCAL 1051 WOLFSSL_LOCAL
int CalcHashId(
const byte* data, word32 len, byte* hash);
1053 WOLFSSL_ASN_API
int wc_BerToDer(
const byte* ber, word32 berSz, byte* der,
1056 WOLFSSL_ASN_API
void FreeAltNames(
DNS_entry*,
void*);
1057 #ifndef IGNORE_NAME_CONSTRAINTS 1058 WOLFSSL_ASN_API
void FreeNameSubtrees(
Base_entry*,
void*);
1060 WOLFSSL_ASN_API
void InitDecodedCert(
DecodedCert*,
const byte*, word32,
void*);
1061 WOLFSSL_ASN_API
void FreeDecodedCert(
DecodedCert*);
1062 WOLFSSL_ASN_API
int ParseCert(
DecodedCert*,
int type,
int verify,
void* cm);
1064 WOLFSSL_LOCAL
int DecodePolicyOID(
char *o, word32 oSz,
1065 const byte *in, word32 inSz);
1066 WOLFSSL_LOCAL
int EncodePolicyOID(byte *out, word32 *outSz,
1067 const char *in,
void* heap);
1068 WOLFSSL_API
int CheckCertSignature(
const byte*,word32,
void*,
void* cm);
1069 WOLFSSL_LOCAL
int CheckCertSignaturePubKey(
const byte* cert, word32 certSz,
1070 void* heap,
const byte* pubKey, word32 pubKeySz,
int pubKeyOID);
1071 WOLFSSL_LOCAL
int ParseCertRelative(
DecodedCert*,
int type,
int verify,
void* cm);
1072 WOLFSSL_LOCAL
int DecodeToKey(
DecodedCert*,
int verify);
1073 WOLFSSL_LOCAL
int wc_GetPubX509(
DecodedCert* cert,
int verify,
int* badDate);
1075 WOLFSSL_LOCAL
const byte* OidFromId(word32
id, word32 type, word32* oidSz);
1076 WOLFSSL_LOCAL
Signer* MakeSigner(
void*);
1077 WOLFSSL_LOCAL
void FreeSigner(
Signer*,
void*);
1078 WOLFSSL_LOCAL
void FreeSignerTable(
Signer**,
int,
void*);
1079 #ifdef WOLFSSL_TRUST_PEER_CERT 1081 WOLFSSL_LOCAL
void FreeTrustedPeerTable(
TrustedPeerCert**,
int,
void*);
1084 WOLFSSL_ASN_API
int ToTraditional(byte* buffer, word32 length);
1085 WOLFSSL_ASN_API
int ToTraditional_ex(byte* buffer, word32 length,
1087 WOLFSSL_LOCAL
int ToTraditionalInline(
const byte* input, word32* inOutIdx,
1089 WOLFSSL_LOCAL
int ToTraditionalInline_ex(
const byte* input, word32* inOutIdx,
1090 word32 length, word32* algId);
1091 WOLFSSL_LOCAL
int ToTraditionalEnc(byte* buffer, word32 length,
const char*,
int,
1093 WOLFSSL_ASN_API
int UnTraditionalEnc(byte* key, word32 keySz, byte* out,
1094 word32* outSz,
const char* password,
int passwordSz,
int vPKCS,
1095 int vAlgo, byte* salt, word32 saltSz,
int itt,
WC_RNG* rng,
void* heap);
1096 WOLFSSL_ASN_API
int TraditionalEnc(byte* key, word32 keySz, byte* out,
1097 word32* outSz,
const char* password,
int passwordSz,
int vPKCS,
1098 int vAlgo,
int encAlgId, byte* salt, word32 saltSz,
int itt,
1099 WC_RNG* rng,
void* heap);
1100 WOLFSSL_LOCAL
int DecryptContent(byte* input, word32 sz,
const char* psw,
int pswSz);
1101 WOLFSSL_LOCAL
int EncryptContent(byte* input, word32 sz, byte* out, word32* outSz,
1102 const char* password,
int passwordSz,
int vPKCS,
int vAlgo,
1103 byte* salt, word32 saltSz,
int itt,
WC_RNG* rng,
void* heap);
1104 WOLFSSL_LOCAL
int wc_GetKeyOID(byte* key, word32 keySz,
const byte** curveOID,
1105 word32* oidSz,
int* algoID,
void* heap);
1107 typedef struct tm wolfssl_tm;
1108 #if defined(OPENSSL_ALL) || defined(WOLFSSL_MYSQL_COMPATIBLE) || defined(OPENSSL_EXTRA) || \ 1109 defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) 1110 WOLFSSL_LOCAL
int GetTimeString(byte* date,
int format,
char* buf,
int len);
1112 #if !defined(NO_ASN_TIME) && defined(HAVE_PKCS7) 1113 WOLFSSL_LOCAL
int GetAsnTimeString(
void* currTime, byte* buf, word32 len);
1115 WOLFSSL_LOCAL
int ExtractDate(
const unsigned char* date,
unsigned char format,
1116 wolfssl_tm* certTime,
int* idx);
1117 WOLFSSL_LOCAL
int DateGreaterThan(
const struct tm* a,
const struct tm* b);
1118 WOLFSSL_LOCAL
int ValidateDate(
const byte* date, byte format,
int dateType);
1119 WOLFSSL_LOCAL
int wc_OBJ_sn2nid(
const char *sn);
1122 #ifdef WOLFSSL_CERT_GEN 1123 WOLFSSL_ASN_API
int SetName(byte* output, word32 outputSz,
CertName* name);
1125 WOLFSSL_LOCAL
int GetShortInt(
const byte* input, word32* inOutIdx,
int* number,
1127 WOLFSSL_LOCAL
int SetShortInt(byte* input, word32* inOutIdx, word32 number,
1130 WOLFSSL_LOCAL
const char* GetSigName(
int oid);
1131 WOLFSSL_LOCAL
int GetLength(
const byte* input, word32* inOutIdx,
int* len,
1133 WOLFSSL_LOCAL
int GetLength_ex(
const byte* input, word32* inOutIdx,
int* len,
1134 word32 maxIdx,
int check);
1135 WOLFSSL_LOCAL
int GetSequence(
const byte* input, word32* inOutIdx,
int* len,
1137 WOLFSSL_LOCAL
int GetSequence_ex(
const byte* input, word32* inOutIdx,
int* len,
1138 word32 maxIdx,
int check);
1139 WOLFSSL_LOCAL
int GetOctetString(
const byte* input, word32* inOutIdx,
int* len,
1141 WOLFSSL_LOCAL
int GetSet(
const byte* input, word32* inOutIdx,
int* len,
1143 WOLFSSL_LOCAL
int GetSet_ex(
const byte* input, word32* inOutIdx,
int* len,
1144 word32 maxIdx,
int check);
1145 WOLFSSL_LOCAL
int GetMyVersion(
const byte* input, word32* inOutIdx,
1146 int* version, word32 maxIdx);
1147 WOLFSSL_LOCAL
int GetInt(
mp_int* mpi,
const byte* input, word32* inOutIdx,
1149 #ifdef HAVE_OID_ENCODING 1150 WOLFSSL_LOCAL
int EncodeObjectId(
const word16* in, word32 inSz,
1151 byte* out, word32* outSz);
1153 #ifdef HAVE_OID_DECODING 1154 WOLFSSL_LOCAL
int DecodeObjectId(
const byte* in, word32 inSz,
1155 word16* out, word32* outSz);
1157 WOLFSSL_LOCAL
int GetASNObjectId(
const byte* input, word32* inOutIdx,
int* len,
1159 WOLFSSL_LOCAL
int SetObjectId(
int len, byte* output);
1160 WOLFSSL_LOCAL
int GetObjectId(
const byte* input, word32* inOutIdx, word32* oid,
1161 word32 oidType, word32 maxIdx);
1162 WOLFSSL_LOCAL
int GetAlgoId(
const byte* input, word32* inOutIdx, word32* oid,
1163 word32 oidType, word32 maxIdx);
1164 WOLFSSL_LOCAL
int GetASNTag(
const byte* input, word32* idx, byte* tag,
1166 WOLFSSL_LOCAL word32 SetLength(word32 length, byte* output);
1167 WOLFSSL_LOCAL word32 SetSequence(word32 len, byte* output);
1168 WOLFSSL_LOCAL word32 SetOctetString(word32 len, byte* output);
1169 #if (defined(WOLFSSL_QT) || defined(OPENSSL_ALL)) && !defined(NO_DH) \ 1170 || defined(WOLFSSL_OPENSSH) 1171 WOLFSSL_LOCAL
int wc_DhParamsToDer(
DhKey* key, byte* out, word32* outSz);
1172 WOLFSSL_LOCAL
int wc_DhPubKeyToDer(
DhKey* key, byte* out, word32* outSz);
1173 WOLFSSL_LOCAL
int wc_DhPrivKeyToDer(
DhKey* key, byte* out, word32* outSz);
1175 WOLFSSL_LOCAL word32 SetBitString(word32 len, byte unusedBits, byte* output);
1176 WOLFSSL_LOCAL word32 SetImplicit(byte tag,byte number,word32 len,byte* output);
1177 WOLFSSL_LOCAL word32 SetExplicit(byte number, word32 len, byte* output);
1178 WOLFSSL_LOCAL word32 SetSet(word32 len, byte* output);
1179 WOLFSSL_LOCAL word32 SetAlgoID(
int algoOID,byte* output,
int type,
int curveSz);
1180 WOLFSSL_LOCAL
int SetMyVersion(word32 version, byte* output,
int header);
1181 WOLFSSL_LOCAL
int SetSerialNumber(
const byte* sn, word32 snSz, byte* output,
1182 word32 outputSz,
int maxSnSz);
1183 WOLFSSL_LOCAL
int GetSerialNumber(
const byte* input, word32* inOutIdx,
1184 byte* serial,
int* serialSz, word32 maxIdx);
1185 WOLFSSL_LOCAL
int GetNameHash(
const byte* source, word32* idx, byte* hash,
1187 WOLFSSL_LOCAL
int wc_CheckPrivateKey(byte* key, word32 keySz,
DecodedCert* der);
1188 WOLFSSL_LOCAL
int StoreDHparams(byte* out, word32* outLen,
mp_int* p,
mp_int* g);
1189 WOLFSSL_LOCAL
int FlattenAltNames( byte*, word32,
const DNS_entry*);
1193 WOLFSSL_LOCAL
int StoreECC_DSA_Sig(byte* out, word32* outLen,
mp_int* r,
1195 WOLFSSL_LOCAL
int DecodeECC_DSA_Sig(
const byte* sig, word32 sigLen,
1198 #if defined HAVE_ECC && (defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)) 1199 WOLFSSL_API
int EccEnumToNID(
int n);
1202 WOLFSSL_LOCAL
void InitSignatureCtx(
SignatureCtx* sigCtx,
void* heap,
int devId);
1203 WOLFSSL_LOCAL
void FreeSignatureCtx(
SignatureCtx* sigCtx);
1207 WOLFSSL_LOCAL
int wc_EncryptedInfoParse(
EncryptedInfo* info,
char** pBuffer,
1210 WOLFSSL_LOCAL
int PemToDer(
const unsigned char* buff,
long sz,
int type,
1213 WOLFSSL_LOCAL
int AllocDer(
DerBuffer** der, word32 length,
int type,
void* heap);
1214 WOLFSSL_LOCAL
void FreeDer(
DerBuffer** der);
1218 #ifdef WOLFSSL_CERT_GEN 1221 #ifdef WOLFSSL_CERT_EXT 1227 EMAIL_JOINT_LEN = 9,
1228 PILOT_JOINT_LEN = 10,
1245 enum Ocsp_Response_Status {
1246 OCSP_SUCCESSFUL = 0,
1247 OCSP_MALFORMED_REQUEST = 1,
1248 OCSP_INTERNAL_ERROR = 2,
1250 OCSP_SIG_REQUIRED = 5,
1251 OCSP_UNAUTHROIZED = 6
1255 enum Ocsp_Cert_Status {
1263 OCSP_BASIC_OID = 117,
1264 OCSP_NONCE_OID = 118
1267 #ifdef OPENSSL_EXTRA 1268 enum Ocsp_Verify_Error {
1269 OCSP_VERIFY_ERROR_NONE = 0,
1282 byte serial[EXTERNAL_SERIAL_SIZE];
1287 byte thisDate[MAX_DATE_SIZE];
1288 byte nextDate[MAX_DATE_SIZE];
1289 byte thisDateFormat;
1290 byte nextDateFormat;
1291 #if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) 1298 byte* rawOcspResponse;
1299 word32 rawOcspResponseSz;
1309 byte producedDate[MAX_DATE_SIZE];
1311 byte producedDateFormat;
1313 byte* issuerKeyHash;
1330 #ifdef OPENSSL_EXTRA 1337 byte issuerHash[KEYID_SIZE];
1338 byte issuerKeyHash[KEYID_SIZE];
1341 #ifdef OPENSSL_EXTRA 1347 byte nonce[MAX_OCSP_NONCE_SZ];
1356 #define OCSP_DIGEST_SIZE WC_SHA256_DIGEST_SIZE 1358 #define OCSP_DIGEST_SIZE WC_SHA_DIGEST_SIZE 1364 byte issuerHash[OCSP_DIGEST_SIZE];
1365 byte issuerKeyHash[OCSP_DIGEST_SIZE];
1371 WOLFSSL_LOCAL
int OcspResponseDecode(
OcspResponse*,
void*,
void* heap,
int);
1375 WOLFSSL_LOCAL
int EncodeOcspRequest(
OcspRequest*, byte*, word32);
1376 WOLFSSL_LOCAL word32 EncodeOcspRequestExtensions(
OcspRequest*, byte*, word32);
1391 byte serialNumber[EXTERNAL_SERIAL_SIZE];
1402 word32 signatureOID;
1404 byte issuerHash[SIGNER_DIGEST_SIZE];
1405 byte crlHash[SIGNER_DIGEST_SIZE];
1406 byte lastDate[MAX_DATE_SIZE];
1407 byte nextDate[MAX_DATE_SIZE];
1408 byte lastDateFormat;
1409 byte nextDateFormat;
1414 byte extAuthKeyIdSet;
1415 byte extAuthKeyId[SIGNER_DIGEST_SIZE];
1419 WOLFSSL_LOCAL
void InitDecodedCRL(
DecodedCRL*,
void* heap);
1420 WOLFSSL_LOCAL
int VerifyCRL_Signature(
SignatureCtx* sigCtx,
1421 const byte* toBeSigned, word32 tbsSz,
1422 const byte* signature, word32 sigSz,
1423 word32 signatureOID,
Signer *ca,
1425 WOLFSSL_LOCAL
int ParseCRL(
DecodedCRL*,
const byte* buff, word32 sz,
void* cm);
1426 WOLFSSL_LOCAL
void FreeDecodedCRL(
DecodedCRL*);
1439 #if !defined(NO_ASN) || !defined(NO_PWDBASED) 1441 #ifndef MAX_KEY_SIZE 1442 #define MAX_KEY_SIZE 64 1444 #ifndef MAX_UNICODE_SZ 1445 #define MAX_UNICODE_SZ 256 1450 PBE_SHA1_RC4_128 = 1,
1456 PBE_SHA1_RC4_128_SUM = 657,
1457 PBE_SHA1_DES3_SUM = 659,
Definition: integer.h:200
Definition: asn_public.h:195
Definition: asn_public.h:260
Definition: asn_public.h:178
Definition: user_rsa.h:60
Definition: asn_public.h:170
Definition: asn_public.h:213