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);
452 int STORE_store_private_key(STORE *s, EVP_PKEY *data, OPENSSL_ITEM attributes[],
453 OPENSSL_ITEM parameters[])
455 STORE_OBJECT *object = STORE_OBJECT_new();
458 check_store(s,STORE_F_STORE_PRIVATE_KEY,
459 store_object,STORE_R_NO_STORE_OBJECT_FUNCTION);
463 STOREerr(STORE_F_STORE_PRIVATE_KEY,
464 ERR_R_MALLOC_FAILURE);
467 object->data.key = EVP_PKEY_new();
468 if (!object->data.key)
470 STOREerr(STORE_F_STORE_PRIVATE_KEY,
471 ERR_R_MALLOC_FAILURE);
475 CRYPTO_add(&data->references,1,CRYPTO_LOCK_EVP_PKEY);
477 REF_PRINT("EVP_PKEY",data);
479 object->data.key = data;
481 i = s->meth->store_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, object,
482 attributes, parameters);
484 STORE_OBJECT_free(object);
488 STOREerr(STORE_F_STORE_PRIVATE_KEY,
489 STORE_R_FAILED_STORING_KEY);
495 int STORE_revoke_private_key(STORE *s, OPENSSL_ITEM attributes[],
496 OPENSSL_ITEM parameters[])
500 check_store(s,STORE_F_STORE_REVOKE_PRIVATE_KEY,
501 revoke_object,STORE_R_NO_REVOKE_OBJECT_FUNCTION);
503 i = s->meth->revoke_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY,
504 attributes, parameters);
508 STOREerr(STORE_F_STORE_REVOKE_PRIVATE_KEY,
509 STORE_R_FAILED_REVOKING_KEY);
515 int STORE_delete_private_key(STORE *s, OPENSSL_ITEM attributes[],
516 OPENSSL_ITEM parameters[])
518 check_store(s,STORE_F_STORE_DELETE_PRIVATE_KEY,
519 delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION);
521 if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY,
522 attributes, parameters))
524 STOREerr(STORE_F_STORE_DELETE_PRIVATE_KEY,
525 STORE_R_FAILED_DELETING_KEY);
531 void *STORE_list_private_key_start(STORE *s, OPENSSL_ITEM attributes[],
532 OPENSSL_ITEM parameters[])
536 check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_START,
537 list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION);
539 handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_PRIVATE_KEY,
540 attributes, parameters);
543 STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_START,
544 STORE_R_FAILED_LISTING_KEYS);
550 EVP_PKEY *STORE_list_private_key_next(STORE *s, void *handle)
552 STORE_OBJECT *object;
555 check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_NEXT,
556 list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION);
558 object = s->meth->list_object_next(s, handle);
559 if (!object || !object->data.key || !object->data.key)
561 STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_NEXT,
562 STORE_R_FAILED_LISTING_KEYS);
565 CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY);
567 REF_PRINT("EVP_PKEY",data);
569 pkey = object->data.key;
570 STORE_OBJECT_free(object);
574 int STORE_list_private_key_end(STORE *s, void *handle)
576 check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_END,
577 list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION);
579 if (!s->meth->list_object_end(s, handle))
581 STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_END,
582 STORE_R_FAILED_LISTING_KEYS);
588 int STORE_list_private_key_endp(STORE *s, void *handle)
590 check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_ENDP,
591 list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION);
593 if (!s->meth->list_object_endp(s, handle))
595 STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_ENDP,
596 STORE_R_FAILED_LISTING_KEYS);
602 EVP_PKEY *STORE_get_public_key(STORE *s, OPENSSL_ITEM attributes[],
603 OPENSSL_ITEM parameters[])
605 STORE_OBJECT *object;
608 check_store(s,STORE_F_STORE_GET_PUBLIC_KEY,
609 get_object,STORE_R_NO_GET_OBJECT_FUNCTION);
611 object = s->meth->get_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY,
612 attributes, parameters);
613 if (!object || !object->data.key || !object->data.key)
615 STOREerr(STORE_F_STORE_GET_PUBLIC_KEY,
616 STORE_R_FAILED_GETTING_KEY);
619 CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY);
621 REF_PRINT("EVP_PKEY",data);
623 pkey = object->data.key;
624 STORE_OBJECT_free(object);
628 int STORE_store_public_key(STORE *s, EVP_PKEY *data, OPENSSL_ITEM attributes[],
629 OPENSSL_ITEM parameters[])
631 STORE_OBJECT *object = STORE_OBJECT_new();
634 check_store(s,STORE_F_STORE_PUBLIC_KEY,
635 store_object,STORE_R_NO_STORE_OBJECT_FUNCTION);
639 STOREerr(STORE_F_STORE_PUBLIC_KEY,
640 ERR_R_MALLOC_FAILURE);
643 object->data.key = EVP_PKEY_new();
644 if (!object->data.key)
646 STOREerr(STORE_F_STORE_PUBLIC_KEY,
647 ERR_R_MALLOC_FAILURE);
651 CRYPTO_add(&data->references,1,CRYPTO_LOCK_EVP_PKEY);
653 REF_PRINT("EVP_PKEY",data);
655 object->data.key = data;
657 i = s->meth->store_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, object,
658 attributes, parameters);
660 STORE_OBJECT_free(object);
664 STOREerr(STORE_F_STORE_PUBLIC_KEY,
665 STORE_R_FAILED_STORING_KEY);
671 int STORE_revoke_public_key(STORE *s, OPENSSL_ITEM attributes[],
672 OPENSSL_ITEM parameters[])
676 check_store(s,STORE_F_STORE_REVOKE_PUBLIC_KEY,
677 revoke_object,STORE_R_NO_REVOKE_OBJECT_FUNCTION);
679 i = s->meth->revoke_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY,
680 attributes, parameters);
684 STOREerr(STORE_F_STORE_REVOKE_PUBLIC_KEY,
685 STORE_R_FAILED_REVOKING_KEY);
691 int STORE_delete_public_key(STORE *s, OPENSSL_ITEM attributes[],
692 OPENSSL_ITEM parameters[])
694 check_store(s,STORE_F_STORE_DELETE_PUBLIC_KEY,
695 delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION);
697 if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY,
698 attributes, parameters))
700 STOREerr(STORE_F_STORE_DELETE_PUBLIC_KEY,
701 STORE_R_FAILED_DELETING_KEY);
707 void *STORE_list_public_key_start(STORE *s, OPENSSL_ITEM attributes[],
708 OPENSSL_ITEM parameters[])
712 check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_START,
713 list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION);
715 handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_PUBLIC_KEY,
716 attributes, parameters);
719 STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_START,
720 STORE_R_FAILED_LISTING_KEYS);
726 EVP_PKEY *STORE_list_public_key_next(STORE *s, void *handle)
728 STORE_OBJECT *object;
731 check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_NEXT,
732 list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION);
734 object = s->meth->list_object_next(s, handle);
735 if (!object || !object->data.key || !object->data.key)
737 STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_NEXT,
738 STORE_R_FAILED_LISTING_KEYS);
741 CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY);
743 REF_PRINT("EVP_PKEY",data);
745 pkey = object->data.key;
746 STORE_OBJECT_free(object);
750 int STORE_list_public_key_end(STORE *s, void *handle)
752 check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_END,
753 list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION);
755 if (!s->meth->list_object_end(s, handle))
757 STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_END,
758 STORE_R_FAILED_LISTING_KEYS);
764 int STORE_list_public_key_endp(STORE *s, void *handle)
766 check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_ENDP,
767 list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION);
769 if (!s->meth->list_object_endp(s, handle))
771 STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_ENDP,
772 STORE_R_FAILED_LISTING_KEYS);
778 X509_CRL *STORE_generate_crl(STORE *s, OPENSSL_ITEM attributes[],
779 OPENSSL_ITEM parameters[])
781 STORE_OBJECT *object;
784 check_store(s,STORE_F_STORE_GENERATE_CRL,
785 generate_object,STORE_R_NO_GENERATE_CRL_FUNCTION);
787 object = s->meth->generate_object(s, STORE_OBJECT_TYPE_X509_CRL,
788 attributes, parameters);
789 if (!object || !object->data.crl)
791 STOREerr(STORE_F_STORE_GENERATE_CRL,
792 STORE_R_FAILED_GENERATING_CRL);
795 CRYPTO_add(&object->data.crl->references,1,CRYPTO_LOCK_X509_CRL);
797 REF_PRINT("X509_CRL",data);
799 crl = object->data.crl;
800 STORE_OBJECT_free(object);
804 X509_CRL *STORE_get_crl(STORE *s, OPENSSL_ITEM attributes[],
805 OPENSSL_ITEM parameters[])
807 STORE_OBJECT *object;
810 check_store(s,STORE_F_STORE_GET_CRL,
811 get_object,STORE_R_NO_GET_OBJECT_FUNCTION);
813 object = s->meth->get_object(s, STORE_OBJECT_TYPE_X509_CRL,
814 attributes, parameters);
815 if (!object || !object->data.crl)
817 STOREerr(STORE_F_STORE_GET_CRL,
818 STORE_R_FAILED_GETTING_KEY);
821 CRYPTO_add(&object->data.crl->references,1,CRYPTO_LOCK_X509_CRL);
823 REF_PRINT("X509_CRL",data);
825 crl = object->data.crl;
826 STORE_OBJECT_free(object);
830 int STORE_store_crl(STORE *s, X509_CRL *data, OPENSSL_ITEM attributes[],
831 OPENSSL_ITEM parameters[])
833 STORE_OBJECT *object = STORE_OBJECT_new();
836 check_store(s,STORE_F_STORE_CRL,
837 store_object,STORE_R_NO_STORE_OBJECT_FUNCTION);
841 STOREerr(STORE_F_STORE_CRL,
842 ERR_R_MALLOC_FAILURE);
846 CRYPTO_add(&data->references,1,CRYPTO_LOCK_X509_CRL);
848 REF_PRINT("X509_CRL",data);
850 object->data.crl = data;
852 i = s->meth->store_object(s, STORE_OBJECT_TYPE_X509_CRL, object,
853 attributes, parameters);
855 STORE_OBJECT_free(object);
859 STOREerr(STORE_F_STORE_CRL,
860 STORE_R_FAILED_STORING_KEY);
866 int STORE_delete_crl(STORE *s, OPENSSL_ITEM attributes[],
867 OPENSSL_ITEM parameters[])
869 check_store(s,STORE_F_STORE_DELETE_CRL,
870 delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION);
872 if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_X509_CRL,
873 attributes, parameters))
875 STOREerr(STORE_F_STORE_DELETE_CRL,
876 STORE_R_FAILED_DELETING_KEY);
882 void *STORE_list_crl_start(STORE *s, OPENSSL_ITEM attributes[],
883 OPENSSL_ITEM parameters[])
887 check_store(s,STORE_F_STORE_LIST_CRL_START,
888 list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION);
890 handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_X509_CRL,
891 attributes, parameters);
894 STOREerr(STORE_F_STORE_LIST_CRL_START,
895 STORE_R_FAILED_LISTING_KEYS);
901 X509_CRL *STORE_list_crl_next(STORE *s, void *handle)
903 STORE_OBJECT *object;
906 check_store(s,STORE_F_STORE_LIST_CRL_NEXT,
907 list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION);
909 object = s->meth->list_object_next(s, handle);
910 if (!object || !object->data.crl)
912 STOREerr(STORE_F_STORE_LIST_CRL_NEXT,
913 STORE_R_FAILED_LISTING_KEYS);
916 CRYPTO_add(&object->data.crl->references,1,CRYPTO_LOCK_X509_CRL);
918 REF_PRINT("X509_CRL",data);
920 crl = object->data.crl;
921 STORE_OBJECT_free(object);
925 int STORE_list_crl_end(STORE *s, void *handle)
927 check_store(s,STORE_F_STORE_LIST_CRL_END,
928 list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION);
930 if (!s->meth->list_object_end(s, handle))
932 STOREerr(STORE_F_STORE_LIST_CRL_END,
933 STORE_R_FAILED_LISTING_KEYS);
939 int STORE_list_crl_endp(STORE *s, void *handle)
941 check_store(s,STORE_F_STORE_LIST_CRL_ENDP,
942 list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION);
944 if (!s->meth->list_object_endp(s, handle))
946 STOREerr(STORE_F_STORE_LIST_CRL_ENDP,
947 STORE_R_FAILED_LISTING_KEYS);
953 int STORE_store_number(STORE *s, BIGNUM *data, OPENSSL_ITEM attributes[],
954 OPENSSL_ITEM parameters[])
956 STORE_OBJECT *object = STORE_OBJECT_new();
959 check_store(s,STORE_F_STORE_NUMBER,
960 store_object,STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION);
964 STOREerr(STORE_F_STORE_NUMBER,
965 ERR_R_MALLOC_FAILURE);
969 object->data.number = data;
971 i = s->meth->store_object(s, STORE_OBJECT_TYPE_NUMBER, object,
972 attributes, parameters);
974 STORE_OBJECT_free(object);
978 STOREerr(STORE_F_STORE_NUMBER,
979 STORE_R_FAILED_STORING_NUMBER);
985 BIGNUM *STORE_get_number(STORE *s, OPENSSL_ITEM attributes[],
986 OPENSSL_ITEM parameters[])
988 STORE_OBJECT *object;
991 check_store(s,STORE_F_STORE_GET_NUMBER,
992 get_object,STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION);
994 object = s->meth->get_object(s, STORE_OBJECT_TYPE_NUMBER, attributes,
996 if (!object || !object->data.number)
998 STOREerr(STORE_F_STORE_GET_NUMBER,
999 STORE_R_FAILED_GETTING_NUMBER);
1002 n = object->data.number;
1003 object->data.number = NULL;
1004 STORE_OBJECT_free(object);
1008 int STORE_delete_number(STORE *s, OPENSSL_ITEM attributes[],
1009 OPENSSL_ITEM parameters[])
1011 check_store(s,STORE_F_STORE_DELETE_NUMBER,
1012 delete_object,STORE_R_NO_DELETE_NUMBER_FUNCTION);
1014 if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_NUMBER, attributes,
1017 STOREerr(STORE_F_STORE_DELETE_NUMBER,
1018 STORE_R_FAILED_DELETING_NUMBER);
1024 int STORE_store_arbitrary(STORE *s, BUF_MEM *data, OPENSSL_ITEM attributes[],
1025 OPENSSL_ITEM parameters[])
1027 STORE_OBJECT *object = STORE_OBJECT_new();
1030 check_store(s,STORE_F_STORE_ARBITRARY,
1031 store_object,STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION);
1035 STOREerr(STORE_F_STORE_ARBITRARY,
1036 ERR_R_MALLOC_FAILURE);
1040 object->data.arbitrary = data;
1042 i = s->meth->store_object(s, STORE_OBJECT_TYPE_ARBITRARY, object,
1043 attributes, parameters);
1045 STORE_OBJECT_free(object);
1049 STOREerr(STORE_F_STORE_ARBITRARY,
1050 STORE_R_FAILED_STORING_ARBITRARY);
1056 BUF_MEM *STORE_get_arbitrary(STORE *s, OPENSSL_ITEM attributes[],
1057 OPENSSL_ITEM parameters[])
1059 STORE_OBJECT *object;
1062 check_store(s,STORE_F_STORE_GET_ARBITRARY,
1063 get_object,STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION);
1065 object = s->meth->get_object(s, STORE_OBJECT_TYPE_ARBITRARY,
1066 attributes, parameters);
1067 if (!object || !object->data.arbitrary)
1069 STOREerr(STORE_F_STORE_GET_ARBITRARY,
1070 STORE_R_FAILED_GETTING_ARBITRARY);
1073 b = object->data.arbitrary;
1074 object->data.arbitrary = NULL;
1075 STORE_OBJECT_free(object);
1079 int STORE_delete_arbitrary(STORE *s, OPENSSL_ITEM attributes[],
1080 OPENSSL_ITEM parameters[])
1082 check_store(s,STORE_F_STORE_DELETE_ARBITRARY,
1083 delete_object,STORE_R_NO_DELETE_ARBITRARY_FUNCTION);
1085 if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_ARBITRARY, attributes,
1088 STOREerr(STORE_F_STORE_DELETE_ARBITRARY,
1089 STORE_R_FAILED_DELETING_ARBITRARY);
1095 STORE_OBJECT *STORE_OBJECT_new(void)
1097 STORE_OBJECT *object = OPENSSL_malloc(sizeof(STORE_OBJECT));
1098 if (object) memset(object, 0, sizeof(STORE_OBJECT));
1101 void STORE_OBJECT_free(STORE_OBJECT *data)
1106 case STORE_OBJECT_TYPE_X509_CERTIFICATE:
1107 X509_free(data->data.x509.certificate);
1109 case STORE_OBJECT_TYPE_X509_CRL:
1110 X509_CRL_free(data->data.crl);
1112 case STORE_OBJECT_TYPE_PRIVATE_KEY:
1113 case STORE_OBJECT_TYPE_PUBLIC_KEY:
1114 EVP_PKEY_free(data->data.key);
1116 case STORE_OBJECT_TYPE_NUMBER:
1117 BN_free(data->data.number);
1119 case STORE_OBJECT_TYPE_ARBITRARY:
1120 BUF_MEM_free(data->data.arbitrary);
1126 IMPLEMENT_STACK_OF(STORE_OBJECT*)
1129 struct STORE_attr_info_st
1131 unsigned char set[(STORE_ATTR_TYPE_NUM + 8) / 8];
1135 unsigned char *sha1string;
1139 } values[STORE_ATTR_TYPE_NUM+1];
1140 size_t value_sizes[STORE_ATTR_TYPE_NUM+1];
1143 #define ATTR_IS_SET(a,i) ((i) > 0 && (i) < STORE_ATTR_TYPE_NUM \
1144 && ((a)->set[(i) / 8] & (1 << ((i) % 8))))
1145 #define SET_ATTRBIT(a,i) ((a)->set[(i) / 8] |= (1 << ((i) % 8)))
1146 #define CLEAR_ATTRBIT(a,i) ((a)->set[(i) / 8] &= ~(1 << ((i) % 8)))
1148 STORE_ATTR_INFO *STORE_ATTR_INFO_new(void)
1150 return (STORE_ATTR_INFO *)OPENSSL_malloc(sizeof(STORE_ATTR_INFO));
1152 static void STORE_ATTR_INFO_attr_free(STORE_ATTR_INFO *attrs,
1153 STORE_ATTR_TYPES code)
1155 if (ATTR_IS_SET(attrs,code))
1159 case STORE_ATTR_FRIENDLYNAME:
1160 case STORE_ATTR_EMAIL:
1161 case STORE_ATTR_FILENAME:
1162 STORE_ATTR_INFO_modify_cstr(attrs, code, NULL, 0);
1164 case STORE_ATTR_KEYID:
1165 case STORE_ATTR_ISSUERKEYID:
1166 case STORE_ATTR_SUBJECTKEYID:
1167 case STORE_ATTR_ISSUERSERIALHASH:
1168 case STORE_ATTR_CERTHASH:
1169 STORE_ATTR_INFO_modify_sha1str(attrs, code, NULL, 0);
1171 case STORE_ATTR_ISSUER:
1172 case STORE_ATTR_SUBJECT:
1173 STORE_ATTR_INFO_modify_dn(attrs, code, NULL);
1175 case STORE_ATTR_SERIAL:
1176 STORE_ATTR_INFO_modify_number(attrs, code, NULL);
1183 int STORE_ATTR_INFO_free(STORE_ATTR_INFO *attrs)
1188 for(i = 0; i++ < STORE_ATTR_TYPE_NUM;)
1189 STORE_ATTR_INFO_attr_free(attrs, i);
1190 OPENSSL_free(attrs);
1194 char *STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code)
1198 STOREerr(STORE_F_STORE_ATTR_INFO_GET0_CSTR,
1199 ERR_R_PASSED_NULL_PARAMETER);
1202 if (ATTR_IS_SET(attrs,code))
1203 return attrs->values[code].cstring;
1204 STOREerr(STORE_F_STORE_ATTR_INFO_GET0_CSTR,
1208 unsigned char *STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs,
1209 STORE_ATTR_TYPES code)
1213 STOREerr(STORE_F_STORE_ATTR_INFO_GET0_SHA1STR,
1214 ERR_R_PASSED_NULL_PARAMETER);
1217 if (ATTR_IS_SET(attrs,code))
1218 return attrs->values[code].sha1string;
1219 STOREerr(STORE_F_STORE_ATTR_INFO_GET0_SHA1STR,
1223 X509_NAME *STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code)
1227 STOREerr(STORE_F_STORE_ATTR_INFO_GET0_DN,
1228 ERR_R_PASSED_NULL_PARAMETER);
1231 if (ATTR_IS_SET(attrs,code))
1232 return attrs->values[code].dn;
1233 STOREerr(STORE_F_STORE_ATTR_INFO_GET0_DN,
1237 BIGNUM *STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code)
1241 STOREerr(STORE_F_STORE_ATTR_INFO_GET0_NUMBER,
1242 ERR_R_PASSED_NULL_PARAMETER);
1245 if (ATTR_IS_SET(attrs,code))
1246 return attrs->values[code].number;
1247 STOREerr(STORE_F_STORE_ATTR_INFO_GET0_NUMBER,
1251 int STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
1252 char *cstr, size_t cstr_size)
1256 STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR,
1257 ERR_R_PASSED_NULL_PARAMETER);
1260 if (!ATTR_IS_SET(attrs,code))
1262 if ((attrs->values[code].cstring = BUF_strndup(cstr, cstr_size)))
1264 STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR,
1265 ERR_R_MALLOC_FAILURE);
1268 STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR, STORE_R_ALREADY_HAS_A_VALUE);
1271 int STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
1272 unsigned char *sha1str, size_t sha1str_size)
1276 STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR,
1277 ERR_R_PASSED_NULL_PARAMETER);
1280 if (!ATTR_IS_SET(attrs,code))
1282 if ((attrs->values[code].sha1string =
1283 (unsigned char *)BUF_memdup(sha1str,
1286 STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR,
1287 ERR_R_MALLOC_FAILURE);
1290 STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR, STORE_R_ALREADY_HAS_A_VALUE);
1293 int STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
1298 STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN,
1299 ERR_R_PASSED_NULL_PARAMETER);
1302 if (!ATTR_IS_SET(attrs,code))
1304 if ((attrs->values[code].dn = X509_NAME_dup(dn)))
1306 STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR,
1307 ERR_R_MALLOC_FAILURE);
1310 STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN, STORE_R_ALREADY_HAS_A_VALUE);
1313 int STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
1318 STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER,
1319 ERR_R_PASSED_NULL_PARAMETER);
1322 if (!ATTR_IS_SET(attrs,code))
1324 if ((attrs->values[code].number = BN_dup(number)))
1326 STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR,
1327 ERR_R_MALLOC_FAILURE);
1330 STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER, STORE_R_ALREADY_HAS_A_VALUE);
1333 int STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
1334 char *cstr, size_t cstr_size)
1338 STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_CSTR,
1339 ERR_R_PASSED_NULL_PARAMETER);
1342 if (ATTR_IS_SET(attrs,code))
1344 OPENSSL_free(attrs->values[code].cstring);
1345 attrs->values[code].cstring = NULL;
1346 CLEAR_ATTRBIT(attrs, code);
1348 return STORE_ATTR_INFO_set_cstr(attrs, code, cstr, cstr_size);
1350 int STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
1351 unsigned char *sha1str, size_t sha1str_size)
1355 STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR,
1356 ERR_R_PASSED_NULL_PARAMETER);
1359 if (ATTR_IS_SET(attrs,code))
1361 OPENSSL_free(attrs->values[code].sha1string);
1362 attrs->values[code].sha1string = NULL;
1363 CLEAR_ATTRBIT(attrs, code);
1365 return STORE_ATTR_INFO_set_sha1str(attrs, code, sha1str, sha1str_size);
1367 int STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
1372 STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_DN,
1373 ERR_R_PASSED_NULL_PARAMETER);
1376 if (ATTR_IS_SET(attrs,code))
1378 OPENSSL_free(attrs->values[code].dn);
1379 attrs->values[code].dn = NULL;
1380 CLEAR_ATTRBIT(attrs, code);
1382 return STORE_ATTR_INFO_set_dn(attrs, code, dn);
1384 int STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
1389 STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER,
1390 ERR_R_PASSED_NULL_PARAMETER);
1393 if (ATTR_IS_SET(attrs,code))
1395 OPENSSL_free(attrs->values[code].number);
1396 attrs->values[code].number = NULL;
1397 CLEAR_ATTRBIT(attrs, code);
1399 return STORE_ATTR_INFO_set_number(attrs, code, number);
1402 struct attr_list_ctx_st
1404 OPENSSL_ITEM *attributes;
1406 void *STORE_parse_attrs_start(OPENSSL_ITEM *attributes)
1410 struct attr_list_ctx_st *context =
1411 (struct attr_list_ctx_st *)OPENSSL_malloc(sizeof(struct attr_list_ctx_st));
1413 context->attributes = attributes;
1415 STOREerr(STORE_F_STORE_PARSE_ATTRS_END,
1416 ERR_R_MALLOC_FAILURE);
1419 STOREerr(STORE_F_STORE_PARSE_ATTRS_END, ERR_R_PASSED_NULL_PARAMETER);
1422 STORE_ATTR_INFO *STORE_parse_attrs_next(void *handle)
1424 struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle;
1426 if (context && context->attributes)
1428 STORE_ATTR_INFO *attrs = NULL;
1430 while(context->attributes
1431 && context->attributes->code != STORE_ATTR_OR
1432 && context->attributes->code != STORE_ATTR_END)
1434 switch(context->attributes->code)
1436 case STORE_ATTR_FRIENDLYNAME:
1437 case STORE_ATTR_EMAIL:
1438 case STORE_ATTR_FILENAME:
1439 if (!attrs) attrs = STORE_ATTR_INFO_new();
1442 STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT,
1443 ERR_R_MALLOC_FAILURE);
1446 STORE_ATTR_INFO_set_cstr(attrs,
1447 context->attributes->code,
1448 context->attributes->value,
1449 context->attributes->value_size);
1451 case STORE_ATTR_KEYID:
1452 case STORE_ATTR_ISSUERKEYID:
1453 case STORE_ATTR_SUBJECTKEYID:
1454 case STORE_ATTR_ISSUERSERIALHASH:
1455 case STORE_ATTR_CERTHASH:
1456 if (!attrs) attrs = STORE_ATTR_INFO_new();
1459 STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT,
1460 ERR_R_MALLOC_FAILURE);
1463 STORE_ATTR_INFO_set_sha1str(attrs,
1464 context->attributes->code,
1465 context->attributes->value,
1466 context->attributes->value_size);
1468 case STORE_ATTR_ISSUER:
1469 case STORE_ATTR_SUBJECT:
1470 if (!attrs) attrs = STORE_ATTR_INFO_new();
1473 STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT,
1474 ERR_R_MALLOC_FAILURE);
1477 STORE_ATTR_INFO_modify_dn(attrs,
1478 context->attributes->code,
1479 context->attributes->value);
1481 case STORE_ATTR_SERIAL:
1482 if (!attrs) attrs = STORE_ATTR_INFO_new();
1485 STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT,
1486 ERR_R_MALLOC_FAILURE);
1489 STORE_ATTR_INFO_modify_number(attrs,
1490 context->attributes->code,
1491 context->attributes->value);
1494 context->attributes++;
1496 if (context->attributes->code == STORE_ATTR_OR)
1497 context->attributes++;
1500 while(context->attributes
1501 && context->attributes->code != STORE_ATTR_OR
1502 && context->attributes->code != STORE_ATTR_END)
1503 context->attributes++;
1504 if (context->attributes->code == STORE_ATTR_OR)
1505 context->attributes++;
1508 STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, ERR_R_PASSED_NULL_PARAMETER);
1511 int STORE_parse_attrs_end(void *handle)
1513 struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle;
1515 if (context && context->attributes)
1518 OPENSSL_ITEM *attributes = context->attributes;
1520 OPENSSL_free(context);
1523 STOREerr(STORE_F_STORE_PARSE_ATTRS_END, ERR_R_PASSED_NULL_PARAMETER);
1527 int STORE_parse_attrs_endp(void *handle)
1529 struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle;
1531 if (context && context->attributes)
1533 return context->attributes->code == STORE_ATTR_END;
1535 STOREerr(STORE_F_STORE_PARSE_ATTRS_END, ERR_R_PASSED_NULL_PARAMETER);
1539 int STORE_ATTR_INFO_compare(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b)
1541 unsigned char *abits, *bbits;
1544 if (a == b) return 0;
1549 for (i = 0; i < (STORE_ATTR_TYPE_NUM + 8) / 8; i++, abits++, bbits++)
1551 if (*abits < *bbits) return -1;
1552 if (*abits > *bbits) return 1;
1556 int STORE_ATTR_INFO_in(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b)
1558 unsigned char *abits, *bbits;
1561 if (a == b) return 1;
1566 for (i = 0; i < (STORE_ATTR_TYPE_NUM + 8) / 8; i++, abits++, bbits++)
1568 if (*abits && *bbits != *abits)
1573 int STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b)
1577 if (a == b) return 1;
1578 if (!STORE_ATTR_INFO_in(a, b)) return 0;
1579 for (i = 1; i < STORE_ATTR_TYPE_NUM; i++)
1580 if (ATTR_IS_SET(a, i))
1584 case STORE_ATTR_FRIENDLYNAME:
1585 case STORE_ATTR_EMAIL:
1586 case STORE_ATTR_FILENAME:
1587 if (strcmp(a->values[i].cstring,
1588 b->values[i].cstring))
1591 case STORE_ATTR_KEYID:
1592 case STORE_ATTR_ISSUERKEYID:
1593 case STORE_ATTR_SUBJECTKEYID:
1594 case STORE_ATTR_ISSUERSERIALHASH:
1595 case STORE_ATTR_CERTHASH:
1596 if (memcmp(a->values[i].sha1string,
1597 b->values[i].sha1string,
1601 case STORE_ATTR_ISSUER:
1602 case STORE_ATTR_SUBJECT:
1603 if (X509_NAME_cmp(a->values[i].dn,
1607 case STORE_ATTR_SERIAL:
1608 if (BN_cmp(a->values[i].number,
1609 b->values[i].number))