diff options
Diffstat (limited to 'src/lib/libcrypto/x509/x509_vfy.h')
-rw-r--r-- | src/lib/libcrypto/x509/x509_vfy.h | 143 |
1 files changed, 126 insertions, 17 deletions
diff --git a/src/lib/libcrypto/x509/x509_vfy.h b/src/lib/libcrypto/x509/x509_vfy.h index 7fd1f0bc4d..76c76e1719 100644 --- a/src/lib/libcrypto/x509/x509_vfy.h +++ b/src/lib/libcrypto/x509/x509_vfy.h | |||
@@ -65,6 +65,7 @@ | |||
65 | #ifndef HEADER_X509_VFY_H | 65 | #ifndef HEADER_X509_VFY_H |
66 | #define HEADER_X509_VFY_H | 66 | #define HEADER_X509_VFY_H |
67 | 67 | ||
68 | #include <openssl/opensslconf.h> | ||
68 | #ifndef OPENSSL_NO_LHASH | 69 | #ifndef OPENSSL_NO_LHASH |
69 | #include <openssl/lhash.h> | 70 | #include <openssl/lhash.h> |
70 | #endif | 71 | #endif |
@@ -155,6 +156,25 @@ typedef struct x509_lookup_method_st | |||
155 | X509_OBJECT *ret); | 156 | X509_OBJECT *ret); |
156 | } X509_LOOKUP_METHOD; | 157 | } X509_LOOKUP_METHOD; |
157 | 158 | ||
159 | /* This structure hold all parameters associated with a verify operation | ||
160 | * by including an X509_VERIFY_PARAM structure in related structures the | ||
161 | * parameters used can be customized | ||
162 | */ | ||
163 | |||
164 | typedef struct X509_VERIFY_PARAM_st | ||
165 | { | ||
166 | char *name; | ||
167 | time_t check_time; /* Time to use */ | ||
168 | unsigned long inh_flags; /* Inheritance flags */ | ||
169 | unsigned long flags; /* Various verify flags */ | ||
170 | int purpose; /* purpose to check untrusted certificates */ | ||
171 | int trust; /* trust setting to check */ | ||
172 | int depth; /* Verify depth */ | ||
173 | STACK_OF(ASN1_OBJECT) *policies; /* Permissible policies */ | ||
174 | } X509_VERIFY_PARAM; | ||
175 | |||
176 | DECLARE_STACK_OF(X509_VERIFY_PARAM) | ||
177 | |||
158 | /* This is used to hold everything. It is used for all certificate | 178 | /* This is used to hold everything. It is used for all certificate |
159 | * validation. Once we have a certificate chain, the 'verify' | 179 | * validation. Once we have a certificate chain, the 'verify' |
160 | * function is then called to actually check the cert chain. */ | 180 | * function is then called to actually check the cert chain. */ |
@@ -167,13 +187,8 @@ struct x509_store_st | |||
167 | /* These are external lookup methods */ | 187 | /* These are external lookup methods */ |
168 | STACK_OF(X509_LOOKUP) *get_cert_methods; | 188 | STACK_OF(X509_LOOKUP) *get_cert_methods; |
169 | 189 | ||
170 | /* The following fields are not used by X509_STORE but are | 190 | X509_VERIFY_PARAM *param; |
171 | * inherited by X509_STORE_CTX when it is initialised. | ||
172 | */ | ||
173 | 191 | ||
174 | unsigned long flags; /* Various verify flags */ | ||
175 | int purpose; | ||
176 | int trust; | ||
177 | /* Callbacks for various operations */ | 192 | /* Callbacks for various operations */ |
178 | int (*verify)(X509_STORE_CTX *ctx); /* called to verify a certificate */ | 193 | int (*verify)(X509_STORE_CTX *ctx); /* called to verify a certificate */ |
179 | int (*verify_cb)(int ok,X509_STORE_CTX *ctx); /* error callback */ | 194 | int (*verify_cb)(int ok,X509_STORE_CTX *ctx); /* error callback */ |
@@ -187,10 +202,9 @@ struct x509_store_st | |||
187 | 202 | ||
188 | CRYPTO_EX_DATA ex_data; | 203 | CRYPTO_EX_DATA ex_data; |
189 | int references; | 204 | int references; |
190 | int depth; /* how deep to look (still unused -- X509_STORE_CTX's depth is used) */ | ||
191 | } /* X509_STORE */; | 205 | } /* X509_STORE */; |
192 | 206 | ||
193 | #define X509_STORE_set_depth(ctx,d) ((ctx)->depth=(d)) | 207 | int X509_STORE_set_depth(X509_STORE *store, int depth); |
194 | 208 | ||
195 | #define X509_STORE_set_verify_cb_func(ctx,func) ((ctx)->verify_cb=(func)) | 209 | #define X509_STORE_set_verify_cb_func(ctx,func) ((ctx)->verify_cb=(func)) |
196 | #define X509_STORE_set_verify_func(ctx,func) ((ctx)->verify=(func)) | 210 | #define X509_STORE_set_verify_func(ctx,func) ((ctx)->verify=(func)) |
@@ -217,10 +231,9 @@ struct x509_store_ctx_st /* X509_STORE_CTX */ | |||
217 | /* The following are set by the caller */ | 231 | /* The following are set by the caller */ |
218 | X509 *cert; /* The cert to check */ | 232 | X509 *cert; /* The cert to check */ |
219 | STACK_OF(X509) *untrusted; /* chain of X509s - untrusted - passed in */ | 233 | STACK_OF(X509) *untrusted; /* chain of X509s - untrusted - passed in */ |
220 | int purpose; /* purpose to check untrusted certificates */ | 234 | STACK_OF(X509_CRL) *crls; /* set of CRLs passed in */ |
221 | int trust; /* trust setting to check */ | 235 | |
222 | time_t check_time; /* time to make verify at */ | 236 | X509_VERIFY_PARAM *param; |
223 | unsigned long flags; /* Various verify flags */ | ||
224 | void *other_ctx; /* Other info for use with get_issuer() */ | 237 | void *other_ctx; /* Other info for use with get_issuer() */ |
225 | 238 | ||
226 | /* Callbacks for various operations */ | 239 | /* Callbacks for various operations */ |
@@ -232,13 +245,16 @@ struct x509_store_ctx_st /* X509_STORE_CTX */ | |||
232 | int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); /* retrieve CRL */ | 245 | int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); /* retrieve CRL */ |
233 | int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */ | 246 | int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */ |
234 | int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */ | 247 | int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */ |
248 | int (*check_policy)(X509_STORE_CTX *ctx); | ||
235 | int (*cleanup)(X509_STORE_CTX *ctx); | 249 | int (*cleanup)(X509_STORE_CTX *ctx); |
236 | 250 | ||
237 | /* The following is built up */ | 251 | /* The following is built up */ |
238 | int depth; /* how far to go looking up certs */ | ||
239 | int valid; /* if 0, rebuild chain */ | 252 | int valid; /* if 0, rebuild chain */ |
240 | int last_untrusted; /* index of last untrusted cert */ | 253 | int last_untrusted; /* index of last untrusted cert */ |
241 | STACK_OF(X509) *chain; /* chain of X509s - built up and trusted */ | 254 | STACK_OF(X509) *chain; /* chain of X509s - built up and trusted */ |
255 | X509_POLICY_TREE *tree; /* Valid policy tree */ | ||
256 | |||
257 | int explicit_policy; /* Require explicit policy value */ | ||
242 | 258 | ||
243 | /* When something goes wrong, this is why */ | 259 | /* When something goes wrong, this is why */ |
244 | int error_depth; | 260 | int error_depth; |
@@ -250,7 +266,7 @@ struct x509_store_ctx_st /* X509_STORE_CTX */ | |||
250 | CRYPTO_EX_DATA ex_data; | 266 | CRYPTO_EX_DATA ex_data; |
251 | } /* X509_STORE_CTX */; | 267 | } /* X509_STORE_CTX */; |
252 | 268 | ||
253 | #define X509_STORE_CTX_set_depth(ctx,d) ((ctx)->depth=(d)) | 269 | void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth); |
254 | 270 | ||
255 | #define X509_STORE_CTX_set_app_data(ctx,data) \ | 271 | #define X509_STORE_CTX_set_app_data(ctx,data) \ |
256 | X509_STORE_CTX_set_ex_data(ctx,0,data) | 272 | X509_STORE_CTX_set_ex_data(ctx,0,data) |
@@ -311,6 +327,12 @@ struct x509_store_ctx_st /* X509_STORE_CTX */ | |||
311 | #define X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE 39 | 327 | #define X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE 39 |
312 | #define X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED 40 | 328 | #define X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED 40 |
313 | 329 | ||
330 | #define X509_V_ERR_INVALID_EXTENSION 41 | ||
331 | #define X509_V_ERR_INVALID_POLICY_EXTENSION 42 | ||
332 | #define X509_V_ERR_NO_EXPLICIT_POLICY 43 | ||
333 | |||
334 | #define X509_V_ERR_UNNESTED_RESOURCE 44 | ||
335 | |||
314 | /* The application is not happy */ | 336 | /* The application is not happy */ |
315 | #define X509_V_ERR_APPLICATION_VERIFICATION 50 | 337 | #define X509_V_ERR_APPLICATION_VERIFICATION 50 |
316 | 338 | ||
@@ -330,6 +352,28 @@ struct x509_store_ctx_st /* X509_STORE_CTX */ | |||
330 | #define X509_V_FLAG_X509_STRICT 0x20 | 352 | #define X509_V_FLAG_X509_STRICT 0x20 |
331 | /* Enable proxy certificate validation */ | 353 | /* Enable proxy certificate validation */ |
332 | #define X509_V_FLAG_ALLOW_PROXY_CERTS 0x40 | 354 | #define X509_V_FLAG_ALLOW_PROXY_CERTS 0x40 |
355 | /* Enable policy checking */ | ||
356 | #define X509_V_FLAG_POLICY_CHECK 0x80 | ||
357 | /* Policy variable require-explicit-policy */ | ||
358 | #define X509_V_FLAG_EXPLICIT_POLICY 0x100 | ||
359 | /* Policy variable inhibit-any-policy */ | ||
360 | #define X509_V_FLAG_INHIBIT_ANY 0x200 | ||
361 | /* Policy variable inhibit-policy-mapping */ | ||
362 | #define X509_V_FLAG_INHIBIT_MAP 0x400 | ||
363 | /* Notify callback that policy is OK */ | ||
364 | #define X509_V_FLAG_NOTIFY_POLICY 0x800 | ||
365 | |||
366 | #define X509_VP_FLAG_DEFAULT 0x1 | ||
367 | #define X509_VP_FLAG_OVERWRITE 0x2 | ||
368 | #define X509_VP_FLAG_RESET_FLAGS 0x4 | ||
369 | #define X509_VP_FLAG_LOCKED 0x8 | ||
370 | #define X509_VP_FLAG_ONCE 0x10 | ||
371 | |||
372 | /* Internal use: mask of policy related options */ | ||
373 | #define X509_V_FLAG_POLICY_MASK (X509_V_FLAG_POLICY_CHECK \ | ||
374 | | X509_V_FLAG_EXPLICIT_POLICY \ | ||
375 | | X509_V_FLAG_INHIBIT_ANY \ | ||
376 | | X509_V_FLAG_INHIBIT_MAP) | ||
333 | 377 | ||
334 | int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type, | 378 | int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type, |
335 | X509_NAME *name); | 379 | X509_NAME *name); |
@@ -340,9 +384,10 @@ void X509_OBJECT_free_contents(X509_OBJECT *a); | |||
340 | X509_STORE *X509_STORE_new(void ); | 384 | X509_STORE *X509_STORE_new(void ); |
341 | void X509_STORE_free(X509_STORE *v); | 385 | void X509_STORE_free(X509_STORE *v); |
342 | 386 | ||
343 | void X509_STORE_set_flags(X509_STORE *ctx, long flags); | 387 | int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags); |
344 | int X509_STORE_set_purpose(X509_STORE *ctx, int purpose); | 388 | int X509_STORE_set_purpose(X509_STORE *ctx, int purpose); |
345 | int X509_STORE_set_trust(X509_STORE *ctx, int trust); | 389 | int X509_STORE_set_trust(X509_STORE *ctx, int trust); |
390 | int X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *pm); | ||
346 | 391 | ||
347 | X509_STORE_CTX *X509_STORE_CTX_new(void); | 392 | X509_STORE_CTX *X509_STORE_CTX_new(void); |
348 | 393 | ||
@@ -406,14 +451,78 @@ STACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx); | |||
406 | STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx); | 451 | STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx); |
407 | void X509_STORE_CTX_set_cert(X509_STORE_CTX *c,X509 *x); | 452 | void X509_STORE_CTX_set_cert(X509_STORE_CTX *c,X509 *x); |
408 | void X509_STORE_CTX_set_chain(X509_STORE_CTX *c,STACK_OF(X509) *sk); | 453 | void X509_STORE_CTX_set_chain(X509_STORE_CTX *c,STACK_OF(X509) *sk); |
454 | void X509_STORE_CTX_set0_crls(X509_STORE_CTX *c,STACK_OF(X509_CRL) *sk); | ||
409 | int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose); | 455 | int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose); |
410 | int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust); | 456 | int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust); |
411 | int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose, | 457 | int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose, |
412 | int purpose, int trust); | 458 | int purpose, int trust); |
413 | void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, long flags); | 459 | void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags); |
414 | void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, long flags, time_t t); | 460 | void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags, |
461 | time_t t); | ||
415 | void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx, | 462 | void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx, |
416 | int (*verify_cb)(int, X509_STORE_CTX *)); | 463 | int (*verify_cb)(int, X509_STORE_CTX *)); |
464 | |||
465 | X509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx); | ||
466 | int X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx); | ||
467 | |||
468 | X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx); | ||
469 | void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param); | ||
470 | int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name); | ||
471 | |||
472 | /* X509_VERIFY_PARAM functions */ | ||
473 | |||
474 | X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void); | ||
475 | void X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param); | ||
476 | int X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to, | ||
477 | const X509_VERIFY_PARAM *from); | ||
478 | int X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to, | ||
479 | const X509_VERIFY_PARAM *from); | ||
480 | int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name); | ||
481 | int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param, unsigned long flags); | ||
482 | int X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param, | ||
483 | unsigned long flags); | ||
484 | unsigned long X509_VERIFY_PARAM_get_flags(X509_VERIFY_PARAM *param); | ||
485 | int X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose); | ||
486 | int X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust); | ||
487 | void X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth); | ||
488 | void X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t); | ||
489 | int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param, | ||
490 | ASN1_OBJECT *policy); | ||
491 | int X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param, | ||
492 | STACK_OF(ASN1_OBJECT) *policies); | ||
493 | int X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param); | ||
494 | |||
495 | int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param); | ||
496 | const X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name); | ||
497 | void X509_VERIFY_PARAM_table_cleanup(void); | ||
498 | |||
499 | int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy, | ||
500 | STACK_OF(X509) *certs, | ||
501 | STACK_OF(ASN1_OBJECT) *policy_oids, | ||
502 | unsigned int flags); | ||
503 | |||
504 | void X509_policy_tree_free(X509_POLICY_TREE *tree); | ||
505 | |||
506 | int X509_policy_tree_level_count(const X509_POLICY_TREE *tree); | ||
507 | X509_POLICY_LEVEL * | ||
508 | X509_policy_tree_get0_level(const X509_POLICY_TREE *tree, int i); | ||
509 | |||
510 | STACK_OF(X509_POLICY_NODE) * | ||
511 | X509_policy_tree_get0_policies(const X509_POLICY_TREE *tree); | ||
512 | |||
513 | STACK_OF(X509_POLICY_NODE) * | ||
514 | X509_policy_tree_get0_user_policies(const X509_POLICY_TREE *tree); | ||
515 | |||
516 | int X509_policy_level_node_count(X509_POLICY_LEVEL *level); | ||
517 | |||
518 | X509_POLICY_NODE *X509_policy_level_get0_node(X509_POLICY_LEVEL *level, int i); | ||
519 | |||
520 | const ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node); | ||
521 | |||
522 | STACK_OF(POLICYQUALINFO) * | ||
523 | X509_policy_node_get0_qualifiers(const X509_POLICY_NODE *node); | ||
524 | const X509_POLICY_NODE * | ||
525 | X509_policy_node_get0_parent(const X509_POLICY_NODE *node); | ||
417 | 526 | ||
418 | #ifdef __cplusplus | 527 | #ifdef __cplusplus |
419 | } | 528 | } |