1 /* 2 * Written by Dr Stephen N Henson ([email protected]) for the OpenSSL project 3 * 2013. 4 */ 5 /* ==================================================================== 6 * Copyright (c) 2013 The OpenSSL Project. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in 17 * the documentation and/or other materials provided with the 18 * distribution. 19 * 20 * 3. All advertising materials mentioning features or use of this 21 * software must display the following acknowledgment: 22 * "This product includes software developed by the OpenSSL Project 23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 24 * 25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 26 * endorse or promote products derived from this software without 27 * prior written permission. For written permission, please contact 28 * [email protected]. 29 * 30 * 5. Products derived from this software may not be called "OpenSSL" 31 * nor may "OpenSSL" appear in their names without prior written 32 * permission of the OpenSSL Project. 33 * 34 * 6. Redistributions of any form whatsoever must retain the following 35 * acknowledgment: 36 * "This product includes software developed by the OpenSSL Project 37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 38 * 39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50 * OF THE POSSIBILITY OF SUCH DAMAGE. 51 * ==================================================================== 52 * 53 * This product includes cryptographic software written by Eric Young 54 * ([email protected]). This product includes software written by Tim 55 * Hudson ([email protected]). 56 * 57 */ 58 59 #ifndef OPENSSL_HEADER_X509_INTERNAL_H 60 #define OPENSSL_HEADER_X509_INTERNAL_H 61 62 #include <openssl/base.h> 63 #include <openssl/evp.h> 64 #include <openssl/x509.h> 65 66 #include "../asn1/internal.h" 67 #include "../internal.h" 68 69 #if defined(__cplusplus) 70 extern "C" { 71 #endif 72 73 74 // Internal structures. 75 76 typedef struct X509_val_st { 77 ASN1_TIME *notBefore; 78 ASN1_TIME *notAfter; 79 } X509_VAL; 80 81 DECLARE_ASN1_FUNCTIONS_const(X509_VAL) 82 83 struct X509_pubkey_st { 84 X509_ALGOR *algor; 85 ASN1_BIT_STRING *public_key; 86 EVP_PKEY *pkey; 87 } /* X509_PUBKEY */; 88 89 // X509_PUBKEY is an |ASN1_ITEM| whose ASN.1 type is SubjectPublicKeyInfo and C 90 // type is |X509_PUBKEY*|. 91 DECLARE_ASN1_ITEM(X509_PUBKEY) 92 93 struct X509_name_entry_st { 94 ASN1_OBJECT *object; 95 ASN1_STRING *value; 96 int set; 97 } /* X509_NAME_ENTRY */; 98 99 // X509_NAME_ENTRY is an |ASN1_ITEM| whose ASN.1 type is AttributeTypeAndValue 100 // (RFC 5280) and C type is |X509_NAME_ENTRY*|. 101 DECLARE_ASN1_ITEM(X509_NAME_ENTRY) 102 103 // we always keep X509_NAMEs in 2 forms. 104 struct X509_name_st { 105 STACK_OF(X509_NAME_ENTRY) *entries; 106 int modified; // true if 'bytes' needs to be built 107 BUF_MEM *bytes; 108 unsigned char *canon_enc; 109 int canon_enclen; 110 } /* X509_NAME */; 111 112 struct x509_attributes_st { 113 ASN1_OBJECT *object; 114 STACK_OF(ASN1_TYPE) *set; 115 } /* X509_ATTRIBUTE */; 116 117 // X509_ATTRIBUTE is an |ASN1_ITEM| whose ASN.1 type is Attribute (RFC 2986) and 118 // C type is |X509_ATTRIBUTE*|. 119 DECLARE_ASN1_ITEM(X509_ATTRIBUTE) 120 121 typedef struct x509_cert_aux_st { 122 STACK_OF(ASN1_OBJECT) *trust; // trusted uses 123 STACK_OF(ASN1_OBJECT) *reject; // rejected uses 124 ASN1_UTF8STRING *alias; // "friendly name" 125 ASN1_OCTET_STRING *keyid; // key id of private key 126 } X509_CERT_AUX; 127 128 DECLARE_ASN1_FUNCTIONS_const(X509_CERT_AUX) 129 130 struct X509_extension_st { 131 ASN1_OBJECT *object; 132 ASN1_BOOLEAN critical; 133 ASN1_OCTET_STRING *value; 134 } /* X509_EXTENSION */; 135 136 // X509_EXTENSION is an |ASN1_ITEM| whose ASN.1 type is X.509 Extension (RFC 137 // 5280) and C type is |X509_EXTENSION*|. 138 DECLARE_ASN1_ITEM(X509_EXTENSION) 139 140 // X509_EXTENSIONS is an |ASN1_ITEM| whose ASN.1 type is SEQUENCE of Extension 141 // (RFC 5280) and C type is |STACK_OF(X509_EXTENSION)*|. 142 DECLARE_ASN1_ITEM(X509_EXTENSIONS) 143 144 typedef struct { 145 ASN1_INTEGER *version; // [ 0 ] default of v1 146 ASN1_INTEGER *serialNumber; 147 X509_ALGOR *signature; 148 X509_NAME *issuer; 149 X509_VAL *validity; 150 X509_NAME *subject; 151 X509_PUBKEY *key; 152 ASN1_BIT_STRING *issuerUID; // [ 1 ] optional in v2 153 ASN1_BIT_STRING *subjectUID; // [ 2 ] optional in v2 154 STACK_OF(X509_EXTENSION) *extensions; // [ 3 ] optional in v3 155 ASN1_ENCODING enc; 156 } X509_CINF; 157 158 // TODO(https://crbug.com/boringssl/407): This is not const because it contains 159 // an |X509_NAME|. 160 DECLARE_ASN1_FUNCTIONS(X509_CINF) 161 162 struct x509_st { 163 X509_CINF *cert_info; 164 X509_ALGOR *sig_alg; 165 ASN1_BIT_STRING *signature; 166 CRYPTO_refcount_t references; 167 CRYPTO_EX_DATA ex_data; 168 // These contain copies of various extension values 169 long ex_pathlen; 170 uint32_t ex_flags; 171 uint32_t ex_kusage; 172 uint32_t ex_xkusage; 173 ASN1_OCTET_STRING *skid; 174 AUTHORITY_KEYID *akid; 175 STACK_OF(DIST_POINT) *crldp; 176 STACK_OF(GENERAL_NAME) *altname; 177 NAME_CONSTRAINTS *nc; 178 unsigned char cert_hash[SHA256_DIGEST_LENGTH]; 179 X509_CERT_AUX *aux; 180 CRYPTO_MUTEX lock; 181 } /* X509 */; 182 183 // X509 is an |ASN1_ITEM| whose ASN.1 type is X.509 Certificate (RFC 5280) and C 184 // type is |X509*|. 185 DECLARE_ASN1_ITEM(X509) 186 187 typedef struct { 188 ASN1_ENCODING enc; 189 ASN1_INTEGER *version; 190 X509_NAME *subject; 191 X509_PUBKEY *pubkey; 192 // d=2 hl=2 l= 0 cons: cont: 00 193 STACK_OF(X509_ATTRIBUTE) *attributes; // [ 0 ] 194 } X509_REQ_INFO; 195 196 // TODO(https://crbug.com/boringssl/407): This is not const because it contains 197 // an |X509_NAME|. 198 DECLARE_ASN1_FUNCTIONS(X509_REQ_INFO) 199 200 struct X509_req_st { 201 X509_REQ_INFO *req_info; 202 X509_ALGOR *sig_alg; 203 ASN1_BIT_STRING *signature; 204 } /* X509_REQ */; 205 206 // X509_REQ is an |ASN1_ITEM| whose ASN.1 type is CertificateRequest (RFC 2986) 207 // and C type is |X509_REQ*|. 208 DECLARE_ASN1_ITEM(X509_REQ) 209 210 struct x509_revoked_st { 211 ASN1_INTEGER *serialNumber; 212 ASN1_TIME *revocationDate; 213 STACK_OF(X509_EXTENSION) /* optional */ *extensions; 214 // Revocation reason 215 int reason; 216 } /* X509_REVOKED */; 217 218 // X509_REVOKED is an |ASN1_ITEM| whose ASN.1 type is an element of the 219 // revokedCertificates field of TBSCertList (RFC 5280) and C type is 220 // |X509_REVOKED*|. 221 DECLARE_ASN1_ITEM(X509_REVOKED) 222 223 typedef struct { 224 ASN1_INTEGER *version; 225 X509_ALGOR *sig_alg; 226 X509_NAME *issuer; 227 ASN1_TIME *lastUpdate; 228 ASN1_TIME *nextUpdate; 229 STACK_OF(X509_REVOKED) *revoked; 230 STACK_OF(X509_EXTENSION) /* [0] */ *extensions; 231 ASN1_ENCODING enc; 232 } X509_CRL_INFO; 233 234 // TODO(https://crbug.com/boringssl/407): This is not const because it contains 235 // an |X509_NAME|. 236 DECLARE_ASN1_FUNCTIONS(X509_CRL_INFO) 237 238 // Values in idp_flags field 239 // IDP present 240 #define IDP_PRESENT 0x1 241 // IDP values inconsistent 242 #define IDP_INVALID 0x2 243 // onlyuser true 244 #define IDP_ONLYUSER 0x4 245 // onlyCA true 246 #define IDP_ONLYCA 0x8 247 // onlyattr true 248 #define IDP_ONLYATTR 0x10 249 // indirectCRL true 250 #define IDP_INDIRECT 0x20 251 // onlysomereasons present 252 #define IDP_REASONS 0x40 253 254 struct X509_crl_st { 255 // actual signature 256 X509_CRL_INFO *crl; 257 X509_ALGOR *sig_alg; 258 ASN1_BIT_STRING *signature; 259 CRYPTO_refcount_t references; 260 int flags; 261 // Copies of various extensions 262 AUTHORITY_KEYID *akid; 263 ISSUING_DIST_POINT *idp; 264 // Convenient breakdown of IDP 265 int idp_flags; 266 unsigned char crl_hash[SHA256_DIGEST_LENGTH]; 267 } /* X509_CRL */; 268 269 // X509_CRL is an |ASN1_ITEM| whose ASN.1 type is X.509 CertificateList (RFC 270 // 5280) and C type is |X509_CRL*|. 271 DECLARE_ASN1_ITEM(X509_CRL) 272 273 // GENERAL_NAME is an |ASN1_ITEM| whose ASN.1 type is GeneralName and C type is 274 // |GENERAL_NAME*|. 275 DECLARE_ASN1_ITEM(GENERAL_NAME) 276 277 // GENERAL_NAMES is an |ASN1_ITEM| whose ASN.1 type is SEQUENCE OF GeneralName 278 // and C type is |GENERAL_NAMES*|, aka |STACK_OF(GENERAL_NAME)*|. 279 DECLARE_ASN1_ITEM(GENERAL_NAMES) 280 281 struct X509_VERIFY_PARAM_st { 282 int64_t check_time; // POSIX time to use 283 unsigned long flags; // Various verify flags 284 int purpose; // purpose to check untrusted certificates 285 int trust; // trust setting to check 286 int depth; // Verify depth 287 STACK_OF(ASN1_OBJECT) *policies; // Permissible policies 288 // The following fields specify acceptable peer identities. 289 STACK_OF(OPENSSL_STRING) *hosts; // Set of acceptable names 290 unsigned int hostflags; // Flags to control matching features 291 char *email; // If not NULL email address to match 292 size_t emaillen; 293 unsigned char *ip; // If not NULL IP address to match 294 size_t iplen; // Length of IP address 295 unsigned char poison; // Fail all verifications at name checking 296 } /* X509_VERIFY_PARAM */; 297 298 struct x509_object_st { 299 // one of the above types 300 int type; 301 union { 302 char *ptr; 303 X509 *x509; 304 X509_CRL *crl; 305 EVP_PKEY *pkey; 306 } data; 307 } /* X509_OBJECT */; 308 309 // NETSCAPE_SPKI is an |ASN1_ITEM| whose ASN.1 type is 310 // SignedPublicKeyAndChallenge and C type is |NETSCAPE_SPKI*|. 311 DECLARE_ASN1_ITEM(NETSCAPE_SPKI) 312 313 // NETSCAPE_SPKAC is an |ASN1_ITEM| whose ASN.1 type is PublicKeyAndChallenge 314 // and C type is |NETSCAPE_SPKAC*|. 315 DECLARE_ASN1_ITEM(NETSCAPE_SPKAC) 316 317 // This is a static that defines the function interface 318 struct x509_lookup_method_st { 319 int (*new_item)(X509_LOOKUP *ctx); 320 void (*free)(X509_LOOKUP *ctx); 321 int (*ctrl)(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, 322 char **ret); 323 int (*get_by_subject)(X509_LOOKUP *ctx, int type, X509_NAME *name, 324 X509_OBJECT *ret); 325 } /* X509_LOOKUP_METHOD */; 326 327 DEFINE_STACK_OF(X509_LOOKUP) 328 329 // This is used to hold everything. It is used for all certificate 330 // validation. Once we have a certificate chain, the 'verify' 331 // function is then called to actually check the cert chain. 332 struct x509_store_st { 333 // The following is a cache of trusted certs 334 STACK_OF(X509_OBJECT) *objs; // Cache of all objects 335 CRYPTO_MUTEX objs_lock; 336 337 // These are external lookup methods 338 STACK_OF(X509_LOOKUP) *get_cert_methods; 339 340 X509_VERIFY_PARAM *param; 341 342 // Callbacks for various operations 343 X509_STORE_CTX_verify_cb verify_cb; // error callback 344 345 CRYPTO_refcount_t references; 346 } /* X509_STORE */; 347 348 // This is the functions plus an instance of the local variables. 349 struct x509_lookup_st { 350 const X509_LOOKUP_METHOD *method; // the functions 351 void *method_data; // method data 352 353 X509_STORE *store_ctx; // who owns us 354 } /* X509_LOOKUP */; 355 356 // This is a used when verifying cert chains. Since the 357 // gathering of the cert chain can take some time (and have to be 358 // 'retried', this needs to be kept and passed around. 359 struct x509_store_ctx_st { 360 X509_STORE *ctx; 361 362 // The following are set by the caller 363 X509 *cert; // The cert to check 364 STACK_OF(X509) *untrusted; // chain of X509s - untrusted - passed in 365 STACK_OF(X509_CRL) *crls; // set of CRLs passed in 366 367 X509_VERIFY_PARAM *param; 368 369 // trusted_stack, if non-NULL, is a set of trusted certificates to consider 370 // instead of those from |X509_STORE|. 371 STACK_OF(X509) *trusted_stack; 372 373 // Callbacks for various operations 374 X509_STORE_CTX_verify_cb verify_cb; // error callback 375 376 // The following is built up 377 int last_untrusted; // index of last untrusted cert 378 STACK_OF(X509) *chain; // chain of X509s - built up and trusted 379 380 // When something goes wrong, this is why 381 int error_depth; 382 int error; 383 X509 *current_cert; 384 X509_CRL *current_crl; // current CRL 385 386 X509 *current_crl_issuer; // issuer of current CRL 387 int current_crl_score; // score of current CRL 388 389 CRYPTO_EX_DATA ex_data; 390 } /* X509_STORE_CTX */; 391 392 ASN1_TYPE *ASN1_generate_v3(const char *str, const X509V3_CTX *cnf); 393 394 int X509_CERT_AUX_print(BIO *bp, X509_CERT_AUX *x, int indent); 395 396 397 // RSA-PSS functions. 398 399 // x509_rsa_pss_to_ctx configures |ctx| for an RSA-PSS operation based on 400 // signature algorithm parameters in |sigalg| (which must have type 401 // |NID_rsassaPss|) and key |pkey|. It returns one on success and zero on 402 // error. 403 int x509_rsa_pss_to_ctx(EVP_MD_CTX *ctx, const X509_ALGOR *sigalg, 404 EVP_PKEY *pkey); 405 406 // x509_rsa_pss_to_ctx sets |algor| to the signature algorithm parameters for 407 // |ctx|, which must have been configured for an RSA-PSS signing operation. It 408 // returns one on success and zero on error. 409 int x509_rsa_ctx_to_pss(EVP_MD_CTX *ctx, X509_ALGOR *algor); 410 411 // x509_print_rsa_pss_params prints a human-readable representation of RSA-PSS 412 // parameters in |sigalg| to |bp|. It returns one on success and zero on 413 // error. 414 int x509_print_rsa_pss_params(BIO *bp, const X509_ALGOR *sigalg, int indent, 415 ASN1_PCTX *pctx); 416 417 418 // Signature algorithm functions. 419 420 // x509_digest_sign_algorithm encodes the signing parameters of |ctx| as an 421 // AlgorithmIdentifier and saves the result in |algor|. It returns one on 422 // success, or zero on error. 423 int x509_digest_sign_algorithm(EVP_MD_CTX *ctx, X509_ALGOR *algor); 424 425 // x509_digest_verify_init sets up |ctx| for a signature verification operation 426 // with public key |pkey| and parameters from |algor|. The |ctx| argument must 427 // have been initialised with |EVP_MD_CTX_init|. It returns one on success, or 428 // zero on error. 429 int x509_digest_verify_init(EVP_MD_CTX *ctx, const X509_ALGOR *sigalg, 430 EVP_PKEY *pkey); 431 432 433 // Path-building functions. 434 435 // X509_policy_check checks certificate policies in |certs|. |user_policies| is 436 // the user-initial-policy-set. If |user_policies| is NULL or empty, it is 437 // interpreted as anyPolicy. |flags| is a set of |X509_V_FLAG_*| values to 438 // apply. It returns |X509_V_OK| on success and |X509_V_ERR_*| on error. It 439 // additionally sets |*out_current_cert| to the certificate where the error 440 // occurred. If the function succeeded, or the error applies to the entire 441 // chain, it sets |*out_current_cert| to NULL. 442 int X509_policy_check(const STACK_OF(X509) *certs, 443 const STACK_OF(ASN1_OBJECT) *user_policies, 444 unsigned long flags, X509 **out_current_cert); 445 446 // x509_check_issued_with_callback calls |X509_check_issued|, but allows the 447 // verify callback to override the result. It returns one on success and zero on 448 // error. 449 // 450 // TODO(davidben): Reduce the scope of the verify callback and remove this. The 451 // callback only runs with |X509_V_FLAG_CB_ISSUER_CHECK|, which is only used by 452 // one internal project and rust-openssl, who use it by mistake. 453 int x509_check_issued_with_callback(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); 454 455 // x509v3_bytes_to_hex encodes |len| bytes from |in| to hex and returns a 456 // newly-allocated NUL-terminated string containing the result, or NULL on 457 // allocation error. 458 // 459 // This function was historically named |hex_to_string| in OpenSSL. Despite the 460 // name, |hex_to_string| converted to hex. 461 OPENSSL_EXPORT char *x509v3_bytes_to_hex(const uint8_t *in, size_t len); 462 463 // x509v3_hex_string_to_bytes decodes |str| in hex and returns a newly-allocated 464 // array containing the result, or NULL on error. On success, it sets |*len| to 465 // the length of the result. Colon separators between bytes in the input are 466 // allowed and ignored. 467 // 468 // This function was historically named |string_to_hex| in OpenSSL. Despite the 469 // name, |string_to_hex| converted from hex. 470 unsigned char *x509v3_hex_to_bytes(const char *str, size_t *len); 471 472 // x509v3_conf_name_matches returns one if |name| is equal to |cmp| or begins 473 // with |cmp| followed by '.', and zero otherwise. 474 int x509v3_conf_name_matches(const char *name, const char *cmp); 475 476 // x509v3_looks_like_dns_name returns one if |in| looks like a DNS name and zero 477 // otherwise. 478 OPENSSL_EXPORT int x509v3_looks_like_dns_name(const unsigned char *in, 479 size_t len); 480 481 // x509v3_cache_extensions fills in a number of fields relating to X.509 482 // extensions in |x|. It returns one on success and zero if some extensions were 483 // invalid. 484 OPENSSL_EXPORT int x509v3_cache_extensions(X509 *x); 485 486 // x509v3_a2i_ipadd decodes |ipasc| as an IPv4 or IPv6 address. IPv6 addresses 487 // use colon-separated syntax while IPv4 addresses use dotted decimal syntax. If 488 // it decodes an IPv4 address, it writes the result to the first four bytes of 489 // |ipout| and returns four. If it decodes an IPv6 address, it writes the result 490 // to all 16 bytes of |ipout| and returns 16. Otherwise, it returns zero. 491 int x509v3_a2i_ipadd(unsigned char ipout[16], const char *ipasc); 492 493 // A |BIT_STRING_BITNAME| is used to contain a list of bit names. 494 typedef struct { 495 int bitnum; 496 const char *lname; 497 const char *sname; 498 } BIT_STRING_BITNAME; 499 500 // x509V3_add_value_asn1_string appends a |CONF_VALUE| with the specified name 501 // and value to |*extlist|. if |*extlist| is NULL, it sets |*extlist| to a 502 // newly-allocated |STACK_OF(CONF_VALUE)| first. It returns one on success and 503 // zero on error. 504 int x509V3_add_value_asn1_string(const char *name, const ASN1_STRING *value, 505 STACK_OF(CONF_VALUE) **extlist); 506 507 // X509V3_NAME_from_section adds attributes to |nm| by interpreting the 508 // key/value pairs in |dn_sk|. It returns one on success and zero on error. 509 // |chtype|, which should be one of |MBSTRING_*| constants, determines the 510 // character encoding used to interpret values. 511 int X509V3_NAME_from_section(X509_NAME *nm, const STACK_OF(CONF_VALUE) *dn_sk, 512 int chtype); 513 514 // X509V3_bool_from_string decodes |str| as a boolean. On success, it returns 515 // one and sets |*out_bool| to resulting value. Otherwise, it returns zero. 516 int X509V3_bool_from_string(const char *str, ASN1_BOOLEAN *out_bool); 517 518 // X509V3_get_value_bool decodes |value| as a boolean. On success, it returns 519 // one and sets |*out_bool| to the resulting value. Otherwise, it returns zero. 520 int X509V3_get_value_bool(const CONF_VALUE *value, ASN1_BOOLEAN *out_bool); 521 522 // X509V3_get_value_int decodes |value| as an integer. On success, it returns 523 // one and sets |*aint| to the resulting value. Otherwise, it returns zero. If 524 // |*aint| was non-NULL at the start of the function, it frees the previous 525 // value before writing a new one. 526 int X509V3_get_value_int(const CONF_VALUE *value, ASN1_INTEGER **aint); 527 528 // X509V3_get_section behaves like |NCONF_get_section| but queries |ctx|'s 529 // config database. 530 const STACK_OF(CONF_VALUE) *X509V3_get_section(const X509V3_CTX *ctx, 531 const char *section); 532 533 // X509V3_add_value appends a |CONF_VALUE| containing |name| and |value| to 534 // |*extlist|. It returns one on success and zero on error. If |*extlist| is 535 // NULL, it sets |*extlist| to a newly-allocated |STACK_OF(CONF_VALUE)| 536 // containing the result. Either |name| or |value| may be NULL to omit the 537 // field. 538 // 539 // On failure, if |*extlist| was NULL, |*extlist| will remain NULL when the 540 // function returns. 541 int X509V3_add_value(const char *name, const char *value, 542 STACK_OF(CONF_VALUE) **extlist); 543 544 // X509V3_add_value_bool behaves like |X509V3_add_value| but stores the value 545 // "TRUE" if |asn1_bool| is non-zero and "FALSE" otherwise. 546 int X509V3_add_value_bool(const char *name, int asn1_bool, 547 STACK_OF(CONF_VALUE) **extlist); 548 549 // X509V3_add_value_bool behaves like |X509V3_add_value| but stores a string 550 // representation of |aint|. Note this string representation may be decimal or 551 // hexadecimal, depending on the size of |aint|. 552 int X509V3_add_value_int(const char *name, const ASN1_INTEGER *aint, 553 STACK_OF(CONF_VALUE) **extlist); 554 555 STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line); 556 557 #define X509V3_conf_err(val) \ 558 ERR_add_error_data(6, "section:", (val)->section, ",name:", (val)->name, \ 559 ",value:", (val)->value); 560 561 // GENERAL_NAME_cmp returns zero if |a| and |b| are equal and a non-zero 562 // value otherwise. Note this function does not provide a comparison suitable 563 // for sorting. 564 // 565 // This function is exported for testing. 566 OPENSSL_EXPORT int GENERAL_NAME_cmp(const GENERAL_NAME *a, 567 const GENERAL_NAME *b); 568 569 // X509_VERIFY_PARAM_lookup returns a pre-defined |X509_VERIFY_PARAM| named by 570 // |name|, or NULL if no such name is defined. 571 const X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name); 572 573 GENERAL_NAME *v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method, 574 const X509V3_CTX *ctx, const CONF_VALUE *cnf); 575 GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out, 576 const X509V3_EXT_METHOD *method, 577 const X509V3_CTX *ctx, const CONF_VALUE *cnf, 578 int is_nc); 579 GENERAL_NAMES *v2i_GENERAL_NAMES(const X509V3_EXT_METHOD *method, 580 const X509V3_CTX *ctx, 581 const STACK_OF(CONF_VALUE) *nval); 582 583 // TODO(https://crbug.com/boringssl/407): Make |issuer| const once the 584 // |X509_NAME| issue is resolved. 585 int X509_check_akid(X509 *issuer, const AUTHORITY_KEYID *akid); 586 587 int X509_is_valid_trust_id(int trust); 588 589 int X509_PURPOSE_get_trust(const X509_PURPOSE *xp); 590 591 // TODO(https://crbug.com/boringssl/695): Remove this. 592 int DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, X509_NAME *iname); 593 594 595 #if defined(__cplusplus) 596 } // extern C 597 #endif 598 599 #endif // OPENSSL_HEADER_X509_INTERNAL_H 600