]>
Commit | Line | Data |
---|---|---|
0124f32a MY |
1 | /* |
2 | * Copyright 2018 The OpenSSL Project Authors. All Rights Reserved. | |
3 | * | |
3e4b43b9 | 4 | * Licensed under the Apache License 2.0 (the "License"). You may not use |
0124f32a MY |
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 | |
8 | */ | |
9 | ||
10 | #include <stdio.h> | |
11 | #include <time.h> | |
12 | #include <errno.h> | |
13 | ||
14 | #include "internal/cryptlib.h" | |
15 | #include <openssl/asn1.h> | |
16 | #include <openssl/x509.h> | |
17 | #include <openssl/ossl_typ.h> | |
18 | #include "x509_lcl.h" | |
19 | ||
20 | X509_LOOKUP_METHOD *X509_LOOKUP_meth_new(const char *name) | |
21 | { | |
22 | X509_LOOKUP_METHOD *method = OPENSSL_zalloc(sizeof(X509_LOOKUP_METHOD)); | |
23 | ||
24 | if (method != NULL) { | |
25 | method->name = OPENSSL_strdup(name); | |
26 | if (method->name == NULL) { | |
27 | X509err(X509_F_X509_LOOKUP_METH_NEW, ERR_R_MALLOC_FAILURE); | |
28 | goto err; | |
29 | } | |
30 | } | |
31 | ||
32 | return method; | |
33 | ||
34 | err: | |
35 | OPENSSL_free(method); | |
36 | return NULL; | |
37 | } | |
38 | ||
39 | void X509_LOOKUP_meth_free(X509_LOOKUP_METHOD *method) | |
40 | { | |
41 | if (method != NULL) | |
42 | OPENSSL_free(method->name); | |
43 | OPENSSL_free(method); | |
44 | } | |
45 | ||
46 | int X509_LOOKUP_meth_set_new_item(X509_LOOKUP_METHOD *method, | |
47 | int (*new_item) (X509_LOOKUP *ctx)) | |
48 | { | |
49 | method->new_item = new_item; | |
50 | return 1; | |
51 | } | |
52 | ||
53 | int (*X509_LOOKUP_meth_get_new_item(const X509_LOOKUP_METHOD* method)) | |
54 | (X509_LOOKUP *ctx) | |
55 | { | |
56 | return method->new_item; | |
57 | } | |
58 | ||
59 | int X509_LOOKUP_meth_set_free( | |
60 | X509_LOOKUP_METHOD *method, | |
50f3994b | 61 | void (*free_fn) (X509_LOOKUP *ctx)) |
0124f32a | 62 | { |
50f3994b | 63 | method->free = free_fn; |
0124f32a MY |
64 | return 1; |
65 | } | |
66 | ||
67 | void (*X509_LOOKUP_meth_get_free(const X509_LOOKUP_METHOD* method)) | |
68 | (X509_LOOKUP *ctx) | |
69 | { | |
70 | return method->free; | |
71 | } | |
72 | ||
73 | int X509_LOOKUP_meth_set_init(X509_LOOKUP_METHOD *method, | |
74 | int (*init) (X509_LOOKUP *ctx)) | |
75 | { | |
76 | method->init = init; | |
77 | return 1; | |
78 | } | |
79 | ||
80 | int (*X509_LOOKUP_meth_get_init(const X509_LOOKUP_METHOD* method)) | |
81 | (X509_LOOKUP *ctx) | |
82 | { | |
83 | return method->init; | |
84 | } | |
85 | ||
86 | int X509_LOOKUP_meth_set_shutdown( | |
87 | X509_LOOKUP_METHOD *method, | |
88 | int (*shutdown) (X509_LOOKUP *ctx)) | |
89 | { | |
90 | method->shutdown = shutdown; | |
91 | return 1; | |
92 | } | |
93 | ||
94 | int (*X509_LOOKUP_meth_get_shutdown(const X509_LOOKUP_METHOD* method)) | |
95 | (X509_LOOKUP *ctx) | |
96 | { | |
97 | return method->shutdown; | |
98 | } | |
99 | ||
100 | int X509_LOOKUP_meth_set_ctrl( | |
101 | X509_LOOKUP_METHOD *method, | |
102 | X509_LOOKUP_ctrl_fn ctrl) | |
103 | { | |
104 | method->ctrl = ctrl; | |
105 | return 1; | |
106 | } | |
107 | ||
108 | X509_LOOKUP_ctrl_fn X509_LOOKUP_meth_get_ctrl(const X509_LOOKUP_METHOD *method) | |
109 | { | |
110 | return method->ctrl; | |
111 | } | |
112 | ||
113 | int X509_LOOKUP_meth_set_get_by_subject(X509_LOOKUP_METHOD *method, | |
114 | X509_LOOKUP_get_by_subject_fn get_by_subject) | |
115 | { | |
116 | method->get_by_subject = get_by_subject; | |
117 | return 1; | |
118 | } | |
119 | ||
120 | X509_LOOKUP_get_by_subject_fn X509_LOOKUP_meth_get_get_by_subject( | |
121 | const X509_LOOKUP_METHOD *method) | |
122 | { | |
123 | return method->get_by_subject; | |
124 | } | |
125 | ||
126 | ||
127 | int X509_LOOKUP_meth_set_get_by_issuer_serial(X509_LOOKUP_METHOD *method, | |
128 | X509_LOOKUP_get_by_issuer_serial_fn get_by_issuer_serial) | |
129 | { | |
130 | method->get_by_issuer_serial = get_by_issuer_serial; | |
131 | return 1; | |
132 | } | |
133 | ||
134 | X509_LOOKUP_get_by_issuer_serial_fn | |
135 | X509_LOOKUP_meth_get_get_by_issuer_serial(const X509_LOOKUP_METHOD *method) | |
136 | { | |
137 | return method->get_by_issuer_serial; | |
138 | } | |
139 | ||
140 | ||
141 | int X509_LOOKUP_meth_set_get_by_fingerprint(X509_LOOKUP_METHOD *method, | |
142 | X509_LOOKUP_get_by_fingerprint_fn get_by_fingerprint) | |
143 | { | |
144 | method->get_by_fingerprint = get_by_fingerprint; | |
145 | return 1; | |
146 | } | |
147 | ||
148 | X509_LOOKUP_get_by_fingerprint_fn X509_LOOKUP_meth_get_get_by_fingerprint( | |
149 | const X509_LOOKUP_METHOD *method) | |
150 | { | |
151 | return method->get_by_fingerprint; | |
152 | } | |
153 | ||
154 | int X509_LOOKUP_meth_set_get_by_alias(X509_LOOKUP_METHOD *method, | |
155 | X509_LOOKUP_get_by_alias_fn get_by_alias) | |
156 | { | |
157 | method->get_by_alias = get_by_alias; | |
158 | return 1; | |
159 | } | |
160 | ||
161 | X509_LOOKUP_get_by_alias_fn X509_LOOKUP_meth_get_get_by_alias( | |
162 | const X509_LOOKUP_METHOD *method) | |
163 | { | |
164 | return method->get_by_alias; | |
165 | } | |
166 |