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