1 /* Written by Dr Stephen N Henson (steve (at) openssl.org) for the OpenSSL 2 * project 1999. */ 3 /* ==================================================================== 4 * Copyright (c) 1999-2004 The OpenSSL Project. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in 15 * the documentation and/or other materials provided with the 16 * distribution. 17 * 18 * 3. All advertising materials mentioning features or use of this 19 * software must display the following acknowledgment: 20 * "This product includes software developed by the OpenSSL Project 21 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 22 * 23 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 24 * endorse or promote products derived from this software without 25 * prior written permission. For written permission, please contact 26 * licensing (at) OpenSSL.org. 27 * 28 * 5. Products derived from this software may not be called "OpenSSL" 29 * nor may "OpenSSL" appear in their names without prior written 30 * permission of the OpenSSL Project. 31 * 32 * 6. Redistributions of any form whatsoever must retain the following 33 * acknowledgment: 34 * "This product includes software developed by the OpenSSL Project 35 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 36 * 37 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 38 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 39 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 40 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 41 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 42 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 43 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 44 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 45 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 46 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48 * OF THE POSSIBILITY OF SUCH DAMAGE. 49 * ==================================================================== 50 * 51 * This product includes cryptographic software written by Eric Young 52 * (eay (at) cryptsoft.com). This product includes software written by Tim 53 * Hudson (tjh (at) cryptsoft.com). */ 54 55 #ifndef HEADER_X509V3_H 56 #define HEADER_X509V3_H 57 58 #include <openssl/bio.h> 59 #include <openssl/conf.h> 60 #include <openssl/x509.h> 61 62 #ifdef __cplusplus 63 extern "C" { 64 #endif 65 66 /* Forward reference */ 67 struct v3_ext_method; 68 struct v3_ext_ctx; 69 70 /* Useful typedefs */ 71 72 typedef void * (*X509V3_EXT_NEW)(void); 73 typedef void (*X509V3_EXT_FREE)(void *); 74 typedef void * (*X509V3_EXT_D2I)(void *, const unsigned char ** , long); 75 typedef int (*X509V3_EXT_I2D)(void *, unsigned char **); 76 typedef STACK_OF(CONF_VALUE) * 77 (*X509V3_EXT_I2V)(const struct v3_ext_method *method, void *ext, 78 STACK_OF(CONF_VALUE) *extlist); 79 typedef void * (*X509V3_EXT_V2I)(const struct v3_ext_method *method, 80 struct v3_ext_ctx *ctx, 81 STACK_OF(CONF_VALUE) *values); 82 typedef char * (*X509V3_EXT_I2S)(const struct v3_ext_method *method, void *ext); 83 typedef void * (*X509V3_EXT_S2I)(const struct v3_ext_method *method, 84 struct v3_ext_ctx *ctx, const char *str); 85 typedef int (*X509V3_EXT_I2R)(const struct v3_ext_method *method, void *ext, 86 BIO *out, int indent); 87 typedef void * (*X509V3_EXT_R2I)(const struct v3_ext_method *method, 88 struct v3_ext_ctx *ctx, const char *str); 89 90 /* V3 extension structure */ 91 92 struct v3_ext_method { 93 int ext_nid; 94 int ext_flags; 95 /* If this is set the following four fields are ignored */ 96 ASN1_ITEM_EXP *it; 97 /* Old style ASN1 calls */ 98 X509V3_EXT_NEW ext_new; 99 X509V3_EXT_FREE ext_free; 100 X509V3_EXT_D2I d2i; 101 X509V3_EXT_I2D i2d; 102 103 /* The following pair is used for string extensions */ 104 X509V3_EXT_I2S i2s; 105 X509V3_EXT_S2I s2i; 106 107 /* The following pair is used for multi-valued extensions */ 108 X509V3_EXT_I2V i2v; 109 X509V3_EXT_V2I v2i; 110 111 /* The following are used for raw extensions */ 112 X509V3_EXT_I2R i2r; 113 X509V3_EXT_R2I r2i; 114 115 void *usr_data; /* Any extension specific data */ 116 }; 117 118 typedef struct X509V3_CONF_METHOD_st { 119 char * (*get_string)(void *db, char *section, char *value); 120 STACK_OF(CONF_VALUE) * (*get_section)(void *db, char *section); 121 void (*free_string)(void *db, char * string); 122 void (*free_section)(void *db, STACK_OF(CONF_VALUE) *section); 123 } X509V3_CONF_METHOD; 124 125 /* Context specific info */ 126 struct v3_ext_ctx { 127 #define CTX_TEST 0x1 128 int flags; 129 X509 *issuer_cert; 130 X509 *subject_cert; 131 X509_REQ *subject_req; 132 X509_CRL *crl; 133 X509V3_CONF_METHOD *db_meth; 134 void *db; 135 /* Maybe more here */ 136 }; 137 138 typedef struct v3_ext_method X509V3_EXT_METHOD; 139 140 DECLARE_STACK_OF(X509V3_EXT_METHOD) 141 142 /* ext_flags values */ 143 #define X509V3_EXT_DYNAMIC 0x1 144 #define X509V3_EXT_CTX_DEP 0x2 145 #define X509V3_EXT_MULTILINE 0x4 146 147 typedef BIT_STRING_BITNAME ENUMERATED_NAMES; 148 149 typedef struct BASIC_CONSTRAINTS_st { 150 int ca; 151 ASN1_INTEGER *pathlen; 152 } BASIC_CONSTRAINTS; 153 154 155 typedef struct PKEY_USAGE_PERIOD_st { 156 ASN1_GENERALIZEDTIME *notBefore; 157 ASN1_GENERALIZEDTIME *notAfter; 158 } PKEY_USAGE_PERIOD; 159 160 typedef struct otherName_st { 161 ASN1_OBJECT *type_id; 162 ASN1_TYPE *value; 163 } OTHERNAME; 164 165 typedef struct EDIPartyName_st { 166 ASN1_STRING *nameAssigner; 167 ASN1_STRING *partyName; 168 } EDIPARTYNAME; 169 170 typedef struct GENERAL_NAME_st { 171 172 #define GEN_OTHERNAME 0 173 #define GEN_EMAIL 1 174 #define GEN_DNS 2 175 #define GEN_X400 3 176 #define GEN_DIRNAME 4 177 #define GEN_EDIPARTY 5 178 #define GEN_URI 6 179 #define GEN_IPADD 7 180 #define GEN_RID 8 181 182 int type; 183 union { 184 char *ptr; 185 OTHERNAME *otherName; /* otherName */ 186 ASN1_IA5STRING *rfc822Name; 187 ASN1_IA5STRING *dNSName; 188 ASN1_TYPE *x400Address; 189 X509_NAME *directoryName; 190 EDIPARTYNAME *ediPartyName; 191 ASN1_IA5STRING *uniformResourceIdentifier; 192 ASN1_OCTET_STRING *iPAddress; 193 ASN1_OBJECT *registeredID; 194 195 /* Old names */ 196 ASN1_OCTET_STRING *ip; /* iPAddress */ 197 X509_NAME *dirn; /* dirn */ 198 ASN1_IA5STRING *ia5;/* rfc822Name, dNSName, uniformResourceIdentifier */ 199 ASN1_OBJECT *rid; /* registeredID */ 200 ASN1_TYPE *other; /* x400Address */ 201 } d; 202 } GENERAL_NAME; 203 204 typedef STACK_OF(GENERAL_NAME) GENERAL_NAMES; 205 206 typedef struct ACCESS_DESCRIPTION_st { 207 ASN1_OBJECT *method; 208 GENERAL_NAME *location; 209 } ACCESS_DESCRIPTION; 210 211 typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS; 212 213 typedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE; 214 215 DECLARE_STACK_OF(GENERAL_NAME) 216 DECLARE_ASN1_SET_OF(GENERAL_NAME) 217 218 DECLARE_STACK_OF(ACCESS_DESCRIPTION) 219 DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION) 220 221 typedef struct DIST_POINT_NAME_st { 222 int type; 223 union { 224 GENERAL_NAMES *fullname; 225 STACK_OF(X509_NAME_ENTRY) *relativename; 226 } name; 227 /* If relativename then this contains the full distribution point name */ 228 X509_NAME *dpname; 229 } DIST_POINT_NAME; 230 /* All existing reasons */ 231 #define CRLDP_ALL_REASONS 0x807f 232 233 #define CRL_REASON_NONE -1 234 #define CRL_REASON_UNSPECIFIED 0 235 #define CRL_REASON_KEY_COMPROMISE 1 236 #define CRL_REASON_CA_COMPROMISE 2 237 #define CRL_REASON_AFFILIATION_CHANGED 3 238 #define CRL_REASON_SUPERSEDED 4 239 #define CRL_REASON_CESSATION_OF_OPERATION 5 240 #define CRL_REASON_CERTIFICATE_HOLD 6 241 #define CRL_REASON_REMOVE_FROM_CRL 8 242 #define CRL_REASON_PRIVILEGE_WITHDRAWN 9 243 #define CRL_REASON_AA_COMPROMISE 10 244 245 struct DIST_POINT_st { 246 DIST_POINT_NAME *distpoint; 247 ASN1_BIT_STRING *reasons; 248 GENERAL_NAMES *CRLissuer; 249 int dp_reasons; 250 }; 251 252 typedef STACK_OF(DIST_POINT) CRL_DIST_POINTS; 253 254 DECLARE_STACK_OF(DIST_POINT) 255 DECLARE_ASN1_SET_OF(DIST_POINT) 256 257 struct AUTHORITY_KEYID_st { 258 ASN1_OCTET_STRING *keyid; 259 GENERAL_NAMES *issuer; 260 ASN1_INTEGER *serial; 261 }; 262 263 /* Strong extranet structures */ 264 265 typedef struct SXNET_ID_st { 266 ASN1_INTEGER *zone; 267 ASN1_OCTET_STRING *user; 268 } SXNETID; 269 270 DECLARE_STACK_OF(SXNETID) 271 DECLARE_ASN1_SET_OF(SXNETID) 272 273 typedef struct SXNET_st { 274 ASN1_INTEGER *version; 275 STACK_OF(SXNETID) *ids; 276 } SXNET; 277 278 typedef struct NOTICEREF_st { 279 ASN1_STRING *organization; 280 STACK_OF(ASN1_INTEGER) *noticenos; 281 } NOTICEREF; 282 283 typedef struct USERNOTICE_st { 284 NOTICEREF *noticeref; 285 ASN1_STRING *exptext; 286 } USERNOTICE; 287 288 typedef struct POLICYQUALINFO_st { 289 ASN1_OBJECT *pqualid; 290 union { 291 ASN1_IA5STRING *cpsuri; 292 USERNOTICE *usernotice; 293 ASN1_TYPE *other; 294 } d; 295 } POLICYQUALINFO; 296 297 DECLARE_STACK_OF(POLICYQUALINFO) 298 DECLARE_ASN1_SET_OF(POLICYQUALINFO) 299 300 typedef struct POLICYINFO_st { 301 ASN1_OBJECT *policyid; 302 STACK_OF(POLICYQUALINFO) *qualifiers; 303 } POLICYINFO; 304 305 typedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES; 306 307 DECLARE_STACK_OF(POLICYINFO) 308 DECLARE_ASN1_SET_OF(POLICYINFO) 309 310 typedef struct POLICY_MAPPING_st { 311 ASN1_OBJECT *issuerDomainPolicy; 312 ASN1_OBJECT *subjectDomainPolicy; 313 } POLICY_MAPPING; 314 315 DECLARE_STACK_OF(POLICY_MAPPING) 316 317 typedef STACK_OF(POLICY_MAPPING) POLICY_MAPPINGS; 318 319 typedef struct GENERAL_SUBTREE_st { 320 GENERAL_NAME *base; 321 ASN1_INTEGER *minimum; 322 ASN1_INTEGER *maximum; 323 } GENERAL_SUBTREE; 324 325 DECLARE_STACK_OF(GENERAL_SUBTREE) 326 327 struct NAME_CONSTRAINTS_st { 328 STACK_OF(GENERAL_SUBTREE) *permittedSubtrees; 329 STACK_OF(GENERAL_SUBTREE) *excludedSubtrees; 330 }; 331 332 typedef struct POLICY_CONSTRAINTS_st { 333 ASN1_INTEGER *requireExplicitPolicy; 334 ASN1_INTEGER *inhibitPolicyMapping; 335 } POLICY_CONSTRAINTS; 336 337 /* Proxy certificate structures, see RFC 3820 */ 338 typedef struct PROXY_POLICY_st 339 { 340 ASN1_OBJECT *policyLanguage; 341 ASN1_OCTET_STRING *policy; 342 } PROXY_POLICY; 343 344 typedef struct PROXY_CERT_INFO_EXTENSION_st 345 { 346 ASN1_INTEGER *pcPathLengthConstraint; 347 PROXY_POLICY *proxyPolicy; 348 } PROXY_CERT_INFO_EXTENSION; 349 350 DECLARE_ASN1_FUNCTIONS(PROXY_POLICY) 351 DECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION) 352 353 struct ISSUING_DIST_POINT_st 354 { 355 DIST_POINT_NAME *distpoint; 356 int onlyuser; 357 int onlyCA; 358 ASN1_BIT_STRING *onlysomereasons; 359 int indirectCRL; 360 int onlyattr; 361 }; 362 363 /* Values in idp_flags field */ 364 /* IDP present */ 365 #define IDP_PRESENT 0x1 366 /* IDP values inconsistent */ 367 #define IDP_INVALID 0x2 368 /* onlyuser true */ 369 #define IDP_ONLYUSER 0x4 370 /* onlyCA true */ 371 #define IDP_ONLYCA 0x8 372 /* onlyattr true */ 373 #define IDP_ONLYATTR 0x10 374 /* indirectCRL true */ 375 #define IDP_INDIRECT 0x20 376 /* onlysomereasons present */ 377 #define IDP_REASONS 0x40 378 379 #define X509V3_conf_err(val) ERR_add_error_data(6, "section:", val->section, \ 380 ",name:", val->name, ",value:", val->value); 381 382 #define X509V3_set_ctx_test(ctx) \ 383 X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, CTX_TEST) 384 #define X509V3_set_ctx_nodb(ctx) (ctx)->db = NULL; 385 386 #define EXT_BITSTRING(nid, table) { nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), \ 387 0,0,0,0, \ 388 0,0, \ 389 (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \ 390 (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, \ 391 NULL, NULL, \ 392 table} 393 394 #define EXT_IA5STRING(nid) { nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), \ 395 0,0,0,0, \ 396 (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \ 397 (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, \ 398 0,0,0,0, \ 399 NULL} 400 401 #define EXT_END { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} 402 403 404 /* X509_PURPOSE stuff */ 405 406 #define EXFLAG_BCONS 0x1 407 #define EXFLAG_KUSAGE 0x2 408 #define EXFLAG_XKUSAGE 0x4 409 #define EXFLAG_NSCERT 0x8 410 411 #define EXFLAG_CA 0x10 412 /* Really self issued not necessarily self signed */ 413 #define EXFLAG_SI 0x20 414 #define EXFLAG_V1 0x40 415 #define EXFLAG_INVALID 0x80 416 #define EXFLAG_SET 0x100 417 #define EXFLAG_CRITICAL 0x200 418 #define EXFLAG_PROXY 0x400 419 420 #define EXFLAG_INVALID_POLICY 0x800 421 #define EXFLAG_FRESHEST 0x1000 422 /* Self signed */ 423 #define EXFLAG_SS 0x2000 424 425 #define KU_DIGITAL_SIGNATURE 0x0080 426 #define KU_NON_REPUDIATION 0x0040 427 #define KU_KEY_ENCIPHERMENT 0x0020 428 #define KU_DATA_ENCIPHERMENT 0x0010 429 #define KU_KEY_AGREEMENT 0x0008 430 #define KU_KEY_CERT_SIGN 0x0004 431 #define KU_CRL_SIGN 0x0002 432 #define KU_ENCIPHER_ONLY 0x0001 433 #define KU_DECIPHER_ONLY 0x8000 434 435 #define NS_SSL_CLIENT 0x80 436 #define NS_SSL_SERVER 0x40 437 #define NS_SMIME 0x20 438 #define NS_OBJSIGN 0x10 439 #define NS_SSL_CA 0x04 440 #define NS_SMIME_CA 0x02 441 #define NS_OBJSIGN_CA 0x01 442 #define NS_ANY_CA (NS_SSL_CA|NS_SMIME_CA|NS_OBJSIGN_CA) 443 444 #define XKU_SSL_SERVER 0x1 445 #define XKU_SSL_CLIENT 0x2 446 #define XKU_SMIME 0x4 447 #define XKU_CODE_SIGN 0x8 448 #define XKU_SGC 0x10 449 #define XKU_OCSP_SIGN 0x20 450 #define XKU_TIMESTAMP 0x40 451 #define XKU_DVCS 0x80 452 #define XKU_ANYEKU 0x100 453 454 #define X509_PURPOSE_DYNAMIC 0x1 455 #define X509_PURPOSE_DYNAMIC_NAME 0x2 456 457 typedef struct x509_purpose_st { 458 int purpose; 459 int trust; /* Default trust ID */ 460 int flags; 461 int (*check_purpose)(const struct x509_purpose_st *, 462 const X509 *, int); 463 char *name; 464 char *sname; 465 void *usr_data; 466 } X509_PURPOSE; 467 468 #define X509_PURPOSE_SSL_CLIENT 1 469 #define X509_PURPOSE_SSL_SERVER 2 470 #define X509_PURPOSE_NS_SSL_SERVER 3 471 #define X509_PURPOSE_SMIME_SIGN 4 472 #define X509_PURPOSE_SMIME_ENCRYPT 5 473 #define X509_PURPOSE_CRL_SIGN 6 474 #define X509_PURPOSE_ANY 7 475 #define X509_PURPOSE_OCSP_HELPER 8 476 #define X509_PURPOSE_TIMESTAMP_SIGN 9 477 478 #define X509_PURPOSE_MIN 1 479 #define X509_PURPOSE_MAX 9 480 481 /* Flags for X509V3_EXT_print() */ 482 483 #define X509V3_EXT_UNKNOWN_MASK (0xfL << 16) 484 /* Return error for unknown extensions */ 485 #define X509V3_EXT_DEFAULT 0 486 /* Print error for unknown extensions */ 487 #define X509V3_EXT_ERROR_UNKNOWN (1L << 16) 488 /* ASN1 parse unknown extensions */ 489 #define X509V3_EXT_PARSE_UNKNOWN (2L << 16) 490 /* BIO_dump unknown extensions */ 491 #define X509V3_EXT_DUMP_UNKNOWN (3L << 16) 492 493 /* Flags for X509V3_add1_i2d */ 494 495 #define X509V3_ADD_OP_MASK 0xfL 496 #define X509V3_ADD_DEFAULT 0L 497 #define X509V3_ADD_APPEND 1L 498 #define X509V3_ADD_REPLACE 2L 499 #define X509V3_ADD_REPLACE_EXISTING 3L 500 #define X509V3_ADD_KEEP_EXISTING 4L 501 #define X509V3_ADD_DELETE 5L 502 #define X509V3_ADD_SILENT 0x10 503 504 DECLARE_STACK_OF(X509_PURPOSE) 505 506 DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS) 507 508 DECLARE_ASN1_FUNCTIONS(SXNET) 509 DECLARE_ASN1_FUNCTIONS(SXNETID) 510 511 int SXNET_add_id_asc(SXNET **psx, char *zone, char *user, int userlen); 512 int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user, int userlen); 513 int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, char *user, int userlen); 514 515 ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, char *zone); 516 ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone); 517 ASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone); 518 519 DECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID) 520 521 DECLARE_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD) 522 523 DECLARE_ASN1_FUNCTIONS(GENERAL_NAME) 524 OPENSSL_EXPORT GENERAL_NAME *GENERAL_NAME_dup(GENERAL_NAME *a); 525 OPENSSL_EXPORT int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b); 526 527 528 529 OPENSSL_EXPORT ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, 530 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); 531 OPENSSL_EXPORT STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, 532 ASN1_BIT_STRING *bits, 533 STACK_OF(CONF_VALUE) *extlist); 534 535 OPENSSL_EXPORT STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, GENERAL_NAME *gen, STACK_OF(CONF_VALUE) *ret); 536 OPENSSL_EXPORT int GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen); 537 538 DECLARE_ASN1_FUNCTIONS(GENERAL_NAMES) 539 540 OPENSSL_EXPORT STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, 541 GENERAL_NAMES *gen, STACK_OF(CONF_VALUE) *extlist); 542 OPENSSL_EXPORT GENERAL_NAMES *v2i_GENERAL_NAMES(const X509V3_EXT_METHOD *method, 543 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); 544 545 DECLARE_ASN1_FUNCTIONS(OTHERNAME) 546 DECLARE_ASN1_FUNCTIONS(EDIPARTYNAME) 547 OPENSSL_EXPORT int OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b); 548 OPENSSL_EXPORT void GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value); 549 OPENSSL_EXPORT void *GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype); 550 OPENSSL_EXPORT int GENERAL_NAME_set0_othername(GENERAL_NAME *gen, 551 ASN1_OBJECT *oid, ASN1_TYPE *value); 552 OPENSSL_EXPORT int GENERAL_NAME_get0_otherName(GENERAL_NAME *gen, 553 ASN1_OBJECT **poid, ASN1_TYPE **pvalue); 554 555 OPENSSL_EXPORT char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, ASN1_OCTET_STRING *ia5); 556 OPENSSL_EXPORT ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str); 557 558 OPENSSL_EXPORT DECLARE_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE) 559 OPENSSL_EXPORT int i2a_ACCESS_DESCRIPTION(BIO *bp, ACCESS_DESCRIPTION* a); 560 561 DECLARE_ASN1_FUNCTIONS(CERTIFICATEPOLICIES) 562 DECLARE_ASN1_FUNCTIONS(POLICYINFO) 563 DECLARE_ASN1_FUNCTIONS(POLICYQUALINFO) 564 DECLARE_ASN1_FUNCTIONS(USERNOTICE) 565 DECLARE_ASN1_FUNCTIONS(NOTICEREF) 566 567 DECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS) 568 DECLARE_ASN1_FUNCTIONS(DIST_POINT) 569 DECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME) 570 DECLARE_ASN1_FUNCTIONS(ISSUING_DIST_POINT) 571 572 OPENSSL_EXPORT int DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, X509_NAME *iname); 573 574 OPENSSL_EXPORT int NAME_CONSTRAINTS_check(X509 *x, NAME_CONSTRAINTS *nc); 575 576 DECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION) 577 DECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS) 578 579 DECLARE_ASN1_ITEM(POLICY_MAPPING) 580 DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_MAPPING) 581 DECLARE_ASN1_ITEM(POLICY_MAPPINGS) 582 583 DECLARE_ASN1_ITEM(GENERAL_SUBTREE) 584 DECLARE_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE) 585 586 DECLARE_ASN1_ITEM(NAME_CONSTRAINTS) 587 DECLARE_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS) 588 589 DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS) 590 DECLARE_ASN1_ITEM(POLICY_CONSTRAINTS) 591 592 OPENSSL_EXPORT GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out, 593 const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, 594 int gen_type, char *value, int is_nc); 595 596 OPENSSL_EXPORT GENERAL_NAME *v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, 597 CONF_VALUE *cnf); 598 OPENSSL_EXPORT GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out, 599 const X509V3_EXT_METHOD *method, 600 X509V3_CTX *ctx, CONF_VALUE *cnf, int is_nc); 601 OPENSSL_EXPORT void X509V3_conf_free(CONF_VALUE *val); 602 603 OPENSSL_EXPORT X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, char *value); 604 OPENSSL_EXPORT X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name, char *value); 605 OPENSSL_EXPORT int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section, STACK_OF(X509_EXTENSION) **sk); 606 OPENSSL_EXPORT int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509 *cert); 607 OPENSSL_EXPORT int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_REQ *req); 608 OPENSSL_EXPORT int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl); 609 610 OPENSSL_EXPORT X509_EXTENSION *X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, 611 int ext_nid, char *value); 612 OPENSSL_EXPORT X509_EXTENSION *X509V3_EXT_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, 613 char *name, char *value); 614 OPENSSL_EXPORT int X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, 615 char *section, X509 *cert); 616 OPENSSL_EXPORT int X509V3_EXT_REQ_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, 617 char *section, X509_REQ *req); 618 OPENSSL_EXPORT int X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, 619 char *section, X509_CRL *crl); 620 621 OPENSSL_EXPORT int X509V3_add_value_bool_nf(char *name, int asn1_bool, 622 STACK_OF(CONF_VALUE) **extlist); 623 OPENSSL_EXPORT int X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool); 624 OPENSSL_EXPORT int X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint); 625 OPENSSL_EXPORT void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf); 626 OPENSSL_EXPORT void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH_OF(CONF_VALUE) *lhash); 627 628 OPENSSL_EXPORT char * X509V3_get_string(X509V3_CTX *ctx, char *name, char *section); 629 OPENSSL_EXPORT STACK_OF(CONF_VALUE) * X509V3_get_section(X509V3_CTX *ctx, char *section); 630 OPENSSL_EXPORT void X509V3_string_free(X509V3_CTX *ctx, char *str); 631 OPENSSL_EXPORT void X509V3_section_free( X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section); 632 OPENSSL_EXPORT void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject, 633 X509_REQ *req, X509_CRL *crl, int flags); 634 635 OPENSSL_EXPORT int X509V3_add_value(const char *name, const char *value, 636 STACK_OF(CONF_VALUE) **extlist); 637 OPENSSL_EXPORT int X509V3_add_value_uchar(const char *name, const unsigned char *value, 638 STACK_OF(CONF_VALUE) **extlist); 639 OPENSSL_EXPORT int X509V3_add_value_bool(const char *name, int asn1_bool, 640 STACK_OF(CONF_VALUE) **extlist); 641 OPENSSL_EXPORT int X509V3_add_value_int(const char *name, ASN1_INTEGER *aint, 642 STACK_OF(CONF_VALUE) **extlist); 643 OPENSSL_EXPORT char * i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, ASN1_INTEGER *aint); 644 OPENSSL_EXPORT ASN1_INTEGER * s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth, char *value); 645 OPENSSL_EXPORT char * i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint); 646 OPENSSL_EXPORT char * i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint); 647 OPENSSL_EXPORT int X509V3_EXT_add(X509V3_EXT_METHOD *ext); 648 OPENSSL_EXPORT int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist); 649 OPENSSL_EXPORT int X509V3_EXT_add_alias(int nid_to, int nid_from); 650 OPENSSL_EXPORT void X509V3_EXT_cleanup(void); 651 652 OPENSSL_EXPORT const X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext); 653 OPENSSL_EXPORT const X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid); 654 OPENSSL_EXPORT int X509V3_add_standard_extensions(void); 655 OPENSSL_EXPORT STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line); 656 OPENSSL_EXPORT void *X509V3_EXT_d2i(X509_EXTENSION *ext); 657 OPENSSL_EXPORT void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx); 658 659 660 OPENSSL_EXPORT X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc); 661 OPENSSL_EXPORT int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, int crit, unsigned long flags); 662 663 char *hex_to_string(const unsigned char *buffer, long len); 664 unsigned char *string_to_hex(const char *str, long *len); 665 int name_cmp(const char *name, const char *cmp); 666 667 OPENSSL_EXPORT void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent, 668 int ml); 669 OPENSSL_EXPORT int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int indent); 670 OPENSSL_EXPORT int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent); 671 672 OPENSSL_EXPORT int X509V3_extensions_print(BIO *out, const char *title, STACK_OF(X509_EXTENSION) *exts, unsigned long flag, int indent); 673 674 OPENSSL_EXPORT int X509_check_ca(X509 *x); 675 OPENSSL_EXPORT int X509_check_purpose(X509 *x, int id, int ca); 676 OPENSSL_EXPORT int X509_supported_extension(X509_EXTENSION *ex); 677 OPENSSL_EXPORT int X509_PURPOSE_set(int *p, int purpose); 678 OPENSSL_EXPORT int X509_check_issued(X509 *issuer, X509 *subject); 679 OPENSSL_EXPORT int X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid); 680 OPENSSL_EXPORT int X509_PURPOSE_get_count(void); 681 OPENSSL_EXPORT X509_PURPOSE * X509_PURPOSE_get0(int idx); 682 OPENSSL_EXPORT int X509_PURPOSE_get_by_sname(char *sname); 683 OPENSSL_EXPORT int X509_PURPOSE_get_by_id(int id); 684 OPENSSL_EXPORT int X509_PURPOSE_add(int id, int trust, int flags, 685 int (*ck)(const X509_PURPOSE *, const X509 *, int), 686 char *name, char *sname, void *arg); 687 OPENSSL_EXPORT char *X509_PURPOSE_get0_name(X509_PURPOSE *xp); 688 OPENSSL_EXPORT char *X509_PURPOSE_get0_sname(X509_PURPOSE *xp); 689 OPENSSL_EXPORT int X509_PURPOSE_get_trust(X509_PURPOSE *xp); 690 OPENSSL_EXPORT void X509_PURPOSE_cleanup(void); 691 OPENSSL_EXPORT int X509_PURPOSE_get_id(X509_PURPOSE *); 692 693 OPENSSL_EXPORT STACK_OF(OPENSSL_STRING) *X509_get1_email(X509 *x); 694 OPENSSL_EXPORT STACK_OF(OPENSSL_STRING) *X509_REQ_get1_email(X509_REQ *x); 695 OPENSSL_EXPORT void X509_email_free(STACK_OF(OPENSSL_STRING) *sk); 696 OPENSSL_EXPORT STACK_OF(OPENSSL_STRING) *X509_get1_ocsp(X509 *x); 697 /* Flags for X509_check_* functions */ 698 699 /* Always check subject name for host match even if subject alt names present */ 700 #define X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT 0x1 701 /* Disable wildcard matching for dnsName fields and common name. */ 702 #define X509_CHECK_FLAG_NO_WILDCARDS 0x2 703 /* Wildcards must not match a partial label. */ 704 #define X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS 0x4 705 /* Allow (non-partial) wildcards to match multiple labels. */ 706 #define X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS 0x8 707 /* Constraint verifier subdomain patterns to match a single labels. */ 708 #define X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS 0x10 709 /* 710 * Match reference identifiers starting with "." to any sub-domain. 711 * This is a non-public flag, turned on implicitly when the subject 712 * reference identity is a DNS name. 713 */ 714 #define _X509_CHECK_FLAG_DOT_SUBDOMAINS 0x8000 715 716 OPENSSL_EXPORT int X509_check_host(X509 *x, const unsigned char *chk, size_t chklen, 717 unsigned int flags); 718 OPENSSL_EXPORT int X509_check_email(X509 *x, const unsigned char *chk, size_t chklen, 719 unsigned int flags); 720 OPENSSL_EXPORT int X509_check_ip(X509 *x, const unsigned char *chk, size_t chklen, 721 unsigned int flags); 722 OPENSSL_EXPORT int X509_check_ip_asc(X509 *x, const char *ipasc, unsigned int flags); 723 724 OPENSSL_EXPORT ASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc); 725 OPENSSL_EXPORT ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc); 726 OPENSSL_EXPORT int a2i_ipadd(unsigned char *ipout, const char *ipasc); 727 OPENSSL_EXPORT int X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE)*dn_sk, 728 unsigned long chtype); 729 730 OPENSSL_EXPORT void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent); 731 DECLARE_STACK_OF(X509_POLICY_NODE) 732 733 /* BEGIN ERROR CODES */ 734 /* The following lines are auto generated by the script mkerr.pl. Any changes 735 * made after this point may be overwritten when the script is next run. 736 */ 737 void ERR_load_X509V3_strings(void); 738 739 740 #ifdef __cplusplus 741 } 742 #endif 743 #define X509V3_F_do_ext_i2d 100 744 #define X509V3_F_v2i_AUTHORITY_KEYID 101 745 #define X509V3_F_X509V3_parse_list 102 746 #define X509V3_F_SXNET_add_id_asc 103 747 #define X509V3_F_SXNET_get_id_ulong 104 748 #define X509V3_F_v2i_AUTHORITY_INFO_ACCESS 105 749 #define X509V3_F_X509V3_EXT_add 106 750 #define X509V3_F_i2s_ASN1_INTEGER 107 751 #define X509V3_F_s2i_ASN1_OCTET_STRING 108 752 #define X509V3_F_copy_issuer 109 753 #define X509V3_F_v2i_subject_alt 110 754 #define X509V3_F_copy_email 111 755 #define X509V3_F_X509V3_EXT_i2d 112 756 #define X509V3_F_v2i_crld 113 757 #define X509V3_F_policy_section 114 758 #define X509V3_F_a2i_GENERAL_NAME 115 759 #define X509V3_F_hex_to_string 116 760 #define X509V3_F_i2s_ASN1_IA5STRING 117 761 #define X509V3_F_string_to_hex 118 762 #define X509V3_F_v3_generic_extension 119 763 #define X509V3_F_X509V3_get_section 120 764 #define X509V3_F_s2i_skey_id 121 765 #define X509V3_F_nref_nos 122 766 #define X509V3_F_X509V3_get_value_bool 123 767 #define X509V3_F_v2i_NAME_CONSTRAINTS 124 768 #define X509V3_F_v2i_POLICY_MAPPINGS 125 769 #define X509V3_F_v2i_GENERAL_NAMES 126 770 #define X509V3_F_do_dirname 127 771 #define X509V3_F_v2i_ASN1_BIT_STRING 128 772 #define X509V3_F_SXNET_add_id_ulong 129 773 #define X509V3_F_X509V3_EXT_add_alias 130 774 #define X509V3_F_X509V3_add1_i2d 131 775 #define X509V3_F_r2i_pci 132 776 #define X509V3_F_X509V3_get_string 133 777 #define X509V3_F_gnames_from_sectname 134 778 #define X509V3_F_r2i_certpol 135 779 #define X509V3_F_X509V3_add_value 136 780 #define X509V3_F_s2i_ASN1_INTEGER 137 781 #define X509V3_F_v2i_issuer_alt 138 782 #define X509V3_F_v2i_GENERAL_NAME_ex 139 783 #define X509V3_F_X509V3_EXT_nconf 140 784 #define X509V3_F_v2i_BASIC_CONSTRAINTS 141 785 #define X509V3_F_process_pci_value 142 786 #define X509V3_F_notice_section 143 787 #define X509V3_F_X509_PURPOSE_set 144 788 #define X509V3_F_do_ext_nconf 145 789 #define X509V3_F_i2s_ASN1_ENUMERATED 146 790 #define X509V3_F_s2i_ASN1_IA5STRING 147 791 #define X509V3_F_v2i_POLICY_CONSTRAINTS 148 792 #define X509V3_F_v2i_EXTENDED_KEY_USAGE 149 793 #define X509V3_F_SXNET_get_id_asc 150 794 #define X509V3_F_set_dist_point_name 151 795 #define X509V3_F_v2i_idp 152 796 #define X509V3_F_X509_PURPOSE_add 153 797 #define X509V3_F_SXNET_add_id_INTEGER 154 798 #define X509V3_F_i2v_AUTHORITY_INFO_ACCESS 155 799 #define X509V3_F_X509V3_EXT_free 156 800 #define X509V3_R_INVALID_BOOLEAN_STRING 100 801 #define X509V3_R_POLICY_SYNTAX_NOT_CURRENTLY_SUPPORTED 101 802 #define X509V3_R_INVALID_NAME 102 803 #define X509V3_R_OPERATION_NOT_DEFINED 103 804 #define X509V3_R_POLICY_PATH_LENGTH 104 805 #define X509V3_R_INVALID_PROXY_POLICY_SETTING 105 806 #define X509V3_R_INVALID_ASRANGE 106 807 #define X509V3_R_ERROR_CREATING_EXTENSION 107 808 #define X509V3_R_ISSUER_DECODE_ERROR 108 809 #define X509V3_R_OTHERNAME_ERROR 109 810 #define X509V3_R_ILLEGAL_HEX_DIGIT 110 811 #define X509V3_R_NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED 111 812 #define X509V3_R_USER_TOO_LONG 112 813 #define X509V3_R_INVALID_INHERITANCE 113 814 #define X509V3_R_INVALID_SAFI 114 815 #define X509V3_R_INVALID_NULL_VALUE 115 816 #define X509V3_R_NO_SUBJECT_DETAILS 116 817 #define X509V3_R_BAD_OBJECT 117 818 #define X509V3_R_DIRNAME_ERROR 118 819 #define X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT 119 820 #define X509V3_R_INVALID_EXTENSION_STRING 120 821 #define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS 121 822 #define X509V3_R_BN_TO_ASN1_INTEGER_ERROR 122 823 #define X509V3_R_INVALID_OPTION 123 824 #define X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS 124 825 #define X509V3_R_INVALID_POLICY_IDENTIFIER 125 826 #define X509V3_R_INVALID_PURPOSE 126 827 #define X509V3_R_UNKNOWN_EXTENSION 127 828 #define X509V3_R_NO_ISSUER_CERTIFICATE 128 829 #define X509V3_R_BN_DEC2BN_ERROR 129 830 #define X509V3_R_EXPECTED_A_SECTION_NAME 130 831 #define X509V3_R_POLICY_PATH_LENGTH_ALREADY_DEFINED 131 832 #define X509V3_R_MISSING_VALUE 132 833 #define X509V3_R_SECTION_NOT_FOUND 133 834 #define X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED 134 835 #define X509V3_R_POLICY_LANGUAGE_ALREADY_DEFINED 135 836 #define X509V3_R_ILLEGAL_EMPTY_EXTENSION 136 837 #define X509V3_R_NO_POLICY_IDENTIFIER 137 838 #define X509V3_R_NO_ISSUER_DETAILS 138 839 #define X509V3_R_NO_CONFIG_DATABASE 139 840 #define X509V3_R_INCORRECT_POLICY_SYNTAX_TAG 140 841 #define X509V3_R_INVALID_SECTION 141 842 #define X509V3_R_INVALID_IPADDRESS 142 843 #define X509V3_R_EXTENSION_VALUE_ERROR 143 844 #define X509V3_R_UNABLE_TO_GET_ISSUER_KEYID 144 845 #define X509V3_R_INVALID_NULL_ARGUMENT 145 846 #define X509V3_R_ERROR_IN_EXTENSION 146 847 #define X509V3_R_INVALID_NULL_NAME 147 848 #define X509V3_R_BAD_IP_ADDRESS 148 849 #define X509V3_R_UNSUPPORTED_OPTION 149 850 #define X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY 150 851 #define X509V3_R_EXTENSION_EXISTS 151 852 #define X509V3_R_UNKNOWN_OPTION 152 853 #define X509V3_R_ERROR_CONVERTING_ZONE 153 854 #define X509V3_R_NO_PUBLIC_KEY 154 855 #define X509V3_R_INVALID_MULTIPLE_RDNS 155 856 #define X509V3_R_INVALID_SYNTAX 156 857 #define X509V3_R_UNKNOWN_EXTENSION_NAME 157 858 #define X509V3_R_ODD_NUMBER_OF_DIGITS 158 859 #define X509V3_R_DISTPOINT_ALREADY_SET 159 860 #define X509V3_R_UNSUPPORTED_TYPE 160 861 #define X509V3_R_EXTENSION_NAME_ERROR 161 862 #define X509V3_R_INVALID_NUMBERS 162 863 #define X509V3_R_INVALID_NUMBER 163 864 #define X509V3_R_INVALID_OBJECT_IDENTIFIER 164 865 #define X509V3_R_DUPLICATE_ZONE_ID 165 866 #define X509V3_R_EXTENSION_NOT_FOUND 166 867 #define X509V3_R_INVALID_ASNUMBER 167 868 #define X509V3_R_CANNOT_FIND_FREE_FUNCTION 168 869 870 #endif 871