1 /* crypto/store/str_lib.c -*- mode:C; c-file-style: "eay" -*- */
2 /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
5 /* ====================================================================
6 * Copyright (c) 2003 The OpenSSL Project. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * openssl-core@openssl.org.
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
34 * 6. Redistributions of any form whatsoever must retain the following
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
60 #include <openssl/bn.h>
61 #include <openssl/err.h>
62 #include <openssl/engine.h>
65 const char * const STORE_object_type_string[STORE_OBJECT_TYPE_NUM+1] =
75 const int STORE_param_sizes[STORE_PARAM_TYPE_NUM+1] =
78 sizeof(int), /* EVP_TYPE */
79 sizeof(size_t), /* BITS */
80 -1, /* KEY_PARAMETERS */
81 0 /* KEY_NO_PARAMETERS */
84 const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM+1] =
87 -1, /* FRIENDLYNAME: C string */
88 SHA_DIGEST_LENGTH, /* KEYID: SHA1 digest, 160 bits */
89 SHA_DIGEST_LENGTH, /* ISSUERKEYID: SHA1 digest, 160 bits */
90 SHA_DIGEST_LENGTH, /* SUBJECTKEYID: SHA1 digest, 160 bits */
91 SHA_DIGEST_LENGTH, /* ISSUERSERIALHASH: SHA1 digest, 160 bits */
92 sizeof(X509_NAME *), /* ISSUER: X509_NAME * */
93 sizeof(BIGNUM *), /* SERIAL: BIGNUM * */
94 sizeof(X509_NAME *), /* SUBJECT: X509_NAME * */
95 SHA_DIGEST_LENGTH, /* CERTHASH: SHA1 digest, 160 bits */
96 -1, /* EMAIL: C string */
97 -1, /* FILENAME: C string */
100 STORE *STORE_new_method(const STORE_METHOD *method)
104 ret=(STORE *)OPENSSL_malloc(sizeof(STORE));
107 STOREerr(STORE_F_STORE_NEW_METHOD,ERR_R_MALLOC_FAILURE);
112 STOREerr(STORE_F_STORE_NEW_METHOD,ERR_R_PASSED_NULL_PARAMETER);
118 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_STORE, ret, &ret->ex_data);
119 if (ret->meth->init && !ret->meth->init(ret))
127 STORE *STORE_new_engine(ENGINE *engine)
131 const STORE_METHOD *meth = 0;
133 #ifdef OPENSSL_NO_ENGINE
138 if (!ENGINE_init(engine))
140 STOREerr(STORE_F_STORE_NEW_ENGINE, ERR_R_ENGINE_LIB);
147 STOREerr(STORE_F_STORE_NEW_ENGINE,ERR_R_PASSED_NULL_PARAMETER);
152 meth = ENGINE_get_STORE(e);
155 STOREerr(STORE_F_STORE_NEW_ENGINE,
163 ret = STORE_new_method(meth);
166 STOREerr(STORE_F_STORE_NEW_ENGINE,ERR_R_STORE_LIB);
175 void STORE_free(STORE *store)
179 if (store->meth->clean)
180 store->meth->clean(store);
181 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_STORE, store, &store->ex_data);
186 int STORE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
187 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
189 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_STORE, argl, argp,
190 new_func, dup_func, free_func);
193 int STORE_set_ex_data(STORE *r, int idx, void *arg)
195 return(CRYPTO_set_ex_data(&r->ex_data,idx,arg));
198 void *STORE_get_ex_data(STORE *r, int idx)
200 return(CRYPTO_get_ex_data(&r->ex_data,idx));
203 const STORE_METHOD *STORE_get_method(STORE *store)
208 const STORE_METHOD *STORE_set_method(STORE *store, const STORE_METHOD *meth)
217 #define check_store(s,fncode,fnname,fnerrcode) \
220 if ((s) == NULL || (s)->meth) \
222 STOREerr((fncode), ERR_R_PASSED_NULL_PARAMETER); \
225 if ((s)->meth->fnname == NULL) \
227 STOREerr((fncode), (fnerrcode)); \
235 X509 *STORE_get_certificate(STORE *s, OPENSSL_ITEM attributes[],
236 OPENSSL_ITEM parameters[])
238 STORE_OBJECT *object;
241 check_store(s,STORE_F_STORE_GET_CERTIFICATE,
242 get_object,STORE_R_NO_GET_OBJECT_FUNCTION);
244 object = s->meth->get_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE,
245 attributes, parameters);
246 if (!object || !object->data.x509.certificate)
248 STOREerr(STORE_F_STORE_GET_CERTIFICATE,
249 STORE_R_FAILED_GETTING_CERTIFICATE);
252 CRYPTO_add(&object->data.x509.certificate->references,1,CRYPTO_LOCK_X509);
254 REF_PRINT("X509",data);
256 x = object->data.x509.certificate;
257 STORE_OBJECT_free(object);
261 int STORE_store_certificate(STORE *s, X509 *data, OPENSSL_ITEM attributes[],
262 OPENSSL_ITEM parameters[])
264 STORE_OBJECT *object = STORE_OBJECT_new();
267 check_store(s,STORE_F_STORE_CERTIFICATE,
268 store_object,STORE_R_NO_STORE_OBJECT_FUNCTION);
272 STOREerr(STORE_F_STORE_CERTIFICATE,
273 ERR_R_MALLOC_FAILURE);
277 CRYPTO_add(&data->references,1,CRYPTO_LOCK_X509);
279 REF_PRINT("X509",data);
281 object->data.x509.certificate = data;
283 i = s->meth->store_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE,
284 object, attributes, parameters);
286 STORE_OBJECT_free(object);
290 STOREerr(STORE_F_STORE_CERTIFICATE,
291 STORE_R_FAILED_STORING_CERTIFICATE);
297 int STORE_revoke_certificate(STORE *s, OPENSSL_ITEM attributes[],
298 OPENSSL_ITEM parameters[])
300 check_store(s,STORE_F_STORE_REVOKE_CERTIFICATE,
301 revoke_object,STORE_R_NO_REVOKE_OBJECT_FUNCTION);
303 if (!s->meth->revoke_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE,
304 attributes, parameters))
306 STOREerr(STORE_F_STORE_REVOKE_CERTIFICATE,
307 STORE_R_FAILED_REVOKING_CERTIFICATE);
313 int STORE_delete_certificate(STORE *s, OPENSSL_ITEM attributes[],
314 OPENSSL_ITEM parameters[])
316 check_store(s,STORE_F_STORE_DELETE_CERTIFICATE,
317 delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION);
319 if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE,
320 attributes, parameters))
322 STOREerr(STORE_F_STORE_DELETE_CERTIFICATE,
323 STORE_R_FAILED_DELETING_CERTIFICATE);
329 void *STORE_list_certificate_start(STORE *s, OPENSSL_ITEM attributes[],
330 OPENSSL_ITEM parameters[])
334 check_store(s,STORE_F_STORE_LIST_CERTIFICATE_START,
335 list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION);
337 handle = s->meth->list_object_start(s,
338 STORE_OBJECT_TYPE_X509_CERTIFICATE, attributes, parameters);
341 STOREerr(STORE_F_STORE_LIST_CERTIFICATE_START,
342 STORE_R_FAILED_LISTING_CERTIFICATES);
348 X509 *STORE_list_certificate_next(STORE *s, void *handle)
350 STORE_OBJECT *object;
353 check_store(s,STORE_F_STORE_LIST_CERTIFICATE_NEXT,
354 list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION);
356 object = s->meth->list_object_next(s, handle);
357 if (!object || !object->data.x509.certificate)
359 STOREerr(STORE_F_STORE_LIST_CERTIFICATE_NEXT,
360 STORE_R_FAILED_LISTING_CERTIFICATES);
363 CRYPTO_add(&object->data.x509.certificate->references,1,CRYPTO_LOCK_X509);
365 REF_PRINT("X509",data);
367 x = object->data.x509.certificate;
368 STORE_OBJECT_free(object);
372 int STORE_list_certificate_end(STORE *s, void *handle)
374 check_store(s,STORE_F_STORE_LIST_CERTIFICATE_END,
375 list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION);
377 if (!s->meth->list_object_end(s, handle))
379 STOREerr(STORE_F_STORE_LIST_CERTIFICATE_END,
380 STORE_R_FAILED_LISTING_CERTIFICATES);
386 int STORE_list_certificate_endp(STORE *s, void *handle)
388 check_store(s,STORE_F_STORE_LIST_CERTIFICATE_ENDP,
389 list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION);
391 if (!s->meth->list_object_endp(s, handle))
393 STOREerr(STORE_F_STORE_LIST_CERTIFICATE_ENDP,
394 STORE_R_FAILED_LISTING_CERTIFICATES);
400 EVP_PKEY *STORE_generate_key(STORE *s, OPENSSL_ITEM attributes[],
401 OPENSSL_ITEM parameters[])
403 STORE_OBJECT *object;
406 check_store(s,STORE_F_STORE_GENERATE_KEY,
407 generate_object,STORE_R_NO_GENERATE_OBJECT_FUNCTION);
409 object = s->meth->generate_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY,
410 attributes, parameters);
411 if (!object || !object->data.key)
413 STOREerr(STORE_F_STORE_GENERATE_KEY,
414 STORE_R_FAILED_GENERATING_KEY);
417 CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY);
419 REF_PRINT("EVP_PKEY",data);
421 pkey = object->data.key;
422 STORE_OBJECT_free(object);
426 EVP_PKEY *STORE_get_private_key(STORE *s, OPENSSL_ITEM attributes[],
427 OPENSSL_ITEM parameters[])
429 STORE_OBJECT *object;
432 check_store(s,STORE_F_STORE_GET_PRIVATE_KEY,
433 get_object,STORE_R_NO_GET_OBJECT_FUNCTION);
435 object = s->meth->get_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY,
436 attributes, parameters);
437 if (!object || !object->data.key || !object->data.key)
439 STOREerr(STORE_F_STORE_GET_PRIVATE_KEY,
440 STORE_R_FAILED_GETTING_KEY);
443 CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY);
445 REF_PRINT("EVP_PKEY",data);
447 pkey = object->data.key;
448 STORE_OBJECT_free(object);TORE *s, EVP_PKEY *data, OPENSSL_ITEM attributes[],
449 OPENSSL_ITEM parameters[])
451 STORE_OBJECT *object = STORE_OBJECT_new();
454 check_store(s,STORE_F_STORE_PRIVATE_KEY,
455 store_object,STORE_R_NO_STORE_OBJECT_FUNCTION);
459 STOREerr(STORE_F_STORE_PRIVATE_KEY,
460 ERR_R_MALLOC_FAILURE);
463 object->data.key = EVP_PKEY_new();
464 if (!object->data.key)
466 STOREerr(STORE_F_STORE_PRIVATE_KEY,
467 ERR_R_MALLOC_FAILURE);
471 CRYPTO_add(&data->references,1,CRYPTO_LOCK_EVP_PKEY);
473 REF_PRINT("EVP_PKEY",data);
475 object->data.key = data;
477 i = s->meth->store_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, object,
478 attributes, parameters);
480 STORE_OBJECT_free(object);
484 STOREerr(STORE_F_STORE_PRIVATE_KEY,
485 STORE_R_FAILED_STORING_KEY);
491 int STORE_revoke_private_key(STORE *s, OPENSSL_ITEM attributes[],
492 OPENSSL_ITEM parameters[])
496 check_store(s,STORE_F_STORE_REVOKE_PRIVATE_KEY,
497 revoke_object,STORE_R_NO_REVOKE_OBJECT_FUNCTION);
499 i = s->meth->revoke_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY,
500 attributes, parameters);
504 STOREerr(STORE_F_STORE_REVOKE_PRIVATE_KEY,
505 STORE_R_FAILED_REVOKING_KEY);
511 int STORE_delete_private_key(STORE *s, OPENSSL_ITEM attributes[],
512 OPENSSL_ITEM parameters[])
514 check_store(s,STORE_F_STORE_DELETE_PRIVATE_KEY,
515 delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION);
517 if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY,
518 attributes, parameters))
520 STOREerr(STORE_F_STORE_DELETE_PRIVATE_KEY,
521 STORE_R_FAILED_DELETING_KEY);
527 void *STORE_list_private_key_start(STORE *s, OPENSSL_ITEM attributes[],
528 OPENSSL_ITEM parameters[])
532 check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_START,
533 list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION);
535 handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_PRIVATE_KEY,
536 attributes, parameters);
539 STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_START,
540 STORE_R_FAILED_LISTING_KEYS);
546 EVP_PKEY *STORE_list_private_key_next(STORE *s, void *handle)
548 STORE_OBJECT *object;
551 check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_NEXT,
552 list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION);
554 object = s->meth->list_object_next(s, handle);
555 if (!object || !object->data.key || !object->data.key)
557 STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_NEXT,
558 STORE_R_FAILED_LISTING_KEYS);
561 CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY);
563 REF_PRINT("EVP_PKEY",data);
565 pkey = object->data.key;
566 STORE_OBJECT_free(object);
570 int STORE_list_private_key_end(STORE *s, void *handle)
572 check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_END,
573 list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION);
575 if (!s->meth->list_object_end(s, handle))
577 STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_END,
578 STORE_R_FAILED_LISTING_KEYS);
584 int STORE_list_private_key_endp(STORE *s, void *handle)
586 check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_ENDP,
587 list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION);
589 if (!s->meth->list_object_endp(s, handle))
591 STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_ENDP,
592 STORE_R_FAILED_LISTING_KEYS);
598 EVP_PKEY *STORE_get_public_key(STORE *s, OPENSSL_ITEM attributes[],
599 OPENSSL_ITEM parameters[])
601 STORE_OBJECT *object;
604 check_store(s,STORE_F_STORE_GET_PUBLIC_KEY,
605 get_object,STORE_R_NO_GET_OBJECT_FUNCTION);
607 object = s->meth->get_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY,
608 attributes, parameters);
609 if (!object || !object->data.key || !object->data.key)
611 STOREerr(STORE_F_STORE_GET_PUBLIC_KEY,
612 STORE_R_FAILED_GETTING_KEY);
615 CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY);
617 REF_PRINT("EVP_PKEY",data);
619 pkey = object->data.key;
620 STORE_OBJECT_free(object);
624 int STORE_store_public_key(STORE *s, EVP_PKEY *data, OPENSSL_ITEM attributes[],
625 OPENSSL_ITEM parameters[])
627 STORE_OBJECT *object = STORE_OBJECT_new();
630 check_store(s,STORE_F_STORE_PUBLIC_KEY,
631 store_object,STORE_R_NO_STORE_OBJECT_FUNCTION);
635 STOREerr(STORE_F_STORE_PUBLIC_KEY,
636 ERR_R_MALLOC_FAILURE);
639 object->data.key = EVP_PKEY_new();
640 if (!object->data.key)
642 STOREerr(STORE_F_STORE_PUBLIC_KEY,
643 ERR_R_MALLOC_FAILURE);
647 CRYPTO_add(&data->references,1,CRYPTO_LOCK_EVP_PKEY);
649 REF_PRINT("EVP_PKEY",data);
651 object->data.key = data;
653 i = s->meth->store_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, object,
654 attributes, parameters);
656 STORE_OBJECT_free(object);
660 STOREerr(STORE_F_STORE_PUBLIC_KEY,
661 STORE_R_FAILED_STORING_KEY);
667 int STORE_revoke_public_key(STORE *s, OPENSSL_ITEM attributes[],
668 OPENSSL_ITEM parameters[])
672 check_store(s,STORE_F_STORE_REVOKE_PUBLIC_KEY,
673 revoke_object,STORE_R_NO_REVOKE_OBJECT_FUNCTION);
675 i = s->meth->revoke_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY,
676 attributes, parameters);
680 STOREerr(STORE_F_STORE_REVOKE_PUBLIC_KEY,
681 STORE_R_FAILED_REVOKING_KEY);
687 int STORE_delete_public_key(STORE *s, OPENSSL_ITEM attributes[],
688 OPENSSL_ITEM parameters[])
690 check_store(s,STORE_F_STORE_DELETE_PUBLIC_KEY,
691 delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION);
693 if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY,
694 attributes, parameters))
696 STOREerr(STORE_F_STORE_DELETE_PUBLIC_KEY,
697 STORE_R_FAILED_DELETING_KEY);
703 void *STORE_list_public_key_start(STORE *s, OPENSSL_ITEM attributes[],
704 OPENSSL_ITEM parameters[])
708 check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_START,
709 list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION);
711 handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_PUBLIC_KEY,
712 attributes, parameters);
715 STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_START,
716 STORE_R_FAILED_LISTING_KEYS);
722 EVP_PKEY *STORE_list_public_key_next(STORE *s, void *handle)
724 STORE_OBJECT *object;
727 check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_NEXT,
728 list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION);
730 object = s->meth->list_object_next(s, handle);
731 if (!object || !object->data.key || !object->data.key)
733 STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_NEXT,
734 STORE_R_FAILED_LISTING_KEYS);
737 CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY);
739 REF_PRINT("EVP_PKEY",data);
741 pkey = object->data.key;
742 STORE_OBJECT_free(object);
746 int STORE_list_public_key_end(STORE *s, void *handle)
748 check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_END,
749 list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION);
751 if (!s->meth->list_object_end(s, handle))
753 STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_END,
754 STORE_R_FAILED_LISTING_KEYS);
760 int STORE_list_public_key_endp(STORE *s, void *handle)
762 check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_ENDP,
763 list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION);
765 if (!s->meth->list_object_endp(s, handle))
767 STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_ENDP,
768 STORE_R_FAILED_LISTING_KEYS);
774 X509_CRL *STORE_generate_crl(STORE *s, OPENSSL_ITEM attributes[],
775 OPENSSL_ITEM parameters[])
777 STORE_OBJECT *object;
780 check_store(s,STORE_F_STORE_GENERATE_CRL,
781 generate_object,STORE_R_NO_GENERATE_CRL_FUNCTION);
783 object = s->meth->generate_object(s, STORE_OBJECT_TYPE_X509_CRL,
784 attributes, parameters);
785 if (!object || !object->data.crl)
787 STOREerr(STORE_F_STORE_GENERATE_CRL,
788 STORE_R_FAILED_GENERATING_CRL);
791 CRYPTO_add(&object->data.crl->references,1,CRYPTO_LOCK_X509_CRL);
793 REF_PRINT("X509_CRL",data);
795 crl = object->data.crl;
796 STORE_OBJECT_free(object);
800 X509_CRL *STORE_get_crl(STORE *s, OPENSSL_ITEM attributes[],
801 OPENSSL_ITEM parameters[])
803 STORE_OBJECT *object;
806 check_store(s,STORE_F_STORE_GET_CRL,
807 get_object,STORE_R_NO_GET_OBJECT_FUNCTION);
809 object = s->meth->get_object(s, STORE_OBJECT_TYPE_X509_CRL,
810 attributes, parameters);
811 if (!object || !object->data.crl)
813 STOREerr(STORE_F_STORE_GET_CRL,
814 STORE_R_FAILED_GETTING_KEY);
817 CRYPTO_add(&object->data.crl->references,1,CRYPTO_LOCK_X509_CRL);
819 REF_PRINT("X509_CRL",data);
821 crl = object->data.crl;
822 STORE_OBJECT_free(object);
826 int STORE_store_crl(STORE *s, X509_CRL *data, OPENSSL_ITEM attributes[],
827 OPENSSL_ITEM parameters[])
829 STORE_OBJECT *object = STORE_OBJECT_new();
832 check_store(s,STORE_F_STORE_CRL,
833 store_object,STORE_R_NO_STORE_OBJECT_FUNCTION);
837 STOREerr(STORE_F_STORE_CRL,
838 ERR_R_MALLOC_FAILURE);
842 CRYPTO_add(&data->references,1,CRYPTO_LOCK_X509_CRL);
844 REF_PRINT("X509_CRL",data);
846 object->data.crl = data;
848 i = s->meth->store_object(s, STORE_OBJECT_TYPE_X509_CRL, object,
849 attributes, parameters);
851 STORE_OBJECT_free(object);
855 STOREerr(STORE_F_STORE_CRL,
856 STORE_R_FAILED_STORING_KEY);
862 int STORE_delete_crl(STORE *s, OPENSSL_ITEM attributes[],
863 OPENSSL_ITEM parameters[])
865 check_store(s,STORE_F_STORE_DELETE_CRL,
866 delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION);
868 if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_X509_CRL,
869 attributes, parameters))
871 STOREerr(STORE_F_STORE_DELETE_CRL,
872 STORE_R_FAILED_DELETING_KEY);
878 void *STORE_list_crl_start(STORE *s, OPENSSL_ITEM attributes[],
879 OPENSSL_ITEM parameters[])
883 check_store(s,STORE_F_STORE_LIST_CRL_START,
884 list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION);
886 handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_X509_CRL,
887 attributes, parameters);
890 STOREerr(STORE_F_STORE_LIST_CRL_START,
891 STORE_R_FAILED_LISTING_KEYS);
897 X509_CRL *STORE_list_crl_next(STORE *s, void *handle)
899 STORE_OBJECT *object;
902 check_store(s,STORE_F_STORE_LIST_CRL_NEXT,
903 list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION);
905 object = s->meth->list_object_next(s, handle);
906 if (!object || !object->data.crl)
908 STOREerr(STORE_F_STORE_LIST_CRL_NEXT,
909 STORE_R_FAILED_LISTING_KEYS);
912 CRYPTO_add(&object->data.crl->references,1,CRYPTO_LOCK_X509_CRL);
914 REF_PRINT("X509_CRL",data);
916 crl = object->data.crl;
917 STORE_OBJECT_free(object);
921 int STORE_list_crl_end(STORE *s, void *handle)
923 check_store(s,STORE_F_STORE_LIST_CRL_END,
924 list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION);
926 if (!s->meth->list_object_end(s, handle))
928 STOREerr(STORE_F_STORE_LIST_CRL_END,
929 STORE_R_FAILED_LISTING_KEYS);
935 int STORE_list_crl_endp(STORE *s, void *handle)
937 check_store(s,STORE_F_STORE_LIST_CRL_ENDP,
938 list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION);
940 if (!s->meth->list_object_endp(s, handle))
942 STOREerr(STORE_F_STORE_LIST_CRL_ENDP,
943 STORE_R_FAILED_LISTING_KEYS);
949 int STORE_store_number(STORE *s, BIGNUM *data, OPENSSL_ITEM attributes[],
950 OPENSSL_ITEM parameters[])
952 STORE_OBJECT *object = STORE_OBJECT_new();
955 check_store(s,STORE_F_STORE_NUMBER,
956 store_object,STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION);
960 STOREerr(STORE_F_STORE_NUMBER,
961 ERR_R_MALLOC_FAILURE);
965 object->data.number = data;
967 i = s->meth->store_object(s, STORE_OBJECT_TYPE_NUMBER, object,
968 attributes, parameters);
970 STORE_OBJECT_free(object);
974 STOREerr(STORE_F_STORE_NUMBER,
975 STORE_R_FAILED_STORING_NUMBER);
981 BIGNUM *STORE_get_number(STORE *s, OPENSSL_ITEM attributes[],
982 OPENSSL_ITEM parameters[])
984 STORE_OBJECT *object;
987 check_store(s,STORE_F_STORE_GET_NUMBER,
988 get_object,STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION);
990 object = s->meth->get_object(s, STORE_OBJECT_TYPE_NUMBER, attributes,
992 if (!object || !object->data.number)
994 STOREerr(STORE_F_STORE_GET_NUMBER,
995 STORE_R_FAILED_GETTING_NUMBER);
998 n = object->data.number;
999 object->data.number = NULL;
1000 STORE_OBJECT_free(object);
1004 int STORE_delete_number(STORE *s, OPENSSL_ITEM attributes[],
1005 OPENSSL_ITEM parameters[])
1007 check_store(s,STORE_F_STORE_DELETE_NUMBER,
1008 delete_object,STORE_R_NO_DELETE_NUMBER_FUNCTION);
1010 if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_NUMBER, attributes,
1013 STOREerr(STORE_F_STORE_DELETE_NUMBER,
1014 STORE_R_FAILED_DELETING_NUMBER);
1020 int STORE_store_arbitrary(STORE *s, BUF_MEM *data, OPENSSL_ITEM attributes[],
1021 OPENSSL_ITEM parameters[])
1023 STORE_OBJECT *object = STORE_OBJECT_new();
1026 check_store(s,STORE_F_STORE_ARBITRARY,
1027 store_object,STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION);
1031 STOREerr(STORE_F_STORE_ARBITRARY,
1032 ERR_R_MALLOC_FAILURE);
1036 object->data.arbitrary = data;
1038 i = s->meth->store_object(s, STORE_OBJECT_TYPE_ARBITRARY, object,
1039 attributes, parameters);
1041 STORE_OBJECT_free(object);
1045 STOREerr(STORE_F_STORE_ARBITRARY,
1046 STORE_R_FAILED_STORING_ARBITRARY);
1052 BUF_MEM *STORE_get_arbitrary(STORE *s, OPENSSL_ITEM attributes[],
1053 OPENSSL_ITEM parameters[])
1055 STORE_OBJECT *object;
1058 check_store(s,STORE_F_STORE_GET_ARBITRARY,
1059 get_object,STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION);
1061 object = s->meth->get_object(s, STORE_OBJECT_TYPE_ARBITRARY,
1062 attributes, parameters);
1063 if (!object || !object->data.arbitrary)
1065 STOREerr(STORE_F_STORE_GET_ARBITRARY,
1066 STORE_R_FAILED_GETTING_ARBITRARY);
1069 b = object->data.arbitrary;
1070 object->data.arbitrary = NULL;
1071 STORE_OBJECT_free(object);
1075 int STORE_delete_arbitrary(STORE *s, OPENSSL_ITEM attributes[],
1076 OPENSSL_ITEM parameters[])
1078 check_store(s,STORE_F_STORE_DELETE_ARBITRARY,
1079 delete_object,STORE_R_NO_DELETE_ARBITRARY_FUNCTION);
1081 if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_ARBITRARY, attributes,
1084 STOREerr(STORE_F_STORE_DELETE_ARBITRARY,
1085 STORE_R_FAILED_DELETING_ARBITRARY);
1091 STORE_OBJECT *STORE_OBJECT_new(void)
1093 STORE_OBJECT *object = OPENSSL_malloc(sizeof(STORE_OBJECT));
1094 if (object) memset(object, 0, sizeof(STORE_OBJECT));
1097 void STORE_OBJECT_free(STORE_OBJECT *data)
1102 case STORE_OBJECT_TYPE_X509_CERTIFICATE:
1103 X509_free(data->data.x509.certificate);
1105 case STORE_OBJECT_TYPE_X509_CRL:
1106 X509_CRL_free(data->data.crl);
1108 case STORE_OBJECT_TYPE_PRIVATE_KEY:
1109 case STORE_OBJECT_TYPE_PUBLIC_KEY:
1110 EVP_PKEY_free(data->data.key);
1112 case STORE_OBJECT_TYPE_NUMBER:
1113 BN_free(data->data.number);
1115 case STORE_OBJECT_TYPE_ARBITRARY:
1116 BUF_MEM_free(data->data.arbitrary);
1122 IMPLEMENT_STACK_OF(STORE_OBJECT*);
1125 struct STORE_attr_info_st
1127 unsigned char set[(STORE_ATTR_TYPE_NUM + 8) / 8];
1131 unsigned char *sha1string;
1135 } values[STORE_ATTR_TYPE_NUM+1];
1136 size_t value_sizes[STORE_ATTR_TYPE_NUM+1];
1139 #define ATTR_IS_SET(a,i) ((i) > 0 && (i) < STORE_ATTR_TYPE_NUM \
1140 && ((a)->set[(i) / 8] & (1 << ((i) % 8))))
1141 #define SET_ATTRBIT(a,i) ((a)->set[(i) / 8] |= (1 << ((i) % 8)))
1142 #define CLEAR_ATTRBIT(a,i) ((a)->set[(i) / 8] &= ~(1 << ((i) % 8)))
1144 STORE_ATTR_INFO *STORE_ATTR_INFO_new(void)
1146 return (STORE_ATTR_INFO *)OPENSSL_malloc(sizeof(STORE_ATTR_INFO));
1148 static void STORE_ATTR_INFO_attr_free(STORE_ATTR_INFO *attrs,
1149 STORE_ATTR_TYPES code)
1151 if (ATTR_IS_SET(attrs,code))
1155 case STORE_ATTR_FRIENDLYNAME:
1156 case STORE_ATTR_EMAIL:
1157 case STORE_ATTR_FILENAME:
1158 STORE_ATTR_INFO_modify_cstr(attrs, code, NULL, 0);
1160 case STORE_ATTR_KEYID:
1161 case STORE_ATTR_ISSUERKEYID:
1162 case STORE_ATTR_SUBJECTKEYID:
1163 case STORE_ATTR_ISSUERSERIALHASH:
1164 case STORE_ATTR_CERTHASH:
1165 STORE_ATTR_INFO_modify_sha1str(attrs, code, NULL, 0);
1167 case STORE_ATTR_ISSUER:
1168 case STORE_ATTR_SUBJECT:
1169 STORE_ATTR_INFO_modify_dn(attrs, code, NULL);
1171 case STORE_ATTR_SERIAL:
1172 STORE_ATTR_INFO_modify_number(attrs, code, NULL);
1179 int STORE_ATTR_INFO_free(STORE_ATTR_INFO *attrs)
1184 for(i = 0; i++ < STORE_ATTR_TYPE_NUM;)
1185 STORE_ATTR_INFO_attr_free(attrs, i);
1186 OPENSSL_free(attrs);
1190 char *STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code)
1194 STOREerr(STORE_F_STORE_ATTR_INFO_GET0_CSTR,
1195 ERR_R_PASSED_NULL_PARAMETER);
1198 if (ATTR_IS_SET(attrs,code))
1199 return attrs->values[code].cstring;
1200 STOREerr(STORE_F_STORE_ATTR_INFO_GET0_CSTR,
1204 unsigned char *STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs,
1205 STORE_ATTR_TYPES code)
1209 STOREerr(STORE_F_STORE_ATTR_INFO_GET0_SHA1STR,
1210 ERR_R_PASSED_NULL_PARAMETER);
1213 if (ATTR_IS_SET(attrs,code))
1214 return attrs->values[code].sha1string;
1215 STOREerr(STORE_F_STORE_ATTR_INFO_GET0_SHA1STR,
1219 X509_NAME *STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code)
1223 STOREerr(STORE_F_STORE_ATTR_INFO_GET0_DN,
1224 ERR_R_PASSED_NULL_PARAMETER);
1227 if (ATTR_IS_SET(attrs,code))
1228 return attrs->values[code].dn;
1229 STOREerr(STORE_F_STORE_ATTR_INFO_GET0_DN,
1233 BIGNUM *STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code)
1237 STOREerr(STORE_F_STORE_ATTR_INFO_GET0_NUMBER,
1238 ERR_R_PASSED_NULL_PARAMETER);
1241 if (ATTR_IS_SET(attrs,code))
1242 return attrs->values[code].number;
1243 STOREerr(STORE_F_STORE_ATTR_INFO_GET0_NUMBER,
1247 int STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
1248 char *cstr, size_t cstr_size)
1252 STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR,
1253 ERR_R_PASSED_NULL_PARAMETER);
1256 if (!ATTR_IS_SET(attrs,code))
1258 if ((attrs->values[code].cstring = BUF_strndup(cstr, cstr_size)))
1260 STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR,
1261 ERR_R_MALLOC_FAILURE);
1264 STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR, STORE_R_ALREADY_HAS_A_VALUE);
1267 int STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
1268 unsigned char *sha1str, size_t sha1str_size)
1272 STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR,
1273 ERR_R_PASSED_NULL_PARAMETER);
1276 if (!ATTR_IS_SET(attrs,code))
1278 if ((attrs->values[code].sha1string =
1279 (unsigned char *)BUF_memdup(sha1str,
1282 STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR,
1283 ERR_R_MALLOC_FAILURE);
1286 STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR, STORE_R_ALREADY_HAS_A_VALUE);
1289 int STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
1294 STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN,
1295 ERR_R_PASSED_NULL_PARAMETER);
1298 if (!ATTR_IS_SET(attrs,code))
1300 if ((attrs->values[code].dn = X509_NAME_dup(dn)))
1302 STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR,
1303 ERR_R_MALLOC_FAILURE);
1306 STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN, STORE_R_ALREADY_HAS_A_VALUE);
1309 int STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
1314 STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER,
1315 ERR_R_PASSED_NULL_PARAMETER);
1318 if (!ATTR_IS_SET(attrs,code))
1320 if ((attrs->values[code].number = BN_dup(number)))
1322 STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR,
1323 ERR_R_MALLOC_FAILURE);
1326 STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER, STORE_R_ALREADY_HAS_A_VALUE);
1329 int STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
1330 char *cstr, size_t cstr_size)
1334 STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_CSTR,
1335 ERR_R_PASSED_NULL_PARAMETER);
1338 if (ATTR_IS_SET(attrs,code))
1340 OPENSSL_free(attrs->values[code].cstring);
1341 attrs->values[code].cstring = NULL;
1342 CLEAR_ATTRBIT(attrs, code);
1344 return STORE_ATTR_INFO_set_cstr(attrs, code, cstr, cstr_size);
1346 int STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
1347 unsigned char *sha1str, size_t sha1str_size)
1351 STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR,
1352 ERR_R_PASSED_NULL_PARAMETER);
1355 if (ATTR_IS_SET(attrs,code))
1357 OPENSSL_free(attrs->values[code].sha1string);
1358 attrs->values[code].sha1string = NULL;
1359 CLEAR_ATTRBIT(attrs, code);
1361 return STORE_ATTR_INFO_set_sha1str(attrs, code, sha1str, sha1str_size);
1363 int STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
1368 STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_DN,
1369 ERR_R_PASSED_NULL_PARAMETER);
1372 if (ATTR_IS_SET(attrs,code))
1374 OPENSSL_free(attrs->values[code].dn);
1375 attrs->values[code].dn = NULL;
1376 CLEAR_ATTRBIT(attrs, code);
1378 return STORE_ATTR_INFO_set_dn(attrs, code, dn);
1380 int STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
1385 STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER,
1386 ERR_R_PASSED_NULL_PARAMETER);
1389 if (ATTR_IS_SET(attrs,code))
1391 OPENSSL_free(attrs->values[code].number);
1392 attrs->values[code].number = NULL;
1393 CLEAR_ATTRBIT(attrs, code);
1395 return STORE_ATTR_INFO_set_number(attrs, code, number);
1398 struct attr_list_ctx_st
1400 OPENSSL_ITEM *attributes;
1402 void *STORE_parse_attrs_start(OPENSSL_ITEM *attributes)
1406 struct attr_list_ctx_st *context =
1407 (struct attr_list_ctx_st *)OPENSSL_malloc(sizeof(struct attr_list_ctx_st));
1409 context->attributes = attributes;
1411 STOREerr(STORE_F_STORE_PARSE_ATTRS_END,
1412 ERR_R_MALLOC_FAILURE);
1415 STOREerr(STORE_F_STORE_PARSE_ATTRS_END, ERR_R_PASSED_NULL_PARAMETER);
1418 STORE_ATTR_INFO *STORE_parse_attrs_next(void *handle)
1420 struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle;
1422 if (context && context->attributes)
1424 STORE_ATTR_INFO *attrs = NULL;
1426 while(context->attributes
1427 && context->attributes->code != STORE_ATTR_OR
1428 && context->attributes->code != STORE_ATTR_END)
1430 switch(context->attributes->code)
1432 case STORE_ATTR_FRIENDLYNAME:
1433 case STORE_ATTR_EMAIL:
1434 case STORE_ATTR_FILENAME:
1435 if (!attrs) attrs = STORE_ATTR_INFO_new();
1438 STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT,
1439 ERR_R_MALLOC_FAILURE);
1442 STORE_ATTR_INFO_set_cstr(attrs,
1443 context->attributes->code,
1444 context->attributes->value,
1445 context->attributes->value_size);
1447 case STORE_ATTR_KEYID:
1448 case STORE_ATTR_ISSUERKEYID:
1449 case STORE_ATTR_SUBJECTKEYID:
1450 case STORE_ATTR_ISSUERSERIALHASH:
1451 case STORE_ATTR_CERTHASH:
1452 if (!attrs) attrs = STORE_ATTR_INFO_new();
1455 STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT,
1456 ERR_R_MALLOC_FAILURE);
1459 STORE_ATTR_INFO_set_sha1str(attrs,
1460 context->attributes->code,
1461 context->attributes->value,
1462 context->attributes->value_size);
1464 case STORE_ATTR_ISSUER:
1465 case STORE_ATTR_SUBJECT:
1466 if (!attrs) attrs = STORE_ATTR_INFO_new();
1469 STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT,
1470 ERR_R_MALLOC_FAILURE);
1473 STORE_ATTR_INFO_modify_dn(attrs,
1474 context->attributes->code,
1475 context->attributes->value);
1477 case STORE_ATTR_SERIAL:
1478 if (!attrs) attrs = STORE_ATTR_INFO_new();
1481 STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT,
1482 ERR_R_MALLOC_FAILURE);
1485 STORE_ATTR_INFO_modify_number(attrs,
1486 context->attributes->code,
1487 context->attributes->value);
1490 context->attributes++;
1492 if (context->attributes->code == STORE_ATTR_OR)
1493 context->attributes++;
1496 while(context->attributes
1497 && context->attributes->code != STORE_ATTR_OR
1498 && context->attributes->code != STORE_ATTR_END)
1499 context->attributes++;
1500 if (context->attributes->code == STORE_ATTR_OR)
1501 context->attributes++;
1504 STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, ERR_R_PASSED_NULL_PARAMETER);
1507 int STORE_parse_attrs_end(void *handle)
1509 struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle;
1511 if (context && context->attributes)
1514 OPENSSL_ITEM *attributes = context->attributes;
1516 OPENSSL_free(context);
1519 STOREerr(STORE_F_STORE_PARSE_ATTRS_END, ERR_R_PASSED_NULL_PARAMETER);
1523 int STORE_parse_attrs_endp(void *handle)
1525 struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle;
1527 if (context && context->attributes)
1529 return context->attributes->code == STORE_ATTR_END;
1531 STOREerr(STORE_F_STORE_PARSE_ATTRS_END, ERR_R_PASSED_NULL_PARAMETER);
1535 int STORE_ATTR_INFO_compare(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b)
1537 unsigned char *abits, *bbits;
1540 if (a == b) return 0;
1545 for (i = 0; i < (STORE_ATTR_TYPE_NUM + 8) / 8; i++, abits++, bbits++)
1547 if (*abits < *bbits) return -1;
1548 if (*abits > *bbits) return 1;
1552 int STORE_ATTR_INFO_in(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b)
1554 unsigned char *abits, *bbits;
1557 if (a == b) return 1;
1562 for (i = 0; i < (STORE_ATTR_TYPE_NUM + 8) / 8; i++, abits++, bbits++)
1564 if (*abits && *bbits != *abits)
1569 int STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b)
1573 if (a == b) return 1;
1574 if (!STORE_ATTR_INFO_in(a, b)) return 0;
1575 for (i = 1; i < STORE_ATTR_TYPE_NUM; i++)
1576 if (ATTR_IS_SET(a, i))
1580 case STORE_ATTR_FRIENDLYNAME:
1581 case STORE_ATTR_EMAIL:
1582 case STORE_ATTR_FILENAME:
1583 if (strcmp(a->values[i].cstring,
1584 b->values[i].cstring))
1587 case STORE_ATTR_KEYID:
1588 case STORE_ATTR_ISSUERKEYID:
1589 case STORE_ATTR_SUBJECTKEYID:
1590 case STORE_ATTR_ISSUERSERIALHASH:
1591 case STORE_ATTR_CERTHASH:
1592 if (memcmp(a->values[i].sha1string,
1593 b->values[i].sha1string,
1597 case STORE_ATTR_ISSUER:
1598 case STORE_ATTR_SUBJECT:
1599 if (X509_NAME_cmp(a->values[i].dn,
1603 case STORE_ATTR_SERIAL:
1604 if (BN_cmp(a->values[i].number,
1605 b->values[i].number))