155714Skris/* crypto/x509/x509_vfy.h */ 255714Skris/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 355714Skris * All rights reserved. 455714Skris * 555714Skris * This package is an SSL implementation written 655714Skris * by Eric Young (eay@cryptsoft.com). 755714Skris * The implementation was written so as to conform with Netscapes SSL. 8296465Sdelphij * 955714Skris * This library is free for commercial and non-commercial use as long as 1055714Skris * the following conditions are aheared to. The following conditions 1155714Skris * apply to all code found in this distribution, be it the RC4, RSA, 1255714Skris * lhash, DES, etc., code; not just the SSL code. The SSL documentation 1355714Skris * included with this distribution is covered by the same copyright terms 1455714Skris * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15296465Sdelphij * 1655714Skris * Copyright remains Eric Young's, and as such any Copyright notices in 1755714Skris * the code are not to be removed. 1855714Skris * If this package is used in a product, Eric Young should be given attribution 1955714Skris * as the author of the parts of the library used. 2055714Skris * This can be in the form of a textual message at program startup or 2155714Skris * in documentation (online or textual) provided with the package. 22296465Sdelphij * 2355714Skris * Redistribution and use in source and binary forms, with or without 2455714Skris * modification, are permitted provided that the following conditions 2555714Skris * are met: 2655714Skris * 1. Redistributions of source code must retain the copyright 2755714Skris * notice, this list of conditions and the following disclaimer. 2855714Skris * 2. Redistributions in binary form must reproduce the above copyright 2955714Skris * notice, this list of conditions and the following disclaimer in the 3055714Skris * documentation and/or other materials provided with the distribution. 3155714Skris * 3. All advertising materials mentioning features or use of this software 3255714Skris * must display the following acknowledgement: 3355714Skris * "This product includes cryptographic software written by 3455714Skris * Eric Young (eay@cryptsoft.com)" 3555714Skris * The word 'cryptographic' can be left out if the rouines from the library 3655714Skris * being used are not cryptographic related :-). 37296465Sdelphij * 4. If you include any Windows specific code (or a derivative thereof) from 3855714Skris * the apps directory (application code) you must include an acknowledgement: 3955714Skris * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40296465Sdelphij * 4155714Skris * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 4255714Skris * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 4355714Skris * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 4455714Skris * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 4555714Skris * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 4655714Skris * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 4755714Skris * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 4855714Skris * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 4955714Skris * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 5055714Skris * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 5155714Skris * SUCH DAMAGE. 52296465Sdelphij * 5355714Skris * The licence and distribution terms for any publically available version or 5455714Skris * derivative of this code cannot be changed. i.e. this code cannot simply be 5555714Skris * copied and put under another distribution licence 5655714Skris * [including the GNU Public Licence.] 5755714Skris */ 5855714Skris 5955714Skris#ifndef HEADER_X509_H 60296465Sdelphij# include <openssl/x509.h> 61296465Sdelphij/* 62296465Sdelphij * openssl/x509.h ends up #include-ing this file at about the only 63296465Sdelphij * appropriate moment. 64296465Sdelphij */ 6555714Skris#endif 6655714Skris 6755714Skris#ifndef HEADER_X509_VFY_H 68296465Sdelphij# define HEADER_X509_VFY_H 6955714Skris 70296465Sdelphij# include <openssl/opensslconf.h> 71296465Sdelphij# ifndef OPENSSL_NO_LHASH 72296465Sdelphij# include <openssl/lhash.h> 73296465Sdelphij# endif 74296465Sdelphij# include <openssl/bio.h> 75296465Sdelphij# include <openssl/crypto.h> 76296465Sdelphij# include <openssl/symhacks.h> 7768651Skris 7855714Skris#ifdef __cplusplus 7955714Skrisextern "C" { 8055714Skris#endif 8155714Skris 8255714Skris/* Outer object */ 83296465Sdelphijtypedef struct x509_hash_dir_st { 84296465Sdelphij int num_dirs; 85296465Sdelphij char **dirs; 86296465Sdelphij int *dirs_type; 87296465Sdelphij int num_dirs_alloced; 88296465Sdelphij} X509_HASH_DIR_CTX; 8955714Skris 90296465Sdelphijtypedef struct x509_file_st { 91296465Sdelphij int num_paths; /* number of paths to files or directories */ 92296465Sdelphij int num_alloced; 93296465Sdelphij char **paths; /* the list of paths or directories */ 94296465Sdelphij int *path_type; 95296465Sdelphij} X509_CERT_FILE_CTX; 9655714Skris 9755714Skris/*******************************/ 98296465Sdelphij/*- 99296465SdelphijSSL_CTX -> X509_STORE 100296465Sdelphij -> X509_LOOKUP 101296465Sdelphij ->X509_LOOKUP_METHOD 102296465Sdelphij -> X509_LOOKUP 103296465Sdelphij ->X509_LOOKUP_METHOD 10455714Skris 105296465SdelphijSSL -> X509_STORE_CTX 106296465Sdelphij ->X509_STORE 107296465Sdelphij 10855714SkrisThe X509_STORE holds the tables etc for verification stuff. 10955714SkrisA X509_STORE_CTX is used while validating a single certificate. 11055714SkrisThe X509_STORE has X509_LOOKUPs for looking up certs. 11155714SkrisThe X509_STORE then calls a function to actually verify the 11255714Skriscertificate chain. 11355714Skris*/ 11455714Skris 115296465Sdelphij# define X509_LU_RETRY -1 116296465Sdelphij# define X509_LU_FAIL 0 117296465Sdelphij# define X509_LU_X509 1 118296465Sdelphij# define X509_LU_CRL 2 119296465Sdelphij# define X509_LU_PKEY 3 12055714Skris 121296465Sdelphijtypedef struct x509_object_st { 122296465Sdelphij /* one of the above types */ 123296465Sdelphij int type; 124296465Sdelphij union { 125296465Sdelphij char *ptr; 126296465Sdelphij X509 *x509; 127296465Sdelphij X509_CRL *crl; 128296465Sdelphij EVP_PKEY *pkey; 129296465Sdelphij } data; 130296465Sdelphij} X509_OBJECT; 13155714Skris 13255714Skristypedef struct x509_lookup_st X509_LOOKUP; 13355714Skris 13455714SkrisDECLARE_STACK_OF(X509_LOOKUP) 13568651SkrisDECLARE_STACK_OF(X509_OBJECT) 13655714Skris 13755714Skris/* This is a static that defines the function interface */ 138296465Sdelphijtypedef struct x509_lookup_method_st { 139296465Sdelphij const char *name; 140296465Sdelphij int (*new_item) (X509_LOOKUP *ctx); 141296465Sdelphij void (*free) (X509_LOOKUP *ctx); 142296465Sdelphij int (*init) (X509_LOOKUP *ctx); 143296465Sdelphij int (*shutdown) (X509_LOOKUP *ctx); 144296465Sdelphij int (*ctrl) (X509_LOOKUP *ctx, int cmd, const char *argc, long argl, 145296465Sdelphij char **ret); 146296465Sdelphij int (*get_by_subject) (X509_LOOKUP *ctx, int type, X509_NAME *name, 147296465Sdelphij X509_OBJECT *ret); 148296465Sdelphij int (*get_by_issuer_serial) (X509_LOOKUP *ctx, int type, X509_NAME *name, 149296465Sdelphij ASN1_INTEGER *serial, X509_OBJECT *ret); 150296465Sdelphij int (*get_by_fingerprint) (X509_LOOKUP *ctx, int type, 151296465Sdelphij unsigned char *bytes, int len, 152296465Sdelphij X509_OBJECT *ret); 153296465Sdelphij int (*get_by_alias) (X509_LOOKUP *ctx, int type, char *str, int len, 154296465Sdelphij X509_OBJECT *ret); 155296465Sdelphij} X509_LOOKUP_METHOD; 15655714Skris 157296465Sdelphij/* 158296465Sdelphij * This structure hold all parameters associated with a verify operation by 159296465Sdelphij * including an X509_VERIFY_PARAM structure in related structures the 160160814Ssimon * parameters used can be customized 161160814Ssimon */ 162160814Ssimon 163296465Sdelphijtypedef struct X509_VERIFY_PARAM_st { 164296465Sdelphij char *name; 165296465Sdelphij time_t check_time; /* Time to use */ 166296465Sdelphij unsigned long inh_flags; /* Inheritance flags */ 167296465Sdelphij unsigned long flags; /* Various verify flags */ 168296465Sdelphij int purpose; /* purpose to check untrusted certificates */ 169296465Sdelphij int trust; /* trust setting to check */ 170296465Sdelphij int depth; /* Verify depth */ 171296465Sdelphij STACK_OF(ASN1_OBJECT) *policies; /* Permissible policies */ 172296465Sdelphij} X509_VERIFY_PARAM; 173160814Ssimon 174160814SsimonDECLARE_STACK_OF(X509_VERIFY_PARAM) 175160814Ssimon 176296465Sdelphij/* 177296465Sdelphij * This is used to hold everything. It is used for all certificate 178296465Sdelphij * validation. Once we have a certificate chain, the 'verify' function is 179296465Sdelphij * then called to actually check the cert chain. 180296465Sdelphij */ 181296465Sdelphijstruct x509_store_st { 182296465Sdelphij /* The following is a cache of trusted certs */ 183296465Sdelphij int cache; /* if true, stash any hits */ 184296465Sdelphij STACK_OF(X509_OBJECT) *objs; /* Cache of all objects */ 185296465Sdelphij /* These are external lookup methods */ 186296465Sdelphij STACK_OF(X509_LOOKUP) *get_cert_methods; 187296465Sdelphij X509_VERIFY_PARAM *param; 188296465Sdelphij /* Callbacks for various operations */ 189296465Sdelphij /* called to verify a certificate */ 190296465Sdelphij int (*verify) (X509_STORE_CTX *ctx); 191296465Sdelphij /* error callback */ 192296465Sdelphij int (*verify_cb) (int ok, X509_STORE_CTX *ctx); 193296465Sdelphij /* get issuers cert from ctx */ 194296465Sdelphij int (*get_issuer) (X509 **issuer, X509_STORE_CTX *ctx, X509 *x); 195296465Sdelphij /* check issued */ 196296465Sdelphij int (*check_issued) (X509_STORE_CTX *ctx, X509 *x, X509 *issuer); 197296465Sdelphij /* Check revocation status of chain */ 198296465Sdelphij int (*check_revocation) (X509_STORE_CTX *ctx); 199296465Sdelphij /* retrieve CRL */ 200296465Sdelphij int (*get_crl) (X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); 201296465Sdelphij /* Check CRL validity */ 202296465Sdelphij int (*check_crl) (X509_STORE_CTX *ctx, X509_CRL *crl); 203296465Sdelphij /* Check certificate against CRL */ 204296465Sdelphij int (*cert_crl) (X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); 205296465Sdelphij int (*cleanup) (X509_STORE_CTX *ctx); 206296465Sdelphij CRYPTO_EX_DATA ex_data; 207296465Sdelphij int references; 208296465Sdelphij} /* X509_STORE */ ; 20955714Skris 210160814Ssimonint X509_STORE_set_depth(X509_STORE *store, int depth); 21155714Skris 212296465Sdelphij# define X509_STORE_set_verify_cb_func(ctx,func) ((ctx)->verify_cb=(func)) 213296465Sdelphij# define X509_STORE_set_verify_func(ctx,func) ((ctx)->verify=(func)) 21455714Skris 21555714Skris/* This is the functions plus an instance of the local variables. */ 216296465Sdelphijstruct x509_lookup_st { 217296465Sdelphij int init; /* have we been started */ 218296465Sdelphij int skip; /* don't use us. */ 219296465Sdelphij X509_LOOKUP_METHOD *method; /* the functions */ 220296465Sdelphij char *method_data; /* method data */ 221296465Sdelphij X509_STORE *store_ctx; /* who owns us */ 222296465Sdelphij} /* X509_LOOKUP */ ; 22355714Skris 224296465Sdelphij/* 225296465Sdelphij * This is a used when verifying cert chains. Since the gathering of the 226296465Sdelphij * cert chain can take some time (and have to be 'retried', this needs to be 227296465Sdelphij * kept and passed around. 228296465Sdelphij */ 229296465Sdelphijstruct x509_store_ctx_st { /* X509_STORE_CTX */ 230296465Sdelphij X509_STORE *ctx; 231296465Sdelphij /* used when looking up certs */ 232296465Sdelphij int current_method; 233296465Sdelphij /* The following are set by the caller */ 234296465Sdelphij /* The cert to check */ 235296465Sdelphij X509 *cert; 236296465Sdelphij /* chain of X509s - untrusted - passed in */ 237296465Sdelphij STACK_OF(X509) *untrusted; 238296465Sdelphij /* set of CRLs passed in */ 239296465Sdelphij STACK_OF(X509_CRL) *crls; 240296465Sdelphij X509_VERIFY_PARAM *param; 241296465Sdelphij /* Other info for use with get_issuer() */ 242296465Sdelphij void *other_ctx; 243296465Sdelphij /* Callbacks for various operations */ 244296465Sdelphij /* called to verify a certificate */ 245296465Sdelphij int (*verify) (X509_STORE_CTX *ctx); 246296465Sdelphij /* error callback */ 247296465Sdelphij int (*verify_cb) (int ok, X509_STORE_CTX *ctx); 248296465Sdelphij /* get issuers cert from ctx */ 249296465Sdelphij int (*get_issuer) (X509 **issuer, X509_STORE_CTX *ctx, X509 *x); 250296465Sdelphij /* check issued */ 251296465Sdelphij int (*check_issued) (X509_STORE_CTX *ctx, X509 *x, X509 *issuer); 252296465Sdelphij /* Check revocation status of chain */ 253296465Sdelphij int (*check_revocation) (X509_STORE_CTX *ctx); 254296465Sdelphij /* retrieve CRL */ 255296465Sdelphij int (*get_crl) (X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); 256296465Sdelphij /* Check CRL validity */ 257296465Sdelphij int (*check_crl) (X509_STORE_CTX *ctx, X509_CRL *crl); 258296465Sdelphij /* Check certificate against CRL */ 259296465Sdelphij int (*cert_crl) (X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); 260296465Sdelphij int (*check_policy) (X509_STORE_CTX *ctx); 261296465Sdelphij int (*cleanup) (X509_STORE_CTX *ctx); 262296465Sdelphij /* The following is built up */ 263296465Sdelphij /* if 0, rebuild chain */ 264296465Sdelphij int valid; 265296465Sdelphij /* index of last untrusted cert */ 266296465Sdelphij int last_untrusted; 267296465Sdelphij /* chain of X509s - built up and trusted */ 268296465Sdelphij STACK_OF(X509) *chain; 269296465Sdelphij /* Valid policy tree */ 270296465Sdelphij X509_POLICY_TREE *tree; 271296465Sdelphij /* Require explicit policy value */ 272296465Sdelphij int explicit_policy; 273296465Sdelphij /* When something goes wrong, this is why */ 274296465Sdelphij int error_depth; 275296465Sdelphij int error; 276296465Sdelphij X509 *current_cert; 277296465Sdelphij /* cert currently being tested as valid issuer */ 278296465Sdelphij X509 *current_issuer; 279296465Sdelphij /* current CRL */ 280296465Sdelphij X509_CRL *current_crl; 281296465Sdelphij CRYPTO_EX_DATA ex_data; 282296465Sdelphij} /* X509_STORE_CTX */ ; 28355714Skris 284160814Ssimonvoid X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth); 28555714Skris 286296465Sdelphij# define X509_STORE_CTX_set_app_data(ctx,data) \ 287296465Sdelphij X509_STORE_CTX_set_ex_data(ctx,0,data) 288296465Sdelphij# define X509_STORE_CTX_get_app_data(ctx) \ 289296465Sdelphij X509_STORE_CTX_get_ex_data(ctx,0) 29055714Skris 291296465Sdelphij# define X509_L_FILE_LOAD 1 292296465Sdelphij# define X509_L_ADD_DIR 2 29355714Skris 294296465Sdelphij# define X509_LOOKUP_load_file(x,name,type) \ 295296465Sdelphij X509_LOOKUP_ctrl((x),X509_L_FILE_LOAD,(name),(long)(type),NULL) 29655714Skris 297296465Sdelphij# define X509_LOOKUP_add_dir(x,name,type) \ 298296465Sdelphij X509_LOOKUP_ctrl((x),X509_L_ADD_DIR,(name),(long)(type),NULL) 29955714Skris 300296465Sdelphij# define X509_V_OK 0 30159191Skris/* illegal error (for uninitialized values, to avoid X509_V_OK): 1 */ 30255714Skris 303296465Sdelphij# define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT 2 304296465Sdelphij# define X509_V_ERR_UNABLE_TO_GET_CRL 3 305296465Sdelphij# define X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE 4 306296465Sdelphij# define X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE 5 307296465Sdelphij# define X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY 6 308296465Sdelphij# define X509_V_ERR_CERT_SIGNATURE_FAILURE 7 309296465Sdelphij# define X509_V_ERR_CRL_SIGNATURE_FAILURE 8 310296465Sdelphij# define X509_V_ERR_CERT_NOT_YET_VALID 9 311296465Sdelphij# define X509_V_ERR_CERT_HAS_EXPIRED 10 312296465Sdelphij# define X509_V_ERR_CRL_NOT_YET_VALID 11 313296465Sdelphij# define X509_V_ERR_CRL_HAS_EXPIRED 12 314296465Sdelphij# define X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD 13 315296465Sdelphij# define X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD 14 316296465Sdelphij# define X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD 15 317296465Sdelphij# define X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD 16 318296465Sdelphij# define X509_V_ERR_OUT_OF_MEM 17 319296465Sdelphij# define X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT 18 320296465Sdelphij# define X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN 19 321296465Sdelphij# define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY 20 322296465Sdelphij# define X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE 21 323296465Sdelphij# define X509_V_ERR_CERT_CHAIN_TOO_LONG 22 324296465Sdelphij# define X509_V_ERR_CERT_REVOKED 23 325296465Sdelphij# define X509_V_ERR_INVALID_CA 24 326296465Sdelphij# define X509_V_ERR_PATH_LENGTH_EXCEEDED 25 327296465Sdelphij# define X509_V_ERR_INVALID_PURPOSE 26 328296465Sdelphij# define X509_V_ERR_CERT_UNTRUSTED 27 329296465Sdelphij# define X509_V_ERR_CERT_REJECTED 28 33068651Skris/* These are 'informational' when looking for issuer cert */ 331296465Sdelphij# define X509_V_ERR_SUBJECT_ISSUER_MISMATCH 29 332296465Sdelphij# define X509_V_ERR_AKID_SKID_MISMATCH 30 333296465Sdelphij# define X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH 31 334296465Sdelphij# define X509_V_ERR_KEYUSAGE_NO_CERTSIGN 32 33555714Skris 336296465Sdelphij# define X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER 33 337296465Sdelphij# define X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION 34 338296465Sdelphij# define X509_V_ERR_KEYUSAGE_NO_CRL_SIGN 35 339296465Sdelphij# define X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION 36 340296465Sdelphij# define X509_V_ERR_INVALID_NON_CA 37 341296465Sdelphij# define X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED 38 342296465Sdelphij# define X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE 39 343296465Sdelphij# define X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED 40 344109998Smarkm 345296465Sdelphij# define X509_V_ERR_INVALID_EXTENSION 41 346296465Sdelphij# define X509_V_ERR_INVALID_POLICY_EXTENSION 42 347296465Sdelphij# define X509_V_ERR_NO_EXPLICIT_POLICY 43 348160814Ssimon 349296465Sdelphij# define X509_V_ERR_UNNESTED_RESOURCE 44 350160814Ssimon 35155714Skris/* The application is not happy */ 352296465Sdelphij# define X509_V_ERR_APPLICATION_VERIFICATION 50 35355714Skris 35468651Skris/* Certificate verify flags */ 35568651Skris 356127128Snectar/* Send issuer+subject checks to verify_cb */ 357296465Sdelphij# define X509_V_FLAG_CB_ISSUER_CHECK 0x1 358127128Snectar/* Use check time instead of current time */ 359296465Sdelphij# define X509_V_FLAG_USE_CHECK_TIME 0x2 360127128Snectar/* Lookup CRLs */ 361296465Sdelphij# define X509_V_FLAG_CRL_CHECK 0x4 362127128Snectar/* Lookup CRLs for whole chain */ 363296465Sdelphij# define X509_V_FLAG_CRL_CHECK_ALL 0x8 364127128Snectar/* Ignore unhandled critical extensions */ 365296465Sdelphij# define X509_V_FLAG_IGNORE_CRITICAL 0x10 366127128Snectar/* Disable workarounds for broken certificates */ 367296465Sdelphij# define X509_V_FLAG_X509_STRICT 0x20 368160814Ssimon/* Enable proxy certificate validation */ 369296465Sdelphij# define X509_V_FLAG_ALLOW_PROXY_CERTS 0x40 370160814Ssimon/* Enable policy checking */ 371296465Sdelphij# define X509_V_FLAG_POLICY_CHECK 0x80 372160814Ssimon/* Policy variable require-explicit-policy */ 373296465Sdelphij# define X509_V_FLAG_EXPLICIT_POLICY 0x100 374160814Ssimon/* Policy variable inhibit-any-policy */ 375296465Sdelphij# define X509_V_FLAG_INHIBIT_ANY 0x200 376160814Ssimon/* Policy variable inhibit-policy-mapping */ 377296465Sdelphij# define X509_V_FLAG_INHIBIT_MAP 0x400 378160814Ssimon/* Notify callback that policy is OK */ 379296465Sdelphij# define X509_V_FLAG_NOTIFY_POLICY 0x800 38068651Skris 381205128Ssimon/* Check selfsigned CA signature */ 382296465Sdelphij# define X509_V_FLAG_CHECK_SS_SIGNATURE 0x4000 383205128Ssimon 384296465Sdelphij# define X509_VP_FLAG_DEFAULT 0x1 385296465Sdelphij# define X509_VP_FLAG_OVERWRITE 0x2 386296465Sdelphij# define X509_VP_FLAG_RESET_FLAGS 0x4 387296465Sdelphij# define X509_VP_FLAG_LOCKED 0x8 388296465Sdelphij# define X509_VP_FLAG_ONCE 0x10 389160814Ssimon 390160814Ssimon/* Internal use: mask of policy related options */ 391296465Sdelphij# define X509_V_FLAG_POLICY_MASK (X509_V_FLAG_POLICY_CHECK \ 392296465Sdelphij | X509_V_FLAG_EXPLICIT_POLICY \ 393296465Sdelphij | X509_V_FLAG_INHIBIT_ANY \ 394296465Sdelphij | X509_V_FLAG_INHIBIT_MAP) 395160814Ssimon 39668651Skrisint X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type, 397296465Sdelphij X509_NAME *name); 398296465SdelphijX509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h, 399296465Sdelphij int type, X509_NAME *name); 400296465SdelphijX509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, 401296465Sdelphij X509_OBJECT *x); 40255714Skrisvoid X509_OBJECT_up_ref_count(X509_OBJECT *a); 40355714Skrisvoid X509_OBJECT_free_contents(X509_OBJECT *a); 404296465SdelphijX509_STORE *X509_STORE_new(void); 40555714Skrisvoid X509_STORE_free(X509_STORE *v); 40655714Skris 407160814Ssimonint X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags); 408109998Smarkmint X509_STORE_set_purpose(X509_STORE *ctx, int purpose); 409109998Smarkmint X509_STORE_set_trust(X509_STORE *ctx, int trust); 410160814Ssimonint X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *pm); 411109998Smarkm 41259191SkrisX509_STORE_CTX *X509_STORE_CTX_new(void); 41368651Skris 41468651Skrisint X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); 41568651Skris 41659191Skrisvoid X509_STORE_CTX_free(X509_STORE_CTX *ctx); 417109998Smarkmint X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, 418296465Sdelphij X509 *x509, STACK_OF(X509) *chain); 41968651Skrisvoid X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk); 42055714Skrisvoid X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx); 42155714Skris 42255714SkrisX509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m); 42355714Skris 42455714SkrisX509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void); 42555714SkrisX509_LOOKUP_METHOD *X509_LOOKUP_file(void); 42655714Skris 42755714Skrisint X509_STORE_add_cert(X509_STORE *ctx, X509 *x); 42855714Skrisint X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x); 42955714Skris 430296465Sdelphijint X509_STORE_get_by_subject(X509_STORE_CTX *vs, int type, X509_NAME *name, 431296465Sdelphij X509_OBJECT *ret); 43255714Skris 43355714Skrisint X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, 434296465Sdelphij long argl, char **ret); 43555714Skris 436296465Sdelphij# ifndef OPENSSL_NO_STDIO 43755714Skrisint X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type); 43855714Skrisint X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type); 43959191Skrisint X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type); 440296465Sdelphij# endif 44155714Skris 44255714SkrisX509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method); 44355714Skrisvoid X509_LOOKUP_free(X509_LOOKUP *ctx); 44455714Skrisint X509_LOOKUP_init(X509_LOOKUP *ctx); 44555714Skrisint X509_LOOKUP_by_subject(X509_LOOKUP *ctx, int type, X509_NAME *name, 446296465Sdelphij X509_OBJECT *ret); 44755714Skrisint X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, int type, X509_NAME *name, 448296465Sdelphij ASN1_INTEGER *serial, X509_OBJECT *ret); 44955714Skrisint X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, int type, 450296465Sdelphij unsigned char *bytes, int len, 451296465Sdelphij X509_OBJECT *ret); 452296465Sdelphijint X509_LOOKUP_by_alias(X509_LOOKUP *ctx, int type, char *str, int len, 453296465Sdelphij X509_OBJECT *ret); 45455714Skrisint X509_LOOKUP_shutdown(X509_LOOKUP *ctx); 45555714Skris 456296465Sdelphij# ifndef OPENSSL_NO_STDIO 457296465Sdelphijint X509_STORE_load_locations(X509_STORE *ctx, 458296465Sdelphij const char *file, const char *dir); 459296465Sdelphijint X509_STORE_set_default_paths(X509_STORE *ctx); 460296465Sdelphij# endif 46155714Skris 462296465Sdelphijint X509_STORE_CTX_get_ex_new_index(long argl, void *argp, 463296465Sdelphij CRYPTO_EX_new *new_func, 464296465Sdelphij CRYPTO_EX_dup *dup_func, 465296465Sdelphij CRYPTO_EX_free *free_func); 466296465Sdelphijint X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx, int idx, void *data); 467296465Sdelphijvoid *X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx, int idx); 468296465Sdelphijint X509_STORE_CTX_get_error(X509_STORE_CTX *ctx); 469296465Sdelphijvoid X509_STORE_CTX_set_error(X509_STORE_CTX *ctx, int s); 470296465Sdelphijint X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx); 471296465SdelphijX509 *X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx); 47255714SkrisSTACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx); 47359191SkrisSTACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx); 474296465Sdelphijvoid X509_STORE_CTX_set_cert(X509_STORE_CTX *c, X509 *x); 475296465Sdelphijvoid X509_STORE_CTX_set_chain(X509_STORE_CTX *c, STACK_OF(X509) *sk); 476296465Sdelphijvoid X509_STORE_CTX_set0_crls(X509_STORE_CTX *c, STACK_OF(X509_CRL) *sk); 47759191Skrisint X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose); 47859191Skrisint X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust); 47959191Skrisint X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose, 480296465Sdelphij int purpose, int trust); 481160814Ssimonvoid X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags); 482160814Ssimonvoid X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags, 483296465Sdelphij time_t t); 48489837Skrisvoid X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx, 485296465Sdelphij int (*verify_cb) (int, X509_STORE_CTX *)); 486296465Sdelphij 487160814SsimonX509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx); 488160814Ssimonint X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx); 48955714Skris 490160814SsimonX509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx); 491160814Ssimonvoid X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param); 492160814Ssimonint X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name); 493160814Ssimon 494160814Ssimon/* X509_VERIFY_PARAM functions */ 495160814Ssimon 496160814SsimonX509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void); 497160814Ssimonvoid X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param); 498160814Ssimonint X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to, 499296465Sdelphij const X509_VERIFY_PARAM *from); 500296465Sdelphijint X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to, 501296465Sdelphij const X509_VERIFY_PARAM *from); 502160814Ssimonint X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name); 503296465Sdelphijint X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param, 504296465Sdelphij unsigned long flags); 505160814Ssimonint X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param, 506296465Sdelphij unsigned long flags); 507160814Ssimonunsigned long X509_VERIFY_PARAM_get_flags(X509_VERIFY_PARAM *param); 508160814Ssimonint X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose); 509160814Ssimonint X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust); 510160814Ssimonvoid X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth); 511160814Ssimonvoid X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t); 512160814Ssimonint X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param, 513296465Sdelphij ASN1_OBJECT *policy); 514296465Sdelphijint X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param, 515296465Sdelphij STACK_OF(ASN1_OBJECT) *policies); 516160814Ssimonint X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param); 517160814Ssimon 518160814Ssimonint X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param); 519160814Ssimonconst X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name); 520160814Ssimonvoid X509_VERIFY_PARAM_table_cleanup(void); 521160814Ssimon 522160814Ssimonint X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy, 523296465Sdelphij STACK_OF(X509) *certs, 524296465Sdelphij STACK_OF(ASN1_OBJECT) *policy_oids, unsigned int flags); 525160814Ssimon 526160814Ssimonvoid X509_policy_tree_free(X509_POLICY_TREE *tree); 527160814Ssimon 528160814Ssimonint X509_policy_tree_level_count(const X509_POLICY_TREE *tree); 529296465SdelphijX509_POLICY_LEVEL *X509_policy_tree_get0_level(const X509_POLICY_TREE *tree, 530296465Sdelphij int i); 531160814Ssimon 532296465SdelphijSTACK_OF(X509_POLICY_NODE) *X509_policy_tree_get0_policies(const 533296465Sdelphij X509_POLICY_TREE 534296465Sdelphij *tree); 535160814Ssimon 536296465SdelphijSTACK_OF(X509_POLICY_NODE) *X509_policy_tree_get0_user_policies(const 537296465Sdelphij X509_POLICY_TREE 538296465Sdelphij *tree); 539160814Ssimon 540160814Ssimonint X509_policy_level_node_count(X509_POLICY_LEVEL *level); 541160814Ssimon 542296465SdelphijX509_POLICY_NODE *X509_policy_level_get0_node(X509_POLICY_LEVEL *level, 543296465Sdelphij int i); 544160814Ssimon 545160814Ssimonconst ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node); 546160814Ssimon 547296465SdelphijSTACK_OF(POLICYQUALINFO) *X509_policy_node_get0_qualifiers(const 548296465Sdelphij X509_POLICY_NODE 549296465Sdelphij *node); 550296465Sdelphijconst X509_POLICY_NODE *X509_policy_node_get0_parent(const X509_POLICY_NODE 551296465Sdelphij *node); 552160814Ssimon 55355714Skris#ifdef __cplusplus 55455714Skris} 55555714Skris#endif 55655714Skris#endif 557