Home | History | Annotate | Line # | Download | only in openssl
      1  1.1  christos /*
      2  1.1  christos  * Copyright 1999-2023 The OpenSSL Project Authors. All Rights Reserved.
      3  1.1  christos  *
      4  1.1  christos  * Licensed under the OpenSSL license (the "License").  You may not use
      5  1.1  christos  * this file except in compliance with the License.  You can obtain a copy
      6  1.1  christos  * in the file LICENSE in the source distribution or at
      7  1.1  christos  * https://www.openssl.org/source/license.html
      8  1.1  christos  */
      9  1.1  christos 
     10  1.1  christos #ifndef HEADER_X509V3_H
     11  1.1  christos # define HEADER_X509V3_H
     12  1.1  christos 
     13  1.1  christos # include <openssl/bio.h>
     14  1.1  christos # include <openssl/x509.h>
     15  1.1  christos # include <openssl/conf.h>
     16  1.1  christos # include <openssl/x509v3err.h>
     17  1.1  christos 
     18  1.1  christos #ifdef __cplusplus
     19  1.1  christos extern "C" {
     20  1.1  christos #endif
     21  1.1  christos 
     22  1.1  christos /* Forward reference */
     23  1.1  christos struct v3_ext_method;
     24  1.1  christos struct v3_ext_ctx;
     25  1.1  christos 
     26  1.1  christos /* Useful typedefs */
     27  1.1  christos 
     28  1.1  christos typedef void *(*X509V3_EXT_NEW)(void);
     29  1.1  christos typedef void (*X509V3_EXT_FREE) (void *);
     30  1.1  christos typedef void *(*X509V3_EXT_D2I)(void *, const unsigned char **, long);
     31  1.1  christos typedef int (*X509V3_EXT_I2D) (void *, unsigned char **);
     32  1.1  christos typedef STACK_OF(CONF_VALUE) *
     33  1.1  christos     (*X509V3_EXT_I2V) (const struct v3_ext_method *method, void *ext,
     34  1.1  christos                        STACK_OF(CONF_VALUE) *extlist);
     35  1.1  christos typedef void *(*X509V3_EXT_V2I)(const struct v3_ext_method *method,
     36  1.1  christos                                 struct v3_ext_ctx *ctx,
     37  1.1  christos                                 STACK_OF(CONF_VALUE) *values);
     38  1.1  christos typedef char *(*X509V3_EXT_I2S)(const struct v3_ext_method *method,
     39  1.1  christos                                 void *ext);
     40  1.1  christos typedef void *(*X509V3_EXT_S2I)(const struct v3_ext_method *method,
     41  1.1  christos                                 struct v3_ext_ctx *ctx, const char *str);
     42  1.1  christos typedef int (*X509V3_EXT_I2R) (const struct v3_ext_method *method, void *ext,
     43  1.1  christos                                BIO *out, int indent);
     44  1.1  christos typedef void *(*X509V3_EXT_R2I)(const struct v3_ext_method *method,
     45  1.1  christos                                 struct v3_ext_ctx *ctx, const char *str);
     46  1.1  christos 
     47  1.1  christos /* V3 extension structure */
     48  1.1  christos 
     49  1.1  christos struct v3_ext_method {
     50  1.1  christos     int ext_nid;
     51  1.1  christos     int ext_flags;
     52  1.1  christos /* If this is set the following four fields are ignored */
     53  1.1  christos     ASN1_ITEM_EXP *it;
     54  1.1  christos /* Old style ASN1 calls */
     55  1.1  christos     X509V3_EXT_NEW ext_new;
     56  1.1  christos     X509V3_EXT_FREE ext_free;
     57  1.1  christos     X509V3_EXT_D2I d2i;
     58  1.1  christos     X509V3_EXT_I2D i2d;
     59  1.1  christos /* The following pair is used for string extensions */
     60  1.1  christos     X509V3_EXT_I2S i2s;
     61  1.1  christos     X509V3_EXT_S2I s2i;
     62  1.1  christos /* The following pair is used for multi-valued extensions */
     63  1.1  christos     X509V3_EXT_I2V i2v;
     64  1.1  christos     X509V3_EXT_V2I v2i;
     65  1.1  christos /* The following are used for raw extensions */
     66  1.1  christos     X509V3_EXT_I2R i2r;
     67  1.1  christos     X509V3_EXT_R2I r2i;
     68  1.1  christos     void *usr_data;             /* Any extension specific data */
     69  1.1  christos };
     70  1.1  christos 
     71  1.1  christos typedef struct X509V3_CONF_METHOD_st {
     72  1.1  christos     char *(*get_string) (void *db, const char *section, const char *value);
     73  1.1  christos     STACK_OF(CONF_VALUE) *(*get_section) (void *db, const char *section);
     74  1.1  christos     void (*free_string) (void *db, char *string);
     75  1.1  christos     void (*free_section) (void *db, STACK_OF(CONF_VALUE) *section);
     76  1.1  christos } X509V3_CONF_METHOD;
     77  1.1  christos 
     78  1.1  christos /* Context specific info */
     79  1.1  christos struct v3_ext_ctx {
     80  1.1  christos # define CTX_TEST 0x1
     81  1.1  christos # define X509V3_CTX_REPLACE 0x2
     82  1.1  christos     int flags;
     83  1.1  christos     X509 *issuer_cert;
     84  1.1  christos     X509 *subject_cert;
     85  1.1  christos     X509_REQ *subject_req;
     86  1.1  christos     X509_CRL *crl;
     87  1.1  christos     X509V3_CONF_METHOD *db_meth;
     88  1.1  christos     void *db;
     89  1.1  christos /* Maybe more here */
     90  1.1  christos };
     91  1.1  christos 
     92  1.1  christos typedef struct v3_ext_method X509V3_EXT_METHOD;
     93  1.1  christos 
     94  1.1  christos DEFINE_STACK_OF(X509V3_EXT_METHOD)
     95  1.1  christos 
     96  1.1  christos /* ext_flags values */
     97  1.1  christos # define X509V3_EXT_DYNAMIC      0x1
     98  1.1  christos # define X509V3_EXT_CTX_DEP      0x2
     99  1.1  christos # define X509V3_EXT_MULTILINE    0x4
    100  1.1  christos 
    101  1.1  christos typedef BIT_STRING_BITNAME ENUMERATED_NAMES;
    102  1.1  christos 
    103  1.1  christos typedef struct BASIC_CONSTRAINTS_st {
    104  1.1  christos     int ca;
    105  1.1  christos     ASN1_INTEGER *pathlen;
    106  1.1  christos } BASIC_CONSTRAINTS;
    107  1.1  christos 
    108  1.1  christos typedef struct PKEY_USAGE_PERIOD_st {
    109  1.1  christos     ASN1_GENERALIZEDTIME *notBefore;
    110  1.1  christos     ASN1_GENERALIZEDTIME *notAfter;
    111  1.1  christos } PKEY_USAGE_PERIOD;
    112  1.1  christos 
    113  1.1  christos typedef struct otherName_st {
    114  1.1  christos     ASN1_OBJECT *type_id;
    115  1.1  christos     ASN1_TYPE *value;
    116  1.1  christos } OTHERNAME;
    117  1.1  christos 
    118  1.1  christos typedef struct EDIPartyName_st {
    119  1.1  christos     ASN1_STRING *nameAssigner;
    120  1.1  christos     ASN1_STRING *partyName;
    121  1.1  christos } EDIPARTYNAME;
    122  1.1  christos 
    123  1.1  christos typedef struct GENERAL_NAME_st {
    124  1.1  christos # define GEN_OTHERNAME   0
    125  1.1  christos # define GEN_EMAIL       1
    126  1.1  christos # define GEN_DNS         2
    127  1.1  christos # define GEN_X400        3
    128  1.1  christos # define GEN_DIRNAME     4
    129  1.1  christos # define GEN_EDIPARTY    5
    130  1.1  christos # define GEN_URI         6
    131  1.1  christos # define GEN_IPADD       7
    132  1.1  christos # define GEN_RID         8
    133  1.1  christos     int type;
    134  1.1  christos     union {
    135  1.1  christos         char *ptr;
    136  1.1  christos         OTHERNAME *otherName;   /* otherName */
    137  1.1  christos         ASN1_IA5STRING *rfc822Name;
    138  1.1  christos         ASN1_IA5STRING *dNSName;
    139  1.1  christos         ASN1_STRING *x400Address;
    140  1.1  christos         X509_NAME *directoryName;
    141  1.1  christos         EDIPARTYNAME *ediPartyName;
    142  1.1  christos         ASN1_IA5STRING *uniformResourceIdentifier;
    143  1.1  christos         ASN1_OCTET_STRING *iPAddress;
    144  1.1  christos         ASN1_OBJECT *registeredID;
    145  1.1  christos         /* Old names */
    146  1.1  christos         ASN1_OCTET_STRING *ip;  /* iPAddress */
    147  1.1  christos         X509_NAME *dirn;        /* dirn */
    148  1.1  christos         ASN1_IA5STRING *ia5;    /* rfc822Name, dNSName,
    149  1.1  christos                                  * uniformResourceIdentifier */
    150  1.1  christos         ASN1_OBJECT *rid;       /* registeredID */
    151  1.1  christos         ASN1_TYPE *other;       /* x400Address */
    152  1.1  christos     } d;
    153  1.1  christos } GENERAL_NAME;
    154  1.1  christos 
    155  1.1  christos typedef struct ACCESS_DESCRIPTION_st {
    156  1.1  christos     ASN1_OBJECT *method;
    157  1.1  christos     GENERAL_NAME *location;
    158  1.1  christos } ACCESS_DESCRIPTION;
    159  1.1  christos 
    160  1.1  christos typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS;
    161  1.1  christos 
    162  1.1  christos typedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE;
    163  1.1  christos 
    164  1.1  christos typedef STACK_OF(ASN1_INTEGER) TLS_FEATURE;
    165  1.1  christos 
    166  1.1  christos DEFINE_STACK_OF(GENERAL_NAME)
    167  1.1  christos typedef STACK_OF(GENERAL_NAME) GENERAL_NAMES;
    168  1.1  christos DEFINE_STACK_OF(GENERAL_NAMES)
    169  1.1  christos 
    170  1.1  christos DEFINE_STACK_OF(ACCESS_DESCRIPTION)
    171  1.1  christos 
    172  1.1  christos typedef struct DIST_POINT_NAME_st {
    173  1.1  christos     int type;
    174  1.1  christos     union {
    175  1.1  christos         GENERAL_NAMES *fullname;
    176  1.1  christos         STACK_OF(X509_NAME_ENTRY) *relativename;
    177  1.1  christos     } name;
    178  1.1  christos /* If relativename then this contains the full distribution point name */
    179  1.1  christos     X509_NAME *dpname;
    180  1.1  christos } DIST_POINT_NAME;
    181  1.1  christos /* All existing reasons */
    182  1.1  christos # define CRLDP_ALL_REASONS       0x807f
    183  1.1  christos 
    184  1.1  christos # define CRL_REASON_NONE                         -1
    185  1.1  christos # define CRL_REASON_UNSPECIFIED                  0
    186  1.1  christos # define CRL_REASON_KEY_COMPROMISE               1
    187  1.1  christos # define CRL_REASON_CA_COMPROMISE                2
    188  1.1  christos # define CRL_REASON_AFFILIATION_CHANGED          3
    189  1.1  christos # define CRL_REASON_SUPERSEDED                   4
    190  1.1  christos # define CRL_REASON_CESSATION_OF_OPERATION       5
    191  1.1  christos # define CRL_REASON_CERTIFICATE_HOLD             6
    192  1.1  christos # define CRL_REASON_REMOVE_FROM_CRL              8
    193  1.1  christos # define CRL_REASON_PRIVILEGE_WITHDRAWN          9
    194  1.1  christos # define CRL_REASON_AA_COMPROMISE                10
    195  1.1  christos 
    196  1.1  christos struct DIST_POINT_st {
    197  1.1  christos     DIST_POINT_NAME *distpoint;
    198  1.1  christos     ASN1_BIT_STRING *reasons;
    199  1.1  christos     GENERAL_NAMES *CRLissuer;
    200  1.1  christos     int dp_reasons;
    201  1.1  christos };
    202  1.1  christos 
    203  1.1  christos typedef STACK_OF(DIST_POINT) CRL_DIST_POINTS;
    204  1.1  christos 
    205  1.1  christos DEFINE_STACK_OF(DIST_POINT)
    206  1.1  christos 
    207  1.1  christos struct AUTHORITY_KEYID_st {
    208  1.1  christos     ASN1_OCTET_STRING *keyid;
    209  1.1  christos     GENERAL_NAMES *issuer;
    210  1.1  christos     ASN1_INTEGER *serial;
    211  1.1  christos };
    212  1.1  christos 
    213  1.1  christos /* Strong extranet structures */
    214  1.1  christos 
    215  1.1  christos typedef struct SXNET_ID_st {
    216  1.1  christos     ASN1_INTEGER *zone;
    217  1.1  christos     ASN1_OCTET_STRING *user;
    218  1.1  christos } SXNETID;
    219  1.1  christos 
    220  1.1  christos DEFINE_STACK_OF(SXNETID)
    221  1.1  christos 
    222  1.1  christos typedef struct SXNET_st {
    223  1.1  christos     ASN1_INTEGER *version;
    224  1.1  christos     STACK_OF(SXNETID) *ids;
    225  1.1  christos } SXNET;
    226  1.1  christos 
    227  1.1  christos typedef struct NOTICEREF_st {
    228  1.1  christos     ASN1_STRING *organization;
    229  1.1  christos     STACK_OF(ASN1_INTEGER) *noticenos;
    230  1.1  christos } NOTICEREF;
    231  1.1  christos 
    232  1.1  christos typedef struct USERNOTICE_st {
    233  1.1  christos     NOTICEREF *noticeref;
    234  1.1  christos     ASN1_STRING *exptext;
    235  1.1  christos } USERNOTICE;
    236  1.1  christos 
    237  1.1  christos typedef struct POLICYQUALINFO_st {
    238  1.1  christos     ASN1_OBJECT *pqualid;
    239  1.1  christos     union {
    240  1.1  christos         ASN1_IA5STRING *cpsuri;
    241  1.1  christos         USERNOTICE *usernotice;
    242  1.1  christos         ASN1_TYPE *other;
    243  1.1  christos     } d;
    244  1.1  christos } POLICYQUALINFO;
    245  1.1  christos 
    246  1.1  christos DEFINE_STACK_OF(POLICYQUALINFO)
    247  1.1  christos 
    248  1.1  christos typedef struct POLICYINFO_st {
    249  1.1  christos     ASN1_OBJECT *policyid;
    250  1.1  christos     STACK_OF(POLICYQUALINFO) *qualifiers;
    251  1.1  christos } POLICYINFO;
    252  1.1  christos 
    253  1.1  christos typedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES;
    254  1.1  christos 
    255  1.1  christos DEFINE_STACK_OF(POLICYINFO)
    256  1.1  christos 
    257  1.1  christos typedef struct POLICY_MAPPING_st {
    258  1.1  christos     ASN1_OBJECT *issuerDomainPolicy;
    259  1.1  christos     ASN1_OBJECT *subjectDomainPolicy;
    260  1.1  christos } POLICY_MAPPING;
    261  1.1  christos 
    262  1.1  christos DEFINE_STACK_OF(POLICY_MAPPING)
    263  1.1  christos 
    264  1.1  christos typedef STACK_OF(POLICY_MAPPING) POLICY_MAPPINGS;
    265  1.1  christos 
    266  1.1  christos typedef struct GENERAL_SUBTREE_st {
    267  1.1  christos     GENERAL_NAME *base;
    268  1.1  christos     ASN1_INTEGER *minimum;
    269  1.1  christos     ASN1_INTEGER *maximum;
    270  1.1  christos } GENERAL_SUBTREE;
    271  1.1  christos 
    272  1.1  christos DEFINE_STACK_OF(GENERAL_SUBTREE)
    273  1.1  christos 
    274  1.1  christos struct NAME_CONSTRAINTS_st {
    275  1.1  christos     STACK_OF(GENERAL_SUBTREE) *permittedSubtrees;
    276  1.1  christos     STACK_OF(GENERAL_SUBTREE) *excludedSubtrees;
    277  1.1  christos };
    278  1.1  christos 
    279  1.1  christos typedef struct POLICY_CONSTRAINTS_st {
    280  1.1  christos     ASN1_INTEGER *requireExplicitPolicy;
    281  1.1  christos     ASN1_INTEGER *inhibitPolicyMapping;
    282  1.1  christos } POLICY_CONSTRAINTS;
    283  1.1  christos 
    284  1.1  christos /* Proxy certificate structures, see RFC 3820 */
    285  1.1  christos typedef struct PROXY_POLICY_st {
    286  1.1  christos     ASN1_OBJECT *policyLanguage;
    287  1.1  christos     ASN1_OCTET_STRING *policy;
    288  1.1  christos } PROXY_POLICY;
    289  1.1  christos 
    290  1.1  christos typedef struct PROXY_CERT_INFO_EXTENSION_st {
    291  1.1  christos     ASN1_INTEGER *pcPathLengthConstraint;
    292  1.1  christos     PROXY_POLICY *proxyPolicy;
    293  1.1  christos } PROXY_CERT_INFO_EXTENSION;
    294  1.1  christos 
    295  1.1  christos DECLARE_ASN1_FUNCTIONS(PROXY_POLICY)
    296  1.1  christos DECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION)
    297  1.1  christos 
    298  1.1  christos struct ISSUING_DIST_POINT_st {
    299  1.1  christos     DIST_POINT_NAME *distpoint;
    300  1.1  christos     int onlyuser;
    301  1.1  christos     int onlyCA;
    302  1.1  christos     ASN1_BIT_STRING *onlysomereasons;
    303  1.1  christos     int indirectCRL;
    304  1.1  christos     int onlyattr;
    305  1.1  christos };
    306  1.1  christos 
    307  1.1  christos /* Values in idp_flags field */
    308  1.1  christos /* IDP present */
    309  1.1  christos # define IDP_PRESENT     0x1
    310  1.1  christos /* IDP values inconsistent */
    311  1.1  christos # define IDP_INVALID     0x2
    312  1.1  christos /* onlyuser true */
    313  1.1  christos # define IDP_ONLYUSER    0x4
    314  1.1  christos /* onlyCA true */
    315  1.1  christos # define IDP_ONLYCA      0x8
    316  1.1  christos /* onlyattr true */
    317  1.1  christos # define IDP_ONLYATTR    0x10
    318  1.1  christos /* indirectCRL true */
    319  1.1  christos # define IDP_INDIRECT    0x20
    320  1.1  christos /* onlysomereasons present */
    321  1.1  christos # define IDP_REASONS     0x40
    322  1.1  christos 
    323  1.1  christos # define X509V3_conf_err(val) ERR_add_error_data(6, \
    324  1.1  christos                         "section:", (val)->section, \
    325  1.1  christos                         ",name:", (val)->name, ",value:", (val)->value)
    326  1.1  christos 
    327  1.1  christos # define X509V3_set_ctx_test(ctx) \
    328  1.1  christos                         X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, CTX_TEST)
    329  1.1  christos # define X509V3_set_ctx_nodb(ctx) (ctx)->db = NULL;
    330  1.1  christos 
    331  1.1  christos # define EXT_BITSTRING(nid, table) { nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), \
    332  1.1  christos                         0,0,0,0, \
    333  1.1  christos                         0,0, \
    334  1.1  christos                         (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \
    335  1.1  christos                         (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, \
    336  1.1  christos                         NULL, NULL, \
    337  1.1  christos                         table}
    338  1.1  christos 
    339  1.1  christos # define EXT_IA5STRING(nid) { nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), \
    340  1.1  christos                         0,0,0,0, \
    341  1.1  christos                         (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \
    342  1.1  christos                         (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, \
    343  1.1  christos                         0,0,0,0, \
    344  1.1  christos                         NULL}
    345  1.1  christos 
    346  1.1  christos # define EXT_END { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
    347  1.1  christos 
    348  1.1  christos /* X509_PURPOSE stuff */
    349  1.1  christos 
    350  1.1  christos # define EXFLAG_BCONS            0x1
    351  1.1  christos # define EXFLAG_KUSAGE           0x2
    352  1.1  christos # define EXFLAG_XKUSAGE          0x4
    353  1.1  christos # define EXFLAG_NSCERT           0x8
    354  1.1  christos 
    355  1.1  christos # define EXFLAG_CA               0x10
    356  1.1  christos /* Really self issued not necessarily self signed */
    357  1.1  christos # define EXFLAG_SI               0x20
    358  1.1  christos # define EXFLAG_V1               0x40
    359  1.1  christos # define EXFLAG_INVALID          0x80
    360  1.1  christos /* EXFLAG_SET is set to indicate that some values have been precomputed */
    361  1.1  christos # define EXFLAG_SET              0x100
    362  1.1  christos # define EXFLAG_CRITICAL         0x200
    363  1.1  christos # define EXFLAG_PROXY            0x400
    364  1.1  christos 
    365  1.1  christos # define EXFLAG_INVALID_POLICY   0x800
    366  1.1  christos # define EXFLAG_FRESHEST         0x1000
    367  1.1  christos # define EXFLAG_SS               0x2000 /* cert is apparently self-signed */
    368  1.1  christos 
    369  1.1  christos # define EXFLAG_NO_FINGERPRINT   0x100000
    370  1.1  christos 
    371  1.1  christos # define KU_DIGITAL_SIGNATURE    0x0080
    372  1.1  christos # define KU_NON_REPUDIATION      0x0040
    373  1.1  christos # define KU_KEY_ENCIPHERMENT     0x0020
    374  1.1  christos # define KU_DATA_ENCIPHERMENT    0x0010
    375  1.1  christos # define KU_KEY_AGREEMENT        0x0008
    376  1.1  christos # define KU_KEY_CERT_SIGN        0x0004
    377  1.1  christos # define KU_CRL_SIGN             0x0002
    378  1.1  christos # define KU_ENCIPHER_ONLY        0x0001
    379  1.1  christos # define KU_DECIPHER_ONLY        0x8000
    380  1.1  christos 
    381  1.1  christos # define NS_SSL_CLIENT           0x80
    382  1.1  christos # define NS_SSL_SERVER           0x40
    383  1.1  christos # define NS_SMIME                0x20
    384  1.1  christos # define NS_OBJSIGN              0x10
    385  1.1  christos # define NS_SSL_CA               0x04
    386  1.1  christos # define NS_SMIME_CA             0x02
    387  1.1  christos # define NS_OBJSIGN_CA           0x01
    388  1.1  christos # define NS_ANY_CA               (NS_SSL_CA|NS_SMIME_CA|NS_OBJSIGN_CA)
    389  1.1  christos 
    390  1.1  christos # define XKU_SSL_SERVER          0x1
    391  1.1  christos # define XKU_SSL_CLIENT          0x2
    392  1.1  christos # define XKU_SMIME               0x4
    393  1.1  christos # define XKU_CODE_SIGN           0x8
    394  1.1  christos # define XKU_SGC                 0x10
    395  1.1  christos # define XKU_OCSP_SIGN           0x20
    396  1.1  christos # define XKU_TIMESTAMP           0x40
    397  1.1  christos # define XKU_DVCS                0x80
    398  1.1  christos # define XKU_ANYEKU              0x100
    399  1.1  christos 
    400  1.1  christos # define X509_PURPOSE_DYNAMIC    0x1
    401  1.1  christos # define X509_PURPOSE_DYNAMIC_NAME       0x2
    402  1.1  christos 
    403  1.1  christos typedef struct x509_purpose_st {
    404  1.1  christos     int purpose;
    405  1.1  christos     int trust;                  /* Default trust ID */
    406  1.1  christos     int flags;
    407  1.1  christos     int (*check_purpose) (const struct x509_purpose_st *, const X509 *, int);
    408  1.1  christos     char *name;
    409  1.1  christos     char *sname;
    410  1.1  christos     void *usr_data;
    411  1.1  christos } X509_PURPOSE;
    412  1.1  christos 
    413  1.1  christos # define X509_PURPOSE_SSL_CLIENT         1
    414  1.1  christos # define X509_PURPOSE_SSL_SERVER         2
    415  1.1  christos # define X509_PURPOSE_NS_SSL_SERVER      3
    416  1.1  christos # define X509_PURPOSE_SMIME_SIGN         4
    417  1.1  christos # define X509_PURPOSE_SMIME_ENCRYPT      5
    418  1.1  christos # define X509_PURPOSE_CRL_SIGN           6
    419  1.1  christos # define X509_PURPOSE_ANY                7
    420  1.1  christos # define X509_PURPOSE_OCSP_HELPER        8
    421  1.1  christos # define X509_PURPOSE_TIMESTAMP_SIGN     9
    422  1.1  christos 
    423  1.1  christos # define X509_PURPOSE_MIN                1
    424  1.1  christos # define X509_PURPOSE_MAX                9
    425  1.1  christos 
    426  1.1  christos /* Flags for X509V3_EXT_print() */
    427  1.1  christos 
    428  1.1  christos # define X509V3_EXT_UNKNOWN_MASK         (0xfL << 16)
    429  1.1  christos /* Return error for unknown extensions */
    430  1.1  christos # define X509V3_EXT_DEFAULT              0
    431  1.1  christos /* Print error for unknown extensions */
    432  1.1  christos # define X509V3_EXT_ERROR_UNKNOWN        (1L << 16)
    433  1.1  christos /* ASN1 parse unknown extensions */
    434  1.1  christos # define X509V3_EXT_PARSE_UNKNOWN        (2L << 16)
    435  1.1  christos /* BIO_dump unknown extensions */
    436  1.1  christos # define X509V3_EXT_DUMP_UNKNOWN         (3L << 16)
    437  1.1  christos 
    438  1.1  christos /* Flags for X509V3_add1_i2d */
    439  1.1  christos 
    440  1.1  christos # define X509V3_ADD_OP_MASK              0xfL
    441  1.1  christos # define X509V3_ADD_DEFAULT              0L
    442  1.1  christos # define X509V3_ADD_APPEND               1L
    443  1.1  christos # define X509V3_ADD_REPLACE              2L
    444  1.1  christos # define X509V3_ADD_REPLACE_EXISTING     3L
    445  1.1  christos # define X509V3_ADD_KEEP_EXISTING        4L
    446  1.1  christos # define X509V3_ADD_DELETE               5L
    447  1.1  christos # define X509V3_ADD_SILENT               0x10
    448  1.1  christos 
    449  1.1  christos DEFINE_STACK_OF(X509_PURPOSE)
    450  1.1  christos 
    451  1.1  christos DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)
    452  1.1  christos 
    453  1.1  christos DECLARE_ASN1_FUNCTIONS(SXNET)
    454  1.1  christos DECLARE_ASN1_FUNCTIONS(SXNETID)
    455  1.1  christos 
    456  1.1  christos int SXNET_add_id_asc(SXNET **psx, const char *zone, const char *user, int userlen);
    457  1.1  christos int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, const char *user,
    458  1.1  christos                        int userlen);
    459  1.1  christos int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, const char *user,
    460  1.1  christos                          int userlen);
    461  1.1  christos 
    462  1.1  christos ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, const char *zone);
    463  1.1  christos ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone);
    464  1.1  christos ASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone);
    465  1.1  christos 
    466  1.1  christos DECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID)
    467  1.1  christos 
    468  1.1  christos DECLARE_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD)
    469  1.1  christos 
    470  1.1  christos DECLARE_ASN1_FUNCTIONS(GENERAL_NAME)
    471  1.1  christos GENERAL_NAME *GENERAL_NAME_dup(GENERAL_NAME *a);
    472  1.1  christos int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b);
    473  1.1  christos 
    474  1.1  christos ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
    475  1.1  christos                                      X509V3_CTX *ctx,
    476  1.1  christos                                      STACK_OF(CONF_VALUE) *nval);
    477  1.1  christos STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
    478  1.1  christos                                           ASN1_BIT_STRING *bits,
    479  1.1  christos                                           STACK_OF(CONF_VALUE) *extlist);
    480  1.1  christos char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5);
    481  1.1  christos ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method,
    482  1.1  christos                                    X509V3_CTX *ctx, const char *str);
    483  1.1  christos 
    484  1.1  christos STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method,
    485  1.1  christos                                        GENERAL_NAME *gen,
    486  1.1  christos                                        STACK_OF(CONF_VALUE) *ret);
    487  1.1  christos int GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen);
    488  1.1  christos 
    489  1.1  christos DECLARE_ASN1_FUNCTIONS(GENERAL_NAMES)
    490  1.1  christos 
    491  1.1  christos STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method,
    492  1.1  christos                                         GENERAL_NAMES *gen,
    493  1.1  christos                                         STACK_OF(CONF_VALUE) *extlist);
    494  1.1  christos GENERAL_NAMES *v2i_GENERAL_NAMES(const X509V3_EXT_METHOD *method,
    495  1.1  christos                                  X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);
    496  1.1  christos 
    497  1.1  christos DECLARE_ASN1_FUNCTIONS(OTHERNAME)
    498  1.1  christos DECLARE_ASN1_FUNCTIONS(EDIPARTYNAME)
    499  1.1  christos int OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b);
    500  1.1  christos void GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value);
    501  1.1  christos void *GENERAL_NAME_get0_value(const GENERAL_NAME *a, int *ptype);
    502  1.1  christos int GENERAL_NAME_set0_othername(GENERAL_NAME *gen,
    503  1.1  christos                                 ASN1_OBJECT *oid, ASN1_TYPE *value);
    504  1.1  christos int GENERAL_NAME_get0_otherName(const GENERAL_NAME *gen,
    505  1.1  christos                                 ASN1_OBJECT **poid, ASN1_TYPE **pvalue);
    506  1.1  christos 
    507  1.1  christos char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method,
    508  1.1  christos                             const ASN1_OCTET_STRING *ia5);
    509  1.1  christos ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method,
    510  1.1  christos                                          X509V3_CTX *ctx, const char *str);
    511  1.1  christos 
    512  1.1  christos DECLARE_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE)
    513  1.1  christos int i2a_ACCESS_DESCRIPTION(BIO *bp, const ACCESS_DESCRIPTION *a);
    514  1.1  christos 
    515  1.1  christos DECLARE_ASN1_ALLOC_FUNCTIONS(TLS_FEATURE)
    516  1.1  christos 
    517  1.1  christos DECLARE_ASN1_FUNCTIONS(CERTIFICATEPOLICIES)
    518  1.1  christos DECLARE_ASN1_FUNCTIONS(POLICYINFO)
    519  1.1  christos DECLARE_ASN1_FUNCTIONS(POLICYQUALINFO)
    520  1.1  christos DECLARE_ASN1_FUNCTIONS(USERNOTICE)
    521  1.1  christos DECLARE_ASN1_FUNCTIONS(NOTICEREF)
    522  1.1  christos 
    523  1.1  christos DECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS)
    524  1.1  christos DECLARE_ASN1_FUNCTIONS(DIST_POINT)
    525  1.1  christos DECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME)
    526  1.1  christos DECLARE_ASN1_FUNCTIONS(ISSUING_DIST_POINT)
    527  1.1  christos 
    528  1.1  christos int DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, X509_NAME *iname);
    529  1.1  christos 
    530  1.1  christos int NAME_CONSTRAINTS_check(X509 *x, NAME_CONSTRAINTS *nc);
    531  1.1  christos int NAME_CONSTRAINTS_check_CN(X509 *x, NAME_CONSTRAINTS *nc);
    532  1.1  christos 
    533  1.1  christos DECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION)
    534  1.1  christos DECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS)
    535  1.1  christos 
    536  1.1  christos DECLARE_ASN1_ITEM(POLICY_MAPPING)
    537  1.1  christos DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_MAPPING)
    538  1.1  christos DECLARE_ASN1_ITEM(POLICY_MAPPINGS)
    539  1.1  christos 
    540  1.1  christos DECLARE_ASN1_ITEM(GENERAL_SUBTREE)
    541  1.1  christos DECLARE_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE)
    542  1.1  christos 
    543  1.1  christos DECLARE_ASN1_ITEM(NAME_CONSTRAINTS)
    544  1.1  christos DECLARE_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS)
    545  1.1  christos 
    546  1.1  christos DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS)
    547  1.1  christos DECLARE_ASN1_ITEM(POLICY_CONSTRAINTS)
    548  1.1  christos 
    549  1.1  christos GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out,
    550  1.1  christos                                const X509V3_EXT_METHOD *method,
    551  1.1  christos                                X509V3_CTX *ctx, int gen_type,
    552  1.1  christos                                const char *value, int is_nc);
    553  1.1  christos 
    554  1.1  christos # ifdef HEADER_CONF_H
    555  1.1  christos GENERAL_NAME *v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method,
    556  1.1  christos                                X509V3_CTX *ctx, CONF_VALUE *cnf);
    557  1.1  christos GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out,
    558  1.1  christos                                   const X509V3_EXT_METHOD *method,
    559  1.1  christos                                   X509V3_CTX *ctx, CONF_VALUE *cnf,
    560  1.1  christos                                   int is_nc);
    561  1.1  christos void X509V3_conf_free(CONF_VALUE *val);
    562  1.1  christos 
    563  1.1  christos X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid,
    564  1.1  christos                                      const char *value);
    565  1.1  christos X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, const char *name,
    566  1.1  christos                                  const char *value);
    567  1.1  christos int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, const char *section,
    568  1.1  christos                             STACK_OF(X509_EXTENSION) **sk);
    569  1.1  christos int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section,
    570  1.1  christos                          X509 *cert);
    571  1.1  christos int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section,
    572  1.1  christos                              X509_REQ *req);
    573  1.1  christos int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section,
    574  1.1  christos                              X509_CRL *crl);
    575  1.1  christos 
    576  1.1  christos X509_EXTENSION *X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf,
    577  1.1  christos                                     X509V3_CTX *ctx, int ext_nid,
    578  1.1  christos                                     const char *value);
    579  1.1  christos X509_EXTENSION *X509V3_EXT_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
    580  1.1  christos                                 const char *name, const char *value);
    581  1.1  christos int X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
    582  1.1  christos                         const char *section, X509 *cert);
    583  1.1  christos int X509V3_EXT_REQ_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
    584  1.1  christos                             const char *section, X509_REQ *req);
    585  1.1  christos int X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
    586  1.1  christos                             const char *section, X509_CRL *crl);
    587  1.1  christos 
    588  1.1  christos int X509V3_add_value_bool_nf(const char *name, int asn1_bool,
    589  1.1  christos                              STACK_OF(CONF_VALUE) **extlist);
    590  1.1  christos int X509V3_get_value_bool(const CONF_VALUE *value, int *asn1_bool);
    591  1.1  christos int X509V3_get_value_int(const CONF_VALUE *value, ASN1_INTEGER **aint);
    592  1.1  christos void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf);
    593  1.1  christos void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH_OF(CONF_VALUE) *lhash);
    594  1.1  christos # endif
    595  1.1  christos 
    596  1.1  christos char *X509V3_get_string(X509V3_CTX *ctx, const char *name, const char *section);
    597  1.1  christos STACK_OF(CONF_VALUE) *X509V3_get_section(X509V3_CTX *ctx, const char *section);
    598  1.1  christos void X509V3_string_free(X509V3_CTX *ctx, char *str);
    599  1.1  christos void X509V3_section_free(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section);
    600  1.1  christos void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject,
    601  1.1  christos                     X509_REQ *req, X509_CRL *crl, int flags);
    602  1.1  christos 
    603  1.1  christos int X509V3_add_value(const char *name, const char *value,
    604  1.1  christos                      STACK_OF(CONF_VALUE) **extlist);
    605  1.1  christos int X509V3_add_value_uchar(const char *name, const unsigned char *value,
    606  1.1  christos                            STACK_OF(CONF_VALUE) **extlist);
    607  1.1  christos int X509V3_add_value_bool(const char *name, int asn1_bool,
    608  1.1  christos                           STACK_OF(CONF_VALUE) **extlist);
    609  1.1  christos int X509V3_add_value_int(const char *name, const ASN1_INTEGER *aint,
    610  1.1  christos                          STACK_OF(CONF_VALUE) **extlist);
    611  1.1  christos char *i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, const ASN1_INTEGER *aint);
    612  1.1  christos ASN1_INTEGER *s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth, const char *value);
    613  1.1  christos char *i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth, const ASN1_ENUMERATED *aint);
    614  1.1  christos char *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth,
    615  1.1  christos                                 const ASN1_ENUMERATED *aint);
    616  1.1  christos int X509V3_EXT_add(X509V3_EXT_METHOD *ext);
    617  1.1  christos int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist);
    618  1.1  christos int X509V3_EXT_add_alias(int nid_to, int nid_from);
    619  1.1  christos void X509V3_EXT_cleanup(void);
    620  1.1  christos 
    621  1.1  christos const X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext);
    622  1.1  christos const X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid);
    623  1.1  christos int X509V3_add_standard_extensions(void);
    624  1.1  christos STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line);
    625  1.1  christos void *X509V3_EXT_d2i(X509_EXTENSION *ext);
    626  1.1  christos void *X509V3_get_d2i(const STACK_OF(X509_EXTENSION) *x, int nid, int *crit,
    627  1.1  christos                      int *idx);
    628  1.1  christos 
    629  1.1  christos X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc);
    630  1.1  christos int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value,
    631  1.1  christos                     int crit, unsigned long flags);
    632  1.1  christos 
    633  1.1  christos #if OPENSSL_API_COMPAT < 0x10100000L
    634  1.1  christos /* The new declarations are in crypto.h, but the old ones were here. */
    635  1.1  christos # define hex_to_string OPENSSL_buf2hexstr
    636  1.1  christos # define string_to_hex OPENSSL_hexstr2buf
    637  1.1  christos #endif
    638  1.1  christos 
    639  1.1  christos void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent,
    640  1.1  christos                         int ml);
    641  1.1  christos int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag,
    642  1.1  christos                      int indent);
    643  1.1  christos #ifndef OPENSSL_NO_STDIO
    644  1.1  christos int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);
    645  1.1  christos #endif
    646  1.1  christos int X509V3_extensions_print(BIO *out, const char *title,
    647  1.1  christos                             const STACK_OF(X509_EXTENSION) *exts,
    648  1.1  christos                             unsigned long flag, int indent);
    649  1.1  christos 
    650  1.1  christos int X509_check_ca(X509 *x);
    651  1.1  christos int X509_check_purpose(X509 *x, int id, int ca);
    652  1.1  christos int X509_supported_extension(X509_EXTENSION *ex);
    653  1.1  christos int X509_PURPOSE_set(int *p, int purpose);
    654  1.1  christos int X509_check_issued(X509 *issuer, X509 *subject);
    655  1.1  christos int X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid);
    656  1.1  christos void X509_set_proxy_flag(X509 *x);
    657  1.1  christos void X509_set_proxy_pathlen(X509 *x, long l);
    658  1.1  christos long X509_get_proxy_pathlen(X509 *x);
    659  1.1  christos 
    660  1.1  christos uint32_t X509_get_extension_flags(X509 *x);
    661  1.1  christos uint32_t X509_get_key_usage(X509 *x);
    662  1.1  christos uint32_t X509_get_extended_key_usage(X509 *x);
    663  1.1  christos const ASN1_OCTET_STRING *X509_get0_subject_key_id(X509 *x);
    664  1.1  christos const ASN1_OCTET_STRING *X509_get0_authority_key_id(X509 *x);
    665  1.1  christos const GENERAL_NAMES *X509_get0_authority_issuer(X509 *x);
    666  1.1  christos const ASN1_INTEGER *X509_get0_authority_serial(X509 *x);
    667  1.1  christos 
    668  1.1  christos int X509_PURPOSE_get_count(void);
    669  1.1  christos X509_PURPOSE *X509_PURPOSE_get0(int idx);
    670  1.1  christos int X509_PURPOSE_get_by_sname(const char *sname);
    671  1.1  christos int X509_PURPOSE_get_by_id(int id);
    672  1.1  christos int X509_PURPOSE_add(int id, int trust, int flags,
    673  1.1  christos                      int (*ck) (const X509_PURPOSE *, const X509 *, int),
    674  1.1  christos                      const char *name, const char *sname, void *arg);
    675  1.1  christos char *X509_PURPOSE_get0_name(const X509_PURPOSE *xp);
    676  1.1  christos char *X509_PURPOSE_get0_sname(const X509_PURPOSE *xp);
    677  1.1  christos int X509_PURPOSE_get_trust(const X509_PURPOSE *xp);
    678  1.1  christos void X509_PURPOSE_cleanup(void);
    679  1.1  christos int X509_PURPOSE_get_id(const X509_PURPOSE *);
    680  1.1  christos 
    681  1.1  christos STACK_OF(OPENSSL_STRING) *X509_get1_email(X509 *x);
    682  1.1  christos STACK_OF(OPENSSL_STRING) *X509_REQ_get1_email(X509_REQ *x);
    683  1.1  christos void X509_email_free(STACK_OF(OPENSSL_STRING) *sk);
    684  1.1  christos STACK_OF(OPENSSL_STRING) *X509_get1_ocsp(X509 *x);
    685  1.1  christos /* Flags for X509_check_* functions */
    686  1.1  christos 
    687  1.1  christos /*
    688  1.1  christos  * Always check subject name for host match even if subject alt names present
    689  1.1  christos  */
    690  1.1  christos # define X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT    0x1
    691  1.1  christos /* Disable wildcard matching for dnsName fields and common name. */
    692  1.1  christos # define X509_CHECK_FLAG_NO_WILDCARDS    0x2
    693  1.1  christos /* Wildcards must not match a partial label. */
    694  1.1  christos # define X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS 0x4
    695  1.1  christos /* Allow (non-partial) wildcards to match multiple labels. */
    696  1.1  christos # define X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS 0x8
    697  1.1  christos /* Constraint verifier subdomain patterns to match a single labels. */
    698  1.1  christos # define X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS 0x10
    699  1.1  christos /* Never check the subject CN */
    700  1.1  christos # define X509_CHECK_FLAG_NEVER_CHECK_SUBJECT    0x20
    701  1.1  christos /*
    702  1.1  christos  * Match reference identifiers starting with "." to any sub-domain.
    703  1.1  christos  * This is a non-public flag, turned on implicitly when the subject
    704  1.1  christos  * reference identity is a DNS name.
    705  1.1  christos  */
    706  1.1  christos # define _X509_CHECK_FLAG_DOT_SUBDOMAINS 0x8000
    707  1.1  christos 
    708  1.1  christos int X509_check_host(X509 *x, const char *chk, size_t chklen,
    709  1.1  christos                     unsigned int flags, char **peername);
    710  1.1  christos int X509_check_email(X509 *x, const char *chk, size_t chklen,
    711  1.1  christos                      unsigned int flags);
    712  1.1  christos int X509_check_ip(X509 *x, const unsigned char *chk, size_t chklen,
    713  1.1  christos                   unsigned int flags);
    714  1.1  christos int X509_check_ip_asc(X509 *x, const char *ipasc, unsigned int flags);
    715  1.1  christos 
    716  1.1  christos ASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc);
    717  1.1  christos ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc);
    718  1.1  christos int X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE) *dn_sk,
    719  1.1  christos                              unsigned long chtype);
    720  1.1  christos 
    721  1.1  christos void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent);
    722  1.1  christos DEFINE_STACK_OF(X509_POLICY_NODE)
    723  1.1  christos 
    724  1.1  christos #ifndef OPENSSL_NO_RFC3779
    725  1.1  christos typedef struct ASRange_st {
    726  1.1  christos     ASN1_INTEGER *min, *max;
    727  1.1  christos } ASRange;
    728  1.1  christos 
    729  1.1  christos # define ASIdOrRange_id          0
    730  1.1  christos # define ASIdOrRange_range       1
    731  1.1  christos 
    732  1.1  christos typedef struct ASIdOrRange_st {
    733  1.1  christos     int type;
    734  1.1  christos     union {
    735  1.1  christos         ASN1_INTEGER *id;
    736  1.1  christos         ASRange *range;
    737  1.1  christos     } u;
    738  1.1  christos } ASIdOrRange;
    739  1.1  christos 
    740  1.1  christos typedef STACK_OF(ASIdOrRange) ASIdOrRanges;
    741  1.1  christos DEFINE_STACK_OF(ASIdOrRange)
    742  1.1  christos 
    743  1.1  christos # define ASIdentifierChoice_inherit              0
    744  1.1  christos # define ASIdentifierChoice_asIdsOrRanges        1
    745  1.1  christos 
    746  1.1  christos typedef struct ASIdentifierChoice_st {
    747  1.1  christos     int type;
    748  1.1  christos     union {
    749  1.1  christos         ASN1_NULL *inherit;
    750  1.1  christos         ASIdOrRanges *asIdsOrRanges;
    751  1.1  christos     } u;
    752  1.1  christos } ASIdentifierChoice;
    753  1.1  christos 
    754  1.1  christos typedef struct ASIdentifiers_st {
    755  1.1  christos     ASIdentifierChoice *asnum, *rdi;
    756  1.1  christos } ASIdentifiers;
    757  1.1  christos 
    758  1.1  christos DECLARE_ASN1_FUNCTIONS(ASRange)
    759  1.1  christos DECLARE_ASN1_FUNCTIONS(ASIdOrRange)
    760  1.1  christos DECLARE_ASN1_FUNCTIONS(ASIdentifierChoice)
    761  1.1  christos DECLARE_ASN1_FUNCTIONS(ASIdentifiers)
    762  1.1  christos 
    763  1.1  christos typedef struct IPAddressRange_st {
    764  1.1  christos     ASN1_BIT_STRING *min, *max;
    765  1.1  christos } IPAddressRange;
    766  1.1  christos 
    767  1.1  christos # define IPAddressOrRange_addressPrefix  0
    768  1.1  christos # define IPAddressOrRange_addressRange   1
    769  1.1  christos 
    770  1.1  christos typedef struct IPAddressOrRange_st {
    771  1.1  christos     int type;
    772  1.1  christos     union {
    773  1.1  christos         ASN1_BIT_STRING *addressPrefix;
    774  1.1  christos         IPAddressRange *addressRange;
    775  1.1  christos     } u;
    776  1.1  christos } IPAddressOrRange;
    777  1.1  christos 
    778  1.1  christos typedef STACK_OF(IPAddressOrRange) IPAddressOrRanges;
    779  1.1  christos DEFINE_STACK_OF(IPAddressOrRange)
    780  1.1  christos 
    781  1.1  christos # define IPAddressChoice_inherit                 0
    782  1.1  christos # define IPAddressChoice_addressesOrRanges       1
    783  1.1  christos 
    784  1.1  christos typedef struct IPAddressChoice_st {
    785  1.1  christos     int type;
    786  1.1  christos     union {
    787  1.1  christos         ASN1_NULL *inherit;
    788  1.1  christos         IPAddressOrRanges *addressesOrRanges;
    789  1.1  christos     } u;
    790  1.1  christos } IPAddressChoice;
    791  1.1  christos 
    792  1.1  christos typedef struct IPAddressFamily_st {
    793  1.1  christos     ASN1_OCTET_STRING *addressFamily;
    794  1.1  christos     IPAddressChoice *ipAddressChoice;
    795  1.1  christos } IPAddressFamily;
    796  1.1  christos 
    797  1.1  christos typedef STACK_OF(IPAddressFamily) IPAddrBlocks;
    798  1.1  christos DEFINE_STACK_OF(IPAddressFamily)
    799  1.1  christos 
    800  1.1  christos DECLARE_ASN1_FUNCTIONS(IPAddressRange)
    801  1.1  christos DECLARE_ASN1_FUNCTIONS(IPAddressOrRange)
    802  1.1  christos DECLARE_ASN1_FUNCTIONS(IPAddressChoice)
    803  1.1  christos DECLARE_ASN1_FUNCTIONS(IPAddressFamily)
    804  1.1  christos 
    805  1.1  christos /*
    806  1.1  christos  * API tag for elements of the ASIdentifer SEQUENCE.
    807  1.1  christos  */
    808  1.1  christos # define V3_ASID_ASNUM   0
    809  1.1  christos # define V3_ASID_RDI     1
    810  1.1  christos 
    811  1.1  christos /*
    812  1.1  christos  * AFI values, assigned by IANA.  It'd be nice to make the AFI
    813  1.1  christos  * handling code totally generic, but there are too many little things
    814  1.1  christos  * that would need to be defined for other address families for it to
    815  1.1  christos  * be worth the trouble.
    816  1.1  christos  */
    817  1.1  christos # define IANA_AFI_IPV4   1
    818  1.1  christos # define IANA_AFI_IPV6   2
    819  1.1  christos 
    820  1.1  christos /*
    821  1.1  christos  * Utilities to construct and extract values from RFC3779 extensions,
    822  1.1  christos  * since some of the encodings (particularly for IP address prefixes
    823  1.1  christos  * and ranges) are a bit tedious to work with directly.
    824  1.1  christos  */
    825  1.1  christos int X509v3_asid_add_inherit(ASIdentifiers *asid, int which);
    826  1.1  christos int X509v3_asid_add_id_or_range(ASIdentifiers *asid, int which,
    827  1.1  christos                                 ASN1_INTEGER *min, ASN1_INTEGER *max);
    828  1.1  christos int X509v3_addr_add_inherit(IPAddrBlocks *addr,
    829  1.1  christos                             const unsigned afi, const unsigned *safi);
    830  1.1  christos int X509v3_addr_add_prefix(IPAddrBlocks *addr,
    831  1.1  christos                            const unsigned afi, const unsigned *safi,
    832  1.1  christos                            unsigned char *a, const int prefixlen);
    833  1.1  christos int X509v3_addr_add_range(IPAddrBlocks *addr,
    834  1.1  christos                           const unsigned afi, const unsigned *safi,
    835  1.1  christos                           unsigned char *min, unsigned char *max);
    836  1.1  christos unsigned X509v3_addr_get_afi(const IPAddressFamily *f);
    837  1.1  christos int X509v3_addr_get_range(IPAddressOrRange *aor, const unsigned afi,
    838  1.1  christos                           unsigned char *min, unsigned char *max,
    839  1.1  christos                           const int length);
    840  1.1  christos 
    841  1.1  christos /*
    842  1.1  christos  * Canonical forms.
    843  1.1  christos  */
    844  1.1  christos int X509v3_asid_is_canonical(ASIdentifiers *asid);
    845  1.1  christos int X509v3_addr_is_canonical(IPAddrBlocks *addr);
    846  1.1  christos int X509v3_asid_canonize(ASIdentifiers *asid);
    847  1.1  christos int X509v3_addr_canonize(IPAddrBlocks *addr);
    848  1.1  christos 
    849  1.1  christos /*
    850  1.1  christos  * Tests for inheritance and containment.
    851  1.1  christos  */
    852  1.1  christos int X509v3_asid_inherits(ASIdentifiers *asid);
    853  1.1  christos int X509v3_addr_inherits(IPAddrBlocks *addr);
    854  1.1  christos int X509v3_asid_subset(ASIdentifiers *a, ASIdentifiers *b);
    855  1.1  christos int X509v3_addr_subset(IPAddrBlocks *a, IPAddrBlocks *b);
    856  1.1  christos 
    857  1.1  christos /*
    858  1.1  christos  * Check whether RFC 3779 extensions nest properly in chains.
    859  1.1  christos  */
    860  1.1  christos int X509v3_asid_validate_path(X509_STORE_CTX *);
    861  1.1  christos int X509v3_addr_validate_path(X509_STORE_CTX *);
    862  1.1  christos int X509v3_asid_validate_resource_set(STACK_OF(X509) *chain,
    863  1.1  christos                                       ASIdentifiers *ext,
    864  1.1  christos                                       int allow_inheritance);
    865  1.1  christos int X509v3_addr_validate_resource_set(STACK_OF(X509) *chain,
    866  1.1  christos                                       IPAddrBlocks *ext, int allow_inheritance);
    867  1.1  christos 
    868  1.1  christos #endif                         /* OPENSSL_NO_RFC3779 */
    869  1.1  christos 
    870  1.1  christos DEFINE_STACK_OF(ASN1_STRING)
    871  1.1  christos 
    872  1.1  christos /*
    873  1.1  christos  * Admission Syntax
    874  1.1  christos  */
    875  1.1  christos typedef struct NamingAuthority_st NAMING_AUTHORITY;
    876  1.1  christos typedef struct ProfessionInfo_st PROFESSION_INFO;
    877  1.1  christos typedef struct Admissions_st ADMISSIONS;
    878  1.1  christos typedef struct AdmissionSyntax_st ADMISSION_SYNTAX;
    879  1.1  christos DECLARE_ASN1_FUNCTIONS(NAMING_AUTHORITY)
    880  1.1  christos DECLARE_ASN1_FUNCTIONS(PROFESSION_INFO)
    881  1.1  christos DECLARE_ASN1_FUNCTIONS(ADMISSIONS)
    882  1.1  christos DECLARE_ASN1_FUNCTIONS(ADMISSION_SYNTAX)
    883  1.1  christos DEFINE_STACK_OF(ADMISSIONS)
    884  1.1  christos DEFINE_STACK_OF(PROFESSION_INFO)
    885  1.1  christos typedef STACK_OF(PROFESSION_INFO) PROFESSION_INFOS;
    886  1.1  christos 
    887  1.1  christos const ASN1_OBJECT *NAMING_AUTHORITY_get0_authorityId(
    888  1.1  christos     const NAMING_AUTHORITY *n);
    889  1.1  christos const ASN1_IA5STRING *NAMING_AUTHORITY_get0_authorityURL(
    890  1.1  christos     const NAMING_AUTHORITY *n);
    891  1.1  christos const ASN1_STRING *NAMING_AUTHORITY_get0_authorityText(
    892  1.1  christos     const NAMING_AUTHORITY *n);
    893  1.1  christos void NAMING_AUTHORITY_set0_authorityId(NAMING_AUTHORITY *n,
    894  1.1  christos     ASN1_OBJECT* namingAuthorityId);
    895  1.1  christos void NAMING_AUTHORITY_set0_authorityURL(NAMING_AUTHORITY *n,
    896  1.1  christos     ASN1_IA5STRING* namingAuthorityUrl);
    897  1.1  christos void NAMING_AUTHORITY_set0_authorityText(NAMING_AUTHORITY *n,
    898  1.1  christos     ASN1_STRING* namingAuthorityText);
    899  1.1  christos 
    900  1.1  christos const GENERAL_NAME *ADMISSION_SYNTAX_get0_admissionAuthority(
    901  1.1  christos     const ADMISSION_SYNTAX *as);
    902  1.1  christos void ADMISSION_SYNTAX_set0_admissionAuthority(
    903  1.1  christos     ADMISSION_SYNTAX *as, GENERAL_NAME *aa);
    904  1.1  christos const STACK_OF(ADMISSIONS) *ADMISSION_SYNTAX_get0_contentsOfAdmissions(
    905  1.1  christos     const ADMISSION_SYNTAX *as);
    906  1.1  christos void ADMISSION_SYNTAX_set0_contentsOfAdmissions(
    907  1.1  christos     ADMISSION_SYNTAX *as, STACK_OF(ADMISSIONS) *a);
    908  1.1  christos const GENERAL_NAME *ADMISSIONS_get0_admissionAuthority(const ADMISSIONS *a);
    909  1.1  christos void ADMISSIONS_set0_admissionAuthority(ADMISSIONS *a, GENERAL_NAME *aa);
    910  1.1  christos const NAMING_AUTHORITY *ADMISSIONS_get0_namingAuthority(const ADMISSIONS *a);
    911  1.1  christos void ADMISSIONS_set0_namingAuthority(ADMISSIONS *a, NAMING_AUTHORITY *na);
    912  1.1  christos const PROFESSION_INFOS *ADMISSIONS_get0_professionInfos(const ADMISSIONS *a);
    913  1.1  christos void ADMISSIONS_set0_professionInfos(ADMISSIONS *a, PROFESSION_INFOS *pi);
    914  1.1  christos const ASN1_OCTET_STRING *PROFESSION_INFO_get0_addProfessionInfo(
    915  1.1  christos     const PROFESSION_INFO *pi);
    916  1.1  christos void PROFESSION_INFO_set0_addProfessionInfo(
    917  1.1  christos     PROFESSION_INFO *pi, ASN1_OCTET_STRING *aos);
    918  1.1  christos const NAMING_AUTHORITY *PROFESSION_INFO_get0_namingAuthority(
    919  1.1  christos     const PROFESSION_INFO *pi);
    920  1.1  christos void PROFESSION_INFO_set0_namingAuthority(
    921  1.1  christos     PROFESSION_INFO *pi, NAMING_AUTHORITY *na);
    922  1.1  christos const STACK_OF(ASN1_STRING) *PROFESSION_INFO_get0_professionItems(
    923  1.1  christos     const PROFESSION_INFO *pi);
    924  1.1  christos void PROFESSION_INFO_set0_professionItems(
    925  1.1  christos     PROFESSION_INFO *pi, STACK_OF(ASN1_STRING) *as);
    926  1.1  christos const STACK_OF(ASN1_OBJECT) *PROFESSION_INFO_get0_professionOIDs(
    927  1.1  christos     const PROFESSION_INFO *pi);
    928  1.1  christos void PROFESSION_INFO_set0_professionOIDs(
    929  1.1  christos     PROFESSION_INFO *pi, STACK_OF(ASN1_OBJECT) *po);
    930  1.1  christos const ASN1_PRINTABLESTRING *PROFESSION_INFO_get0_registrationNumber(
    931  1.1  christos     const PROFESSION_INFO *pi);
    932  1.1  christos void PROFESSION_INFO_set0_registrationNumber(
    933  1.1  christos     PROFESSION_INFO *pi, ASN1_PRINTABLESTRING *rn);
    934  1.1  christos 
    935  1.1  christos # ifdef  __cplusplus
    936  1.1  christos }
    937  1.1  christos # endif
    938  1.1  christos #endif
    939