os/ossrv/ssl/libcrypto/src/crypto/x509/x509_vfy.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/* crypto/x509/x509_vfy.h */
sl@0
     2
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
sl@0
     3
 * All rights reserved.
sl@0
     4
 *
sl@0
     5
 * This package is an SSL implementation written
sl@0
     6
 * by Eric Young (eay@cryptsoft.com).
sl@0
     7
 * The implementation was written so as to conform with Netscapes SSL.
sl@0
     8
 * 
sl@0
     9
 * This library is free for commercial and non-commercial use as long as
sl@0
    10
 * the following conditions are aheared to.  The following conditions
sl@0
    11
 * apply to all code found in this distribution, be it the RC4, RSA,
sl@0
    12
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
sl@0
    13
 * included with this distribution is covered by the same copyright terms
sl@0
    14
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
sl@0
    15
 * 
sl@0
    16
 * Copyright remains Eric Young's, and as such any Copyright notices in
sl@0
    17
 * the code are not to be removed.
sl@0
    18
 * If this package is used in a product, Eric Young should be given attribution
sl@0
    19
 * as the author of the parts of the library used.
sl@0
    20
 * This can be in the form of a textual message at program startup or
sl@0
    21
 * in documentation (online or textual) provided with the package.
sl@0
    22
 * 
sl@0
    23
 * Redistribution and use in source and binary forms, with or without
sl@0
    24
 * modification, are permitted provided that the following conditions
sl@0
    25
 * are met:
sl@0
    26
 * 1. Redistributions of source code must retain the copyright
sl@0
    27
 *    notice, this list of conditions and the following disclaimer.
sl@0
    28
 * 2. Redistributions in binary form must reproduce the above copyright
sl@0
    29
 *    notice, this list of conditions and the following disclaimer in the
sl@0
    30
 *    documentation and/or other materials provided with the distribution.
sl@0
    31
 * 3. All advertising materials mentioning features or use of this software
sl@0
    32
 *    must display the following acknowledgement:
sl@0
    33
 *    "This product includes cryptographic software written by
sl@0
    34
 *     Eric Young (eay@cryptsoft.com)"
sl@0
    35
 *    The word 'cryptographic' can be left out if the rouines from the library
sl@0
    36
 *    being used are not cryptographic related :-).
sl@0
    37
 * 4. If you include any Windows specific code (or a derivative thereof) from 
sl@0
    38
 *    the apps directory (application code) you must include an acknowledgement:
sl@0
    39
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
sl@0
    40
 * 
sl@0
    41
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
sl@0
    42
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
sl@0
    43
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
sl@0
    44
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
sl@0
    45
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
sl@0
    46
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
sl@0
    47
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
sl@0
    48
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
sl@0
    49
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
sl@0
    50
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
sl@0
    51
 * SUCH DAMAGE.
sl@0
    52
 * 
sl@0
    53
 * The licence and distribution terms for any publically available version or
sl@0
    54
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
sl@0
    55
 * copied and put under another distribution licence
sl@0
    56
 * [including the GNU Public Licence.]
sl@0
    57
 */
sl@0
    58
/*
sl@0
    59
 © Portions copyright (c) 2006 Nokia Corporation.  All rights reserved.
sl@0
    60
 */
sl@0
    61
sl@0
    62
#ifndef HEADER_X509_H
sl@0
    63
sl@0
    64
#if (defined(__SYMBIAN32__) && !defined(SYMBIAN))
sl@0
    65
#define SYMBIAN
sl@0
    66
#endif
sl@0
    67
sl@0
    68
#ifdef SYMBIAN
sl@0
    69
#include <e32def.h>
sl@0
    70
#endif
sl@0
    71
#include <openssl/x509.h>
sl@0
    72
/* openssl/x509.h ends up #include-ing this file at about the only
sl@0
    73
 * appropriate moment. */
sl@0
    74
#endif
sl@0
    75
sl@0
    76
#ifndef HEADER_X509_VFY_H
sl@0
    77
#define HEADER_X509_VFY_H
sl@0
    78
sl@0
    79
#include <openssl/opensslconf.h>
sl@0
    80
#ifndef OPENSSL_NO_LHASH
sl@0
    81
#include <openssl/lhash.h>
sl@0
    82
#endif
sl@0
    83
#include <openssl/bio.h>
sl@0
    84
#include <openssl/crypto.h>
sl@0
    85
#include <openssl/symhacks.h>
sl@0
    86
sl@0
    87
#ifdef  __cplusplus
sl@0
    88
extern "C" {
sl@0
    89
#endif
sl@0
    90
sl@0
    91
/* Outer object */
sl@0
    92
typedef struct x509_hash_dir_st
sl@0
    93
	{
sl@0
    94
	int num_dirs;
sl@0
    95
	char **dirs;
sl@0
    96
	int *dirs_type;
sl@0
    97
	int num_dirs_alloced;
sl@0
    98
	} X509_HASH_DIR_CTX;
sl@0
    99
sl@0
   100
typedef struct x509_file_st
sl@0
   101
	{
sl@0
   102
	int num_paths;	/* number of paths to files or directories */
sl@0
   103
	int num_alloced;
sl@0
   104
	char **paths;	/* the list of paths or directories */
sl@0
   105
	int *path_type;
sl@0
   106
	} X509_CERT_FILE_CTX;
sl@0
   107
sl@0
   108
/*******************************/
sl@0
   109
/*
sl@0
   110
SSL_CTX -> X509_STORE    
sl@0
   111
		-> X509_LOOKUP
sl@0
   112
			->X509_LOOKUP_METHOD
sl@0
   113
		-> X509_LOOKUP
sl@0
   114
			->X509_LOOKUP_METHOD
sl@0
   115
 
sl@0
   116
SSL	-> X509_STORE_CTX
sl@0
   117
		->X509_STORE    
sl@0
   118
sl@0
   119
The X509_STORE holds the tables etc for verification stuff.
sl@0
   120
A X509_STORE_CTX is used while validating a single certificate.
sl@0
   121
The X509_STORE has X509_LOOKUPs for looking up certs.
sl@0
   122
The X509_STORE then calls a function to actually verify the
sl@0
   123
certificate chain.
sl@0
   124
*/
sl@0
   125
sl@0
   126
#define X509_LU_RETRY		-1
sl@0
   127
#define X509_LU_FAIL		0
sl@0
   128
#define X509_LU_X509		1
sl@0
   129
#define X509_LU_CRL		2
sl@0
   130
#define X509_LU_PKEY		3
sl@0
   131
sl@0
   132
typedef struct x509_object_st
sl@0
   133
	{
sl@0
   134
	/* one of the above types */
sl@0
   135
	int type;
sl@0
   136
	union	{
sl@0
   137
		char *ptr;
sl@0
   138
		X509 *x509;
sl@0
   139
		X509_CRL *crl;
sl@0
   140
		EVP_PKEY *pkey;
sl@0
   141
		} data;
sl@0
   142
	} X509_OBJECT;
sl@0
   143
sl@0
   144
typedef struct x509_lookup_st X509_LOOKUP;
sl@0
   145
sl@0
   146
DECLARE_STACK_OF(X509_LOOKUP)
sl@0
   147
DECLARE_STACK_OF(X509_OBJECT)
sl@0
   148
sl@0
   149
/* This is a static that defines the function interface */
sl@0
   150
typedef struct x509_lookup_method_st
sl@0
   151
	{
sl@0
   152
	const char *name;
sl@0
   153
	int (*new_item)(X509_LOOKUP *ctx);
sl@0
   154
	void (*free)(X509_LOOKUP *ctx);
sl@0
   155
	int (*init)(X509_LOOKUP *ctx);
sl@0
   156
	int (*shutdown)(X509_LOOKUP *ctx);
sl@0
   157
	int (*ctrl)(X509_LOOKUP *ctx,int cmd,const char *argc,long argl,
sl@0
   158
			char **ret);
sl@0
   159
	int (*get_by_subject)(X509_LOOKUP *ctx,int type,X509_NAME *name,
sl@0
   160
			      X509_OBJECT *ret);
sl@0
   161
	int (*get_by_issuer_serial)(X509_LOOKUP *ctx,int type,X509_NAME *name,
sl@0
   162
				    ASN1_INTEGER *serial,X509_OBJECT *ret);
sl@0
   163
	int (*get_by_fingerprint)(X509_LOOKUP *ctx,int type,
sl@0
   164
				  unsigned char *bytes,int len,
sl@0
   165
				  X509_OBJECT *ret);
sl@0
   166
	int (*get_by_alias)(X509_LOOKUP *ctx,int type,char *str,int len,
sl@0
   167
			    X509_OBJECT *ret);
sl@0
   168
	} X509_LOOKUP_METHOD;
sl@0
   169
sl@0
   170
/* This structure hold all parameters associated with a verify operation
sl@0
   171
 * by including an X509_VERIFY_PARAM structure in related structures the
sl@0
   172
 * parameters used can be customized
sl@0
   173
 */
sl@0
   174
sl@0
   175
typedef struct X509_VERIFY_PARAM_st
sl@0
   176
	{
sl@0
   177
	char *name;
sl@0
   178
	time_t check_time;	/* Time to use */
sl@0
   179
	unsigned long inh_flags; /* Inheritance flags */
sl@0
   180
	unsigned long flags;	/* Various verify flags */
sl@0
   181
	int purpose;		/* purpose to check untrusted certificates */
sl@0
   182
	int trust;		/* trust setting to check */
sl@0
   183
	int depth;		/* Verify depth */
sl@0
   184
	STACK_OF(ASN1_OBJECT) *policies;	/* Permissible policies */
sl@0
   185
	} X509_VERIFY_PARAM;
sl@0
   186
sl@0
   187
DECLARE_STACK_OF(X509_VERIFY_PARAM)
sl@0
   188
sl@0
   189
/* This is used to hold everything.  It is used for all certificate
sl@0
   190
 * validation.  Once we have a certificate chain, the 'verify'
sl@0
   191
 * function is then called to actually check the cert chain. */
sl@0
   192
struct x509_store_st
sl@0
   193
	{
sl@0
   194
	/* The following is a cache of trusted certs */
sl@0
   195
	int cache; 	/* if true, stash any hits */
sl@0
   196
	STACK_OF(X509_OBJECT) *objs;	/* Cache of all objects */
sl@0
   197
sl@0
   198
	/* These are external lookup methods */
sl@0
   199
	STACK_OF(X509_LOOKUP) *get_cert_methods;
sl@0
   200
sl@0
   201
	X509_VERIFY_PARAM *param;
sl@0
   202
sl@0
   203
	/* Callbacks for various operations */
sl@0
   204
	int (*verify)(X509_STORE_CTX *ctx);	/* called to verify a certificate */
sl@0
   205
	int (*verify_cb)(int ok,X509_STORE_CTX *ctx);	/* error callback */
sl@0
   206
	int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x);	/* get issuers cert from ctx */
sl@0
   207
	int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); /* check issued */
sl@0
   208
	int (*check_revocation)(X509_STORE_CTX *ctx); /* Check revocation status of chain */
sl@0
   209
	int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); /* retrieve CRL */
sl@0
   210
	int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */
sl@0
   211
	int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */
sl@0
   212
	int (*cleanup)(X509_STORE_CTX *ctx);
sl@0
   213
sl@0
   214
	CRYPTO_EX_DATA ex_data;
sl@0
   215
	int references;
sl@0
   216
	} /* X509_STORE */;
sl@0
   217
sl@0
   218
int X509_STORE_set_depth(X509_STORE *store, int depth);
sl@0
   219
sl@0
   220
#define X509_STORE_set_verify_cb_func(ctx,func) ((ctx)->verify_cb=(func))
sl@0
   221
#define X509_STORE_set_verify_func(ctx,func)	((ctx)->verify=(func))
sl@0
   222
sl@0
   223
/* This is the functions plus an instance of the local variables. */
sl@0
   224
struct x509_lookup_st
sl@0
   225
	{
sl@0
   226
	int init;			/* have we been started */
sl@0
   227
	int skip;			/* don't use us. */
sl@0
   228
	X509_LOOKUP_METHOD *method;	/* the functions */
sl@0
   229
	char *method_data;		/* method data */
sl@0
   230
sl@0
   231
	X509_STORE *store_ctx;	/* who owns us */
sl@0
   232
	} /* X509_LOOKUP */;
sl@0
   233
sl@0
   234
/* This is a used when verifying cert chains.  Since the
sl@0
   235
 * gathering of the cert chain can take some time (and have to be
sl@0
   236
 * 'retried', this needs to be kept and passed around. */
sl@0
   237
struct x509_store_ctx_st      /* X509_STORE_CTX */
sl@0
   238
	{
sl@0
   239
	X509_STORE *ctx;
sl@0
   240
	int current_method;	/* used when looking up certs */
sl@0
   241
sl@0
   242
	/* The following are set by the caller */
sl@0
   243
	X509 *cert;		/* The cert to check */
sl@0
   244
	STACK_OF(X509) *untrusted;	/* chain of X509s - untrusted - passed in */
sl@0
   245
	STACK_OF(X509_CRL) *crls;	/* set of CRLs passed in */
sl@0
   246
sl@0
   247
	X509_VERIFY_PARAM *param;
sl@0
   248
	void *other_ctx;	/* Other info for use with get_issuer() */
sl@0
   249
sl@0
   250
	/* Callbacks for various operations */
sl@0
   251
	int (*verify)(X509_STORE_CTX *ctx);	/* called to verify a certificate */
sl@0
   252
	int (*verify_cb)(int ok,X509_STORE_CTX *ctx);		/* error callback */
sl@0
   253
	int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x);	/* get issuers cert from ctx */
sl@0
   254
	int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); /* check issued */
sl@0
   255
	int (*check_revocation)(X509_STORE_CTX *ctx); /* Check revocation status of chain */
sl@0
   256
	int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); /* retrieve CRL */
sl@0
   257
	int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */
sl@0
   258
	int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */
sl@0
   259
	int (*check_policy)(X509_STORE_CTX *ctx);
sl@0
   260
	int (*cleanup)(X509_STORE_CTX *ctx);
sl@0
   261
sl@0
   262
	/* The following is built up */
sl@0
   263
	int valid;		/* if 0, rebuild chain */
sl@0
   264
	int last_untrusted;	/* index of last untrusted cert */
sl@0
   265
	STACK_OF(X509) *chain; 		/* chain of X509s - built up and trusted */
sl@0
   266
	X509_POLICY_TREE *tree;	/* Valid policy tree */
sl@0
   267
sl@0
   268
	int explicit_policy;	/* Require explicit policy value */
sl@0
   269
sl@0
   270
	/* When something goes wrong, this is why */
sl@0
   271
	int error_depth;
sl@0
   272
	int error;
sl@0
   273
	X509 *current_cert;
sl@0
   274
	X509 *current_issuer;	/* cert currently being tested as valid issuer */
sl@0
   275
	X509_CRL *current_crl;	/* current CRL */
sl@0
   276
sl@0
   277
	CRYPTO_EX_DATA ex_data;
sl@0
   278
	} /* X509_STORE_CTX */;
sl@0
   279
sl@0
   280
IMPORT_C void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth);
sl@0
   281
sl@0
   282
#define X509_STORE_CTX_set_app_data(ctx,data) \
sl@0
   283
	X509_STORE_CTX_set_ex_data(ctx,0,data)
sl@0
   284
#define X509_STORE_CTX_get_app_data(ctx) \
sl@0
   285
	X509_STORE_CTX_get_ex_data(ctx,0)
sl@0
   286
sl@0
   287
#define X509_L_FILE_LOAD	1
sl@0
   288
#define X509_L_ADD_DIR		2
sl@0
   289
sl@0
   290
#define X509_LOOKUP_load_file(x,name,type) \
sl@0
   291
		X509_LOOKUP_ctrl((x),X509_L_FILE_LOAD,(name),(long)(type),NULL)
sl@0
   292
sl@0
   293
#define X509_LOOKUP_add_dir(x,name,type) \
sl@0
   294
		X509_LOOKUP_ctrl((x),X509_L_ADD_DIR,(name),(long)(type),NULL)
sl@0
   295
sl@0
   296
#define		X509_V_OK					0
sl@0
   297
/* illegal error (for uninitialized values, to avoid X509_V_OK): 1 */
sl@0
   298
sl@0
   299
#define		X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT		2
sl@0
   300
#define		X509_V_ERR_UNABLE_TO_GET_CRL			3
sl@0
   301
#define		X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE	4
sl@0
   302
#define		X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE	5
sl@0
   303
#define		X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY	6
sl@0
   304
#define		X509_V_ERR_CERT_SIGNATURE_FAILURE		7
sl@0
   305
#define		X509_V_ERR_CRL_SIGNATURE_FAILURE		8
sl@0
   306
#define		X509_V_ERR_CERT_NOT_YET_VALID			9
sl@0
   307
#define		X509_V_ERR_CERT_HAS_EXPIRED			10
sl@0
   308
#define		X509_V_ERR_CRL_NOT_YET_VALID			11
sl@0
   309
#define		X509_V_ERR_CRL_HAS_EXPIRED			12
sl@0
   310
#define		X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD	13
sl@0
   311
#define		X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD	14
sl@0
   312
#define		X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD	15
sl@0
   313
#define		X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD	16
sl@0
   314
#define		X509_V_ERR_OUT_OF_MEM				17
sl@0
   315
#define		X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT		18
sl@0
   316
#define		X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN		19
sl@0
   317
#define		X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY	20
sl@0
   318
#define		X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE	21
sl@0
   319
#define		X509_V_ERR_CERT_CHAIN_TOO_LONG			22
sl@0
   320
#define		X509_V_ERR_CERT_REVOKED				23
sl@0
   321
#define		X509_V_ERR_INVALID_CA				24
sl@0
   322
#define		X509_V_ERR_PATH_LENGTH_EXCEEDED			25
sl@0
   323
#define		X509_V_ERR_INVALID_PURPOSE			26
sl@0
   324
#define		X509_V_ERR_CERT_UNTRUSTED			27
sl@0
   325
#define		X509_V_ERR_CERT_REJECTED			28
sl@0
   326
/* These are 'informational' when looking for issuer cert */
sl@0
   327
#define		X509_V_ERR_SUBJECT_ISSUER_MISMATCH		29
sl@0
   328
#define		X509_V_ERR_AKID_SKID_MISMATCH			30
sl@0
   329
#define		X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH		31
sl@0
   330
#define		X509_V_ERR_KEYUSAGE_NO_CERTSIGN			32
sl@0
   331
sl@0
   332
#define		X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER		33
sl@0
   333
#define		X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION		34
sl@0
   334
#define		X509_V_ERR_KEYUSAGE_NO_CRL_SIGN			35
sl@0
   335
#define		X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION	36
sl@0
   336
#define		X509_V_ERR_INVALID_NON_CA			37
sl@0
   337
#define		X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED		38
sl@0
   338
#define		X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE	39
sl@0
   339
#define		X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED	40
sl@0
   340
sl@0
   341
#define		X509_V_ERR_INVALID_EXTENSION			41
sl@0
   342
#define		X509_V_ERR_INVALID_POLICY_EXTENSION		42
sl@0
   343
#define		X509_V_ERR_NO_EXPLICIT_POLICY			43
sl@0
   344
sl@0
   345
#define		X509_V_ERR_UNNESTED_RESOURCE			44
sl@0
   346
sl@0
   347
/* The application is not happy */
sl@0
   348
#define		X509_V_ERR_APPLICATION_VERIFICATION		50
sl@0
   349
sl@0
   350
/* Certificate verify flags */
sl@0
   351
sl@0
   352
/* Send issuer+subject checks to verify_cb */
sl@0
   353
#define	X509_V_FLAG_CB_ISSUER_CHECK		0x1
sl@0
   354
/* Use check time instead of current time */
sl@0
   355
#define	X509_V_FLAG_USE_CHECK_TIME		0x2
sl@0
   356
/* Lookup CRLs */
sl@0
   357
#define	X509_V_FLAG_CRL_CHECK			0x4
sl@0
   358
/* Lookup CRLs for whole chain */
sl@0
   359
#define	X509_V_FLAG_CRL_CHECK_ALL		0x8
sl@0
   360
/* Ignore unhandled critical extensions */
sl@0
   361
#define	X509_V_FLAG_IGNORE_CRITICAL		0x10
sl@0
   362
/* Disable workarounds for broken certificates */
sl@0
   363
#define	X509_V_FLAG_X509_STRICT			0x20
sl@0
   364
/* Enable proxy certificate validation */
sl@0
   365
#define	X509_V_FLAG_ALLOW_PROXY_CERTS		0x40
sl@0
   366
/* Enable policy checking */
sl@0
   367
#define X509_V_FLAG_POLICY_CHECK		0x80
sl@0
   368
/* Policy variable require-explicit-policy */
sl@0
   369
#define X509_V_FLAG_EXPLICIT_POLICY		0x100
sl@0
   370
/* Policy variable inhibit-any-policy */
sl@0
   371
#define	X509_V_FLAG_INHIBIT_ANY			0x200
sl@0
   372
/* Policy variable inhibit-policy-mapping */
sl@0
   373
#define X509_V_FLAG_INHIBIT_MAP			0x400
sl@0
   374
/* Notify callback that policy is OK */
sl@0
   375
#define X509_V_FLAG_NOTIFY_POLICY		0x800
sl@0
   376
sl@0
   377
#define X509_VP_FLAG_DEFAULT			0x1
sl@0
   378
#define X509_VP_FLAG_OVERWRITE			0x2
sl@0
   379
#define X509_VP_FLAG_RESET_FLAGS		0x4
sl@0
   380
#define X509_VP_FLAG_LOCKED			0x8
sl@0
   381
#define X509_VP_FLAG_ONCE			0x10
sl@0
   382
sl@0
   383
/* Internal use: mask of policy related options */
sl@0
   384
#define X509_V_FLAG_POLICY_MASK (X509_V_FLAG_POLICY_CHECK \
sl@0
   385
				| X509_V_FLAG_EXPLICIT_POLICY \
sl@0
   386
				| X509_V_FLAG_INHIBIT_ANY \
sl@0
   387
				| X509_V_FLAG_INHIBIT_MAP)
sl@0
   388
sl@0
   389
IMPORT_C int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type,
sl@0
   390
	     X509_NAME *name);
sl@0
   391
IMPORT_C X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,int type,X509_NAME *name);
sl@0
   392
IMPORT_C X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, X509_OBJECT *x);
sl@0
   393
IMPORT_C void X509_OBJECT_up_ref_count(X509_OBJECT *a);
sl@0
   394
IMPORT_C void X509_OBJECT_free_contents(X509_OBJECT *a);
sl@0
   395
IMPORT_C X509_STORE *X509_STORE_new(void );
sl@0
   396
IMPORT_C void X509_STORE_free(X509_STORE *v);
sl@0
   397
sl@0
   398
IMPORT_C int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags);
sl@0
   399
IMPORT_C int X509_STORE_set_purpose(X509_STORE *ctx, int purpose);
sl@0
   400
IMPORT_C int X509_STORE_set_trust(X509_STORE *ctx, int trust);
sl@0
   401
IMPORT_C int X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *pm);
sl@0
   402
sl@0
   403
IMPORT_C X509_STORE_CTX *X509_STORE_CTX_new(void);
sl@0
   404
sl@0
   405
IMPORT_C int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x);
sl@0
   406
sl@0
   407
IMPORT_C void X509_STORE_CTX_free(X509_STORE_CTX *ctx);
sl@0
   408
IMPORT_C int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store,
sl@0
   409
			 X509 *x509, STACK_OF(X509) *chain);
sl@0
   410
IMPORT_C void X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);
sl@0
   411
IMPORT_C void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);
sl@0
   412
sl@0
   413
IMPORT_C X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m);
sl@0
   414
sl@0
   415
IMPORT_C X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void);
sl@0
   416
IMPORT_C X509_LOOKUP_METHOD *X509_LOOKUP_file(void);
sl@0
   417
sl@0
   418
IMPORT_C int X509_STORE_add_cert(X509_STORE *ctx, X509 *x);
sl@0
   419
IMPORT_C int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x);
sl@0
   420
sl@0
   421
IMPORT_C int X509_STORE_get_by_subject(X509_STORE_CTX *vs,int type,X509_NAME *name,
sl@0
   422
	X509_OBJECT *ret);
sl@0
   423
sl@0
   424
IMPORT_C int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
sl@0
   425
	long argl, char **ret);
sl@0
   426
sl@0
   427
#ifndef OPENSSL_NO_STDIO
sl@0
   428
IMPORT_C int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type);
sl@0
   429
IMPORT_C int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type);
sl@0
   430
IMPORT_C int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type);
sl@0
   431
#endif
sl@0
   432
sl@0
   433
sl@0
   434
IMPORT_C X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method);
sl@0
   435
IMPORT_C void X509_LOOKUP_free(X509_LOOKUP *ctx);
sl@0
   436
IMPORT_C int X509_LOOKUP_init(X509_LOOKUP *ctx);
sl@0
   437
IMPORT_C int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, int type, X509_NAME *name,
sl@0
   438
	X509_OBJECT *ret);
sl@0
   439
IMPORT_C int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, int type, X509_NAME *name,
sl@0
   440
	ASN1_INTEGER *serial, X509_OBJECT *ret);
sl@0
   441
IMPORT_C int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, int type,
sl@0
   442
	unsigned char *bytes, int len, X509_OBJECT *ret);
sl@0
   443
IMPORT_C int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, int type, char *str,
sl@0
   444
	int len, X509_OBJECT *ret);
sl@0
   445
IMPORT_C int X509_LOOKUP_shutdown(X509_LOOKUP *ctx);
sl@0
   446
sl@0
   447
#ifndef OPENSSL_NO_STDIO
sl@0
   448
IMPORT_C int	X509_STORE_load_locations (X509_STORE *ctx,
sl@0
   449
		const char *file, const char *dir);
sl@0
   450
IMPORT_C int	X509_STORE_set_default_paths(X509_STORE *ctx);
sl@0
   451
#endif
sl@0
   452
sl@0
   453
IMPORT_C int X509_STORE_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
sl@0
   454
	CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
sl@0
   455
IMPORT_C int	X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx,int idx,void *data);
sl@0
   456
IMPORT_C void *	X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx,int idx);
sl@0
   457
IMPORT_C int	X509_STORE_CTX_get_error(X509_STORE_CTX *ctx);
sl@0
   458
IMPORT_C void	X509_STORE_CTX_set_error(X509_STORE_CTX *ctx,int s);
sl@0
   459
IMPORT_C int	X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx);
sl@0
   460
IMPORT_C X509 *	X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx);
sl@0
   461
IMPORT_C STACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx);
sl@0
   462
IMPORT_C STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx);
sl@0
   463
IMPORT_C void	X509_STORE_CTX_set_cert(X509_STORE_CTX *c,X509 *x);
sl@0
   464
IMPORT_C void	X509_STORE_CTX_set_chain(X509_STORE_CTX *c,STACK_OF(X509) *sk);
sl@0
   465
IMPORT_C void	X509_STORE_CTX_set0_crls(X509_STORE_CTX *c,STACK_OF(X509_CRL) *sk);
sl@0
   466
IMPORT_C int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose);
sl@0
   467
IMPORT_C int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust);
sl@0
   468
IMPORT_C int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
sl@0
   469
				int purpose, int trust);
sl@0
   470
IMPORT_C void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags);
sl@0
   471
IMPORT_C void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags,
sl@0
   472
								time_t t);
sl@0
   473
IMPORT_C void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx,
sl@0
   474
				  int (*verify_cb)(int, X509_STORE_CTX *));
sl@0
   475
  
sl@0
   476
IMPORT_C X509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx);
sl@0
   477
IMPORT_C int X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx);
sl@0
   478
sl@0
   479
IMPORT_C X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx);
sl@0
   480
IMPORT_C void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param);
sl@0
   481
IMPORT_C int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name);
sl@0
   482
sl@0
   483
/* X509_VERIFY_PARAM functions */
sl@0
   484
sl@0
   485
IMPORT_C X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void);
sl@0
   486
IMPORT_C void X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param);
sl@0
   487
IMPORT_C int X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to,
sl@0
   488
						const X509_VERIFY_PARAM *from);
sl@0
   489
IMPORT_C int X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to, 
sl@0
   490
						const X509_VERIFY_PARAM *from);
sl@0
   491
IMPORT_C int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name);
sl@0
   492
IMPORT_C int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param, unsigned long flags);
sl@0
   493
IMPORT_C int X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param,
sl@0
   494
							unsigned long flags);
sl@0
   495
IMPORT_C unsigned long X509_VERIFY_PARAM_get_flags(X509_VERIFY_PARAM *param);
sl@0
   496
IMPORT_C int X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose);
sl@0
   497
IMPORT_C int X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust);
sl@0
   498
IMPORT_C void X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth);
sl@0
   499
IMPORT_C void X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t);
sl@0
   500
IMPORT_C int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param,
sl@0
   501
						ASN1_OBJECT *policy);
sl@0
   502
IMPORT_C int X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param, 
sl@0
   503
					STACK_OF(ASN1_OBJECT) *policies);
sl@0
   504
IMPORT_C int X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param);
sl@0
   505
sl@0
   506
IMPORT_C int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param);
sl@0
   507
IMPORT_C const X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name);
sl@0
   508
IMPORT_C void X509_VERIFY_PARAM_table_cleanup(void);
sl@0
   509
sl@0
   510
IMPORT_C int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy,
sl@0
   511
			STACK_OF(X509) *certs,
sl@0
   512
			STACK_OF(ASN1_OBJECT) *policy_oids,
sl@0
   513
			unsigned int flags);
sl@0
   514
sl@0
   515
IMPORT_C void X509_policy_tree_free(X509_POLICY_TREE *tree);
sl@0
   516
sl@0
   517
IMPORT_C int X509_policy_tree_level_count(const X509_POLICY_TREE *tree);
sl@0
   518
IMPORT_C X509_POLICY_LEVEL *
sl@0
   519
	X509_policy_tree_get0_level(const X509_POLICY_TREE *tree, int i);
sl@0
   520
sl@0
   521
IMPORT_C STACK_OF(X509_POLICY_NODE) *
sl@0
   522
	X509_policy_tree_get0_policies(const X509_POLICY_TREE *tree);
sl@0
   523
sl@0
   524
IMPORT_C STACK_OF(X509_POLICY_NODE) *
sl@0
   525
	X509_policy_tree_get0_user_policies(const X509_POLICY_TREE *tree);
sl@0
   526
sl@0
   527
IMPORT_C int X509_policy_level_node_count(X509_POLICY_LEVEL *level);
sl@0
   528
sl@0
   529
IMPORT_C X509_POLICY_NODE *X509_policy_level_get0_node(X509_POLICY_LEVEL *level, int i);
sl@0
   530
sl@0
   531
IMPORT_C const ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node);
sl@0
   532
sl@0
   533
IMPORT_C STACK_OF(POLICYQUALINFO) *
sl@0
   534
	X509_policy_node_get0_qualifiers(const X509_POLICY_NODE *node);
sl@0
   535
IMPORT_C const X509_POLICY_NODE *
sl@0
   536
	X509_policy_node_get0_parent(const X509_POLICY_NODE *node);
sl@0
   537
sl@0
   538
#ifdef  __cplusplus
sl@0
   539
}
sl@0
   540
#endif
sl@0
   541
#endif
sl@0
   542