2 * Copyright 2014-2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
11 * This structure holds all parameters associated with a verify operation by
12 * including an X509_VERIFY_PARAM structure in related structures the
13 * parameters used can be customized
16 struct X509_VERIFY_PARAM_st {
18 time_t check_time; /* Time to use */
19 unsigned long inh_flags; /* Inheritance flags */
20 unsigned long flags; /* Various verify flags */
21 int purpose; /* purpose to check untrusted certificates */
22 int trust; /* trust setting to check */
23 int depth; /* Verify depth */
24 int auth_level; /* Security level for chain verification */
25 STACK_OF(ASN1_OBJECT) *policies; /* Permissible policies */
26 /* Peer identity details */
27 STACK_OF(OPENSSL_STRING) *hosts; /* Set of acceptable names */
28 unsigned int hostflags; /* Flags to control matching features */
29 char *peername; /* Matching hostname in peer certificate */
30 char *email; /* If not NULL email address to match */
32 unsigned char *ip; /* If not NULL IP address to match */
33 size_t iplen; /* Length of IP address */
36 /* No error callback if depth < 0 */
37 int x509_check_cert_time(X509_STORE_CTX *ctx, X509 *x, int depth);
39 /* a sequence of these are used */
40 struct x509_attributes_st {
42 STACK_OF(ASN1_TYPE) *set;
45 struct X509_extension_st {
47 ASN1_BOOLEAN critical;
48 ASN1_OCTET_STRING value;
52 * Method to handle CRL access. In general a CRL could be very large (several
53 * Mb) and can consume large amounts of resources if stored in memory by
54 * multiple processes. This method allows general CRL operations to be
55 * redirected to more efficient callbacks: for example a CRL entry database.
58 #define X509_CRL_METHOD_DYNAMIC 1
60 struct x509_crl_method_st {
62 int (*crl_init) (X509_CRL *crl);
63 int (*crl_free) (X509_CRL *crl);
64 int (*crl_lookup) (X509_CRL *crl, X509_REVOKED **ret,
65 ASN1_INTEGER *ser, X509_NAME *issuer);
66 int (*crl_verify) (X509_CRL *crl, EVP_PKEY *pk);
69 struct x509_lookup_method_st {
71 int (*new_item) (X509_LOOKUP *ctx);
72 void (*free) (X509_LOOKUP *ctx);
73 int (*init) (X509_LOOKUP *ctx);
74 int (*shutdown) (X509_LOOKUP *ctx);
75 int (*ctrl) (X509_LOOKUP *ctx, int cmd, const char *argc, long argl,
77 int (*get_by_subject) (X509_LOOKUP *ctx, int type, X509_NAME *name,
79 int (*get_by_issuer_serial) (X509_LOOKUP *ctx, int type, X509_NAME *name,
80 ASN1_INTEGER *serial, X509_OBJECT *ret);
81 int (*get_by_fingerprint) (X509_LOOKUP *ctx, int type,
82 unsigned char *bytes, int len,
84 int (*get_by_alias) (X509_LOOKUP *ctx, int type, char *str, int len,
88 /* This is the functions plus an instance of the local variables. */
89 struct x509_lookup_st {
90 int init; /* have we been started */
91 int skip; /* don't use us. */
92 X509_LOOKUP_METHOD *method; /* the functions */
93 char *method_data; /* method data */
94 X509_STORE *store_ctx; /* who owns us */
98 * This is used to hold everything. It is used for all certificate
99 * validation. Once we have a certificate chain, the 'verify' function is
100 * then called to actually check the cert chain.
102 struct x509_store_st {
103 /* The following is a cache of trusted certs */
104 int cache; /* if true, stash any hits */
105 STACK_OF(X509_OBJECT) *objs; /* Cache of all objects */
106 /* These are external lookup methods */
107 STACK_OF(X509_LOOKUP) *get_cert_methods;
108 X509_VERIFY_PARAM *param;
109 /* Callbacks for various operations */
110 /* called to verify a certificate */
111 int (*verify) (X509_STORE_CTX *ctx);
113 int (*verify_cb) (int ok, X509_STORE_CTX *ctx);
114 /* get issuers cert from ctx */
115 int (*get_issuer) (X509 **issuer, X509_STORE_CTX *ctx, X509 *x);
117 int (*check_issued) (X509_STORE_CTX *ctx, X509 *x, X509 *issuer);
118 /* Check revocation status of chain */
119 int (*check_revocation) (X509_STORE_CTX *ctx);
121 int (*get_crl) (X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x);
122 /* Check CRL validity */
123 int (*check_crl) (X509_STORE_CTX *ctx, X509_CRL *crl);
124 /* Check certificate against CRL */
125 int (*cert_crl) (X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x);
126 STACK_OF(X509) *(*lookup_certs) (X509_STORE_CTX *ctx, X509_NAME *nm);
127 STACK_OF(X509_CRL) *(*lookup_crls) (X509_STORE_CTX *ctx, X509_NAME *nm);
128 int (*cleanup) (X509_STORE_CTX *ctx);
129 CRYPTO_EX_DATA ex_data;
134 typedef struct lookup_dir_hashes_st BY_DIR_HASH;
135 typedef struct lookup_dir_entry_st BY_DIR_ENTRY;
136 DEFINE_STACK_OF(BY_DIR_HASH)
137 DEFINE_STACK_OF(BY_DIR_ENTRY)
138 typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;
139 DEFINE_STACK_OF(STACK_OF_X509_NAME_ENTRY)