]>
Commit | Line | Data |
---|---|---|
b1322259 | 1 | /* |
4333b89f | 2 | * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. |
d02b48c6 | 3 | * |
3e4b43b9 | 4 | * Licensed under the Apache License 2.0 (the "License"). You may not use |
b1322259 RS |
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 | |
d02b48c6 RE |
8 | */ |
9 | ||
10 | #include <stdio.h> | |
b39fc560 | 11 | #include "internal/cryptlib.h" |
cd420b0b | 12 | #include "internal/refcount.h" |
ec577822 | 13 | #include <openssl/x509.h> |
25f2138b | 14 | #include "crypto/x509.h" |
926a56bf | 15 | #include <openssl/x509v3.h> |
706457b7 | 16 | #include "x509_local.h" |
d02b48c6 | 17 | |
6b691a5c | 18 | X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method) |
0f113f3e | 19 | { |
7fcdbd83 | 20 | X509_LOOKUP *ret = OPENSSL_zalloc(sizeof(*ret)); |
0f113f3e | 21 | |
7fcdbd83 | 22 | if (ret == NULL) { |
9311d0c4 | 23 | ERR_raise(ERR_LIB_X509, ERR_R_MALLOC_FAILURE); |
0f113f3e | 24 | return NULL; |
7fcdbd83 | 25 | } |
0f113f3e | 26 | |
0f113f3e | 27 | ret->method = method; |
7fcdbd83 | 28 | if (method->new_item != NULL && method->new_item(ret) == 0) { |
0f113f3e MC |
29 | OPENSSL_free(ret); |
30 | return NULL; | |
31 | } | |
32 | return ret; | |
33 | } | |
d02b48c6 | 34 | |
6b691a5c | 35 | void X509_LOOKUP_free(X509_LOOKUP *ctx) |
0f113f3e MC |
36 | { |
37 | if (ctx == NULL) | |
38 | return; | |
39 | if ((ctx->method != NULL) && (ctx->method->free != NULL)) | |
40 | (*ctx->method->free) (ctx); | |
41 | OPENSSL_free(ctx); | |
42 | } | |
d02b48c6 | 43 | |
3067095e RL |
44 | int X509_STORE_lock(X509_STORE *s) |
45 | { | |
46 | return CRYPTO_THREAD_write_lock(s->lock); | |
47 | } | |
48 | ||
49 | int X509_STORE_unlock(X509_STORE *s) | |
50 | { | |
51 | return CRYPTO_THREAD_unlock(s->lock); | |
52 | } | |
53 | ||
6b691a5c | 54 | int X509_LOOKUP_init(X509_LOOKUP *ctx) |
0f113f3e MC |
55 | { |
56 | if (ctx->method == NULL) | |
57 | return 0; | |
58 | if (ctx->method->init != NULL) | |
59 | return ctx->method->init(ctx); | |
60 | else | |
61 | return 1; | |
62 | } | |
d02b48c6 | 63 | |
6b691a5c | 64 | int X509_LOOKUP_shutdown(X509_LOOKUP *ctx) |
0f113f3e MC |
65 | { |
66 | if (ctx->method == NULL) | |
67 | return 0; | |
68 | if (ctx->method->shutdown != NULL) | |
69 | return ctx->method->shutdown(ctx); | |
70 | else | |
71 | return 1; | |
72 | } | |
d02b48c6 | 73 | |
d8652be0 | 74 | int X509_LOOKUP_ctrl_ex(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, |
b4250010 | 75 | char **ret, OSSL_LIB_CTX *libctx, const char *propq) |
0f113f3e MC |
76 | { |
77 | if (ctx->method == NULL) | |
78 | return -1; | |
d8652be0 MC |
79 | if (ctx->method->ctrl_ex != NULL) |
80 | return ctx->method->ctrl_ex(ctx, cmd, argc, argl, ret, libctx, propq); | |
0f113f3e MC |
81 | if (ctx->method->ctrl != NULL) |
82 | return ctx->method->ctrl(ctx, cmd, argc, argl, ret); | |
6725682d SL |
83 | return 1; |
84 | } | |
85 | ||
86 | int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, | |
87 | char **ret) | |
88 | { | |
d8652be0 | 89 | return X509_LOOKUP_ctrl_ex(ctx, cmd, argc, argl, ret, NULL, NULL); |
6725682d SL |
90 | } |
91 | ||
d8652be0 MC |
92 | int X509_LOOKUP_by_subject_ex(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, |
93 | const X509_NAME *name, X509_OBJECT *ret, | |
b4250010 | 94 | OSSL_LIB_CTX *libctx, const char *propq) |
6725682d SL |
95 | { |
96 | if (ctx->skip | |
97 | || ctx->method == NULL | |
98 | || (ctx->method->get_by_subject == NULL | |
d8652be0 | 99 | && ctx->method->get_by_subject_ex == NULL)) |
6725682d | 100 | return 0; |
d8652be0 MC |
101 | if (ctx->method->get_by_subject_ex != NULL) |
102 | return ctx->method->get_by_subject_ex(ctx, type, name, ret, libctx, | |
103 | propq); | |
0f113f3e | 104 | else |
6725682d | 105 | return ctx->method->get_by_subject(ctx, type, name, ret); |
0f113f3e | 106 | } |
d02b48c6 | 107 | |
0946a198 | 108 | int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, |
8cc86b81 | 109 | const X509_NAME *name, X509_OBJECT *ret) |
0f113f3e | 110 | { |
d8652be0 | 111 | return X509_LOOKUP_by_subject_ex(ctx, type, name, ret, NULL, NULL); |
0f113f3e | 112 | } |
d02b48c6 | 113 | |
0946a198 | 114 | int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, |
8cc86b81 DDO |
115 | const X509_NAME *name, |
116 | const ASN1_INTEGER *serial, | |
0946a198 | 117 | X509_OBJECT *ret) |
0f113f3e MC |
118 | { |
119 | if ((ctx->method == NULL) || (ctx->method->get_by_issuer_serial == NULL)) | |
ba1a1c37 | 120 | return 0; |
0f113f3e MC |
121 | return ctx->method->get_by_issuer_serial(ctx, type, name, serial, ret); |
122 | } | |
d02b48c6 | 123 | |
0946a198 | 124 | int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, |
cfc5e0aa | 125 | const unsigned char *bytes, int len, |
0f113f3e MC |
126 | X509_OBJECT *ret) |
127 | { | |
128 | if ((ctx->method == NULL) || (ctx->method->get_by_fingerprint == NULL)) | |
ba1a1c37 | 129 | return 0; |
0f113f3e MC |
130 | return ctx->method->get_by_fingerprint(ctx, type, bytes, len, ret); |
131 | } | |
d02b48c6 | 132 | |
0946a198 | 133 | int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, |
cfc5e0aa | 134 | const char *str, int len, X509_OBJECT *ret) |
0f113f3e MC |
135 | { |
136 | if ((ctx->method == NULL) || (ctx->method->get_by_alias == NULL)) | |
ba1a1c37 | 137 | return 0; |
0f113f3e MC |
138 | return ctx->method->get_by_alias(ctx, type, str, len, ret); |
139 | } | |
140 | ||
0124f32a MY |
141 | int X509_LOOKUP_set_method_data(X509_LOOKUP *ctx, void *data) |
142 | { | |
143 | ctx->method_data = data; | |
144 | return 1; | |
145 | } | |
146 | ||
147 | void *X509_LOOKUP_get_method_data(const X509_LOOKUP *ctx) | |
148 | { | |
149 | return ctx->method_data; | |
150 | } | |
151 | ||
152 | X509_STORE *X509_LOOKUP_get_store(const X509_LOOKUP *ctx) | |
153 | { | |
154 | return ctx->store_ctx; | |
155 | } | |
156 | ||
157 | ||
0f113f3e MC |
158 | static int x509_object_cmp(const X509_OBJECT *const *a, |
159 | const X509_OBJECT *const *b) | |
160 | { | |
161 | int ret; | |
162 | ||
163 | ret = ((*a)->type - (*b)->type); | |
164 | if (ret) | |
165 | return ret; | |
166 | switch ((*a)->type) { | |
167 | case X509_LU_X509: | |
168 | ret = X509_subject_name_cmp((*a)->data.x509, (*b)->data.x509); | |
169 | break; | |
170 | case X509_LU_CRL: | |
171 | ret = X509_CRL_cmp((*a)->data.crl, (*b)->data.crl); | |
172 | break; | |
f3b3d7f0 | 173 | case X509_LU_NONE: |
0f113f3e MC |
174 | /* abort(); */ |
175 | return 0; | |
176 | } | |
177 | return ret; | |
178 | } | |
d02b48c6 | 179 | |
6b691a5c | 180 | X509_STORE *X509_STORE_new(void) |
0f113f3e | 181 | { |
7fcdbd83 | 182 | X509_STORE *ret = OPENSSL_zalloc(sizeof(*ret)); |
0f113f3e | 183 | |
7fcdbd83 | 184 | if (ret == NULL) { |
9311d0c4 | 185 | ERR_raise(ERR_LIB_X509, ERR_R_MALLOC_FAILURE); |
0f113f3e | 186 | return NULL; |
7fcdbd83 F |
187 | } |
188 | if ((ret->objs = sk_X509_OBJECT_new(x509_object_cmp)) == NULL) { | |
9311d0c4 | 189 | ERR_raise(ERR_LIB_X509, ERR_R_MALLOC_FAILURE); |
90945fa3 | 190 | goto err; |
7fcdbd83 | 191 | } |
0f113f3e | 192 | ret->cache = 1; |
7fcdbd83 | 193 | if ((ret->get_cert_methods = sk_X509_LOOKUP_new_null()) == NULL) { |
9311d0c4 | 194 | ERR_raise(ERR_LIB_X509, ERR_R_MALLOC_FAILURE); |
90945fa3 | 195 | goto err; |
7fcdbd83 | 196 | } |
0f113f3e | 197 | |
7fcdbd83 | 198 | if ((ret->param = X509_VERIFY_PARAM_new()) == NULL) { |
9311d0c4 | 199 | ERR_raise(ERR_LIB_X509, ERR_R_MALLOC_FAILURE); |
90945fa3 | 200 | goto err; |
7fcdbd83 F |
201 | } |
202 | if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_X509_STORE, ret, &ret->ex_data)) { | |
9311d0c4 | 203 | ERR_raise(ERR_LIB_X509, ERR_R_MALLOC_FAILURE); |
90945fa3 | 204 | goto err; |
7fcdbd83 | 205 | } |
0f113f3e | 206 | |
c001ce33 | 207 | ret->lock = CRYPTO_THREAD_lock_new(); |
7fcdbd83 | 208 | if (ret->lock == NULL) { |
9311d0c4 | 209 | ERR_raise(ERR_LIB_X509, ERR_R_MALLOC_FAILURE); |
c001ce33 | 210 | goto err; |
7fcdbd83 | 211 | } |
0f113f3e MC |
212 | ret->references = 1; |
213 | return ret; | |
c001ce33 | 214 | |
90945fa3 MC |
215 | err: |
216 | X509_VERIFY_PARAM_free(ret->param); | |
217 | sk_X509_OBJECT_free(ret->objs); | |
218 | sk_X509_LOOKUP_free(ret->get_cert_methods); | |
219 | OPENSSL_free(ret); | |
220 | return NULL; | |
0f113f3e | 221 | } |
d02b48c6 | 222 | |
6b691a5c | 223 | void X509_STORE_free(X509_STORE *vfy) |
0f113f3e MC |
224 | { |
225 | int i; | |
226 | STACK_OF(X509_LOOKUP) *sk; | |
227 | X509_LOOKUP *lu; | |
d02b48c6 | 228 | |
e6e9170d RS |
229 | if (vfy == NULL) |
230 | return; | |
2f545ae4 | 231 | CRYPTO_DOWN_REF(&vfy->references, &i, vfy->lock); |
f3f1cf84 | 232 | REF_PRINT_COUNT("X509_STORE", vfy); |
0f113f3e MC |
233 | if (i > 0) |
234 | return; | |
f3f1cf84 | 235 | REF_ASSERT_ISNT(i < 0); |
bff9ce4d | 236 | |
0f113f3e MC |
237 | sk = vfy->get_cert_methods; |
238 | for (i = 0; i < sk_X509_LOOKUP_num(sk); i++) { | |
239 | lu = sk_X509_LOOKUP_value(sk, i); | |
240 | X509_LOOKUP_shutdown(lu); | |
241 | X509_LOOKUP_free(lu); | |
242 | } | |
243 | sk_X509_LOOKUP_free(sk); | |
b6ef12c4 | 244 | sk_X509_OBJECT_pop_free(vfy->objs, X509_OBJECT_free); |
0f113f3e MC |
245 | |
246 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_X509_STORE, vfy, &vfy->ex_data); | |
222561fe | 247 | X509_VERIFY_PARAM_free(vfy->param); |
c001ce33 | 248 | CRYPTO_THREAD_lock_free(vfy->lock); |
0f113f3e MC |
249 | OPENSSL_free(vfy); |
250 | } | |
d02b48c6 | 251 | |
c001ce33 AG |
252 | int X509_STORE_up_ref(X509_STORE *vfy) |
253 | { | |
254 | int i; | |
255 | ||
2f545ae4 | 256 | if (CRYPTO_UP_REF(&vfy->references, &i, vfy->lock) <= 0) |
c001ce33 AG |
257 | return 0; |
258 | ||
e26f653d | 259 | REF_PRINT_COUNT("X509_STORE", vfy); |
c001ce33 AG |
260 | REF_ASSERT_ISNT(i < 2); |
261 | return ((i > 1) ? 1 : 0); | |
262 | } | |
263 | ||
6b691a5c | 264 | X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m) |
0f113f3e MC |
265 | { |
266 | int i; | |
267 | STACK_OF(X509_LOOKUP) *sk; | |
268 | X509_LOOKUP *lu; | |
269 | ||
270 | sk = v->get_cert_methods; | |
271 | for (i = 0; i < sk_X509_LOOKUP_num(sk); i++) { | |
272 | lu = sk_X509_LOOKUP_value(sk, i); | |
273 | if (m == lu->method) { | |
274 | return lu; | |
275 | } | |
276 | } | |
277 | /* a new one */ | |
278 | lu = X509_LOOKUP_new(m); | |
7fcdbd83 | 279 | if (lu == NULL) { |
9311d0c4 | 280 | ERR_raise(ERR_LIB_X509, ERR_R_MALLOC_FAILURE); |
0f113f3e | 281 | return NULL; |
0f113f3e | 282 | } |
7fcdbd83 F |
283 | |
284 | lu->store_ctx = v; | |
285 | if (sk_X509_LOOKUP_push(v->get_cert_methods, lu)) | |
286 | return lu; | |
287 | /* malloc failed */ | |
9311d0c4 | 288 | ERR_raise(ERR_LIB_X509, ERR_R_MALLOC_FAILURE); |
7fcdbd83 F |
289 | X509_LOOKUP_free(lu); |
290 | return NULL; | |
0f113f3e | 291 | } |
d02b48c6 | 292 | |
0946a198 DSH |
293 | X509_OBJECT *X509_STORE_CTX_get_obj_by_subject(X509_STORE_CTX *vs, |
294 | X509_LOOKUP_TYPE type, | |
8cc86b81 | 295 | const X509_NAME *name) |
f0e0fd51 | 296 | { |
6ddbb4cd | 297 | X509_OBJECT *ret = X509_OBJECT_new(); |
f0e0fd51 | 298 | |
6ddbb4cd | 299 | if (ret == NULL) |
f0e0fd51 | 300 | return NULL; |
6ddbb4cd RS |
301 | if (!X509_STORE_CTX_get_by_subject(vs, type, name, ret)) { |
302 | X509_OBJECT_free(ret); | |
f0e0fd51 RS |
303 | return NULL; |
304 | } | |
305 | return ret; | |
306 | } | |
307 | ||
8cc86b81 DDO |
308 | int X509_STORE_CTX_get_by_subject(const X509_STORE_CTX *vs, |
309 | X509_LOOKUP_TYPE type, | |
310 | const X509_NAME *name, X509_OBJECT *ret) | |
0f113f3e | 311 | { |
faa9dcd4 | 312 | X509_STORE *store = vs->store; |
0f113f3e MC |
313 | X509_LOOKUP *lu; |
314 | X509_OBJECT stmp, *tmp; | |
315 | int i, j; | |
316 | ||
7a9abccd | 317 | if (store == NULL) |
1c705121 MC |
318 | return 0; |
319 | ||
b926f9de MC |
320 | stmp.type = X509_LU_NONE; |
321 | stmp.data.ptr = NULL; | |
322 | ||
7a9abccd SL |
323 | |
324 | X509_STORE_lock(store); | |
325 | tmp = X509_OBJECT_retrieve_by_subject(store->objs, type, name); | |
326 | X509_STORE_unlock(store); | |
0f113f3e MC |
327 | |
328 | if (tmp == NULL || type == X509_LU_CRL) { | |
7a9abccd SL |
329 | for (i = 0; i < sk_X509_LOOKUP_num(store->get_cert_methods); i++) { |
330 | lu = sk_X509_LOOKUP_value(store->get_cert_methods, i); | |
d8652be0 MC |
331 | j = X509_LOOKUP_by_subject_ex(lu, type, name, &stmp, vs->libctx, |
332 | vs->propq); | |
fc9d1ef3 | 333 | if (j) { |
0f113f3e MC |
334 | tmp = &stmp; |
335 | break; | |
336 | } | |
337 | } | |
0f113f3e MC |
338 | if (tmp == NULL) |
339 | return 0; | |
340 | } | |
341 | ||
c70e2ec3 BE |
342 | if (!X509_OBJECT_up_ref_count(tmp)) |
343 | return 0; | |
344 | ||
0f113f3e MC |
345 | ret->type = tmp->type; |
346 | ret->data.ptr = tmp->data.ptr; | |
347 | ||
0f113f3e MC |
348 | return 1; |
349 | } | |
d02b48c6 | 350 | |
7a9abccd | 351 | static int x509_store_add(X509_STORE *store, void *x, int crl) { |
0f113f3e | 352 | X509_OBJECT *obj; |
c0452248 | 353 | int ret = 0, added = 0; |
0f113f3e MC |
354 | |
355 | if (x == NULL) | |
356 | return 0; | |
6ddbb4cd RS |
357 | obj = X509_OBJECT_new(); |
358 | if (obj == NULL) | |
0f113f3e | 359 | return 0; |
c0452248 RS |
360 | |
361 | if (crl) { | |
362 | obj->type = X509_LU_CRL; | |
363 | obj->data.crl = (X509_CRL *)x; | |
364 | } else { | |
365 | obj->type = X509_LU_X509; | |
366 | obj->data.x509 = (X509 *)x; | |
367 | } | |
c70e2ec3 BE |
368 | if (!X509_OBJECT_up_ref_count(obj)) { |
369 | obj->type = X509_LU_NONE; | |
370 | X509_OBJECT_free(obj); | |
371 | return 0; | |
372 | } | |
0f113f3e | 373 | |
7a9abccd SL |
374 | X509_STORE_lock(store); |
375 | if (X509_OBJECT_retrieve_match(store->objs, obj)) { | |
c0452248 | 376 | ret = 1; |
68efafc5 | 377 | } else { |
7a9abccd | 378 | added = sk_X509_OBJECT_push(store->objs, obj); |
68efafc5 F |
379 | ret = added != 0; |
380 | } | |
7a9abccd | 381 | X509_STORE_unlock(store); |
0f113f3e | 382 | |
c0452248 | 383 | if (added == 0) /* obj not pushed */ |
68efafc5 | 384 | X509_OBJECT_free(obj); |
68efafc5 | 385 | |
0f113f3e MC |
386 | return ret; |
387 | } | |
2f043896 | 388 | |
c0452248 | 389 | int X509_STORE_add_cert(X509_STORE *ctx, X509 *x) |
0f113f3e | 390 | { |
c0452248 | 391 | if (!x509_store_add(ctx, x, 0)) { |
9311d0c4 | 392 | ERR_raise(ERR_LIB_X509, ERR_R_MALLOC_FAILURE); |
0f113f3e | 393 | return 0; |
68efafc5 | 394 | } |
c0452248 RS |
395 | return 1; |
396 | } | |
0f113f3e | 397 | |
c0452248 RS |
398 | int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x) |
399 | { | |
400 | if (!x509_store_add(ctx, x, 1)) { | |
9311d0c4 | 401 | ERR_raise(ERR_LIB_X509, ERR_R_MALLOC_FAILURE); |
c0452248 RS |
402 | return 0; |
403 | } | |
404 | return 1; | |
0f113f3e | 405 | } |
2f043896 | 406 | |
c5ebfcab | 407 | int X509_OBJECT_up_ref_count(X509_OBJECT *a) |
0f113f3e MC |
408 | { |
409 | switch (a->type) { | |
f3b3d7f0 | 410 | case X509_LU_NONE: |
bca3f06b | 411 | break; |
0f113f3e | 412 | case X509_LU_X509: |
c5ebfcab | 413 | return X509_up_ref(a->data.x509); |
0f113f3e | 414 | case X509_LU_CRL: |
c5ebfcab | 415 | return X509_CRL_up_ref(a->data.crl); |
0f113f3e | 416 | } |
c5ebfcab | 417 | return 1; |
0f113f3e | 418 | } |
d02b48c6 | 419 | |
7d7da288 | 420 | X509 *X509_OBJECT_get0_X509(const X509_OBJECT *a) |
f0e0fd51 | 421 | { |
6ddbb4cd RS |
422 | if (a == NULL || a->type != X509_LU_X509) |
423 | return NULL; | |
f0e0fd51 RS |
424 | return a->data.x509; |
425 | } | |
426 | ||
8cc86b81 | 427 | X509_CRL *X509_OBJECT_get0_X509_CRL(const X509_OBJECT *a) |
6ddbb4cd RS |
428 | { |
429 | if (a == NULL || a->type != X509_LU_CRL) | |
430 | return NULL; | |
431 | return a->data.crl; | |
432 | } | |
433 | ||
0946a198 | 434 | X509_LOOKUP_TYPE X509_OBJECT_get_type(const X509_OBJECT *a) |
f0c58c32 CH |
435 | { |
436 | return a->type; | |
437 | } | |
438 | ||
3cb7c5cf | 439 | X509_OBJECT *X509_OBJECT_new(void) |
f0e0fd51 | 440 | { |
6ddbb4cd RS |
441 | X509_OBJECT *ret = OPENSSL_zalloc(sizeof(*ret)); |
442 | ||
443 | if (ret == NULL) { | |
9311d0c4 | 444 | ERR_raise(ERR_LIB_X509, ERR_R_MALLOC_FAILURE); |
6ddbb4cd RS |
445 | return NULL; |
446 | } | |
ba1a1c37 | 447 | ret->type = X509_LU_NONE; |
6ddbb4cd | 448 | return ret; |
f0e0fd51 RS |
449 | } |
450 | ||
0124f32a | 451 | static void x509_object_free_internal(X509_OBJECT *a) |
0f113f3e | 452 | { |
f0e0fd51 | 453 | if (a == NULL) |
222561fe | 454 | return; |
0f113f3e | 455 | switch (a->type) { |
f3b3d7f0 | 456 | case X509_LU_NONE: |
bca3f06b | 457 | break; |
0f113f3e MC |
458 | case X509_LU_X509: |
459 | X509_free(a->data.x509); | |
460 | break; | |
461 | case X509_LU_CRL: | |
462 | X509_CRL_free(a->data.crl); | |
463 | break; | |
464 | } | |
0124f32a MY |
465 | } |
466 | ||
467 | int X509_OBJECT_set1_X509(X509_OBJECT *a, X509 *obj) | |
468 | { | |
469 | if (a == NULL || !X509_up_ref(obj)) | |
470 | return 0; | |
471 | ||
472 | x509_object_free_internal(a); | |
473 | a->type = X509_LU_X509; | |
474 | a->data.x509 = obj; | |
475 | return 1; | |
476 | } | |
477 | ||
478 | int X509_OBJECT_set1_X509_CRL(X509_OBJECT *a, X509_CRL *obj) | |
479 | { | |
480 | if (a == NULL || !X509_CRL_up_ref(obj)) | |
481 | return 0; | |
482 | ||
483 | x509_object_free_internal(a); | |
484 | a->type = X509_LU_CRL; | |
485 | a->data.crl = obj; | |
486 | return 1; | |
487 | } | |
488 | ||
489 | void X509_OBJECT_free(X509_OBJECT *a) | |
490 | { | |
491 | x509_object_free_internal(a); | |
6ddbb4cd | 492 | OPENSSL_free(a); |
0f113f3e | 493 | } |
d02b48c6 | 494 | |
0946a198 | 495 | static int x509_object_idx_cnt(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type, |
8cc86b81 | 496 | const X509_NAME *name, int *pnmatch) |
0f113f3e MC |
497 | { |
498 | X509_OBJECT stmp; | |
499 | X509 x509_s; | |
0f113f3e | 500 | X509_CRL crl_s; |
0f113f3e MC |
501 | int idx; |
502 | ||
503 | stmp.type = type; | |
504 | switch (type) { | |
505 | case X509_LU_X509: | |
506 | stmp.data.x509 = &x509_s; | |
8cc86b81 | 507 | x509_s.cert_info.subject = (X509_NAME *)name; /* won't modify it */ |
0f113f3e MC |
508 | break; |
509 | case X509_LU_CRL: | |
510 | stmp.data.crl = &crl_s; | |
8cc86b81 | 511 | crl_s.crl.issuer = (X509_NAME *)name; /* won't modify it */ |
0f113f3e | 512 | break; |
f3b3d7f0 | 513 | case X509_LU_NONE: |
0f113f3e MC |
514 | /* abort(); */ |
515 | return -1; | |
516 | } | |
517 | ||
518 | idx = sk_X509_OBJECT_find(h, &stmp); | |
519 | if (idx >= 0 && pnmatch) { | |
520 | int tidx; | |
521 | const X509_OBJECT *tobj, *pstmp; | |
522 | *pnmatch = 1; | |
523 | pstmp = &stmp; | |
524 | for (tidx = idx + 1; tidx < sk_X509_OBJECT_num(h); tidx++) { | |
525 | tobj = sk_X509_OBJECT_value(h, tidx); | |
526 | if (x509_object_cmp(&tobj, &pstmp)) | |
527 | break; | |
528 | (*pnmatch)++; | |
529 | } | |
530 | } | |
531 | return idx; | |
532 | } | |
4d50a2b4 | 533 | |
0946a198 | 534 | int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type, |
8cc86b81 | 535 | const X509_NAME *name) |
0f113f3e MC |
536 | { |
537 | return x509_object_idx_cnt(h, type, name, NULL); | |
538 | } | |
539 | ||
540 | X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h, | |
0946a198 | 541 | X509_LOOKUP_TYPE type, |
8cc86b81 | 542 | const X509_NAME *name) |
0f113f3e MC |
543 | { |
544 | int idx; | |
545 | idx = X509_OBJECT_idx_by_subject(h, type, name); | |
546 | if (idx == -1) | |
547 | return NULL; | |
548 | return sk_X509_OBJECT_value(h, idx); | |
549 | } | |
11262391 | 550 | |
8cc86b81 | 551 | STACK_OF(X509_OBJECT) *X509_STORE_get0_objects(const X509_STORE *v) |
f0c58c32 CH |
552 | { |
553 | return v->objs; | |
554 | } | |
555 | ||
8cc86b81 | 556 | /* TODO param type could be constified as change to lock is intermittent */ |
31b28ad9 DDO |
557 | STACK_OF(X509) *X509_STORE_get1_all_certs(X509_STORE *store) |
558 | { | |
559 | STACK_OF(X509) *sk; | |
560 | STACK_OF(X509_OBJECT) *objs; | |
561 | int i; | |
562 | ||
563 | if (store == NULL) { | |
9311d0c4 | 564 | ERR_raise(ERR_LIB_X509, ERR_R_PASSED_NULL_PARAMETER); |
31b28ad9 DDO |
565 | return NULL; |
566 | } | |
567 | if ((sk = sk_X509_new_null()) == NULL) | |
568 | return NULL; | |
569 | X509_STORE_lock(store); | |
570 | objs = X509_STORE_get0_objects(store); | |
571 | for (i = 0; i < sk_X509_OBJECT_num(objs); i++) { | |
572 | X509 *cert = X509_OBJECT_get0_X509(sk_X509_OBJECT_value(objs, i)); | |
573 | ||
eeccc237 DDO |
574 | if (cert != NULL |
575 | && !X509_add_cert(sk, cert, X509_ADD_FLAG_UP_REF)) | |
576 | goto err; | |
31b28ad9 DDO |
577 | } |
578 | X509_STORE_unlock(store); | |
579 | return sk; | |
580 | ||
581 | err: | |
582 | X509_STORE_unlock(store); | |
583 | sk_X509_pop_free(sk, X509_free); | |
584 | return NULL; | |
585 | } | |
586 | ||
8cc86b81 DDO |
587 | STACK_OF(X509) *X509_STORE_CTX_get1_certs(X509_STORE_CTX *ctx, |
588 | const X509_NAME *nm) | |
0f113f3e MC |
589 | { |
590 | int i, idx, cnt; | |
6ddbb4cd | 591 | STACK_OF(X509) *sk = NULL; |
0f113f3e MC |
592 | X509 *x; |
593 | X509_OBJECT *obj; | |
faa9dcd4 | 594 | X509_STORE *store = ctx->store; |
6ddbb4cd | 595 | |
7a9abccd | 596 | if (store == NULL) |
1c705121 MC |
597 | return NULL; |
598 | ||
7a9abccd SL |
599 | X509_STORE_lock(store); |
600 | idx = x509_object_idx_cnt(store->objs, X509_LU_X509, nm, &cnt); | |
0f113f3e MC |
601 | if (idx < 0) { |
602 | /* | |
603 | * Nothing found in cache: do lookup to possibly add new objects to | |
604 | * cache | |
605 | */ | |
6ddbb4cd RS |
606 | X509_OBJECT *xobj = X509_OBJECT_new(); |
607 | ||
7a9abccd SL |
608 | X509_STORE_unlock(store); |
609 | ||
6ddbb4cd RS |
610 | if (xobj == NULL) |
611 | return NULL; | |
612 | if (!X509_STORE_CTX_get_by_subject(ctx, X509_LU_X509, nm, xobj)) { | |
613 | X509_OBJECT_free(xobj); | |
0f113f3e MC |
614 | return NULL; |
615 | } | |
6ddbb4cd | 616 | X509_OBJECT_free(xobj); |
7a9abccd SL |
617 | X509_STORE_lock(store); |
618 | idx = x509_object_idx_cnt(store->objs, X509_LU_X509, nm, &cnt); | |
0f113f3e | 619 | if (idx < 0) { |
7a9abccd | 620 | X509_STORE_unlock(store); |
0f113f3e MC |
621 | return NULL; |
622 | } | |
623 | } | |
6ddbb4cd RS |
624 | |
625 | sk = sk_X509_new_null(); | |
0f113f3e | 626 | for (i = 0; i < cnt; i++, idx++) { |
7a9abccd | 627 | obj = sk_X509_OBJECT_value(store->objs, idx); |
0f113f3e | 628 | x = obj->data.x509; |
eeccc237 | 629 | if (!X509_add_cert(sk, x, X509_ADD_FLAG_UP_REF)) { |
7a9abccd | 630 | X509_STORE_unlock(store); |
0f113f3e MC |
631 | sk_X509_pop_free(sk, X509_free); |
632 | return NULL; | |
633 | } | |
634 | } | |
7a9abccd | 635 | X509_STORE_unlock(store); |
0f113f3e | 636 | return sk; |
0f113f3e | 637 | } |
4d50a2b4 | 638 | |
8cc86b81 DDO |
639 | STACK_OF(X509_CRL) *X509_STORE_CTX_get1_crls(const X509_STORE_CTX *ctx, |
640 | const X509_NAME *nm) | |
0f113f3e MC |
641 | { |
642 | int i, idx, cnt; | |
6ddbb4cd | 643 | STACK_OF(X509_CRL) *sk = sk_X509_CRL_new_null(); |
0f113f3e | 644 | X509_CRL *x; |
6ddbb4cd | 645 | X509_OBJECT *obj, *xobj = X509_OBJECT_new(); |
faa9dcd4 | 646 | X509_STORE *store = ctx->store; |
0f113f3e | 647 | |
6ddbb4cd | 648 | /* Always do lookup to possibly add new CRLs to cache */ |
1c705121 MC |
649 | if (sk == NULL |
650 | || xobj == NULL | |
7a9abccd | 651 | || store == NULL |
1c705121 | 652 | || !X509_STORE_CTX_get_by_subject(ctx, X509_LU_CRL, nm, xobj)) { |
6ddbb4cd | 653 | X509_OBJECT_free(xobj); |
0f113f3e MC |
654 | sk_X509_CRL_free(sk); |
655 | return NULL; | |
656 | } | |
6ddbb4cd | 657 | X509_OBJECT_free(xobj); |
7a9abccd SL |
658 | X509_STORE_lock(store); |
659 | idx = x509_object_idx_cnt(store->objs, X509_LU_CRL, nm, &cnt); | |
0f113f3e | 660 | if (idx < 0) { |
7a9abccd | 661 | X509_STORE_unlock(store); |
0f113f3e MC |
662 | sk_X509_CRL_free(sk); |
663 | return NULL; | |
664 | } | |
665 | ||
666 | for (i = 0; i < cnt; i++, idx++) { | |
7a9abccd | 667 | obj = sk_X509_OBJECT_value(store->objs, idx); |
0f113f3e | 668 | x = obj->data.crl; |
c70e2ec3 BE |
669 | if (!X509_CRL_up_ref(x)) { |
670 | X509_STORE_unlock(store); | |
671 | sk_X509_CRL_pop_free(sk, X509_CRL_free); | |
672 | return NULL; | |
673 | } | |
0f113f3e | 674 | if (!sk_X509_CRL_push(sk, x)) { |
7a9abccd | 675 | X509_STORE_unlock(store); |
0f113f3e MC |
676 | X509_CRL_free(x); |
677 | sk_X509_CRL_pop_free(sk, X509_CRL_free); | |
678 | return NULL; | |
679 | } | |
680 | } | |
7a9abccd | 681 | X509_STORE_unlock(store); |
0f113f3e MC |
682 | return sk; |
683 | } | |
684 | ||
685 | X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, | |
686 | X509_OBJECT *x) | |
687 | { | |
5b37fef0 | 688 | int idx, i, num; |
0f113f3e | 689 | X509_OBJECT *obj; |
5b37fef0 | 690 | |
0f113f3e | 691 | idx = sk_X509_OBJECT_find(h, x); |
5b37fef0 | 692 | if (idx < 0) |
0f113f3e MC |
693 | return NULL; |
694 | if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL)) | |
695 | return sk_X509_OBJECT_value(h, idx); | |
5b37fef0 | 696 | for (i = idx, num = sk_X509_OBJECT_num(h); i < num; i++) { |
0f113f3e | 697 | obj = sk_X509_OBJECT_value(h, i); |
5b37fef0 AP |
698 | if (x509_object_cmp((const X509_OBJECT **)&obj, |
699 | (const X509_OBJECT **)&x)) | |
0f113f3e MC |
700 | return NULL; |
701 | if (x->type == X509_LU_X509) { | |
702 | if (!X509_cmp(obj->data.x509, x->data.x509)) | |
703 | return obj; | |
704 | } else if (x->type == X509_LU_CRL) { | |
f2a04587 | 705 | if (X509_CRL_match(obj->data.crl, x->data.crl) == 0) |
0f113f3e MC |
706 | return obj; |
707 | } else | |
708 | return obj; | |
709 | } | |
710 | return NULL; | |
711 | } | |
d02b48c6 | 712 | |
1d97c843 TH |
713 | /*- |
714 | * Try to get issuer certificate from store. Due to limitations | |
2f043896 DSH |
715 | * of the API this can only retrieve a single certificate matching |
716 | * a given subject name. However it will fill the cache with all | |
a8397553 | 717 | * matching certificates, so we can examine the cache for all |
2f043896 DSH |
718 | * matches. |
719 | * | |
720 | * Return values are: | |
721 | * 1 lookup successful. | |
722 | * 0 certificate not found. | |
723 | * -1 some other error. | |
724 | */ | |
2f043896 | 725 | int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x) |
0f113f3e | 726 | { |
8cc86b81 | 727 | const X509_NAME *xn; |
6ddbb4cd | 728 | X509_OBJECT *obj = X509_OBJECT_new(), *pobj = NULL; |
faa9dcd4 | 729 | X509_STORE *store = ctx->store; |
0f113f3e | 730 | int i, ok, idx, ret; |
f0e0fd51 | 731 | |
6ddbb4cd RS |
732 | if (obj == NULL) |
733 | return -1; | |
0f113f3e MC |
734 | *issuer = NULL; |
735 | xn = X509_get_issuer_name(x); | |
6ddbb4cd | 736 | ok = X509_STORE_CTX_get_by_subject(ctx, X509_LU_X509, xn, obj); |
ba1a1c37 | 737 | if (ok != 1) { |
6ddbb4cd | 738 | X509_OBJECT_free(obj); |
0f113f3e MC |
739 | return 0; |
740 | } | |
741 | /* If certificate matches all OK */ | |
6ddbb4cd RS |
742 | if (ctx->check_issued(ctx, x, obj->data.x509)) { |
743 | if (x509_check_cert_time(ctx, obj->data.x509, -1)) { | |
744 | *issuer = obj->data.x509; | |
c70e2ec3 BE |
745 | if (!X509_up_ref(*issuer)) { |
746 | *issuer = NULL; | |
747 | ok = -1; | |
748 | } | |
6ddbb4cd | 749 | X509_OBJECT_free(obj); |
c70e2ec3 | 750 | return ok; |
0f113f3e MC |
751 | } |
752 | } | |
6ddbb4cd | 753 | X509_OBJECT_free(obj); |
0f113f3e | 754 | |
7a9abccd | 755 | if (store == NULL) |
1c705121 MC |
756 | return 0; |
757 | ||
0f113f3e MC |
758 | /* Else find index of first cert accepted by 'check_issued' */ |
759 | ret = 0; | |
7a9abccd SL |
760 | X509_STORE_lock(store); |
761 | idx = X509_OBJECT_idx_by_subject(store->objs, X509_LU_X509, xn); | |
0f113f3e MC |
762 | if (idx != -1) { /* should be true as we've had at least one |
763 | * match */ | |
764 | /* Look through all matching certs for suitable issuer */ | |
7a9abccd SL |
765 | for (i = idx; i < sk_X509_OBJECT_num(store->objs); i++) { |
766 | pobj = sk_X509_OBJECT_value(store->objs, i); | |
0f113f3e MC |
767 | /* See if we've run past the matches */ |
768 | if (pobj->type != X509_LU_X509) | |
769 | break; | |
770 | if (X509_NAME_cmp(xn, X509_get_subject_name(pobj->data.x509))) | |
771 | break; | |
772 | if (ctx->check_issued(ctx, x, pobj->data.x509)) { | |
773 | *issuer = pobj->data.x509; | |
774 | ret = 1; | |
775 | /* | |
776 | * If times check, exit with match, | |
777 | * otherwise keep looking. Leave last | |
778 | * match in issuer so we return nearest | |
779 | * match if no certificate time is OK. | |
780 | */ | |
781 | ||
70dd3c65 | 782 | if (x509_check_cert_time(ctx, *issuer, -1)) |
0f113f3e MC |
783 | break; |
784 | } | |
785 | } | |
786 | } | |
c70e2ec3 BE |
787 | if (*issuer && !X509_up_ref(*issuer)) { |
788 | *issuer = NULL; | |
789 | ret = -1; | |
790 | } | |
7a9abccd | 791 | X509_STORE_unlock(store); |
0f113f3e MC |
792 | return ret; |
793 | } | |
d02b48c6 | 794 | |
5d7c222d | 795 | int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags) |
0f113f3e MC |
796 | { |
797 | return X509_VERIFY_PARAM_set_flags(ctx->param, flags); | |
798 | } | |
5d7c222d DSH |
799 | |
800 | int X509_STORE_set_depth(X509_STORE *ctx, int depth) | |
0f113f3e MC |
801 | { |
802 | X509_VERIFY_PARAM_set_depth(ctx->param, depth); | |
803 | return 1; | |
804 | } | |
bdee69f7 | 805 | |
926a56bf | 806 | int X509_STORE_set_purpose(X509_STORE *ctx, int purpose) |
0f113f3e MC |
807 | { |
808 | return X509_VERIFY_PARAM_set_purpose(ctx->param, purpose); | |
809 | } | |
926a56bf DSH |
810 | |
811 | int X509_STORE_set_trust(X509_STORE *ctx, int trust) | |
0f113f3e MC |
812 | { |
813 | return X509_VERIFY_PARAM_set_trust(ctx->param, trust); | |
814 | } | |
5d7c222d | 815 | |
8cc86b81 | 816 | int X509_STORE_set1_param(X509_STORE *ctx, const X509_VERIFY_PARAM *param) |
0f113f3e MC |
817 | { |
818 | return X509_VERIFY_PARAM_set1(ctx->param, param); | |
819 | } | |
926a56bf | 820 | |
8cc86b81 | 821 | X509_VERIFY_PARAM *X509_STORE_get0_param(const X509_STORE *ctx) |
f0c58c32 CH |
822 | { |
823 | return ctx->param; | |
824 | } | |
825 | ||
1060a50b RL |
826 | void X509_STORE_set_verify(X509_STORE *ctx, X509_STORE_CTX_verify_fn verify) |
827 | { | |
828 | ctx->verify = verify; | |
829 | } | |
830 | ||
8cc86b81 | 831 | X509_STORE_CTX_verify_fn X509_STORE_get_verify(const X509_STORE *ctx) |
1060a50b RL |
832 | { |
833 | return ctx->verify; | |
834 | } | |
835 | ||
a5b37fca | 836 | void X509_STORE_set_verify_cb(X509_STORE *ctx, |
1060a50b | 837 | X509_STORE_CTX_verify_cb verify_cb) |
0f113f3e MC |
838 | { |
839 | ctx->verify_cb = verify_cb; | |
840 | } | |
a5b37fca | 841 | |
8cc86b81 | 842 | X509_STORE_CTX_verify_cb X509_STORE_get_verify_cb(const X509_STORE *ctx) |
7cafbb4b | 843 | { |
1060a50b RL |
844 | return ctx->verify_cb; |
845 | } | |
846 | ||
847 | void X509_STORE_set_get_issuer(X509_STORE *ctx, | |
848 | X509_STORE_CTX_get_issuer_fn get_issuer) | |
849 | { | |
850 | ctx->get_issuer = get_issuer; | |
851 | } | |
852 | ||
8cc86b81 | 853 | X509_STORE_CTX_get_issuer_fn X509_STORE_get_get_issuer(const X509_STORE *ctx) |
1060a50b RL |
854 | { |
855 | return ctx->get_issuer; | |
856 | } | |
857 | ||
858 | void X509_STORE_set_check_issued(X509_STORE *ctx, | |
859 | X509_STORE_CTX_check_issued_fn check_issued) | |
860 | { | |
861 | ctx->check_issued = check_issued; | |
862 | } | |
863 | ||
8cc86b81 | 864 | X509_STORE_CTX_check_issued_fn X509_STORE_get_check_issued(const X509_STORE *ctx) |
1060a50b RL |
865 | { |
866 | return ctx->check_issued; | |
867 | } | |
868 | ||
869 | void X509_STORE_set_check_revocation(X509_STORE *ctx, | |
870 | X509_STORE_CTX_check_revocation_fn check_revocation) | |
871 | { | |
872 | ctx->check_revocation = check_revocation; | |
873 | } | |
874 | ||
8cc86b81 | 875 | X509_STORE_CTX_check_revocation_fn X509_STORE_get_check_revocation(const X509_STORE *ctx) |
1060a50b RL |
876 | { |
877 | return ctx->check_revocation; | |
878 | } | |
879 | ||
880 | void X509_STORE_set_get_crl(X509_STORE *ctx, | |
881 | X509_STORE_CTX_get_crl_fn get_crl) | |
882 | { | |
883 | ctx->get_crl = get_crl; | |
884 | } | |
885 | ||
8cc86b81 | 886 | X509_STORE_CTX_get_crl_fn X509_STORE_get_get_crl(const X509_STORE *ctx) |
1060a50b RL |
887 | { |
888 | return ctx->get_crl; | |
889 | } | |
890 | ||
891 | void X509_STORE_set_check_crl(X509_STORE *ctx, | |
892 | X509_STORE_CTX_check_crl_fn check_crl) | |
893 | { | |
894 | ctx->check_crl = check_crl; | |
895 | } | |
896 | ||
8cc86b81 | 897 | X509_STORE_CTX_check_crl_fn X509_STORE_get_check_crl(const X509_STORE *ctx) |
1060a50b RL |
898 | { |
899 | return ctx->check_crl; | |
900 | } | |
901 | ||
902 | void X509_STORE_set_cert_crl(X509_STORE *ctx, | |
903 | X509_STORE_CTX_cert_crl_fn cert_crl) | |
904 | { | |
905 | ctx->cert_crl = cert_crl; | |
906 | } | |
907 | ||
8cc86b81 | 908 | X509_STORE_CTX_cert_crl_fn X509_STORE_get_cert_crl(const X509_STORE *ctx) |
1060a50b RL |
909 | { |
910 | return ctx->cert_crl; | |
911 | } | |
912 | ||
0a5fe2eb RL |
913 | void X509_STORE_set_check_policy(X509_STORE *ctx, |
914 | X509_STORE_CTX_check_policy_fn check_policy) | |
915 | { | |
916 | ctx->check_policy = check_policy; | |
917 | } | |
918 | ||
8cc86b81 | 919 | X509_STORE_CTX_check_policy_fn X509_STORE_get_check_policy(const X509_STORE *ctx) |
0a5fe2eb RL |
920 | { |
921 | return ctx->check_policy; | |
922 | } | |
923 | ||
1060a50b RL |
924 | void X509_STORE_set_lookup_certs(X509_STORE *ctx, |
925 | X509_STORE_CTX_lookup_certs_fn lookup_certs) | |
926 | { | |
927 | ctx->lookup_certs = lookup_certs; | |
928 | } | |
929 | ||
8cc86b81 | 930 | X509_STORE_CTX_lookup_certs_fn X509_STORE_get_lookup_certs(const X509_STORE *ctx) |
1060a50b RL |
931 | { |
932 | return ctx->lookup_certs; | |
933 | } | |
934 | ||
935 | void X509_STORE_set_lookup_crls(X509_STORE *ctx, | |
936 | X509_STORE_CTX_lookup_crls_fn lookup_crls) | |
937 | { | |
938 | ctx->lookup_crls = lookup_crls; | |
939 | } | |
940 | ||
8cc86b81 | 941 | X509_STORE_CTX_lookup_crls_fn X509_STORE_get_lookup_crls(const X509_STORE *ctx) |
1060a50b RL |
942 | { |
943 | return ctx->lookup_crls; | |
944 | } | |
945 | ||
946 | void X509_STORE_set_cleanup(X509_STORE *ctx, | |
947 | X509_STORE_CTX_cleanup_fn ctx_cleanup) | |
948 | { | |
949 | ctx->cleanup = ctx_cleanup; | |
7cafbb4b MC |
950 | } |
951 | ||
8cc86b81 | 952 | X509_STORE_CTX_cleanup_fn X509_STORE_get_cleanup(const X509_STORE *ctx) |
0f113f3e | 953 | { |
1060a50b | 954 | return ctx->cleanup; |
0f113f3e | 955 | } |
2c340864 | 956 | |
3aec886e KY |
957 | int X509_STORE_set_ex_data(X509_STORE *ctx, int idx, void *data) |
958 | { | |
959 | return CRYPTO_set_ex_data(&ctx->ex_data, idx, data); | |
960 | } | |
961 | ||
8cc86b81 | 962 | void *X509_STORE_get_ex_data(const X509_STORE *ctx, int idx) |
3aec886e KY |
963 | { |
964 | return CRYPTO_get_ex_data(&ctx->ex_data, idx); | |
965 | } | |
966 | ||
8cc86b81 | 967 | X509_STORE *X509_STORE_CTX_get0_store(const X509_STORE_CTX *ctx) |
0f113f3e | 968 | { |
faa9dcd4 | 969 | return ctx->store; |
0f113f3e | 970 | } |