diff options
author | jsing <> | 2014-05-26 11:24:48 +0000 |
---|---|---|
committer | jsing <> | 2014-05-26 11:24:48 +0000 |
commit | 1918fecccdef550d51f6267a095575731f873b2b (patch) | |
tree | f3df1497c7d3c4533bdb1a09664b32b2c989b047 /src/lib/libcrypto/store/str_lib.c | |
parent | 8ba2fea129dbe500a291768b0aec33a3fd015669 (diff) | |
download | openbsd-1918fecccdef550d51f6267a095575731f873b2b.tar.gz openbsd-1918fecccdef550d51f6267a095575731f873b2b.tar.bz2 openbsd-1918fecccdef550d51f6267a095575731f873b2b.zip |
KNF.
Diffstat (limited to 'src/lib/libcrypto/store/str_lib.c')
-rw-r--r-- | src/lib/libcrypto/store/str_lib.c | 1946 |
1 files changed, 992 insertions, 954 deletions
diff --git a/src/lib/libcrypto/store/str_lib.c b/src/lib/libcrypto/store/str_lib.c index 197f19e769..f9beab2952 100644 --- a/src/lib/libcrypto/store/str_lib.c +++ b/src/lib/libcrypto/store/str_lib.c | |||
@@ -10,7 +10,7 @@ | |||
10 | * are met: | 10 | * are met: |
11 | * | 11 | * |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * | 14 | * |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
@@ -66,8 +66,7 @@ | |||
66 | #include <openssl/x509.h> | 66 | #include <openssl/x509.h> |
67 | #include "str_locl.h" | 67 | #include "str_locl.h" |
68 | 68 | ||
69 | const char * const STORE_object_type_string[STORE_OBJECT_TYPE_NUM+1] = | 69 | const char * const STORE_object_type_string[STORE_OBJECT_TYPE_NUM + 1] = { |
70 | { | ||
71 | 0, | 70 | 0, |
72 | "X.509 Certificate", | 71 | "X.509 Certificate", |
73 | "X.509 CRL", | 72 | "X.509 CRL", |
@@ -75,19 +74,17 @@ const char * const STORE_object_type_string[STORE_OBJECT_TYPE_NUM+1] = | |||
75 | "Public Key", | 74 | "Public Key", |
76 | "Number", | 75 | "Number", |
77 | "Arbitrary Data" | 76 | "Arbitrary Data" |
78 | }; | 77 | }; |
79 | 78 | ||
80 | const int STORE_param_sizes[STORE_PARAM_TYPE_NUM+1] = | 79 | const int STORE_param_sizes[STORE_PARAM_TYPE_NUM + 1] = { |
81 | { | ||
82 | 0, | 80 | 0, |
83 | sizeof(int), /* EVP_TYPE */ | 81 | sizeof(int), /* EVP_TYPE */ |
84 | sizeof(size_t), /* BITS */ | 82 | sizeof(size_t), /* BITS */ |
85 | -1, /* KEY_PARAMETERS */ | 83 | -1, /* KEY_PARAMETERS */ |
86 | 0 /* KEY_NO_PARAMETERS */ | 84 | 0 /* KEY_NO_PARAMETERS */ |
87 | }; | 85 | }; |
88 | 86 | ||
89 | const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM+1] = | 87 | const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM + 1] = { |
90 | { | ||
91 | 0, | 88 | 0, |
92 | -1, /* FRIENDLYNAME: C string */ | 89 | -1, /* FRIENDLYNAME: C string */ |
93 | SHA_DIGEST_LENGTH, /* KEYID: SHA1 digest, 160 bits */ | 90 | SHA_DIGEST_LENGTH, /* KEYID: SHA1 digest, 160 bits */ |
@@ -100,38 +97,37 @@ const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM+1] = | |||
100 | SHA_DIGEST_LENGTH, /* CERTHASH: SHA1 digest, 160 bits */ | 97 | SHA_DIGEST_LENGTH, /* CERTHASH: SHA1 digest, 160 bits */ |
101 | -1, /* EMAIL: C string */ | 98 | -1, /* EMAIL: C string */ |
102 | -1, /* FILENAME: C string */ | 99 | -1, /* FILENAME: C string */ |
103 | }; | 100 | }; |
104 | 101 | ||
105 | STORE *STORE_new_method(const STORE_METHOD *method) | 102 | STORE * |
106 | { | 103 | STORE_new_method(const STORE_METHOD *method) |
104 | { | ||
107 | STORE *ret; | 105 | STORE *ret; |
108 | 106 | ||
109 | if (method == NULL) | 107 | if (method == NULL) { |
110 | { | 108 | STOREerr(STORE_F_STORE_NEW_METHOD, ERR_R_PASSED_NULL_PARAMETER); |
111 | STOREerr(STORE_F_STORE_NEW_METHOD,ERR_R_PASSED_NULL_PARAMETER); | ||
112 | return NULL; | 109 | return NULL; |
113 | } | 110 | } |
114 | 111 | ||
115 | ret=(STORE *)malloc(sizeof(STORE)); | 112 | ret = (STORE *)malloc(sizeof(STORE)); |
116 | if (ret == NULL) | 113 | if (ret == NULL) { |
117 | { | 114 | STOREerr(STORE_F_STORE_NEW_METHOD, ERR_R_MALLOC_FAILURE); |
118 | STOREerr(STORE_F_STORE_NEW_METHOD,ERR_R_MALLOC_FAILURE); | ||
119 | return NULL; | 115 | return NULL; |
120 | } | 116 | } |
121 | 117 | ||
122 | ret->meth=method; | 118 | ret->meth = method; |
123 | 119 | ||
124 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_STORE, ret, &ret->ex_data); | 120 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_STORE, ret, &ret->ex_data); |
125 | if (ret->meth->init && !ret->meth->init(ret)) | 121 | if (ret->meth->init && !ret->meth->init(ret)) { |
126 | { | ||
127 | STORE_free(ret); | 122 | STORE_free(ret); |
128 | ret = NULL; | 123 | ret = NULL; |
129 | } | ||
130 | return ret; | ||
131 | } | 124 | } |
125 | return ret; | ||
126 | } | ||
132 | 127 | ||
133 | STORE *STORE_new_engine(ENGINE *engine) | 128 | STORE * |
134 | { | 129 | STORE_new_engine(ENGINE *engine) |
130 | { | ||
135 | STORE *ret = NULL; | 131 | STORE *ret = NULL; |
136 | ENGINE *e = engine; | 132 | ENGINE *e = engine; |
137 | const STORE_METHOD *meth = 0; | 133 | const STORE_METHOD *meth = 0; |
@@ -139,96 +135,95 @@ STORE *STORE_new_engine(ENGINE *engine) | |||
139 | #ifdef OPENSSL_NO_ENGINE | 135 | #ifdef OPENSSL_NO_ENGINE |
140 | e = NULL; | 136 | e = NULL; |
141 | #else | 137 | #else |
142 | if (engine) | 138 | if (engine) { |
143 | { | 139 | if (!ENGINE_init(engine)) { |
144 | if (!ENGINE_init(engine)) | ||
145 | { | ||
146 | STOREerr(STORE_F_STORE_NEW_ENGINE, ERR_R_ENGINE_LIB); | 140 | STOREerr(STORE_F_STORE_NEW_ENGINE, ERR_R_ENGINE_LIB); |
147 | return NULL; | 141 | return NULL; |
148 | } | ||
149 | e = engine; | ||
150 | } | 142 | } |
151 | else | 143 | e = engine; |
152 | { | 144 | } else { |
153 | STOREerr(STORE_F_STORE_NEW_ENGINE,ERR_R_PASSED_NULL_PARAMETER); | 145 | STOREerr(STORE_F_STORE_NEW_ENGINE, ERR_R_PASSED_NULL_PARAMETER); |
154 | return NULL; | 146 | return NULL; |
155 | } | 147 | } |
156 | if(e) | 148 | if (e) { |
157 | { | ||
158 | meth = ENGINE_get_STORE(e); | 149 | meth = ENGINE_get_STORE(e); |
159 | if(!meth) | 150 | if (!meth) { |
160 | { | ||
161 | STOREerr(STORE_F_STORE_NEW_ENGINE, | 151 | STOREerr(STORE_F_STORE_NEW_ENGINE, |
162 | ERR_R_ENGINE_LIB); | 152 | ERR_R_ENGINE_LIB); |
163 | ENGINE_finish(e); | 153 | ENGINE_finish(e); |
164 | return NULL; | 154 | return NULL; |
165 | } | ||
166 | } | 155 | } |
156 | } | ||
167 | #endif | 157 | #endif |
168 | 158 | ||
169 | ret = STORE_new_method(meth); | 159 | ret = STORE_new_method(meth); |
170 | if (ret == NULL) | 160 | if (ret == NULL) { |
171 | { | 161 | STOREerr(STORE_F_STORE_NEW_ENGINE, ERR_R_STORE_LIB); |
172 | STOREerr(STORE_F_STORE_NEW_ENGINE,ERR_R_STORE_LIB); | ||
173 | return NULL; | 162 | return NULL; |
174 | } | 163 | } |
175 | 164 | ||
176 | ret->engine = e; | 165 | ret->engine = e; |
177 | 166 | ||
178 | return(ret); | 167 | return (ret); |
179 | } | 168 | } |
180 | 169 | ||
181 | void STORE_free(STORE *store) | 170 | void |
182 | { | 171 | STORE_free(STORE *store) |
172 | { | ||
183 | if (store == NULL) | 173 | if (store == NULL) |
184 | return; | 174 | return; |
185 | if (store->meth->clean) | 175 | if (store->meth->clean) |
186 | store->meth->clean(store); | 176 | store->meth->clean(store); |
187 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_STORE, store, &store->ex_data); | 177 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_STORE, store, &store->ex_data); |
188 | free(store); | 178 | free(store); |
189 | } | 179 | } |
190 | 180 | ||
191 | int STORE_ctrl(STORE *store, int cmd, long i, void *p, void (*f)(void)) | 181 | int |
192 | { | 182 | STORE_ctrl(STORE *store, int cmd, long i, void *p, void (*f)(void)) |
193 | if (store == NULL) | 183 | { |
194 | { | 184 | if (store == NULL) { |
195 | STOREerr(STORE_F_STORE_CTRL,ERR_R_PASSED_NULL_PARAMETER); | 185 | STOREerr(STORE_F_STORE_CTRL, ERR_R_PASSED_NULL_PARAMETER); |
196 | return 0; | 186 | return 0; |
197 | } | 187 | } |
198 | if (store->meth->ctrl) | 188 | if (store->meth->ctrl) |
199 | return store->meth->ctrl(store, cmd, i, p, f); | 189 | return store->meth->ctrl(store, cmd, i, p, f); |
200 | STOREerr(STORE_F_STORE_CTRL,STORE_R_NO_CONTROL_FUNCTION); | 190 | STOREerr(STORE_F_STORE_CTRL, STORE_R_NO_CONTROL_FUNCTION); |
201 | return 0; | 191 | return 0; |
202 | } | 192 | } |
203 | 193 | ||
204 | 194 | ||
205 | int STORE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, | 195 | int |
206 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) | 196 | STORE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, |
207 | { | 197 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) |
198 | { | ||
208 | return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_STORE, argl, argp, | 199 | return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_STORE, argl, argp, |
209 | new_func, dup_func, free_func); | 200 | new_func, dup_func, free_func); |
210 | } | 201 | } |
211 | 202 | ||
212 | int STORE_set_ex_data(STORE *r, int idx, void *arg) | 203 | int |
213 | { | 204 | STORE_set_ex_data(STORE *r, int idx, void *arg) |
214 | return(CRYPTO_set_ex_data(&r->ex_data,idx,arg)); | 205 | { |
215 | } | 206 | return (CRYPTO_set_ex_data(&r->ex_data, idx, arg)); |
216 | 207 | } | |
217 | void *STORE_get_ex_data(STORE *r, int idx) | 208 | |
218 | { | 209 | void * |
219 | return(CRYPTO_get_ex_data(&r->ex_data,idx)); | 210 | STORE_get_ex_data(STORE *r, int idx) |
220 | } | 211 | { |
221 | 212 | return (CRYPTO_get_ex_data(&r->ex_data, idx)); | |
222 | const STORE_METHOD *STORE_get_method(STORE *store) | 213 | } |
223 | { | 214 | |
215 | const STORE_METHOD * | ||
216 | STORE_get_method(STORE *store) | ||
217 | { | ||
224 | return store->meth; | 218 | return store->meth; |
225 | } | 219 | } |
226 | 220 | ||
227 | const STORE_METHOD *STORE_set_method(STORE *store, const STORE_METHOD *meth) | 221 | const STORE_METHOD * |
228 | { | 222 | STORE_set_method(STORE *store, const STORE_METHOD *meth) |
229 | store->meth=meth; | 223 | { |
224 | store->meth = meth; | ||
230 | return store->meth; | 225 | return store->meth; |
231 | } | 226 | } |
232 | 227 | ||
233 | 228 | ||
234 | /* API helpers */ | 229 | /* API helpers */ |
@@ -252,948 +247,946 @@ const STORE_METHOD *STORE_set_method(STORE *store, const STORE_METHOD *meth) | |||
252 | /* API functions */ | 247 | /* API functions */ |
253 | 248 | ||
254 | X509 *STORE_get_certificate(STORE *s, OPENSSL_ITEM attributes[], | 249 | X509 *STORE_get_certificate(STORE *s, OPENSSL_ITEM attributes[], |
255 | OPENSSL_ITEM parameters[]) | 250 | OPENSSL_ITEM parameters[]) |
256 | { | 251 | { |
257 | STORE_OBJECT *object; | 252 | STORE_OBJECT *object; |
258 | X509 *x; | 253 | X509 *x; |
259 | 254 | ||
260 | check_store(s,STORE_F_STORE_GET_CERTIFICATE, | 255 | check_store(s, STORE_F_STORE_GET_CERTIFICATE, |
261 | get_object,STORE_R_NO_GET_OBJECT_FUNCTION); | 256 | get_object, STORE_R_NO_GET_OBJECT_FUNCTION); |
262 | 257 | ||
263 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, | 258 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, |
264 | attributes, parameters); | 259 | attributes, parameters); |
265 | if (!object || !object->data.x509.certificate) | 260 | if (!object || !object->data.x509.certificate) { |
266 | { | ||
267 | STOREerr(STORE_F_STORE_GET_CERTIFICATE, | 261 | STOREerr(STORE_F_STORE_GET_CERTIFICATE, |
268 | STORE_R_FAILED_GETTING_CERTIFICATE); | 262 | STORE_R_FAILED_GETTING_CERTIFICATE); |
269 | return 0; | 263 | return 0; |
270 | } | 264 | } |
271 | CRYPTO_add(&object->data.x509.certificate->references,1,CRYPTO_LOCK_X509); | 265 | CRYPTO_add(&object->data.x509.certificate->references, |
266 | 1, CRYPTO_LOCK_X509); | ||
272 | x = object->data.x509.certificate; | 267 | x = object->data.x509.certificate; |
273 | STORE_OBJECT_free(object); | 268 | STORE_OBJECT_free(object); |
274 | return x; | 269 | return x; |
275 | } | 270 | } |
276 | 271 | ||
277 | int STORE_store_certificate(STORE *s, X509 *data, OPENSSL_ITEM attributes[], | 272 | int |
278 | OPENSSL_ITEM parameters[]) | 273 | STORE_store_certificate(STORE *s, X509 *data, OPENSSL_ITEM attributes[], |
279 | { | 274 | OPENSSL_ITEM parameters[]) |
275 | { | ||
280 | STORE_OBJECT *object; | 276 | STORE_OBJECT *object; |
281 | int i; | 277 | int i; |
282 | 278 | ||
283 | check_store(s,STORE_F_STORE_CERTIFICATE, | 279 | check_store(s, STORE_F_STORE_CERTIFICATE, |
284 | store_object,STORE_R_NO_STORE_OBJECT_FUNCTION); | 280 | store_object, STORE_R_NO_STORE_OBJECT_FUNCTION); |
285 | 281 | ||
286 | object = STORE_OBJECT_new(); | 282 | object = STORE_OBJECT_new(); |
287 | if (!object) | 283 | if (!object) { |
288 | { | ||
289 | STOREerr(STORE_F_STORE_STORE_CERTIFICATE, | 284 | STOREerr(STORE_F_STORE_STORE_CERTIFICATE, |
290 | ERR_R_MALLOC_FAILURE); | 285 | ERR_R_MALLOC_FAILURE); |
291 | return 0; | 286 | return 0; |
292 | } | 287 | } |
293 | 288 | ||
294 | CRYPTO_add(&data->references,1,CRYPTO_LOCK_X509); | 289 | CRYPTO_add(&data->references, 1, CRYPTO_LOCK_X509); |
295 | object->data.x509.certificate = data; | 290 | object->data.x509.certificate = data; |
296 | 291 | ||
297 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, | 292 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, |
298 | object, attributes, parameters); | 293 | object, attributes, parameters); |
299 | 294 | ||
300 | STORE_OBJECT_free(object); | 295 | STORE_OBJECT_free(object); |
301 | 296 | ||
302 | if (!i) | 297 | if (!i) { |
303 | { | ||
304 | STOREerr(STORE_F_STORE_STORE_CERTIFICATE, | 298 | STOREerr(STORE_F_STORE_STORE_CERTIFICATE, |
305 | STORE_R_FAILED_STORING_CERTIFICATE); | 299 | STORE_R_FAILED_STORING_CERTIFICATE); |
306 | return 0; | 300 | return 0; |
307 | } | ||
308 | return 1; | ||
309 | } | 301 | } |
302 | return 1; | ||
303 | } | ||
310 | 304 | ||
311 | int STORE_modify_certificate(STORE *s, OPENSSL_ITEM search_attributes[], | 305 | int |
312 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | 306 | STORE_modify_certificate(STORE *s, OPENSSL_ITEM search_attributes[], |
313 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) | 307 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], |
314 | { | 308 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) |
315 | check_store(s,STORE_F_STORE_MODIFY_CERTIFICATE, | 309 | { |
316 | modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION); | 310 | check_store(s, STORE_F_STORE_MODIFY_CERTIFICATE, |
311 | modify_object, STORE_R_NO_MODIFY_OBJECT_FUNCTION); | ||
317 | 312 | ||
318 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, | 313 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, |
319 | search_attributes, add_attributes, modify_attributes, | 314 | search_attributes, add_attributes, modify_attributes, |
320 | delete_attributes, parameters)) | 315 | delete_attributes, parameters)) { |
321 | { | ||
322 | STOREerr(STORE_F_STORE_MODIFY_CERTIFICATE, | 316 | STOREerr(STORE_F_STORE_MODIFY_CERTIFICATE, |
323 | STORE_R_FAILED_MODIFYING_CERTIFICATE); | 317 | STORE_R_FAILED_MODIFYING_CERTIFICATE); |
324 | return 0; | 318 | return 0; |
325 | } | ||
326 | return 1; | ||
327 | } | 319 | } |
320 | return 1; | ||
321 | } | ||
328 | 322 | ||
329 | int STORE_revoke_certificate(STORE *s, OPENSSL_ITEM attributes[], | 323 | int |
330 | OPENSSL_ITEM parameters[]) | 324 | STORE_revoke_certificate(STORE *s, OPENSSL_ITEM attributes[], |
331 | { | 325 | OPENSSL_ITEM parameters[]) |
332 | check_store(s,STORE_F_STORE_REVOKE_CERTIFICATE, | 326 | { |
333 | revoke_object,STORE_R_NO_REVOKE_OBJECT_FUNCTION); | 327 | check_store(s, STORE_F_STORE_REVOKE_CERTIFICATE, |
328 | revoke_object, STORE_R_NO_REVOKE_OBJECT_FUNCTION); | ||
334 | 329 | ||
335 | if (!s->meth->revoke_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, | 330 | if (!s->meth->revoke_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, |
336 | attributes, parameters)) | 331 | attributes, parameters)) { |
337 | { | ||
338 | STOREerr(STORE_F_STORE_REVOKE_CERTIFICATE, | 332 | STOREerr(STORE_F_STORE_REVOKE_CERTIFICATE, |
339 | STORE_R_FAILED_REVOKING_CERTIFICATE); | 333 | STORE_R_FAILED_REVOKING_CERTIFICATE); |
340 | return 0; | 334 | return 0; |
341 | } | ||
342 | return 1; | ||
343 | } | 335 | } |
336 | return 1; | ||
337 | } | ||
344 | 338 | ||
345 | int STORE_delete_certificate(STORE *s, OPENSSL_ITEM attributes[], | 339 | int |
346 | OPENSSL_ITEM parameters[]) | 340 | STORE_delete_certificate(STORE *s, OPENSSL_ITEM attributes[], |
347 | { | 341 | OPENSSL_ITEM parameters[]) |
348 | check_store(s,STORE_F_STORE_DELETE_CERTIFICATE, | 342 | { |
349 | delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION); | 343 | check_store(s, STORE_F_STORE_DELETE_CERTIFICATE, |
344 | delete_object, STORE_R_NO_DELETE_OBJECT_FUNCTION); | ||
350 | 345 | ||
351 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, | 346 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, |
352 | attributes, parameters)) | 347 | attributes, parameters)) { |
353 | { | ||
354 | STOREerr(STORE_F_STORE_DELETE_CERTIFICATE, | 348 | STOREerr(STORE_F_STORE_DELETE_CERTIFICATE, |
355 | STORE_R_FAILED_DELETING_CERTIFICATE); | 349 | STORE_R_FAILED_DELETING_CERTIFICATE); |
356 | return 0; | 350 | return 0; |
357 | } | ||
358 | return 1; | ||
359 | } | 351 | } |
352 | return 1; | ||
353 | } | ||
360 | 354 | ||
361 | void *STORE_list_certificate_start(STORE *s, OPENSSL_ITEM attributes[], | 355 | void * |
362 | OPENSSL_ITEM parameters[]) | 356 | STORE_list_certificate_start(STORE *s, OPENSSL_ITEM attributes[], |
363 | { | 357 | OPENSSL_ITEM parameters[]) |
358 | { | ||
364 | void *handle; | 359 | void *handle; |
365 | 360 | ||
366 | check_store(s,STORE_F_STORE_LIST_CERTIFICATE_START, | 361 | check_store(s, STORE_F_STORE_LIST_CERTIFICATE_START, |
367 | list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION); | 362 | list_object_start, STORE_R_NO_LIST_OBJECT_START_FUNCTION); |
368 | 363 | ||
369 | handle = s->meth->list_object_start(s, | 364 | handle = s->meth->list_object_start(s, |
370 | STORE_OBJECT_TYPE_X509_CERTIFICATE, attributes, parameters); | 365 | STORE_OBJECT_TYPE_X509_CERTIFICATE, attributes, parameters); |
371 | if (!handle) | 366 | if (!handle) { |
372 | { | ||
373 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_START, | 367 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_START, |
374 | STORE_R_FAILED_LISTING_CERTIFICATES); | 368 | STORE_R_FAILED_LISTING_CERTIFICATES); |
375 | return 0; | 369 | return 0; |
376 | } | ||
377 | return handle; | ||
378 | } | 370 | } |
371 | return handle; | ||
372 | } | ||
379 | 373 | ||
380 | X509 *STORE_list_certificate_next(STORE *s, void *handle) | 374 | X509 * |
381 | { | 375 | STORE_list_certificate_next(STORE *s, void *handle) |
376 | { | ||
382 | STORE_OBJECT *object; | 377 | STORE_OBJECT *object; |
383 | X509 *x; | 378 | X509 *x; |
384 | 379 | ||
385 | check_store(s,STORE_F_STORE_LIST_CERTIFICATE_NEXT, | 380 | check_store(s, STORE_F_STORE_LIST_CERTIFICATE_NEXT, |
386 | list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); | 381 | list_object_next, STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); |
387 | 382 | ||
388 | object = s->meth->list_object_next(s, handle); | 383 | object = s->meth->list_object_next(s, handle); |
389 | if (!object || !object->data.x509.certificate) | 384 | if (!object || !object->data.x509.certificate) { |
390 | { | ||
391 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_NEXT, | 385 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_NEXT, |
392 | STORE_R_FAILED_LISTING_CERTIFICATES); | 386 | STORE_R_FAILED_LISTING_CERTIFICATES); |
393 | return 0; | 387 | return 0; |
394 | } | 388 | } |
395 | CRYPTO_add(&object->data.x509.certificate->references,1,CRYPTO_LOCK_X509); | 389 | CRYPTO_add(&object->data.x509.certificate->references, |
390 | 1, CRYPTO_LOCK_X509); | ||
396 | x = object->data.x509.certificate; | 391 | x = object->data.x509.certificate; |
397 | STORE_OBJECT_free(object); | 392 | STORE_OBJECT_free(object); |
398 | return x; | 393 | return x; |
399 | } | 394 | } |
400 | 395 | ||
401 | int STORE_list_certificate_end(STORE *s, void *handle) | 396 | int |
402 | { | 397 | STORE_list_certificate_end(STORE *s, void *handle) |
403 | check_store(s,STORE_F_STORE_LIST_CERTIFICATE_END, | 398 | { |
404 | list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION); | 399 | check_store(s, STORE_F_STORE_LIST_CERTIFICATE_END, |
400 | list_object_end, STORE_R_NO_LIST_OBJECT_END_FUNCTION); | ||
405 | 401 | ||
406 | if (!s->meth->list_object_end(s, handle)) | 402 | if (!s->meth->list_object_end(s, handle)) { |
407 | { | ||
408 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_END, | 403 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_END, |
409 | STORE_R_FAILED_LISTING_CERTIFICATES); | 404 | STORE_R_FAILED_LISTING_CERTIFICATES); |
410 | return 0; | 405 | return 0; |
411 | } | ||
412 | return 1; | ||
413 | } | 406 | } |
407 | return 1; | ||
408 | } | ||
414 | 409 | ||
415 | int STORE_list_certificate_endp(STORE *s, void *handle) | 410 | int |
416 | { | 411 | STORE_list_certificate_endp(STORE *s, void *handle) |
417 | check_store(s,STORE_F_STORE_LIST_CERTIFICATE_ENDP, | 412 | { |
418 | list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | 413 | check_store(s, STORE_F_STORE_LIST_CERTIFICATE_ENDP, |
414 | list_object_endp, STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | ||
419 | 415 | ||
420 | if (!s->meth->list_object_endp(s, handle)) | 416 | if (!s->meth->list_object_endp(s, handle)) { |
421 | { | ||
422 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_ENDP, | 417 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_ENDP, |
423 | STORE_R_FAILED_LISTING_CERTIFICATES); | 418 | STORE_R_FAILED_LISTING_CERTIFICATES); |
424 | return 0; | 419 | return 0; |
425 | } | ||
426 | return 1; | ||
427 | } | 420 | } |
421 | return 1; | ||
422 | } | ||
428 | 423 | ||
429 | EVP_PKEY *STORE_generate_key(STORE *s, OPENSSL_ITEM attributes[], | 424 | EVP_PKEY * |
430 | OPENSSL_ITEM parameters[]) | 425 | STORE_generate_key(STORE *s, OPENSSL_ITEM attributes[], |
431 | { | 426 | OPENSSL_ITEM parameters[]) |
427 | { | ||
432 | STORE_OBJECT *object; | 428 | STORE_OBJECT *object; |
433 | EVP_PKEY *pkey; | 429 | EVP_PKEY *pkey; |
434 | 430 | ||
435 | check_store(s,STORE_F_STORE_GENERATE_KEY, | 431 | check_store(s, STORE_F_STORE_GENERATE_KEY, |
436 | generate_object,STORE_R_NO_GENERATE_OBJECT_FUNCTION); | 432 | generate_object, STORE_R_NO_GENERATE_OBJECT_FUNCTION); |
437 | 433 | ||
438 | object = s->meth->generate_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, | 434 | object = s->meth->generate_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, |
439 | attributes, parameters); | 435 | attributes, parameters); |
440 | if (!object || !object->data.key) | 436 | if (!object || !object->data.key) { |
441 | { | ||
442 | STOREerr(STORE_F_STORE_GENERATE_KEY, | 437 | STOREerr(STORE_F_STORE_GENERATE_KEY, |
443 | STORE_R_FAILED_GENERATING_KEY); | 438 | STORE_R_FAILED_GENERATING_KEY); |
444 | return 0; | 439 | return 0; |
445 | } | 440 | } |
446 | CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY); | 441 | CRYPTO_add(&object->data.key->references, 1, CRYPTO_LOCK_EVP_PKEY); |
447 | pkey = object->data.key; | 442 | pkey = object->data.key; |
448 | STORE_OBJECT_free(object); | 443 | STORE_OBJECT_free(object); |
449 | return pkey; | 444 | return pkey; |
450 | } | 445 | } |
451 | 446 | ||
452 | EVP_PKEY *STORE_get_private_key(STORE *s, OPENSSL_ITEM attributes[], | 447 | EVP_PKEY * |
453 | OPENSSL_ITEM parameters[]) | 448 | STORE_get_private_key(STORE *s, OPENSSL_ITEM attributes[], |
454 | { | 449 | OPENSSL_ITEM parameters[]) |
450 | { | ||
455 | STORE_OBJECT *object; | 451 | STORE_OBJECT *object; |
456 | EVP_PKEY *pkey; | 452 | EVP_PKEY *pkey; |
457 | 453 | ||
458 | check_store(s,STORE_F_STORE_GET_PRIVATE_KEY, | 454 | check_store(s, STORE_F_STORE_GET_PRIVATE_KEY, |
459 | get_object,STORE_R_NO_GET_OBJECT_FUNCTION); | 455 | get_object, STORE_R_NO_GET_OBJECT_FUNCTION); |
460 | 456 | ||
461 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, | 457 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, |
462 | attributes, parameters); | 458 | attributes, parameters); |
463 | if (!object || !object->data.key) | 459 | if (!object || !object->data.key) { |
464 | { | ||
465 | STOREerr(STORE_F_STORE_GET_PRIVATE_KEY, | 460 | STOREerr(STORE_F_STORE_GET_PRIVATE_KEY, |
466 | STORE_R_FAILED_GETTING_KEY); | 461 | STORE_R_FAILED_GETTING_KEY); |
467 | return 0; | 462 | return 0; |
468 | } | 463 | } |
469 | CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY); | 464 | CRYPTO_add(&object->data.key->references, 1, CRYPTO_LOCK_EVP_PKEY); |
470 | pkey = object->data.key; | 465 | pkey = object->data.key; |
471 | STORE_OBJECT_free(object); | 466 | STORE_OBJECT_free(object); |
472 | return pkey; | 467 | return pkey; |
473 | } | 468 | } |
474 | 469 | ||
475 | int STORE_store_private_key(STORE *s, EVP_PKEY *data, OPENSSL_ITEM attributes[], | 470 | int |
476 | OPENSSL_ITEM parameters[]) | 471 | STORE_store_private_key(STORE *s, EVP_PKEY *data, OPENSSL_ITEM attributes[], |
477 | { | 472 | OPENSSL_ITEM parameters[]) |
473 | { | ||
478 | STORE_OBJECT *object; | 474 | STORE_OBJECT *object; |
479 | int i; | 475 | int i; |
480 | 476 | ||
481 | check_store(s,STORE_F_STORE_STORE_PRIVATE_KEY, | 477 | check_store(s, STORE_F_STORE_STORE_PRIVATE_KEY, |
482 | store_object,STORE_R_NO_STORE_OBJECT_FUNCTION); | 478 | store_object, STORE_R_NO_STORE_OBJECT_FUNCTION); |
483 | 479 | ||
484 | object = STORE_OBJECT_new(); | 480 | object = STORE_OBJECT_new(); |
485 | if (!object) | 481 | if (!object) { |
486 | { | ||
487 | STOREerr(STORE_F_STORE_STORE_PRIVATE_KEY, | 482 | STOREerr(STORE_F_STORE_STORE_PRIVATE_KEY, |
488 | ERR_R_MALLOC_FAILURE); | 483 | ERR_R_MALLOC_FAILURE); |
489 | return 0; | 484 | return 0; |
490 | } | 485 | } |
491 | object->data.key = EVP_PKEY_new(); | 486 | object->data.key = EVP_PKEY_new(); |
492 | if (!object->data.key) | 487 | if (!object->data.key) { |
493 | { | ||
494 | STOREerr(STORE_F_STORE_STORE_PRIVATE_KEY, | 488 | STOREerr(STORE_F_STORE_STORE_PRIVATE_KEY, |
495 | ERR_R_MALLOC_FAILURE); | 489 | ERR_R_MALLOC_FAILURE); |
496 | return 0; | 490 | return 0; |
497 | } | 491 | } |
498 | 492 | ||
499 | CRYPTO_add(&data->references,1,CRYPTO_LOCK_EVP_PKEY); | 493 | CRYPTO_add(&data->references, 1, CRYPTO_LOCK_EVP_PKEY); |
500 | object->data.key = data; | 494 | object->data.key = data; |
501 | 495 | ||
502 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, object, | 496 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, object, |
503 | attributes, parameters); | 497 | attributes, parameters); |
504 | 498 | ||
505 | STORE_OBJECT_free(object); | 499 | STORE_OBJECT_free(object); |
506 | 500 | ||
507 | if (!i) | 501 | if (!i) { |
508 | { | ||
509 | STOREerr(STORE_F_STORE_STORE_PRIVATE_KEY, | 502 | STOREerr(STORE_F_STORE_STORE_PRIVATE_KEY, |
510 | STORE_R_FAILED_STORING_KEY); | 503 | STORE_R_FAILED_STORING_KEY); |
511 | return 0; | 504 | return 0; |
512 | } | ||
513 | return i; | ||
514 | } | 505 | } |
506 | return i; | ||
507 | } | ||
515 | 508 | ||
516 | int STORE_modify_private_key(STORE *s, OPENSSL_ITEM search_attributes[], | 509 | int |
517 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | 510 | STORE_modify_private_key(STORE *s, OPENSSL_ITEM search_attributes[], |
518 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) | 511 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], |
519 | { | 512 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) |
520 | check_store(s,STORE_F_STORE_MODIFY_PRIVATE_KEY, | 513 | { |
521 | modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION); | 514 | check_store(s, STORE_F_STORE_MODIFY_PRIVATE_KEY, |
515 | modify_object, STORE_R_NO_MODIFY_OBJECT_FUNCTION); | ||
522 | 516 | ||
523 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, | 517 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, |
524 | search_attributes, add_attributes, modify_attributes, | 518 | search_attributes, add_attributes, modify_attributes, |
525 | delete_attributes, parameters)) | 519 | delete_attributes, parameters)) { |
526 | { | ||
527 | STOREerr(STORE_F_STORE_MODIFY_PRIVATE_KEY, | 520 | STOREerr(STORE_F_STORE_MODIFY_PRIVATE_KEY, |
528 | STORE_R_FAILED_MODIFYING_PRIVATE_KEY); | 521 | STORE_R_FAILED_MODIFYING_PRIVATE_KEY); |
529 | return 0; | 522 | return 0; |
530 | } | ||
531 | return 1; | ||
532 | } | 523 | } |
524 | return 1; | ||
525 | } | ||
533 | 526 | ||
534 | int STORE_revoke_private_key(STORE *s, OPENSSL_ITEM attributes[], | 527 | int |
535 | OPENSSL_ITEM parameters[]) | 528 | STORE_revoke_private_key(STORE *s, OPENSSL_ITEM attributes[], |
536 | { | 529 | OPENSSL_ITEM parameters[]) |
530 | { | ||
537 | int i; | 531 | int i; |
538 | 532 | ||
539 | check_store(s,STORE_F_STORE_REVOKE_PRIVATE_KEY, | 533 | check_store(s, STORE_F_STORE_REVOKE_PRIVATE_KEY, |
540 | revoke_object,STORE_R_NO_REVOKE_OBJECT_FUNCTION); | 534 | revoke_object, STORE_R_NO_REVOKE_OBJECT_FUNCTION); |
541 | 535 | ||
542 | i = s->meth->revoke_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, | 536 | i = s->meth->revoke_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, |
543 | attributes, parameters); | 537 | attributes, parameters); |
544 | 538 | ||
545 | if (!i) | 539 | if (!i) { |
546 | { | ||
547 | STOREerr(STORE_F_STORE_REVOKE_PRIVATE_KEY, | 540 | STOREerr(STORE_F_STORE_REVOKE_PRIVATE_KEY, |
548 | STORE_R_FAILED_REVOKING_KEY); | 541 | STORE_R_FAILED_REVOKING_KEY); |
549 | return 0; | 542 | return 0; |
550 | } | ||
551 | return i; | ||
552 | } | 543 | } |
544 | return i; | ||
545 | } | ||
546 | |||
547 | int | ||
548 | STORE_delete_private_key(STORE *s, OPENSSL_ITEM attributes[], | ||
549 | OPENSSL_ITEM parameters[]) | ||
550 | { | ||
551 | check_store(s, STORE_F_STORE_DELETE_PRIVATE_KEY, | ||
552 | delete_object, STORE_R_NO_DELETE_OBJECT_FUNCTION); | ||
553 | 553 | ||
554 | int STORE_delete_private_key(STORE *s, OPENSSL_ITEM attributes[], | ||
555 | OPENSSL_ITEM parameters[]) | ||
556 | { | ||
557 | check_store(s,STORE_F_STORE_DELETE_PRIVATE_KEY, | ||
558 | delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION); | ||
559 | |||
560 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, | 554 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, |
561 | attributes, parameters)) | 555 | attributes, parameters)) { |
562 | { | ||
563 | STOREerr(STORE_F_STORE_DELETE_PRIVATE_KEY, | 556 | STOREerr(STORE_F_STORE_DELETE_PRIVATE_KEY, |
564 | STORE_R_FAILED_DELETING_KEY); | 557 | STORE_R_FAILED_DELETING_KEY); |
565 | return 0; | 558 | return 0; |
566 | } | ||
567 | return 1; | ||
568 | } | 559 | } |
560 | return 1; | ||
561 | } | ||
569 | 562 | ||
570 | void *STORE_list_private_key_start(STORE *s, OPENSSL_ITEM attributes[], | 563 | void * |
571 | OPENSSL_ITEM parameters[]) | 564 | STORE_list_private_key_start(STORE *s, OPENSSL_ITEM attributes[], |
572 | { | 565 | OPENSSL_ITEM parameters[]) |
566 | { | ||
573 | void *handle; | 567 | void *handle; |
574 | 568 | ||
575 | check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_START, | 569 | check_store(s, STORE_F_STORE_LIST_PRIVATE_KEY_START, |
576 | list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION); | 570 | list_object_start, STORE_R_NO_LIST_OBJECT_START_FUNCTION); |
577 | 571 | ||
578 | handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_PRIVATE_KEY, | 572 | handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_PRIVATE_KEY, |
579 | attributes, parameters); | 573 | attributes, parameters); |
580 | if (!handle) | 574 | if (!handle) { |
581 | { | ||
582 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_START, | 575 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_START, |
583 | STORE_R_FAILED_LISTING_KEYS); | 576 | STORE_R_FAILED_LISTING_KEYS); |
584 | return 0; | 577 | return 0; |
585 | } | ||
586 | return handle; | ||
587 | } | 578 | } |
579 | return handle; | ||
580 | } | ||
588 | 581 | ||
589 | EVP_PKEY *STORE_list_private_key_next(STORE *s, void *handle) | 582 | EVP_PKEY * |
590 | { | 583 | STORE_list_private_key_next(STORE *s, void *handle) |
584 | { | ||
591 | STORE_OBJECT *object; | 585 | STORE_OBJECT *object; |
592 | EVP_PKEY *pkey; | 586 | EVP_PKEY *pkey; |
593 | 587 | ||
594 | check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_NEXT, | 588 | check_store(s, STORE_F_STORE_LIST_PRIVATE_KEY_NEXT, |
595 | list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); | 589 | list_object_next, STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); |
596 | 590 | ||
597 | object = s->meth->list_object_next(s, handle); | 591 | object = s->meth->list_object_next(s, handle); |
598 | if (!object || !object->data.key) | 592 | if (!object || !object->data.key) { |
599 | { | ||
600 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_NEXT, | 593 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_NEXT, |
601 | STORE_R_FAILED_LISTING_KEYS); | 594 | STORE_R_FAILED_LISTING_KEYS); |
602 | return 0; | 595 | return 0; |
603 | } | 596 | } |
604 | CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY); | 597 | CRYPTO_add(&object->data.key->references, 1, CRYPTO_LOCK_EVP_PKEY); |
605 | pkey = object->data.key; | 598 | pkey = object->data.key; |
606 | STORE_OBJECT_free(object); | 599 | STORE_OBJECT_free(object); |
607 | return pkey; | 600 | return pkey; |
608 | } | 601 | } |
609 | 602 | ||
610 | int STORE_list_private_key_end(STORE *s, void *handle) | 603 | int |
611 | { | 604 | STORE_list_private_key_end(STORE *s, void *handle) |
612 | check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_END, | 605 | { |
613 | list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION); | 606 | check_store(s, STORE_F_STORE_LIST_PRIVATE_KEY_END, |
607 | list_object_end, STORE_R_NO_LIST_OBJECT_END_FUNCTION); | ||
614 | 608 | ||
615 | if (!s->meth->list_object_end(s, handle)) | 609 | if (!s->meth->list_object_end(s, handle)) { |
616 | { | ||
617 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_END, | 610 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_END, |
618 | STORE_R_FAILED_LISTING_KEYS); | 611 | STORE_R_FAILED_LISTING_KEYS); |
619 | return 0; | 612 | return 0; |
620 | } | ||
621 | return 1; | ||
622 | } | 613 | } |
614 | return 1; | ||
615 | } | ||
623 | 616 | ||
624 | int STORE_list_private_key_endp(STORE *s, void *handle) | 617 | int |
625 | { | 618 | STORE_list_private_key_endp(STORE *s, void *handle) |
626 | check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_ENDP, | 619 | { |
627 | list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | 620 | check_store(s, STORE_F_STORE_LIST_PRIVATE_KEY_ENDP, |
621 | list_object_endp, STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | ||
628 | 622 | ||
629 | if (!s->meth->list_object_endp(s, handle)) | 623 | if (!s->meth->list_object_endp(s, handle)) { |
630 | { | ||
631 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_ENDP, | 624 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_ENDP, |
632 | STORE_R_FAILED_LISTING_KEYS); | 625 | STORE_R_FAILED_LISTING_KEYS); |
633 | return 0; | 626 | return 0; |
634 | } | ||
635 | return 1; | ||
636 | } | 627 | } |
628 | return 1; | ||
629 | } | ||
637 | 630 | ||
638 | EVP_PKEY *STORE_get_public_key(STORE *s, OPENSSL_ITEM attributes[], | 631 | EVP_PKEY * |
639 | OPENSSL_ITEM parameters[]) | 632 | STORE_get_public_key(STORE *s, OPENSSL_ITEM attributes[], |
640 | { | 633 | OPENSSL_ITEM parameters[]) |
634 | { | ||
641 | STORE_OBJECT *object; | 635 | STORE_OBJECT *object; |
642 | EVP_PKEY *pkey; | 636 | EVP_PKEY *pkey; |
643 | 637 | ||
644 | check_store(s,STORE_F_STORE_GET_PUBLIC_KEY, | 638 | check_store(s, STORE_F_STORE_GET_PUBLIC_KEY, |
645 | get_object,STORE_R_NO_GET_OBJECT_FUNCTION); | 639 | get_object, STORE_R_NO_GET_OBJECT_FUNCTION); |
646 | 640 | ||
647 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, | 641 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, |
648 | attributes, parameters); | 642 | attributes, parameters); |
649 | if (!object || !object->data.key) | 643 | if (!object || !object->data.key) { |
650 | { | ||
651 | STOREerr(STORE_F_STORE_GET_PUBLIC_KEY, | 644 | STOREerr(STORE_F_STORE_GET_PUBLIC_KEY, |
652 | STORE_R_FAILED_GETTING_KEY); | 645 | STORE_R_FAILED_GETTING_KEY); |
653 | return 0; | 646 | return 0; |
654 | } | 647 | } |
655 | CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY); | 648 | CRYPTO_add(&object->data.key->references, 1, CRYPTO_LOCK_EVP_PKEY); |
656 | pkey = object->data.key; | 649 | pkey = object->data.key; |
657 | STORE_OBJECT_free(object); | 650 | STORE_OBJECT_free(object); |
658 | return pkey; | 651 | return pkey; |
659 | } | 652 | } |
660 | 653 | ||
661 | int STORE_store_public_key(STORE *s, EVP_PKEY *data, OPENSSL_ITEM attributes[], | 654 | int |
662 | OPENSSL_ITEM parameters[]) | 655 | STORE_store_public_key(STORE *s, EVP_PKEY *data, OPENSSL_ITEM attributes[], |
663 | { | 656 | OPENSSL_ITEM parameters[]) |
657 | { | ||
664 | STORE_OBJECT *object; | 658 | STORE_OBJECT *object; |
665 | int i; | 659 | int i; |
666 | 660 | ||
667 | check_store(s,STORE_F_STORE_STORE_PUBLIC_KEY, | 661 | check_store(s, STORE_F_STORE_STORE_PUBLIC_KEY, |
668 | store_object,STORE_R_NO_STORE_OBJECT_FUNCTION); | 662 | store_object, STORE_R_NO_STORE_OBJECT_FUNCTION); |
669 | 663 | ||
670 | object = STORE_OBJECT_new(); | 664 | object = STORE_OBJECT_new(); |
671 | if (!object) | 665 | if (!object) { |
672 | { | ||
673 | STOREerr(STORE_F_STORE_STORE_PUBLIC_KEY, | 666 | STOREerr(STORE_F_STORE_STORE_PUBLIC_KEY, |
674 | ERR_R_MALLOC_FAILURE); | 667 | ERR_R_MALLOC_FAILURE); |
675 | return 0; | 668 | return 0; |
676 | } | 669 | } |
677 | object->data.key = EVP_PKEY_new(); | 670 | object->data.key = EVP_PKEY_new(); |
678 | if (!object->data.key) | 671 | if (!object->data.key) { |
679 | { | ||
680 | STOREerr(STORE_F_STORE_STORE_PUBLIC_KEY, | 672 | STOREerr(STORE_F_STORE_STORE_PUBLIC_KEY, |
681 | ERR_R_MALLOC_FAILURE); | 673 | ERR_R_MALLOC_FAILURE); |
682 | return 0; | 674 | return 0; |
683 | } | 675 | } |
684 | 676 | ||
685 | CRYPTO_add(&data->references,1,CRYPTO_LOCK_EVP_PKEY); | 677 | CRYPTO_add(&data->references, 1, CRYPTO_LOCK_EVP_PKEY); |
686 | object->data.key = data; | 678 | object->data.key = data; |
687 | 679 | ||
688 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, object, | 680 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, object, |
689 | attributes, parameters); | 681 | attributes, parameters); |
690 | 682 | ||
691 | STORE_OBJECT_free(object); | 683 | STORE_OBJECT_free(object); |
692 | 684 | ||
693 | if (!i) | 685 | if (!i) { |
694 | { | ||
695 | STOREerr(STORE_F_STORE_STORE_PUBLIC_KEY, | 686 | STOREerr(STORE_F_STORE_STORE_PUBLIC_KEY, |
696 | STORE_R_FAILED_STORING_KEY); | 687 | STORE_R_FAILED_STORING_KEY); |
697 | return 0; | 688 | return 0; |
698 | } | ||
699 | return i; | ||
700 | } | 689 | } |
690 | return i; | ||
691 | } | ||
701 | 692 | ||
702 | int STORE_modify_public_key(STORE *s, OPENSSL_ITEM search_attributes[], | 693 | int |
703 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | 694 | STORE_modify_public_key(STORE *s, OPENSSL_ITEM search_attributes[], |
704 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) | 695 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], |
705 | { | 696 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) |
706 | check_store(s,STORE_F_STORE_MODIFY_PUBLIC_KEY, | 697 | { |
707 | modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION); | 698 | check_store(s, STORE_F_STORE_MODIFY_PUBLIC_KEY, |
699 | modify_object, STORE_R_NO_MODIFY_OBJECT_FUNCTION); | ||
708 | 700 | ||
709 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, | 701 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, |
710 | search_attributes, add_attributes, modify_attributes, | 702 | search_attributes, add_attributes, modify_attributes, |
711 | delete_attributes, parameters)) | 703 | delete_attributes, parameters)) { |
712 | { | ||
713 | STOREerr(STORE_F_STORE_MODIFY_PUBLIC_KEY, | 704 | STOREerr(STORE_F_STORE_MODIFY_PUBLIC_KEY, |
714 | STORE_R_FAILED_MODIFYING_PUBLIC_KEY); | 705 | STORE_R_FAILED_MODIFYING_PUBLIC_KEY); |
715 | return 0; | 706 | return 0; |
716 | } | ||
717 | return 1; | ||
718 | } | 707 | } |
708 | return 1; | ||
709 | } | ||
719 | 710 | ||
720 | int STORE_revoke_public_key(STORE *s, OPENSSL_ITEM attributes[], | 711 | int |
721 | OPENSSL_ITEM parameters[]) | 712 | STORE_revoke_public_key(STORE *s, OPENSSL_ITEM attributes[], |
722 | { | 713 | OPENSSL_ITEM parameters[]) |
714 | { | ||
723 | int i; | 715 | int i; |
724 | 716 | ||
725 | check_store(s,STORE_F_STORE_REVOKE_PUBLIC_KEY, | 717 | check_store(s, STORE_F_STORE_REVOKE_PUBLIC_KEY, |
726 | revoke_object,STORE_R_NO_REVOKE_OBJECT_FUNCTION); | 718 | revoke_object, STORE_R_NO_REVOKE_OBJECT_FUNCTION); |
727 | 719 | ||
728 | i = s->meth->revoke_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, | 720 | i = s->meth->revoke_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, |
729 | attributes, parameters); | 721 | attributes, parameters); |
730 | 722 | ||
731 | if (!i) | 723 | if (!i) { |
732 | { | ||
733 | STOREerr(STORE_F_STORE_REVOKE_PUBLIC_KEY, | 724 | STOREerr(STORE_F_STORE_REVOKE_PUBLIC_KEY, |
734 | STORE_R_FAILED_REVOKING_KEY); | 725 | STORE_R_FAILED_REVOKING_KEY); |
735 | return 0; | 726 | return 0; |
736 | } | ||
737 | return i; | ||
738 | } | 727 | } |
728 | return i; | ||
729 | } | ||
730 | |||
731 | int | ||
732 | STORE_delete_public_key(STORE *s, OPENSSL_ITEM attributes[], | ||
733 | OPENSSL_ITEM parameters[]) | ||
734 | { | ||
735 | check_store(s, STORE_F_STORE_DELETE_PUBLIC_KEY, | ||
736 | delete_object, STORE_R_NO_DELETE_OBJECT_FUNCTION); | ||
739 | 737 | ||
740 | int STORE_delete_public_key(STORE *s, OPENSSL_ITEM attributes[], | ||
741 | OPENSSL_ITEM parameters[]) | ||
742 | { | ||
743 | check_store(s,STORE_F_STORE_DELETE_PUBLIC_KEY, | ||
744 | delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION); | ||
745 | |||
746 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, | 738 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, |
747 | attributes, parameters)) | 739 | attributes, parameters)) { |
748 | { | ||
749 | STOREerr(STORE_F_STORE_DELETE_PUBLIC_KEY, | 740 | STOREerr(STORE_F_STORE_DELETE_PUBLIC_KEY, |
750 | STORE_R_FAILED_DELETING_KEY); | 741 | STORE_R_FAILED_DELETING_KEY); |
751 | return 0; | 742 | return 0; |
752 | } | ||
753 | return 1; | ||
754 | } | 743 | } |
744 | return 1; | ||
745 | } | ||
755 | 746 | ||
756 | void *STORE_list_public_key_start(STORE *s, OPENSSL_ITEM attributes[], | 747 | void * |
757 | OPENSSL_ITEM parameters[]) | 748 | STORE_list_public_key_start(STORE *s, OPENSSL_ITEM attributes[], |
758 | { | 749 | OPENSSL_ITEM parameters[]) |
750 | { | ||
759 | void *handle; | 751 | void *handle; |
760 | 752 | ||
761 | check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_START, | 753 | check_store(s, STORE_F_STORE_LIST_PUBLIC_KEY_START, |
762 | list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION); | 754 | list_object_start, STORE_R_NO_LIST_OBJECT_START_FUNCTION); |
763 | 755 | ||
764 | handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_PUBLIC_KEY, | 756 | handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_PUBLIC_KEY, |
765 | attributes, parameters); | 757 | attributes, parameters); |
766 | if (!handle) | 758 | if (!handle) { |
767 | { | ||
768 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_START, | 759 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_START, |
769 | STORE_R_FAILED_LISTING_KEYS); | 760 | STORE_R_FAILED_LISTING_KEYS); |
770 | return 0; | 761 | return 0; |
771 | } | ||
772 | return handle; | ||
773 | } | 762 | } |
763 | return handle; | ||
764 | } | ||
774 | 765 | ||
775 | EVP_PKEY *STORE_list_public_key_next(STORE *s, void *handle) | 766 | EVP_PKEY * |
776 | { | 767 | STORE_list_public_key_next(STORE *s, void *handle) |
768 | { | ||
777 | STORE_OBJECT *object; | 769 | STORE_OBJECT *object; |
778 | EVP_PKEY *pkey; | 770 | EVP_PKEY *pkey; |
779 | 771 | ||
780 | check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_NEXT, | 772 | check_store(s, STORE_F_STORE_LIST_PUBLIC_KEY_NEXT, |
781 | list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); | 773 | list_object_next, STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); |
782 | 774 | ||
783 | object = s->meth->list_object_next(s, handle); | 775 | object = s->meth->list_object_next(s, handle); |
784 | if (!object || !object->data.key) | 776 | if (!object || !object->data.key) { |
785 | { | ||
786 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_NEXT, | 777 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_NEXT, |
787 | STORE_R_FAILED_LISTING_KEYS); | 778 | STORE_R_FAILED_LISTING_KEYS); |
788 | return 0; | 779 | return 0; |
789 | } | 780 | } |
790 | CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY); | 781 | CRYPTO_add(&object->data.key->references, 1, CRYPTO_LOCK_EVP_PKEY); |
791 | pkey = object->data.key; | 782 | pkey = object->data.key; |
792 | STORE_OBJECT_free(object); | 783 | STORE_OBJECT_free(object); |
793 | return pkey; | 784 | return pkey; |
794 | } | 785 | } |
795 | 786 | ||
796 | int STORE_list_public_key_end(STORE *s, void *handle) | 787 | int |
797 | { | 788 | STORE_list_public_key_end(STORE *s, void *handle) |
798 | check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_END, | 789 | { |
799 | list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION); | 790 | check_store(s, STORE_F_STORE_LIST_PUBLIC_KEY_END, |
791 | list_object_end, STORE_R_NO_LIST_OBJECT_END_FUNCTION); | ||
800 | 792 | ||
801 | if (!s->meth->list_object_end(s, handle)) | 793 | if (!s->meth->list_object_end(s, handle)) { |
802 | { | ||
803 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_END, | 794 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_END, |
804 | STORE_R_FAILED_LISTING_KEYS); | 795 | STORE_R_FAILED_LISTING_KEYS); |
805 | return 0; | 796 | return 0; |
806 | } | ||
807 | return 1; | ||
808 | } | 797 | } |
798 | return 1; | ||
799 | } | ||
809 | 800 | ||
810 | int STORE_list_public_key_endp(STORE *s, void *handle) | 801 | int |
811 | { | 802 | STORE_list_public_key_endp(STORE *s, void *handle) |
812 | check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_ENDP, | 803 | { |
813 | list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | 804 | check_store(s, STORE_F_STORE_LIST_PUBLIC_KEY_ENDP, |
805 | list_object_endp, STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | ||
814 | 806 | ||
815 | if (!s->meth->list_object_endp(s, handle)) | 807 | if (!s->meth->list_object_endp(s, handle)) { |
816 | { | ||
817 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_ENDP, | 808 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_ENDP, |
818 | STORE_R_FAILED_LISTING_KEYS); | 809 | STORE_R_FAILED_LISTING_KEYS); |
819 | return 0; | 810 | return 0; |
820 | } | ||
821 | return 1; | ||
822 | } | 811 | } |
812 | return 1; | ||
813 | } | ||
823 | 814 | ||
824 | X509_CRL *STORE_generate_crl(STORE *s, OPENSSL_ITEM attributes[], | 815 | X509_CRL * |
825 | OPENSSL_ITEM parameters[]) | 816 | STORE_generate_crl(STORE *s, OPENSSL_ITEM attributes[], |
826 | { | 817 | OPENSSL_ITEM parameters[]) |
818 | { | ||
827 | STORE_OBJECT *object; | 819 | STORE_OBJECT *object; |
828 | X509_CRL *crl; | 820 | X509_CRL *crl; |
829 | 821 | ||
830 | check_store(s,STORE_F_STORE_GENERATE_CRL, | 822 | check_store(s, STORE_F_STORE_GENERATE_CRL, |
831 | generate_object,STORE_R_NO_GENERATE_CRL_FUNCTION); | 823 | generate_object, STORE_R_NO_GENERATE_CRL_FUNCTION); |
832 | 824 | ||
833 | object = s->meth->generate_object(s, STORE_OBJECT_TYPE_X509_CRL, | 825 | object = s->meth->generate_object(s, STORE_OBJECT_TYPE_X509_CRL, |
834 | attributes, parameters); | 826 | attributes, parameters); |
835 | if (!object || !object->data.crl) | 827 | if (!object || !object->data.crl) { |
836 | { | ||
837 | STOREerr(STORE_F_STORE_GENERATE_CRL, | 828 | STOREerr(STORE_F_STORE_GENERATE_CRL, |
838 | STORE_R_FAILED_GENERATING_CRL); | 829 | STORE_R_FAILED_GENERATING_CRL); |
839 | return 0; | 830 | return 0; |
840 | } | 831 | } |
841 | CRYPTO_add(&object->data.crl->references,1,CRYPTO_LOCK_X509_CRL); | 832 | CRYPTO_add(&object->data.crl->references, 1, CRYPTO_LOCK_X509_CRL); |
842 | crl = object->data.crl; | 833 | crl = object->data.crl; |
843 | STORE_OBJECT_free(object); | 834 | STORE_OBJECT_free(object); |
844 | return crl; | 835 | return crl; |
845 | } | 836 | } |
846 | 837 | ||
847 | X509_CRL *STORE_get_crl(STORE *s, OPENSSL_ITEM attributes[], | 838 | X509_CRL * |
848 | OPENSSL_ITEM parameters[]) | 839 | STORE_get_crl(STORE *s, OPENSSL_ITEM attributes[], |
849 | { | 840 | OPENSSL_ITEM parameters[]) |
841 | { | ||
850 | STORE_OBJECT *object; | 842 | STORE_OBJECT *object; |
851 | X509_CRL *crl; | 843 | X509_CRL *crl; |
852 | 844 | ||
853 | check_store(s,STORE_F_STORE_GET_CRL, | 845 | check_store(s, STORE_F_STORE_GET_CRL, |
854 | get_object,STORE_R_NO_GET_OBJECT_FUNCTION); | 846 | get_object, STORE_R_NO_GET_OBJECT_FUNCTION); |
855 | 847 | ||
856 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_X509_CRL, | 848 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_X509_CRL, |
857 | attributes, parameters); | 849 | attributes, parameters); |
858 | if (!object || !object->data.crl) | 850 | if (!object || !object->data.crl) { |
859 | { | ||
860 | STOREerr(STORE_F_STORE_GET_CRL, | 851 | STOREerr(STORE_F_STORE_GET_CRL, |
861 | STORE_R_FAILED_GETTING_KEY); | 852 | STORE_R_FAILED_GETTING_KEY); |
862 | return 0; | 853 | return 0; |
863 | } | 854 | } |
864 | CRYPTO_add(&object->data.crl->references,1,CRYPTO_LOCK_X509_CRL); | 855 | CRYPTO_add(&object->data.crl->references, 1, CRYPTO_LOCK_X509_CRL); |
865 | crl = object->data.crl; | 856 | crl = object->data.crl; |
866 | STORE_OBJECT_free(object); | 857 | STORE_OBJECT_free(object); |
867 | return crl; | 858 | return crl; |
868 | } | 859 | } |
869 | 860 | ||
870 | int STORE_store_crl(STORE *s, X509_CRL *data, OPENSSL_ITEM attributes[], | 861 | int |
871 | OPENSSL_ITEM parameters[]) | 862 | STORE_store_crl(STORE *s, X509_CRL *data, OPENSSL_ITEM attributes[], |
872 | { | 863 | OPENSSL_ITEM parameters[]) |
864 | { | ||
873 | STORE_OBJECT *object; | 865 | STORE_OBJECT *object; |
874 | int i; | 866 | int i; |
875 | 867 | ||
876 | check_store(s,STORE_F_STORE_STORE_CRL, | 868 | check_store(s, STORE_F_STORE_STORE_CRL, |
877 | store_object,STORE_R_NO_STORE_OBJECT_FUNCTION); | 869 | store_object, STORE_R_NO_STORE_OBJECT_FUNCTION); |
878 | 870 | ||
879 | object = STORE_OBJECT_new(); | 871 | object = STORE_OBJECT_new(); |
880 | if (!object) | 872 | if (!object) { |
881 | { | ||
882 | STOREerr(STORE_F_STORE_STORE_CRL, | 873 | STOREerr(STORE_F_STORE_STORE_CRL, |
883 | ERR_R_MALLOC_FAILURE); | 874 | ERR_R_MALLOC_FAILURE); |
884 | return 0; | 875 | return 0; |
885 | } | 876 | } |
886 | 877 | ||
887 | CRYPTO_add(&data->references,1,CRYPTO_LOCK_X509_CRL); | 878 | CRYPTO_add(&data->references, 1, CRYPTO_LOCK_X509_CRL); |
888 | object->data.crl = data; | 879 | object->data.crl = data; |
889 | 880 | ||
890 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_X509_CRL, object, | 881 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_X509_CRL, object, |
891 | attributes, parameters); | 882 | attributes, parameters); |
892 | 883 | ||
893 | STORE_OBJECT_free(object); | 884 | STORE_OBJECT_free(object); |
894 | 885 | ||
895 | if (!i) | 886 | if (!i) { |
896 | { | ||
897 | STOREerr(STORE_F_STORE_STORE_CRL, | 887 | STOREerr(STORE_F_STORE_STORE_CRL, |
898 | STORE_R_FAILED_STORING_KEY); | 888 | STORE_R_FAILED_STORING_KEY); |
899 | return 0; | 889 | return 0; |
900 | } | ||
901 | return i; | ||
902 | } | 890 | } |
891 | return i; | ||
892 | } | ||
903 | 893 | ||
904 | int STORE_modify_crl(STORE *s, OPENSSL_ITEM search_attributes[], | 894 | int |
905 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | 895 | STORE_modify_crl(STORE *s, OPENSSL_ITEM search_attributes[], |
906 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) | 896 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], |
907 | { | 897 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) |
908 | check_store(s,STORE_F_STORE_MODIFY_CRL, | 898 | { |
909 | modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION); | 899 | check_store(s, STORE_F_STORE_MODIFY_CRL, |
900 | modify_object, STORE_R_NO_MODIFY_OBJECT_FUNCTION); | ||
910 | 901 | ||
911 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_X509_CRL, | 902 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_X509_CRL, |
912 | search_attributes, add_attributes, modify_attributes, | 903 | search_attributes, add_attributes, modify_attributes, |
913 | delete_attributes, parameters)) | 904 | delete_attributes, parameters)) { |
914 | { | ||
915 | STOREerr(STORE_F_STORE_MODIFY_CRL, | 905 | STOREerr(STORE_F_STORE_MODIFY_CRL, |
916 | STORE_R_FAILED_MODIFYING_CRL); | 906 | STORE_R_FAILED_MODIFYING_CRL); |
917 | return 0; | 907 | return 0; |
918 | } | ||
919 | return 1; | ||
920 | } | 908 | } |
909 | return 1; | ||
910 | } | ||
911 | |||
912 | int | ||
913 | STORE_delete_crl(STORE *s, OPENSSL_ITEM attributes[], | ||
914 | OPENSSL_ITEM parameters[]) | ||
915 | { | ||
916 | check_store(s, STORE_F_STORE_DELETE_CRL, | ||
917 | delete_object, STORE_R_NO_DELETE_OBJECT_FUNCTION); | ||
921 | 918 | ||
922 | int STORE_delete_crl(STORE *s, OPENSSL_ITEM attributes[], | ||
923 | OPENSSL_ITEM parameters[]) | ||
924 | { | ||
925 | check_store(s,STORE_F_STORE_DELETE_CRL, | ||
926 | delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION); | ||
927 | |||
928 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_X509_CRL, | 919 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_X509_CRL, |
929 | attributes, parameters)) | 920 | attributes, parameters)) { |
930 | { | ||
931 | STOREerr(STORE_F_STORE_DELETE_CRL, | 921 | STOREerr(STORE_F_STORE_DELETE_CRL, |
932 | STORE_R_FAILED_DELETING_KEY); | 922 | STORE_R_FAILED_DELETING_KEY); |
933 | return 0; | 923 | return 0; |
934 | } | ||
935 | return 1; | ||
936 | } | 924 | } |
925 | return 1; | ||
926 | } | ||
937 | 927 | ||
938 | void *STORE_list_crl_start(STORE *s, OPENSSL_ITEM attributes[], | 928 | void * |
939 | OPENSSL_ITEM parameters[]) | 929 | STORE_list_crl_start(STORE *s, OPENSSL_ITEM attributes[], |
940 | { | 930 | OPENSSL_ITEM parameters[]) |
931 | { | ||
941 | void *handle; | 932 | void *handle; |
942 | 933 | ||
943 | check_store(s,STORE_F_STORE_LIST_CRL_START, | 934 | check_store(s, STORE_F_STORE_LIST_CRL_START, |
944 | list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION); | 935 | list_object_start, STORE_R_NO_LIST_OBJECT_START_FUNCTION); |
945 | 936 | ||
946 | handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_X509_CRL, | 937 | handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_X509_CRL, |
947 | attributes, parameters); | 938 | attributes, parameters); |
948 | if (!handle) | 939 | if (!handle) { |
949 | { | ||
950 | STOREerr(STORE_F_STORE_LIST_CRL_START, | 940 | STOREerr(STORE_F_STORE_LIST_CRL_START, |
951 | STORE_R_FAILED_LISTING_KEYS); | 941 | STORE_R_FAILED_LISTING_KEYS); |
952 | return 0; | 942 | return 0; |
953 | } | ||
954 | return handle; | ||
955 | } | 943 | } |
944 | return handle; | ||
945 | } | ||
956 | 946 | ||
957 | X509_CRL *STORE_list_crl_next(STORE *s, void *handle) | 947 | X509_CRL * |
958 | { | 948 | STORE_list_crl_next(STORE *s, void *handle) |
949 | { | ||
959 | STORE_OBJECT *object; | 950 | STORE_OBJECT *object; |
960 | X509_CRL *crl; | 951 | X509_CRL *crl; |
961 | 952 | ||
962 | check_store(s,STORE_F_STORE_LIST_CRL_NEXT, | 953 | check_store(s, STORE_F_STORE_LIST_CRL_NEXT, |
963 | list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); | 954 | list_object_next, STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); |
964 | 955 | ||
965 | object = s->meth->list_object_next(s, handle); | 956 | object = s->meth->list_object_next(s, handle); |
966 | if (!object || !object->data.crl) | 957 | if (!object || !object->data.crl) { |
967 | { | ||
968 | STOREerr(STORE_F_STORE_LIST_CRL_NEXT, | 958 | STOREerr(STORE_F_STORE_LIST_CRL_NEXT, |
969 | STORE_R_FAILED_LISTING_KEYS); | 959 | STORE_R_FAILED_LISTING_KEYS); |
970 | return 0; | 960 | return 0; |
971 | } | 961 | } |
972 | CRYPTO_add(&object->data.crl->references,1,CRYPTO_LOCK_X509_CRL); | 962 | CRYPTO_add(&object->data.crl->references, 1, CRYPTO_LOCK_X509_CRL); |
973 | crl = object->data.crl; | 963 | crl = object->data.crl; |
974 | STORE_OBJECT_free(object); | 964 | STORE_OBJECT_free(object); |
975 | return crl; | 965 | return crl; |
976 | } | 966 | } |
977 | 967 | ||
978 | int STORE_list_crl_end(STORE *s, void *handle) | 968 | int |
979 | { | 969 | STORE_list_crl_end(STORE *s, void *handle) |
980 | check_store(s,STORE_F_STORE_LIST_CRL_END, | 970 | { |
981 | list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION); | 971 | check_store(s, STORE_F_STORE_LIST_CRL_END, |
972 | list_object_end, STORE_R_NO_LIST_OBJECT_END_FUNCTION); | ||
982 | 973 | ||
983 | if (!s->meth->list_object_end(s, handle)) | 974 | if (!s->meth->list_object_end(s, handle)) { |
984 | { | ||
985 | STOREerr(STORE_F_STORE_LIST_CRL_END, | 975 | STOREerr(STORE_F_STORE_LIST_CRL_END, |
986 | STORE_R_FAILED_LISTING_KEYS); | 976 | STORE_R_FAILED_LISTING_KEYS); |
987 | return 0; | 977 | return 0; |
988 | } | ||
989 | return 1; | ||
990 | } | 978 | } |
979 | return 1; | ||
980 | } | ||
991 | 981 | ||
992 | int STORE_list_crl_endp(STORE *s, void *handle) | 982 | int |
993 | { | 983 | STORE_list_crl_endp(STORE *s, void *handle) |
994 | check_store(s,STORE_F_STORE_LIST_CRL_ENDP, | 984 | { |
995 | list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | 985 | check_store(s, STORE_F_STORE_LIST_CRL_ENDP, |
986 | list_object_endp, STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | ||
996 | 987 | ||
997 | if (!s->meth->list_object_endp(s, handle)) | 988 | if (!s->meth->list_object_endp(s, handle)) { |
998 | { | ||
999 | STOREerr(STORE_F_STORE_LIST_CRL_ENDP, | 989 | STOREerr(STORE_F_STORE_LIST_CRL_ENDP, |
1000 | STORE_R_FAILED_LISTING_KEYS); | 990 | STORE_R_FAILED_LISTING_KEYS); |
1001 | return 0; | 991 | return 0; |
1002 | } | ||
1003 | return 1; | ||
1004 | } | 992 | } |
993 | return 1; | ||
994 | } | ||
1005 | 995 | ||
1006 | int STORE_store_number(STORE *s, BIGNUM *data, OPENSSL_ITEM attributes[], | 996 | int |
1007 | OPENSSL_ITEM parameters[]) | 997 | STORE_store_number(STORE *s, BIGNUM *data, OPENSSL_ITEM attributes[], |
1008 | { | 998 | OPENSSL_ITEM parameters[]) |
999 | { | ||
1009 | STORE_OBJECT *object; | 1000 | STORE_OBJECT *object; |
1010 | int i; | 1001 | int i; |
1011 | 1002 | ||
1012 | check_store(s,STORE_F_STORE_STORE_NUMBER, | 1003 | check_store(s, STORE_F_STORE_STORE_NUMBER, |
1013 | store_object,STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION); | 1004 | store_object, STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION); |
1014 | 1005 | ||
1015 | object = STORE_OBJECT_new(); | 1006 | object = STORE_OBJECT_new(); |
1016 | if (!object) | 1007 | if (!object) { |
1017 | { | ||
1018 | STOREerr(STORE_F_STORE_STORE_NUMBER, | 1008 | STOREerr(STORE_F_STORE_STORE_NUMBER, |
1019 | ERR_R_MALLOC_FAILURE); | 1009 | ERR_R_MALLOC_FAILURE); |
1020 | return 0; | 1010 | return 0; |
1021 | } | 1011 | } |
1022 | 1012 | ||
1023 | object->data.number = data; | 1013 | object->data.number = data; |
1024 | 1014 | ||
1025 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_NUMBER, object, | 1015 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_NUMBER, object, |
1026 | attributes, parameters); | 1016 | attributes, parameters); |
1027 | 1017 | ||
1028 | STORE_OBJECT_free(object); | 1018 | STORE_OBJECT_free(object); |
1029 | 1019 | ||
1030 | if (!i) | 1020 | if (!i) { |
1031 | { | ||
1032 | STOREerr(STORE_F_STORE_STORE_NUMBER, | 1021 | STOREerr(STORE_F_STORE_STORE_NUMBER, |
1033 | STORE_R_FAILED_STORING_NUMBER); | 1022 | STORE_R_FAILED_STORING_NUMBER); |
1034 | return 0; | 1023 | return 0; |
1035 | } | ||
1036 | return 1; | ||
1037 | } | 1024 | } |
1025 | return 1; | ||
1026 | } | ||
1038 | 1027 | ||
1039 | int STORE_modify_number(STORE *s, OPENSSL_ITEM search_attributes[], | 1028 | int |
1040 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | 1029 | STORE_modify_number(STORE *s, OPENSSL_ITEM search_attributes[], |
1041 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) | 1030 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], |
1042 | { | 1031 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) |
1043 | check_store(s,STORE_F_STORE_MODIFY_NUMBER, | 1032 | { |
1044 | modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION); | 1033 | check_store(s, STORE_F_STORE_MODIFY_NUMBER, |
1034 | modify_object, STORE_R_NO_MODIFY_OBJECT_FUNCTION); | ||
1045 | 1035 | ||
1046 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_NUMBER, | 1036 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_NUMBER, |
1047 | search_attributes, add_attributes, modify_attributes, | 1037 | search_attributes, add_attributes, modify_attributes, |
1048 | delete_attributes, parameters)) | 1038 | delete_attributes, parameters)) { |
1049 | { | ||
1050 | STOREerr(STORE_F_STORE_MODIFY_NUMBER, | 1039 | STOREerr(STORE_F_STORE_MODIFY_NUMBER, |
1051 | STORE_R_FAILED_MODIFYING_NUMBER); | 1040 | STORE_R_FAILED_MODIFYING_NUMBER); |
1052 | return 0; | 1041 | return 0; |
1053 | } | ||
1054 | return 1; | ||
1055 | } | 1042 | } |
1043 | return 1; | ||
1044 | } | ||
1056 | 1045 | ||
1057 | BIGNUM *STORE_get_number(STORE *s, OPENSSL_ITEM attributes[], | 1046 | BIGNUM * |
1058 | OPENSSL_ITEM parameters[]) | 1047 | STORE_get_number(STORE *s, OPENSSL_ITEM attributes[], |
1059 | { | 1048 | OPENSSL_ITEM parameters[]) |
1049 | { | ||
1060 | STORE_OBJECT *object; | 1050 | STORE_OBJECT *object; |
1061 | BIGNUM *n; | 1051 | BIGNUM *n; |
1062 | 1052 | ||
1063 | check_store(s,STORE_F_STORE_GET_NUMBER, | 1053 | check_store(s, STORE_F_STORE_GET_NUMBER, |
1064 | get_object,STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION); | 1054 | get_object, STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION); |
1065 | 1055 | ||
1066 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_NUMBER, attributes, | 1056 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_NUMBER, attributes, |
1067 | parameters); | 1057 | parameters); |
1068 | if (!object || !object->data.number) | 1058 | if (!object || !object->data.number) { |
1069 | { | ||
1070 | STOREerr(STORE_F_STORE_GET_NUMBER, | 1059 | STOREerr(STORE_F_STORE_GET_NUMBER, |
1071 | STORE_R_FAILED_GETTING_NUMBER); | 1060 | STORE_R_FAILED_GETTING_NUMBER); |
1072 | return 0; | 1061 | return 0; |
1073 | } | 1062 | } |
1074 | n = object->data.number; | 1063 | n = object->data.number; |
1075 | object->data.number = NULL; | 1064 | object->data.number = NULL; |
1076 | STORE_OBJECT_free(object); | 1065 | STORE_OBJECT_free(object); |
1077 | return n; | 1066 | return n; |
1078 | } | 1067 | } |
1079 | 1068 | ||
1080 | int STORE_delete_number(STORE *s, OPENSSL_ITEM attributes[], | 1069 | int |
1081 | OPENSSL_ITEM parameters[]) | 1070 | STORE_delete_number(STORE *s, OPENSSL_ITEM attributes[], |
1082 | { | 1071 | OPENSSL_ITEM parameters[]) |
1083 | check_store(s,STORE_F_STORE_DELETE_NUMBER, | 1072 | { |
1084 | delete_object,STORE_R_NO_DELETE_NUMBER_FUNCTION); | 1073 | check_store(s, STORE_F_STORE_DELETE_NUMBER, |
1074 | delete_object, STORE_R_NO_DELETE_NUMBER_FUNCTION); | ||
1085 | 1075 | ||
1086 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_NUMBER, attributes, | 1076 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_NUMBER, attributes, |
1087 | parameters)) | 1077 | parameters)) { |
1088 | { | ||
1089 | STOREerr(STORE_F_STORE_DELETE_NUMBER, | 1078 | STOREerr(STORE_F_STORE_DELETE_NUMBER, |
1090 | STORE_R_FAILED_DELETING_NUMBER); | 1079 | STORE_R_FAILED_DELETING_NUMBER); |
1091 | return 0; | 1080 | return 0; |
1092 | } | ||
1093 | return 1; | ||
1094 | } | 1081 | } |
1082 | return 1; | ||
1083 | } | ||
1095 | 1084 | ||
1096 | int STORE_store_arbitrary(STORE *s, BUF_MEM *data, OPENSSL_ITEM attributes[], | 1085 | int |
1097 | OPENSSL_ITEM parameters[]) | 1086 | STORE_store_arbitrary(STORE *s, BUF_MEM *data, OPENSSL_ITEM attributes[], |
1098 | { | 1087 | OPENSSL_ITEM parameters[]) |
1088 | { | ||
1099 | STORE_OBJECT *object; | 1089 | STORE_OBJECT *object; |
1100 | int i; | 1090 | int i; |
1101 | 1091 | ||
1102 | check_store(s,STORE_F_STORE_STORE_ARBITRARY, | 1092 | check_store(s, STORE_F_STORE_STORE_ARBITRARY, |
1103 | store_object,STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION); | 1093 | store_object, STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION); |
1104 | 1094 | ||
1105 | object = STORE_OBJECT_new(); | 1095 | object = STORE_OBJECT_new(); |
1106 | if (!object) | 1096 | if (!object) { |
1107 | { | ||
1108 | STOREerr(STORE_F_STORE_STORE_ARBITRARY, | 1097 | STOREerr(STORE_F_STORE_STORE_ARBITRARY, |
1109 | ERR_R_MALLOC_FAILURE); | 1098 | ERR_R_MALLOC_FAILURE); |
1110 | return 0; | 1099 | return 0; |
1111 | } | 1100 | } |
1112 | 1101 | ||
1113 | object->data.arbitrary = data; | 1102 | object->data.arbitrary = data; |
1114 | 1103 | ||
1115 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_ARBITRARY, object, | 1104 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_ARBITRARY, object, |
1116 | attributes, parameters); | 1105 | attributes, parameters); |
1117 | 1106 | ||
1118 | STORE_OBJECT_free(object); | 1107 | STORE_OBJECT_free(object); |
1119 | 1108 | ||
1120 | if (!i) | 1109 | if (!i) { |
1121 | { | ||
1122 | STOREerr(STORE_F_STORE_STORE_ARBITRARY, | 1110 | STOREerr(STORE_F_STORE_STORE_ARBITRARY, |
1123 | STORE_R_FAILED_STORING_ARBITRARY); | 1111 | STORE_R_FAILED_STORING_ARBITRARY); |
1124 | return 0; | 1112 | return 0; |
1125 | } | ||
1126 | return 1; | ||
1127 | } | 1113 | } |
1114 | return 1; | ||
1115 | } | ||
1128 | 1116 | ||
1129 | int STORE_modify_arbitrary(STORE *s, OPENSSL_ITEM search_attributes[], | 1117 | int |
1130 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | 1118 | STORE_modify_arbitrary(STORE *s, OPENSSL_ITEM search_attributes[], |
1131 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) | 1119 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], |
1132 | { | 1120 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) |
1133 | check_store(s,STORE_F_STORE_MODIFY_ARBITRARY, | 1121 | { |
1134 | modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION); | 1122 | check_store(s, STORE_F_STORE_MODIFY_ARBITRARY, |
1123 | modify_object, STORE_R_NO_MODIFY_OBJECT_FUNCTION); | ||
1135 | 1124 | ||
1136 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_ARBITRARY, | 1125 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_ARBITRARY, |
1137 | search_attributes, add_attributes, modify_attributes, | 1126 | search_attributes, add_attributes, modify_attributes, |
1138 | delete_attributes, parameters)) | 1127 | delete_attributes, parameters)) { |
1139 | { | ||
1140 | STOREerr(STORE_F_STORE_MODIFY_ARBITRARY, | 1128 | STOREerr(STORE_F_STORE_MODIFY_ARBITRARY, |
1141 | STORE_R_FAILED_MODIFYING_ARBITRARY); | 1129 | STORE_R_FAILED_MODIFYING_ARBITRARY); |
1142 | return 0; | 1130 | return 0; |
1143 | } | ||
1144 | return 1; | ||
1145 | } | 1131 | } |
1132 | return 1; | ||
1133 | } | ||
1146 | 1134 | ||
1147 | BUF_MEM *STORE_get_arbitrary(STORE *s, OPENSSL_ITEM attributes[], | 1135 | BUF_MEM * |
1148 | OPENSSL_ITEM parameters[]) | 1136 | STORE_get_arbitrary(STORE *s, OPENSSL_ITEM attributes[], |
1149 | { | 1137 | OPENSSL_ITEM parameters[]) |
1138 | { | ||
1150 | STORE_OBJECT *object; | 1139 | STORE_OBJECT *object; |
1151 | BUF_MEM *b; | 1140 | BUF_MEM *b; |
1152 | 1141 | ||
1153 | check_store(s,STORE_F_STORE_GET_ARBITRARY, | 1142 | check_store(s, STORE_F_STORE_GET_ARBITRARY, |
1154 | get_object,STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION); | 1143 | get_object, STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION); |
1155 | 1144 | ||
1156 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_ARBITRARY, | 1145 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_ARBITRARY, |
1157 | attributes, parameters); | 1146 | attributes, parameters); |
1158 | if (!object || !object->data.arbitrary) | 1147 | if (!object || !object->data.arbitrary) { |
1159 | { | ||
1160 | STOREerr(STORE_F_STORE_GET_ARBITRARY, | 1148 | STOREerr(STORE_F_STORE_GET_ARBITRARY, |
1161 | STORE_R_FAILED_GETTING_ARBITRARY); | 1149 | STORE_R_FAILED_GETTING_ARBITRARY); |
1162 | return 0; | 1150 | return 0; |
1163 | } | 1151 | } |
1164 | b = object->data.arbitrary; | 1152 | b = object->data.arbitrary; |
1165 | object->data.arbitrary = NULL; | 1153 | object->data.arbitrary = NULL; |
1166 | STORE_OBJECT_free(object); | 1154 | STORE_OBJECT_free(object); |
1167 | return b; | 1155 | return b; |
1168 | } | 1156 | } |
1169 | 1157 | ||
1170 | int STORE_delete_arbitrary(STORE *s, OPENSSL_ITEM attributes[], | 1158 | int |
1171 | OPENSSL_ITEM parameters[]) | 1159 | STORE_delete_arbitrary(STORE *s, OPENSSL_ITEM attributes[], |
1172 | { | 1160 | OPENSSL_ITEM parameters[]) |
1173 | check_store(s,STORE_F_STORE_DELETE_ARBITRARY, | 1161 | { |
1174 | delete_object,STORE_R_NO_DELETE_ARBITRARY_FUNCTION); | 1162 | check_store(s, STORE_F_STORE_DELETE_ARBITRARY, |
1163 | delete_object, STORE_R_NO_DELETE_ARBITRARY_FUNCTION); | ||
1175 | 1164 | ||
1176 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_ARBITRARY, attributes, | 1165 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_ARBITRARY, attributes, |
1177 | parameters)) | 1166 | parameters)) { |
1178 | { | ||
1179 | STOREerr(STORE_F_STORE_DELETE_ARBITRARY, | 1167 | STOREerr(STORE_F_STORE_DELETE_ARBITRARY, |
1180 | STORE_R_FAILED_DELETING_ARBITRARY); | 1168 | STORE_R_FAILED_DELETING_ARBITRARY); |
1181 | return 0; | 1169 | return 0; |
1182 | } | ||
1183 | return 1; | ||
1184 | } | 1170 | } |
1171 | return 1; | ||
1172 | } | ||
1185 | 1173 | ||
1186 | STORE_OBJECT *STORE_OBJECT_new(void) | 1174 | STORE_OBJECT * |
1187 | { | 1175 | STORE_OBJECT_new(void) |
1176 | { | ||
1188 | STORE_OBJECT *object = malloc(sizeof(STORE_OBJECT)); | 1177 | STORE_OBJECT *object = malloc(sizeof(STORE_OBJECT)); |
1189 | if (object) memset(object, 0, sizeof(STORE_OBJECT)); | 1178 | |
1179 | if (object) | ||
1180 | memset(object, 0, sizeof(STORE_OBJECT)); | ||
1190 | return object; | 1181 | return object; |
1191 | } | 1182 | } |
1192 | void STORE_OBJECT_free(STORE_OBJECT *data) | 1183 | |
1193 | { | 1184 | void |
1194 | if (!data) return; | 1185 | STORE_OBJECT_free(STORE_OBJECT *data) |
1195 | switch (data->type) | 1186 | { |
1196 | { | 1187 | if (!data) |
1188 | return; | ||
1189 | switch (data->type) { | ||
1197 | case STORE_OBJECT_TYPE_X509_CERTIFICATE: | 1190 | case STORE_OBJECT_TYPE_X509_CERTIFICATE: |
1198 | X509_free(data->data.x509.certificate); | 1191 | X509_free(data->data.x509.certificate); |
1199 | break; | 1192 | break; |
@@ -1210,43 +1203,42 @@ void STORE_OBJECT_free(STORE_OBJECT *data) | |||
1210 | case STORE_OBJECT_TYPE_ARBITRARY: | 1203 | case STORE_OBJECT_TYPE_ARBITRARY: |
1211 | BUF_MEM_free(data->data.arbitrary); | 1204 | BUF_MEM_free(data->data.arbitrary); |
1212 | break; | 1205 | break; |
1213 | } | ||
1214 | free(data); | ||
1215 | } | 1206 | } |
1207 | free(data); | ||
1208 | } | ||
1216 | 1209 | ||
1217 | IMPLEMENT_STACK_OF(STORE_OBJECT*) | 1210 | IMPLEMENT_STACK_OF(STORE_OBJECT*) |
1218 | 1211 | ||
1219 | 1212 | ||
1220 | struct STORE_attr_info_st | 1213 | struct STORE_attr_info_st { |
1221 | { | ||
1222 | unsigned char set[(STORE_ATTR_TYPE_NUM + 8) / 8]; | 1214 | unsigned char set[(STORE_ATTR_TYPE_NUM + 8) / 8]; |
1223 | union | 1215 | union { |
1224 | { | ||
1225 | char *cstring; | 1216 | char *cstring; |
1226 | unsigned char *sha1string; | 1217 | unsigned char *sha1string; |
1227 | X509_NAME *dn; | 1218 | X509_NAME *dn; |
1228 | BIGNUM *number; | 1219 | BIGNUM *number; |
1229 | void *any; | 1220 | void *any; |
1230 | } values[STORE_ATTR_TYPE_NUM+1]; | 1221 | } values[STORE_ATTR_TYPE_NUM + 1]; |
1231 | size_t value_sizes[STORE_ATTR_TYPE_NUM+1]; | 1222 | size_t value_sizes[STORE_ATTR_TYPE_NUM + 1]; |
1232 | }; | 1223 | }; |
1233 | 1224 | ||
1234 | #define ATTR_IS_SET(a,i) ((i) > 0 && (i) < STORE_ATTR_TYPE_NUM \ | 1225 | #define ATTR_IS_SET(a,i) ((i) > 0 && (i) < STORE_ATTR_TYPE_NUM \ |
1235 | && ((a)->set[(i) / 8] & (1 << ((i) % 8)))) | 1226 | && ((a)->set[(i) / 8] & (1 << ((i) % 8)))) |
1236 | #define SET_ATTRBIT(a,i) ((a)->set[(i) / 8] |= (1 << ((i) % 8))) | 1227 | #define SET_ATTRBIT(a,i) ((a)->set[(i) / 8] |= (1 << ((i) % 8))) |
1237 | #define CLEAR_ATTRBIT(a,i) ((a)->set[(i) / 8] &= ~(1 << ((i) % 8))) | 1228 | #define CLEAR_ATTRBIT(a,i) ((a)->set[(i) / 8] &= ~(1 << ((i) % 8))) |
1238 | 1229 | ||
1239 | STORE_ATTR_INFO *STORE_ATTR_INFO_new(void) | 1230 | STORE_ATTR_INFO * |
1240 | { | 1231 | STORE_ATTR_INFO_new(void) |
1232 | { | ||
1241 | return (STORE_ATTR_INFO *)malloc(sizeof(STORE_ATTR_INFO)); | 1233 | return (STORE_ATTR_INFO *)malloc(sizeof(STORE_ATTR_INFO)); |
1242 | } | 1234 | } |
1243 | static void STORE_ATTR_INFO_attr_free(STORE_ATTR_INFO *attrs, | 1235 | |
1244 | STORE_ATTR_TYPES code) | 1236 | static void |
1245 | { | 1237 | STORE_ATTR_INFO_attr_free(STORE_ATTR_INFO *attrs, |
1246 | if (ATTR_IS_SET(attrs,code)) | 1238 | STORE_ATTR_TYPES code) |
1247 | { | 1239 | { |
1248 | switch(code) | 1240 | if (ATTR_IS_SET(attrs, code)) { |
1249 | { | 1241 | switch (code) { |
1250 | case STORE_ATTR_FRIENDLYNAME: | 1242 | case STORE_ATTR_FRIENDLYNAME: |
1251 | case STORE_ATTR_EMAIL: | 1243 | case STORE_ATTR_EMAIL: |
1252 | case STORE_ATTR_FILENAME: | 1244 | case STORE_ATTR_FILENAME: |
@@ -1268,492 +1260,538 @@ static void STORE_ATTR_INFO_attr_free(STORE_ATTR_INFO *attrs, | |||
1268 | break; | 1260 | break; |
1269 | default: | 1261 | default: |
1270 | break; | 1262 | break; |
1271 | } | ||
1272 | } | 1263 | } |
1273 | } | 1264 | } |
1274 | int STORE_ATTR_INFO_free(STORE_ATTR_INFO *attrs) | 1265 | } |
1275 | { | 1266 | |
1276 | if (attrs) | 1267 | int |
1277 | { | 1268 | STORE_ATTR_INFO_free(STORE_ATTR_INFO *attrs) |
1269 | { | ||
1270 | if (attrs) { | ||
1278 | STORE_ATTR_TYPES i; | 1271 | STORE_ATTR_TYPES i; |
1279 | for(i = 0; i++ < STORE_ATTR_TYPE_NUM;) | 1272 | for (i = 0; i++ < STORE_ATTR_TYPE_NUM; ) |
1280 | STORE_ATTR_INFO_attr_free(attrs, i); | 1273 | STORE_ATTR_INFO_attr_free(attrs, i); |
1281 | free(attrs); | 1274 | free(attrs); |
1282 | } | ||
1283 | return 1; | ||
1284 | } | 1275 | } |
1285 | char *STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code) | 1276 | return 1; |
1286 | { | 1277 | } |
1287 | if (!attrs) | 1278 | |
1288 | { | 1279 | char * |
1280 | STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code) | ||
1281 | { | ||
1282 | if (!attrs) { | ||
1289 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_CSTR, | 1283 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_CSTR, |
1290 | ERR_R_PASSED_NULL_PARAMETER); | 1284 | ERR_R_PASSED_NULL_PARAMETER); |
1291 | return NULL; | 1285 | return NULL; |
1292 | } | 1286 | } |
1293 | if (ATTR_IS_SET(attrs,code)) | 1287 | if (ATTR_IS_SET(attrs, code)) |
1294 | return attrs->values[code].cstring; | 1288 | return attrs->values[code].cstring; |
1295 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_CSTR, | 1289 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_CSTR, STORE_R_NO_VALUE); |
1296 | STORE_R_NO_VALUE); | ||
1297 | return NULL; | 1290 | return NULL; |
1298 | } | 1291 | } |
1299 | unsigned char *STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs, | 1292 | |
1300 | STORE_ATTR_TYPES code) | 1293 | unsigned char * |
1301 | { | 1294 | STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code) |
1302 | if (!attrs) | 1295 | { |
1303 | { | 1296 | if (!attrs) { |
1304 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_SHA1STR, | 1297 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_SHA1STR, |
1305 | ERR_R_PASSED_NULL_PARAMETER); | 1298 | ERR_R_PASSED_NULL_PARAMETER); |
1306 | return NULL; | 1299 | return NULL; |
1307 | } | 1300 | } |
1308 | if (ATTR_IS_SET(attrs,code)) | 1301 | if (ATTR_IS_SET(attrs, code)) |
1309 | return attrs->values[code].sha1string; | 1302 | return attrs->values[code].sha1string; |
1310 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_SHA1STR, | 1303 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_SHA1STR, STORE_R_NO_VALUE); |
1311 | STORE_R_NO_VALUE); | ||
1312 | return NULL; | 1304 | return NULL; |
1313 | } | 1305 | } |
1314 | X509_NAME *STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code) | 1306 | |
1315 | { | 1307 | X509_NAME * |
1316 | if (!attrs) | 1308 | STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code) |
1317 | { | 1309 | { |
1310 | if (!attrs) { | ||
1318 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_DN, | 1311 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_DN, |
1319 | ERR_R_PASSED_NULL_PARAMETER); | 1312 | ERR_R_PASSED_NULL_PARAMETER); |
1320 | return NULL; | 1313 | return NULL; |
1321 | } | 1314 | } |
1322 | if (ATTR_IS_SET(attrs,code)) | 1315 | if (ATTR_IS_SET(attrs, code)) |
1323 | return attrs->values[code].dn; | 1316 | return attrs->values[code].dn; |
1324 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_DN, | 1317 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_DN, STORE_R_NO_VALUE); |
1325 | STORE_R_NO_VALUE); | ||
1326 | return NULL; | 1318 | return NULL; |
1327 | } | 1319 | } |
1328 | BIGNUM *STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code) | 1320 | |
1329 | { | 1321 | BIGNUM * |
1330 | if (!attrs) | 1322 | STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code) |
1331 | { | 1323 | { |
1324 | if (!attrs) { | ||
1332 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_NUMBER, | 1325 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_NUMBER, |
1333 | ERR_R_PASSED_NULL_PARAMETER); | 1326 | ERR_R_PASSED_NULL_PARAMETER); |
1334 | return NULL; | 1327 | return NULL; |
1335 | } | 1328 | } |
1336 | if (ATTR_IS_SET(attrs,code)) | 1329 | if (ATTR_IS_SET(attrs, code)) |
1337 | return attrs->values[code].number; | 1330 | return attrs->values[code].number; |
1338 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_NUMBER, | 1331 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_NUMBER, STORE_R_NO_VALUE); |
1339 | STORE_R_NO_VALUE); | ||
1340 | return NULL; | 1332 | return NULL; |
1341 | } | 1333 | } |
1342 | int STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 1334 | |
1343 | char *cstr, size_t cstr_size) | 1335 | int |
1344 | { | 1336 | STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
1345 | if (!attrs) | 1337 | char *cstr, size_t cstr_size) |
1346 | { | 1338 | { |
1339 | if (!attrs) { | ||
1347 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR, | 1340 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR, |
1348 | ERR_R_PASSED_NULL_PARAMETER); | 1341 | ERR_R_PASSED_NULL_PARAMETER); |
1349 | return 0; | 1342 | return 0; |
1350 | } | 1343 | } |
1351 | if (!ATTR_IS_SET(attrs,code)) | 1344 | if (!ATTR_IS_SET(attrs, code)) { |
1352 | { | ||
1353 | if ((attrs->values[code].cstring = BUF_strndup(cstr, cstr_size))) | 1345 | if ((attrs->values[code].cstring = BUF_strndup(cstr, cstr_size))) |
1354 | return 1; | 1346 | return 1; |
1355 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR, | 1347 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR, |
1356 | ERR_R_MALLOC_FAILURE); | 1348 | ERR_R_MALLOC_FAILURE); |
1357 | return 0; | 1349 | return 0; |
1358 | } | 1350 | } |
1359 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR, STORE_R_ALREADY_HAS_A_VALUE); | 1351 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR, STORE_R_ALREADY_HAS_A_VALUE); |
1360 | return 0; | 1352 | return 0; |
1361 | } | 1353 | } |
1362 | int STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 1354 | |
1363 | unsigned char *sha1str, size_t sha1str_size) | 1355 | int |
1364 | { | 1356 | STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
1365 | if (!attrs) | 1357 | unsigned char *sha1str, size_t sha1str_size) |
1366 | { | 1358 | { |
1359 | if (!attrs) { | ||
1367 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR, | 1360 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR, |
1368 | ERR_R_PASSED_NULL_PARAMETER); | 1361 | ERR_R_PASSED_NULL_PARAMETER); |
1369 | return 0; | 1362 | return 0; |
1370 | } | 1363 | } |
1371 | if (!ATTR_IS_SET(attrs,code)) | 1364 | if (!ATTR_IS_SET(attrs, code)) { |
1372 | { | ||
1373 | if ((attrs->values[code].sha1string = | 1365 | if ((attrs->values[code].sha1string = |
1374 | (unsigned char *)BUF_memdup(sha1str, | 1366 | (unsigned char *)BUF_memdup(sha1str, |
1375 | sha1str_size))) | 1367 | sha1str_size))) |
1376 | return 1; | 1368 | return 1; |
1377 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR, | 1369 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR, |
1378 | ERR_R_MALLOC_FAILURE); | 1370 | ERR_R_MALLOC_FAILURE); |
1379 | return 0; | 1371 | return 0; |
1380 | } | ||
1381 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR, STORE_R_ALREADY_HAS_A_VALUE); | ||
1382 | return 0; | ||
1383 | } | 1372 | } |
1384 | int STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 1373 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR, |
1385 | X509_NAME *dn) | 1374 | STORE_R_ALREADY_HAS_A_VALUE); |
1386 | { | 1375 | return 0; |
1387 | if (!attrs) | 1376 | } |
1388 | { | 1377 | |
1378 | int | ||
1379 | STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | ||
1380 | X509_NAME *dn) | ||
1381 | { | ||
1382 | if (!attrs) { | ||
1389 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN, | 1383 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN, |
1390 | ERR_R_PASSED_NULL_PARAMETER); | 1384 | ERR_R_PASSED_NULL_PARAMETER); |
1391 | return 0; | 1385 | return 0; |
1392 | } | 1386 | } |
1393 | if (!ATTR_IS_SET(attrs,code)) | 1387 | if (!ATTR_IS_SET(attrs, code)) { |
1394 | { | ||
1395 | if ((attrs->values[code].dn = X509_NAME_dup(dn))) | 1388 | if ((attrs->values[code].dn = X509_NAME_dup(dn))) |
1396 | return 1; | 1389 | return 1; |
1397 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN, | 1390 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN, |
1398 | ERR_R_MALLOC_FAILURE); | 1391 | ERR_R_MALLOC_FAILURE); |
1399 | return 0; | 1392 | return 0; |
1400 | } | 1393 | } |
1401 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN, STORE_R_ALREADY_HAS_A_VALUE); | 1394 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN, STORE_R_ALREADY_HAS_A_VALUE); |
1402 | return 0; | 1395 | return 0; |
1403 | } | 1396 | } |
1404 | int STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 1397 | |
1405 | BIGNUM *number) | 1398 | int |
1406 | { | 1399 | STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
1407 | if (!attrs) | 1400 | BIGNUM *number) |
1408 | { | 1401 | { |
1402 | if (!attrs) { | ||
1409 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER, | 1403 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER, |
1410 | ERR_R_PASSED_NULL_PARAMETER); | 1404 | ERR_R_PASSED_NULL_PARAMETER); |
1411 | return 0; | 1405 | return 0; |
1412 | } | 1406 | } |
1413 | if (!ATTR_IS_SET(attrs,code)) | 1407 | if (!ATTR_IS_SET(attrs, code)) { |
1414 | { | ||
1415 | if ((attrs->values[code].number = BN_dup(number))) | 1408 | if ((attrs->values[code].number = BN_dup(number))) |
1416 | return 1; | 1409 | return 1; |
1417 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER, | 1410 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER, |
1418 | ERR_R_MALLOC_FAILURE); | 1411 | ERR_R_MALLOC_FAILURE); |
1419 | return 0; | 1412 | return 0; |
1420 | } | ||
1421 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER, STORE_R_ALREADY_HAS_A_VALUE); | ||
1422 | return 0; | ||
1423 | } | 1413 | } |
1424 | int STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 1414 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER, |
1425 | char *cstr, size_t cstr_size) | 1415 | STORE_R_ALREADY_HAS_A_VALUE); |
1426 | { | 1416 | return 0; |
1427 | if (!attrs) | 1417 | } |
1428 | { | 1418 | |
1419 | int | ||
1420 | STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | ||
1421 | char *cstr, size_t cstr_size) | ||
1422 | { | ||
1423 | if (!attrs) { | ||
1429 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_CSTR, | 1424 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_CSTR, |
1430 | ERR_R_PASSED_NULL_PARAMETER); | 1425 | ERR_R_PASSED_NULL_PARAMETER); |
1431 | return 0; | 1426 | return 0; |
1432 | } | 1427 | } |
1433 | if (ATTR_IS_SET(attrs,code)) | 1428 | if (ATTR_IS_SET(attrs, code)) { |
1434 | { | ||
1435 | free(attrs->values[code].cstring); | 1429 | free(attrs->values[code].cstring); |
1436 | attrs->values[code].cstring = NULL; | 1430 | attrs->values[code].cstring = NULL; |
1437 | CLEAR_ATTRBIT(attrs, code); | 1431 | CLEAR_ATTRBIT(attrs, code); |
1438 | } | ||
1439 | return STORE_ATTR_INFO_set_cstr(attrs, code, cstr, cstr_size); | ||
1440 | } | 1432 | } |
1441 | int STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 1433 | return STORE_ATTR_INFO_set_cstr(attrs, code, cstr, cstr_size); |
1442 | unsigned char *sha1str, size_t sha1str_size) | 1434 | } |
1443 | { | 1435 | |
1444 | if (!attrs) | 1436 | int |
1445 | { | 1437 | STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
1438 | unsigned char *sha1str, size_t sha1str_size) | ||
1439 | { | ||
1440 | if (!attrs) { | ||
1446 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR, | 1441 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR, |
1447 | ERR_R_PASSED_NULL_PARAMETER); | 1442 | ERR_R_PASSED_NULL_PARAMETER); |
1448 | return 0; | 1443 | return 0; |
1449 | } | 1444 | } |
1450 | if (ATTR_IS_SET(attrs,code)) | 1445 | if (ATTR_IS_SET(attrs, code)) { |
1451 | { | ||
1452 | free(attrs->values[code].sha1string); | 1446 | free(attrs->values[code].sha1string); |
1453 | attrs->values[code].sha1string = NULL; | 1447 | attrs->values[code].sha1string = NULL; |
1454 | CLEAR_ATTRBIT(attrs, code); | 1448 | CLEAR_ATTRBIT(attrs, code); |
1455 | } | ||
1456 | return STORE_ATTR_INFO_set_sha1str(attrs, code, sha1str, sha1str_size); | ||
1457 | } | 1449 | } |
1458 | int STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 1450 | return STORE_ATTR_INFO_set_sha1str(attrs, code, sha1str, sha1str_size); |
1459 | X509_NAME *dn) | 1451 | } |
1460 | { | 1452 | |
1461 | if (!attrs) | 1453 | int |
1462 | { | 1454 | STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
1455 | X509_NAME *dn) | ||
1456 | { | ||
1457 | if (!attrs) { | ||
1463 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_DN, | 1458 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_DN, |
1464 | ERR_R_PASSED_NULL_PARAMETER); | 1459 | ERR_R_PASSED_NULL_PARAMETER); |
1465 | return 0; | 1460 | return 0; |
1466 | } | 1461 | } |
1467 | if (ATTR_IS_SET(attrs,code)) | 1462 | if (ATTR_IS_SET(attrs, code)) { |
1468 | { | ||
1469 | free(attrs->values[code].dn); | 1463 | free(attrs->values[code].dn); |
1470 | attrs->values[code].dn = NULL; | 1464 | attrs->values[code].dn = NULL; |
1471 | CLEAR_ATTRBIT(attrs, code); | 1465 | CLEAR_ATTRBIT(attrs, code); |
1472 | } | ||
1473 | return STORE_ATTR_INFO_set_dn(attrs, code, dn); | ||
1474 | } | 1466 | } |
1475 | int STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 1467 | return STORE_ATTR_INFO_set_dn(attrs, code, dn); |
1476 | BIGNUM *number) | 1468 | } |
1477 | { | 1469 | |
1478 | if (!attrs) | 1470 | int |
1479 | { | 1471 | STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
1472 | BIGNUM *number) | ||
1473 | { | ||
1474 | if (!attrs) { | ||
1480 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER, | 1475 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER, |
1481 | ERR_R_PASSED_NULL_PARAMETER); | 1476 | ERR_R_PASSED_NULL_PARAMETER); |
1482 | return 0; | 1477 | return 0; |
1483 | } | 1478 | } |
1484 | if (ATTR_IS_SET(attrs,code)) | 1479 | if (ATTR_IS_SET(attrs, code)) { |
1485 | { | ||
1486 | free(attrs->values[code].number); | 1480 | free(attrs->values[code].number); |
1487 | attrs->values[code].number = NULL; | 1481 | attrs->values[code].number = NULL; |
1488 | CLEAR_ATTRBIT(attrs, code); | 1482 | CLEAR_ATTRBIT(attrs, code); |
1489 | } | ||
1490 | return STORE_ATTR_INFO_set_number(attrs, code, number); | ||
1491 | } | 1483 | } |
1484 | return STORE_ATTR_INFO_set_number(attrs, code, number); | ||
1485 | } | ||
1492 | 1486 | ||
1493 | struct attr_list_ctx_st | 1487 | struct attr_list_ctx_st { |
1494 | { | ||
1495 | OPENSSL_ITEM *attributes; | 1488 | OPENSSL_ITEM *attributes; |
1496 | }; | 1489 | }; |
1497 | void *STORE_parse_attrs_start(OPENSSL_ITEM *attributes) | 1490 | |
1498 | { | 1491 | void * |
1499 | if (attributes) | 1492 | STORE_parse_attrs_start(OPENSSL_ITEM *attributes) |
1500 | { | 1493 | { |
1494 | if (attributes) { | ||
1501 | struct attr_list_ctx_st *context = | 1495 | struct attr_list_ctx_st *context = |
1502 | (struct attr_list_ctx_st *)malloc(sizeof(struct attr_list_ctx_st)); | 1496 | (struct attr_list_ctx_st *)malloc(sizeof(struct attr_list_ctx_st)); |
1503 | if (context) | 1497 | if (context) |
1504 | context->attributes = attributes; | 1498 | context->attributes = attributes; |
1505 | else | 1499 | else |
1506 | STOREerr(STORE_F_STORE_PARSE_ATTRS_START, | 1500 | STOREerr(STORE_F_STORE_PARSE_ATTRS_START, |
1507 | ERR_R_MALLOC_FAILURE); | 1501 | ERR_R_MALLOC_FAILURE); |
1508 | return context; | 1502 | return context; |
1509 | } | 1503 | } |
1510 | STOREerr(STORE_F_STORE_PARSE_ATTRS_START, ERR_R_PASSED_NULL_PARAMETER); | 1504 | STOREerr(STORE_F_STORE_PARSE_ATTRS_START, ERR_R_PASSED_NULL_PARAMETER); |
1511 | return 0; | 1505 | return 0; |
1512 | } | 1506 | } |
1513 | STORE_ATTR_INFO *STORE_parse_attrs_next(void *handle) | 1507 | |
1514 | { | 1508 | STORE_ATTR_INFO * |
1509 | STORE_parse_attrs_next(void *handle) | ||
1510 | { | ||
1515 | struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle; | 1511 | struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle; |
1516 | 1512 | ||
1517 | if (context && context->attributes) | 1513 | if (context && context->attributes) { |
1518 | { | ||
1519 | STORE_ATTR_INFO *attrs = NULL; | 1514 | STORE_ATTR_INFO *attrs = NULL; |
1520 | 1515 | ||
1521 | while(context->attributes | 1516 | while (context->attributes && |
1522 | && context->attributes->code != STORE_ATTR_OR | 1517 | context->attributes->code != STORE_ATTR_OR && |
1523 | && context->attributes->code != STORE_ATTR_END) | 1518 | context->attributes->code != STORE_ATTR_END) { |
1524 | { | 1519 | switch (context->attributes->code) { |
1525 | switch(context->attributes->code) | ||
1526 | { | ||
1527 | case STORE_ATTR_FRIENDLYNAME: | 1520 | case STORE_ATTR_FRIENDLYNAME: |
1528 | case STORE_ATTR_EMAIL: | 1521 | case STORE_ATTR_EMAIL: |
1529 | case STORE_ATTR_FILENAME: | 1522 | case STORE_ATTR_FILENAME: |
1530 | if (!attrs) attrs = STORE_ATTR_INFO_new(); | 1523 | if (!attrs) |
1531 | if (attrs == NULL) | 1524 | attrs = STORE_ATTR_INFO_new(); |
1532 | { | 1525 | if (attrs == NULL) { |
1533 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, | 1526 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, |
1534 | ERR_R_MALLOC_FAILURE); | 1527 | ERR_R_MALLOC_FAILURE); |
1535 | goto err; | 1528 | goto err; |
1536 | } | 1529 | } |
1537 | STORE_ATTR_INFO_set_cstr(attrs, | 1530 | STORE_ATTR_INFO_set_cstr(attrs, |
1538 | context->attributes->code, | 1531 | context->attributes->code, |
1539 | context->attributes->value, | 1532 | context->attributes->value, |
1540 | context->attributes->value_size); | 1533 | context->attributes->value_size); |
1541 | break; | 1534 | break; |
1542 | case STORE_ATTR_KEYID: | 1535 | case STORE_ATTR_KEYID: |
1543 | case STORE_ATTR_ISSUERKEYID: | 1536 | case STORE_ATTR_ISSUERKEYID: |
1544 | case STORE_ATTR_SUBJECTKEYID: | 1537 | case STORE_ATTR_SUBJECTKEYID: |
1545 | case STORE_ATTR_ISSUERSERIALHASH: | 1538 | case STORE_ATTR_ISSUERSERIALHASH: |
1546 | case STORE_ATTR_CERTHASH: | 1539 | case STORE_ATTR_CERTHASH: |
1547 | if (!attrs) attrs = STORE_ATTR_INFO_new(); | 1540 | if (!attrs) |
1548 | if (attrs == NULL) | 1541 | attrs = STORE_ATTR_INFO_new(); |
1549 | { | 1542 | if (attrs == NULL) { |
1550 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, | 1543 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, |
1551 | ERR_R_MALLOC_FAILURE); | 1544 | ERR_R_MALLOC_FAILURE); |
1552 | goto err; | 1545 | goto err; |
1553 | } | 1546 | } |
1554 | STORE_ATTR_INFO_set_sha1str(attrs, | 1547 | STORE_ATTR_INFO_set_sha1str(attrs, |
1555 | context->attributes->code, | 1548 | context->attributes->code, |
1556 | context->attributes->value, | 1549 | context->attributes->value, |
1557 | context->attributes->value_size); | 1550 | context->attributes->value_size); |
1558 | break; | 1551 | break; |
1559 | case STORE_ATTR_ISSUER: | 1552 | case STORE_ATTR_ISSUER: |
1560 | case STORE_ATTR_SUBJECT: | 1553 | case STORE_ATTR_SUBJECT: |
1561 | if (!attrs) attrs = STORE_ATTR_INFO_new(); | 1554 | if (!attrs) |
1562 | if (attrs == NULL) | 1555 | attrs = STORE_ATTR_INFO_new(); |
1563 | { | 1556 | if (attrs == NULL) { |
1564 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, | 1557 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, |
1565 | ERR_R_MALLOC_FAILURE); | 1558 | ERR_R_MALLOC_FAILURE); |
1566 | goto err; | 1559 | goto err; |
1567 | } | 1560 | } |
1568 | STORE_ATTR_INFO_modify_dn(attrs, | 1561 | STORE_ATTR_INFO_modify_dn(attrs, |
1569 | context->attributes->code, | 1562 | context->attributes->code, |
1570 | context->attributes->value); | 1563 | context->attributes->value); |
1571 | break; | 1564 | break; |
1572 | case STORE_ATTR_SERIAL: | 1565 | case STORE_ATTR_SERIAL: |
1573 | if (!attrs) attrs = STORE_ATTR_INFO_new(); | 1566 | if (!attrs) |
1574 | if (attrs == NULL) | 1567 | attrs = STORE_ATTR_INFO_new(); |
1575 | { | 1568 | if (attrs == NULL) { |
1576 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, | 1569 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, |
1577 | ERR_R_MALLOC_FAILURE); | 1570 | ERR_R_MALLOC_FAILURE); |
1578 | goto err; | 1571 | goto err; |
1579 | } | 1572 | } |
1580 | STORE_ATTR_INFO_modify_number(attrs, | 1573 | STORE_ATTR_INFO_modify_number(attrs, |
1581 | context->attributes->code, | 1574 | context->attributes->code, |
1582 | context->attributes->value); | 1575 | context->attributes->value); |
1583 | break; | 1576 | break; |
1584 | } | ||
1585 | context->attributes++; | ||
1586 | } | 1577 | } |
1578 | context->attributes++; | ||
1579 | } | ||
1587 | if (context->attributes->code == STORE_ATTR_OR) | 1580 | if (context->attributes->code == STORE_ATTR_OR) |
1588 | context->attributes++; | 1581 | context->attributes++; |
1589 | return attrs; | 1582 | return attrs; |
1590 | err: | 1583 | |
1591 | while(context->attributes | 1584 | err: |
1592 | && context->attributes->code != STORE_ATTR_OR | 1585 | while (context->attributes && |
1593 | && context->attributes->code != STORE_ATTR_END) | 1586 | context->attributes->code != STORE_ATTR_OR && |
1587 | context->attributes->code != STORE_ATTR_END) | ||
1594 | context->attributes++; | 1588 | context->attributes++; |
1595 | if (context->attributes->code == STORE_ATTR_OR) | 1589 | if (context->attributes->code == STORE_ATTR_OR) |
1596 | context->attributes++; | 1590 | context->attributes++; |
1597 | return NULL; | 1591 | return NULL; |
1598 | } | 1592 | } |
1599 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, ERR_R_PASSED_NULL_PARAMETER); | 1593 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, ERR_R_PASSED_NULL_PARAMETER); |
1600 | return NULL; | 1594 | return NULL; |
1601 | } | 1595 | } |
1602 | int STORE_parse_attrs_end(void *handle) | 1596 | |
1603 | { | 1597 | int |
1598 | STORE_parse_attrs_end(void *handle) | ||
1599 | { | ||
1604 | struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle; | 1600 | struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle; |
1605 | 1601 | ||
1606 | if (context && context->attributes) | 1602 | if (context && context->attributes) { |
1607 | { | ||
1608 | #if 0 | 1603 | #if 0 |
1609 | OPENSSL_ITEM *attributes = context->attributes; | 1604 | OPENSSL_ITEM *attributes = context->attributes; |
1610 | #endif | 1605 | #endif |
1611 | free(context); | 1606 | free(context); |
1612 | return 1; | 1607 | return 1; |
1613 | } | 1608 | } |
1614 | STOREerr(STORE_F_STORE_PARSE_ATTRS_END, ERR_R_PASSED_NULL_PARAMETER); | 1609 | STOREerr(STORE_F_STORE_PARSE_ATTRS_END, ERR_R_PASSED_NULL_PARAMETER); |
1615 | return 0; | 1610 | return 0; |
1616 | } | 1611 | } |
1617 | 1612 | ||
1618 | int STORE_parse_attrs_endp(void *handle) | 1613 | int |
1619 | { | 1614 | STORE_parse_attrs_endp(void *handle) |
1615 | { | ||
1620 | struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle; | 1616 | struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle; |
1621 | 1617 | ||
1622 | if (context && context->attributes) | 1618 | if (context && context->attributes) { |
1623 | { | ||
1624 | return context->attributes->code == STORE_ATTR_END; | 1619 | return context->attributes->code == STORE_ATTR_END; |
1625 | } | 1620 | } |
1626 | STOREerr(STORE_F_STORE_PARSE_ATTRS_ENDP, ERR_R_PASSED_NULL_PARAMETER); | 1621 | STOREerr(STORE_F_STORE_PARSE_ATTRS_ENDP, ERR_R_PASSED_NULL_PARAMETER); |
1627 | return 0; | 1622 | return 0; |
1628 | } | 1623 | } |
1629 | 1624 | ||
1630 | static int attr_info_compare_compute_range( | 1625 | static int |
1631 | const unsigned char *abits, const unsigned char *bbits, | 1626 | attr_info_compare_compute_range(const unsigned char *abits, |
1632 | unsigned int *alowp, unsigned int *ahighp, | 1627 | const unsigned char *bbits, unsigned int *alowp, unsigned int *ahighp, |
1633 | unsigned int *blowp, unsigned int *bhighp) | 1628 | unsigned int *blowp, unsigned int *bhighp) |
1634 | { | 1629 | { |
1635 | unsigned int alow = (unsigned int)-1, ahigh = 0; | 1630 | unsigned int alow = (unsigned int) - 1, ahigh = 0; |
1636 | unsigned int blow = (unsigned int)-1, bhigh = 0; | 1631 | unsigned int blow = (unsigned int) - 1, bhigh = 0; |
1637 | int i, res = 0; | 1632 | int i, res = 0; |
1638 | 1633 | ||
1639 | for (i = 0; i < (STORE_ATTR_TYPE_NUM + 8) / 8; i++, abits++, bbits++) | 1634 | for (i = 0; i < (STORE_ATTR_TYPE_NUM + 8) / 8; i++, abits++, bbits++) { |
1640 | { | 1635 | if (res == 0) { |
1641 | if (res == 0) | 1636 | if (*abits < *bbits) |
1642 | { | 1637 | res = -1; |
1643 | if (*abits < *bbits) res = -1; | 1638 | if (*abits > *bbits) |
1644 | if (*abits > *bbits) res = 1; | 1639 | res = 1; |
1645 | } | 1640 | } |
1646 | if (*abits) | 1641 | if (*abits) { |
1647 | { | 1642 | if (alow == (unsigned int) - 1) { |
1648 | if (alow == (unsigned int)-1) | ||
1649 | { | ||
1650 | alow = i * 8; | 1643 | alow = i * 8; |
1651 | if (!(*abits & 0x01)) alow++; | 1644 | if (!(*abits & 0x01)) |
1652 | if (!(*abits & 0x02)) alow++; | 1645 | alow++; |
1653 | if (!(*abits & 0x04)) alow++; | 1646 | if (!(*abits & 0x02)) |
1654 | if (!(*abits & 0x08)) alow++; | 1647 | alow++; |
1655 | if (!(*abits & 0x10)) alow++; | 1648 | if (!(*abits & 0x04)) |
1656 | if (!(*abits & 0x20)) alow++; | 1649 | alow++; |
1657 | if (!(*abits & 0x40)) alow++; | 1650 | if (!(*abits & 0x08)) |
1658 | } | 1651 | alow++; |
1659 | ahigh = i * 8 + 7; | 1652 | if (!(*abits & 0x10)) |
1660 | if (!(*abits & 0x80)) ahigh++; | 1653 | alow++; |
1661 | if (!(*abits & 0x40)) ahigh++; | 1654 | if (!(*abits & 0x20)) |
1662 | if (!(*abits & 0x20)) ahigh++; | 1655 | alow++; |
1663 | if (!(*abits & 0x10)) ahigh++; | 1656 | if (!(*abits & 0x40)) |
1664 | if (!(*abits & 0x08)) ahigh++; | 1657 | alow++; |
1665 | if (!(*abits & 0x04)) ahigh++; | ||
1666 | if (!(*abits & 0x02)) ahigh++; | ||
1667 | } | 1658 | } |
1668 | if (*bbits) | 1659 | ahigh = i * 8 + 7; |
1669 | { | 1660 | if (!(*abits & 0x80)) |
1670 | if (blow == (unsigned int)-1) | 1661 | ahigh++; |
1671 | { | 1662 | if (!(*abits & 0x40)) |
1663 | ahigh++; | ||
1664 | if (!(*abits & 0x20)) | ||
1665 | ahigh++; | ||
1666 | if (!(*abits & 0x10)) | ||
1667 | ahigh++; | ||
1668 | if (!(*abits & 0x08)) | ||
1669 | ahigh++; | ||
1670 | if (!(*abits & 0x04)) | ||
1671 | ahigh++; | ||
1672 | if (!(*abits & 0x02)) | ||
1673 | ahigh++; | ||
1674 | } | ||
1675 | if (*bbits) { | ||
1676 | if (blow == (unsigned int) - 1) { | ||
1672 | blow = i * 8; | 1677 | blow = i * 8; |
1673 | if (!(*bbits & 0x01)) blow++; | 1678 | if (!(*bbits & 0x01)) |
1674 | if (!(*bbits & 0x02)) blow++; | 1679 | blow++; |
1675 | if (!(*bbits & 0x04)) blow++; | 1680 | if (!(*bbits & 0x02)) |
1676 | if (!(*bbits & 0x08)) blow++; | 1681 | blow++; |
1677 | if (!(*bbits & 0x10)) blow++; | 1682 | if (!(*bbits & 0x04)) |
1678 | if (!(*bbits & 0x20)) blow++; | 1683 | blow++; |
1679 | if (!(*bbits & 0x40)) blow++; | 1684 | if (!(*bbits & 0x08)) |
1680 | } | 1685 | blow++; |
1681 | bhigh = i * 8 + 7; | 1686 | if (!(*bbits & 0x10)) |
1682 | if (!(*bbits & 0x80)) bhigh++; | 1687 | blow++; |
1683 | if (!(*bbits & 0x40)) bhigh++; | 1688 | if (!(*bbits & 0x20)) |
1684 | if (!(*bbits & 0x20)) bhigh++; | 1689 | blow++; |
1685 | if (!(*bbits & 0x10)) bhigh++; | 1690 | if (!(*bbits & 0x40)) |
1686 | if (!(*bbits & 0x08)) bhigh++; | 1691 | blow++; |
1687 | if (!(*bbits & 0x04)) bhigh++; | ||
1688 | if (!(*bbits & 0x02)) bhigh++; | ||
1689 | } | 1692 | } |
1690 | } | 1693 | bhigh = i * 8 + 7; |
1691 | if (ahigh + alow < bhigh + blow) res = -1; | 1694 | if (!(*bbits & 0x80)) |
1692 | if (ahigh + alow > bhigh + blow) res = 1; | 1695 | bhigh++; |
1693 | if (alowp) *alowp = alow; | 1696 | if (!(*bbits & 0x40)) |
1694 | if (ahighp) *ahighp = ahigh; | 1697 | bhigh++; |
1695 | if (blowp) *blowp = blow; | 1698 | if (!(*bbits & 0x20)) |
1696 | if (bhighp) *bhighp = bhigh; | 1699 | bhigh++; |
1700 | if (!(*bbits & 0x10)) | ||
1701 | bhigh++; | ||
1702 | if (!(*bbits & 0x08)) | ||
1703 | bhigh++; | ||
1704 | if (!(*bbits & 0x04)) | ||
1705 | bhigh++; | ||
1706 | if (!(*bbits & 0x02)) | ||
1707 | bhigh++; | ||
1708 | } | ||
1709 | } | ||
1710 | if (ahigh + alow < bhigh + blow) | ||
1711 | res = -1; | ||
1712 | if (ahigh + alow > bhigh + blow) | ||
1713 | res = 1; | ||
1714 | if (alowp) | ||
1715 | *alowp = alow; | ||
1716 | if (ahighp) | ||
1717 | *ahighp = ahigh; | ||
1718 | if (blowp) | ||
1719 | *blowp = blow; | ||
1720 | if (bhighp) | ||
1721 | *bhighp = bhigh; | ||
1697 | return res; | 1722 | return res; |
1698 | } | 1723 | } |
1699 | 1724 | ||
1700 | int STORE_ATTR_INFO_compare(const STORE_ATTR_INFO * const *a, | 1725 | int |
1701 | const STORE_ATTR_INFO * const *b) | 1726 | STORE_ATTR_INFO_compare(const STORE_ATTR_INFO * const *a, |
1702 | { | 1727 | const STORE_ATTR_INFO * const *b) |
1703 | if (a == b) return 0; | 1728 | { |
1704 | if (!a) return -1; | 1729 | if (a == b) |
1705 | if (!b) return 1; | 1730 | return 0; |
1706 | return attr_info_compare_compute_range((*a)->set, (*b)->set, 0, 0, 0, 0); | 1731 | if (!a) |
1707 | } | 1732 | return -1; |
1733 | if (!b) | ||
1734 | return 1; | ||
1735 | return attr_info_compare_compute_range((*a)->set, (*b)->set, | ||
1736 | 0, 0, 0, 0); | ||
1737 | } | ||
1708 | 1738 | ||
1709 | int STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) | 1739 | int |
1710 | { | 1740 | STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) |
1741 | { | ||
1711 | unsigned int alow, ahigh, blow, bhigh; | 1742 | unsigned int alow, ahigh, blow, bhigh; |
1712 | 1743 | ||
1713 | if (a == b) return 1; | 1744 | if (a == b) |
1714 | if (!a) return 0; | 1745 | return 1; |
1715 | if (!b) return 0; | 1746 | if (!a) |
1747 | return 0; | ||
1748 | if (!b) | ||
1749 | return 0; | ||
1716 | attr_info_compare_compute_range(a->set, b->set, | 1750 | attr_info_compare_compute_range(a->set, b->set, |
1717 | &alow, &ahigh, &blow, &bhigh); | 1751 | &alow, &ahigh, &blow, &bhigh); |
1718 | if (alow >= blow && ahigh <= bhigh) | 1752 | if (alow >= blow && ahigh <= bhigh) |
1719 | return 1; | 1753 | return 1; |
1720 | return 0; | 1754 | return 0; |
1721 | } | 1755 | } |
1722 | 1756 | ||
1723 | int STORE_ATTR_INFO_in(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) | 1757 | int |
1724 | { | 1758 | STORE_ATTR_INFO_in(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) |
1759 | { | ||
1725 | unsigned char *abits, *bbits; | 1760 | unsigned char *abits, *bbits; |
1726 | int i; | 1761 | int i; |
1727 | 1762 | ||
1728 | if (a == b) return 1; | 1763 | if (a == b) |
1729 | if (!a) return 0; | 1764 | return 1; |
1730 | if (!b) return 0; | 1765 | if (!a) |
1766 | return 0; | ||
1767 | if (!b) | ||
1768 | return 0; | ||
1731 | abits = a->set; | 1769 | abits = a->set; |
1732 | bbits = b->set; | 1770 | bbits = b->set; |
1733 | for (i = 0; i < (STORE_ATTR_TYPE_NUM + 8) / 8; i++, abits++, bbits++) | 1771 | for (i = 0; i < (STORE_ATTR_TYPE_NUM + 8) / 8; i++, abits++, bbits++) { |
1734 | { | ||
1735 | if (*abits && (*bbits & *abits) != *abits) | 1772 | if (*abits && (*bbits & *abits) != *abits) |
1736 | return 0; | 1773 | return 0; |
1737 | } | ||
1738 | return 1; | ||
1739 | } | 1774 | } |
1775 | return 1; | ||
1776 | } | ||
1740 | 1777 | ||
1741 | int STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) | 1778 | int |
1742 | { | 1779 | STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) |
1780 | { | ||
1743 | STORE_ATTR_TYPES i; | 1781 | STORE_ATTR_TYPES i; |
1744 | 1782 | ||
1745 | if (a == b) return 1; | 1783 | if (a == b) |
1746 | if (!STORE_ATTR_INFO_in(a, b)) return 0; | 1784 | return 1; |
1785 | if (!STORE_ATTR_INFO_in(a, b)) | ||
1786 | return 0; | ||
1747 | for (i = 1; i < STORE_ATTR_TYPE_NUM; i++) | 1787 | for (i = 1; i < STORE_ATTR_TYPE_NUM; i++) |
1748 | if (ATTR_IS_SET(a, i)) | 1788 | if (ATTR_IS_SET(a, i)) { |
1749 | { | 1789 | switch (i) { |
1750 | switch(i) | ||
1751 | { | ||
1752 | case STORE_ATTR_FRIENDLYNAME: | 1790 | case STORE_ATTR_FRIENDLYNAME: |
1753 | case STORE_ATTR_EMAIL: | 1791 | case STORE_ATTR_EMAIL: |
1754 | case STORE_ATTR_FILENAME: | 1792 | case STORE_ATTR_FILENAME: |
1755 | if (strcmp(a->values[i].cstring, | 1793 | if (strcmp(a->values[i].cstring, |
1756 | b->values[i].cstring)) | 1794 | b->values[i].cstring)) |
1757 | return 0; | 1795 | return 0; |
1758 | break; | 1796 | break; |
1759 | case STORE_ATTR_KEYID: | 1797 | case STORE_ATTR_KEYID: |
@@ -1762,25 +1800,25 @@ int STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) | |||
1762 | case STORE_ATTR_ISSUERSERIALHASH: | 1800 | case STORE_ATTR_ISSUERSERIALHASH: |
1763 | case STORE_ATTR_CERTHASH: | 1801 | case STORE_ATTR_CERTHASH: |
1764 | if (memcmp(a->values[i].sha1string, | 1802 | if (memcmp(a->values[i].sha1string, |
1765 | b->values[i].sha1string, | 1803 | b->values[i].sha1string, |
1766 | a->value_sizes[i])) | 1804 | a->value_sizes[i])) |
1767 | return 0; | 1805 | return 0; |
1768 | break; | 1806 | break; |
1769 | case STORE_ATTR_ISSUER: | 1807 | case STORE_ATTR_ISSUER: |
1770 | case STORE_ATTR_SUBJECT: | 1808 | case STORE_ATTR_SUBJECT: |
1771 | if (X509_NAME_cmp(a->values[i].dn, | 1809 | if (X509_NAME_cmp(a->values[i].dn, |
1772 | b->values[i].dn)) | 1810 | b->values[i].dn)) |
1773 | return 0; | 1811 | return 0; |
1774 | break; | 1812 | break; |
1775 | case STORE_ATTR_SERIAL: | 1813 | case STORE_ATTR_SERIAL: |
1776 | if (BN_cmp(a->values[i].number, | 1814 | if (BN_cmp(a->values[i].number, |
1777 | b->values[i].number)) | 1815 | b->values[i].number)) |
1778 | return 0; | 1816 | return 0; |
1779 | break; | 1817 | break; |
1780 | default: | 1818 | default: |
1781 | break; | 1819 | break; |
1782 | } | ||
1783 | } | 1820 | } |
1821 | } | ||
1784 | 1822 | ||
1785 | return 1; | 1823 | return 1; |
1786 | } | 1824 | } |