diff options
Diffstat (limited to 'src/lib/libcrypto/store')
| -rw-r--r-- | src/lib/libcrypto/store/Makefile | 112 | ||||
| -rw-r--r-- | src/lib/libcrypto/store/README | 95 | ||||
| -rw-r--r-- | src/lib/libcrypto/store/store.h | 561 | ||||
| -rw-r--r-- | src/lib/libcrypto/store/str_err.c | 211 | ||||
| -rw-r--r-- | src/lib/libcrypto/store/str_lib.c | 1828 | ||||
| -rw-r--r-- | src/lib/libcrypto/store/str_locl.h | 124 | ||||
| -rw-r--r-- | src/lib/libcrypto/store/str_mem.c | 365 | ||||
| -rw-r--r-- | src/lib/libcrypto/store/str_meth.c | 250 | 
8 files changed, 3546 insertions, 0 deletions
diff --git a/src/lib/libcrypto/store/Makefile b/src/lib/libcrypto/store/Makefile new file mode 100644 index 0000000000..0dcfd7857a --- /dev/null +++ b/src/lib/libcrypto/store/Makefile  | |||
| @@ -0,0 +1,112 @@ | |||
| 1 | # | ||
| 2 | # OpenSSL/crypto/store/Makefile | ||
| 3 | # | ||
| 4 | |||
| 5 | DIR= store | ||
| 6 | TOP= ../.. | ||
| 7 | CC= cc | ||
| 8 | INCLUDES= -I.. -I$(TOP) -I../../include | ||
| 9 | CFLAG=-g | ||
| 10 | MAKEFILE= Makefile | ||
| 11 | AR= ar r | ||
| 12 | |||
| 13 | CFLAGS= $(INCLUDES) $(CFLAG) | ||
| 14 | |||
| 15 | GENERAL=Makefile | ||
| 16 | #TEST= storetest.c | ||
| 17 | TEST= | ||
| 18 | APPS= | ||
| 19 | |||
| 20 | LIB=$(TOP)/libcrypto.a | ||
| 21 | LIBSRC= str_err.c str_lib.c str_meth.c str_mem.c | ||
| 22 | LIBOBJ= str_err.o str_lib.o str_meth.o str_mem.o | ||
| 23 | |||
| 24 | SRC= $(LIBSRC) | ||
| 25 | |||
| 26 | #EXHEADER= store.h str_compat.h | ||
| 27 | EXHEADER= store.h | ||
| 28 | HEADER= $(EXHEADER) str_locl.h | ||
| 29 | |||
| 30 | ALL= $(GENERAL) $(SRC) $(HEADER) | ||
| 31 | |||
| 32 | top: | ||
| 33 | (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) | ||
| 34 | |||
| 35 | all: lib | ||
| 36 | |||
| 37 | lib: $(LIBOBJ) | ||
| 38 | $(AR) $(LIB) $(LIBOBJ) | ||
| 39 | $(RANLIB) $(LIB) || echo Never mind. | ||
| 40 | @touch lib | ||
| 41 | |||
| 42 | files: | ||
| 43 | $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO | ||
| 44 | |||
| 45 | links: | ||
| 46 | @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) | ||
| 47 | @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) | ||
| 48 | @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) | ||
| 49 | |||
| 50 | install: | ||
| 51 | @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile... | ||
| 52 | @headerlist="$(EXHEADER)"; for i in $$headerlist; \ | ||
| 53 | do \ | ||
| 54 | (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ | ||
| 55 | chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ | ||
| 56 | done; | ||
| 57 | |||
| 58 | tags: | ||
| 59 | ctags $(SRC) | ||
| 60 | |||
| 61 | tests: | ||
| 62 | |||
| 63 | lint: | ||
| 64 | lint -DLINT $(INCLUDES) $(SRC)>fluff | ||
| 65 | |||
| 66 | depend: | ||
| 67 | @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile... | ||
| 68 | $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC) | ||
| 69 | |||
| 70 | dclean: | ||
| 71 | $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new | ||
| 72 | mv -f Makefile.new $(MAKEFILE) | ||
| 73 | |||
| 74 | clean: | ||
| 75 | rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff | ||
| 76 | |||
| 77 | # DO NOT DELETE THIS LINE -- make depend depends on it. | ||
| 78 | |||
| 79 | str_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h | ||
| 80 | str_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 81 | str_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 82 | str_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 83 | str_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 84 | str_err.o: ../../include/openssl/store.h ../../include/openssl/symhacks.h | ||
| 85 | str_err.o: str_err.c | ||
| 86 | str_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 87 | str_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
| 88 | str_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | ||
| 89 | str_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h | ||
| 90 | str_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h | ||
| 91 | str_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 92 | str_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | ||
| 93 | str_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
| 94 | str_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 95 | str_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h | ||
| 96 | str_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 97 | str_lib.o: ../../include/openssl/store.h ../../include/openssl/symhacks.h | ||
| 98 | str_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 99 | str_lib.o: str_lib.c str_locl.h | ||
| 100 | str_mem.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h | ||
| 101 | str_mem.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 102 | str_mem.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 103 | str_mem.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 104 | str_mem.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 105 | str_mem.o: ../../include/openssl/store.h ../../include/openssl/symhacks.h | ||
| 106 | str_mem.o: str_locl.h str_mem.c | ||
| 107 | str_meth.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 108 | str_meth.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h | ||
| 109 | str_meth.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 110 | str_meth.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 111 | str_meth.o: ../../include/openssl/store.h ../../include/openssl/symhacks.h | ||
| 112 | str_meth.o: str_locl.h str_meth.c | ||
diff --git a/src/lib/libcrypto/store/README b/src/lib/libcrypto/store/README new file mode 100644 index 0000000000..966168f6a5 --- /dev/null +++ b/src/lib/libcrypto/store/README  | |||
| @@ -0,0 +1,95 @@ | |||
| 1 | The STORE type | ||
| 2 | ============== | ||
| 3 | |||
| 4 | A STORE, as defined in this code section, is really a rather simple | ||
| 5 | thing which stores objects and per-object associations to a number | ||
| 6 | of attributes. What attributes are supported entirely depends on | ||
| 7 | the particular implementation of a STORE. It has some support for | ||
| 8 | generation of certain objects (for example, keys and CRLs). | ||
| 9 | |||
| 10 | |||
| 11 | Supported object types | ||
| 12 | ---------------------- | ||
| 13 | |||
| 14 | For now, the objects that are supported are the following: | ||
| 15 | |||
| 16 | X.509 certificate | ||
| 17 | X.509 CRL | ||
| 18 | private key | ||
| 19 | public key | ||
| 20 | number | ||
| 21 | arbitrary (application) data | ||
| 22 | |||
| 23 | The intention is that a STORE should be able to store everything | ||
| 24 | needed by an application that wants a cert/key store, as well as | ||
| 25 | the data a CA might need to store (this includes the serial number | ||
| 26 | counter, which explains the support for numbers). | ||
| 27 | |||
| 28 | |||
| 29 | Supported attribute types | ||
| 30 | ------------------------- | ||
| 31 | |||
| 32 | For now, the following attributes are supported: | ||
| 33 | |||
| 34 | Friendly Name - the value is a normal C string | ||
| 35 | Key ID - the value is a 160 bit SHA1 hash | ||
| 36 | Issuer Key ID - the value is a 160 bit SHA1 hash | ||
| 37 | Subject Key ID - the value is a 160 bit SHA1 hash | ||
| 38 | Issuer/Serial Hash - the value is a 160 bit SHA1 hash | ||
| 39 | Issuer - the value is a X509_NAME | ||
| 40 | Serial - the value is a BIGNUM | ||
| 41 | Subject - the value is a X509_NAME | ||
| 42 | Certificate Hash - the value is a 160 bit SHA1 hash | ||
| 43 | Email - the value is a normal C string | ||
| 44 | Filename - the value is a normal C string | ||
| 45 | |||
| 46 | It is expected that these attributes should be enough to support | ||
| 47 | the need from most, if not all, current applications. Applications | ||
| 48 | that need to do certificate verification would typically use Subject | ||
| 49 | Key ID, Issuer/Serial Hash or Subject to look up issuer certificates. | ||
| 50 | S/MIME applications would typically use Email to look up recipient | ||
| 51 | and signer certificates. | ||
| 52 | |||
| 53 | There's added support for combined sets of attributes to search for, | ||
| 54 | with the special OR attribute. | ||
| 55 | |||
| 56 | |||
| 57 | Supported basic functionality | ||
| 58 | ----------------------------- | ||
| 59 | |||
| 60 | The functions that are supported through the STORE type are these: | ||
| 61 | |||
| 62 | generate_object - for example to generate keys and CRLs | ||
| 63 | get_object - to look up one object | ||
| 64 | NOTE: this function is really rather | ||
| 65 | redundant and probably of lesser usage | ||
| 66 | than the list functions | ||
| 67 | store_object - store an object and the attributes | ||
| 68 | associated with it | ||
| 69 | modify_object - modify the attributes associated with | ||
| 70 | a specific object | ||
| 71 | revoke_object - revoke an object | ||
| 72 | NOTE: this only marks an object as | ||
| 73 | invalid, it doesn't remove the object | ||
| 74 | from the database | ||
| 75 | delete_object - remove an object from the database | ||
| 76 | list_object - list objects associated with a given | ||
| 77 | set of attributes | ||
| 78 | NOTE: this is really four functions: | ||
| 79 | list_start, list_next, list_end and | ||
| 80 | list_endp | ||
| 81 | update_store - update the internal data of the store | ||
| 82 | lock_store - lock the store | ||
| 83 | unlock_store - unlock the store | ||
| 84 | |||
| 85 | The list functions need some extra explanation: list_start is | ||
| 86 | used to set up a lookup. That's where the attributes to use in | ||
| 87 | the search are set up. It returns a search context. list_next | ||
| 88 | returns the next object searched for. list_end closes the search. | ||
| 89 | list_endp is used to check if we have reached the end. | ||
| 90 | |||
| 91 | A few words on the store functions as well: update_store is | ||
| 92 | typically used by a CA application to update the internal | ||
| 93 | structure of a database. This may for example involve automatic | ||
| 94 | removal of expired certificates. lock_store and unlock_store | ||
| 95 | are used for locking a store to allow exclusive writes. | ||
diff --git a/src/lib/libcrypto/store/store.h b/src/lib/libcrypto/store/store.h new file mode 100644 index 0000000000..0a28c7d5a2 --- /dev/null +++ b/src/lib/libcrypto/store/store.h  | |||
| @@ -0,0 +1,561 @@ | |||
| 1 | /* crypto/store/store.h -*- mode:C; c-file-style: "eay" -*- */ | ||
| 2 | /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL | ||
| 3 | * project 2003. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 2003 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 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 | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 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/)" | ||
| 24 | * | ||
| 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. | ||
| 29 | * | ||
| 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. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
| 38 | * | ||
| 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 | * ==================================================================== | ||
| 52 | * | ||
| 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). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef HEADER_STORE_H | ||
| 60 | #define HEADER_STORE_H | ||
| 61 | |||
| 62 | #include <openssl/opensslconf.h> | ||
| 63 | |||
| 64 | #ifdef OPENSSL_NO_STORE | ||
| 65 | #error STORE is disabled. | ||
| 66 | #endif | ||
| 67 | |||
| 68 | #include <openssl/ossl_typ.h> | ||
| 69 | #ifndef OPENSSL_NO_DEPRECATED | ||
| 70 | #include <openssl/evp.h> | ||
| 71 | #include <openssl/bn.h> | ||
| 72 | #include <openssl/x509.h> | ||
| 73 | #endif | ||
| 74 | |||
| 75 | #ifdef __cplusplus | ||
| 76 | extern "C" { | ||
| 77 | #endif | ||
| 78 | |||
| 79 | /* Already defined in ossl_typ.h */ | ||
| 80 | /* typedef struct store_st STORE; */ | ||
| 81 | /* typedef struct store_method_st STORE_METHOD; */ | ||
| 82 | |||
| 83 | |||
| 84 | /* All the following functions return 0, a negative number or NULL on error. | ||
| 85 | When everything is fine, they return a positive value or a non-NULL | ||
| 86 | pointer, all depending on their purpose. */ | ||
| 87 | |||
| 88 | /* Creators and destructor. */ | ||
| 89 | STORE *STORE_new_method(const STORE_METHOD *method); | ||
| 90 | STORE *STORE_new_engine(ENGINE *engine); | ||
| 91 | void STORE_free(STORE *ui); | ||
| 92 | |||
| 93 | |||
| 94 | /* Give a user interface parametrised control commands. This can be used to | ||
| 95 | send down an integer, a data pointer or a function pointer, as well as | ||
| 96 | be used to get information from a STORE. */ | ||
| 97 | int STORE_ctrl(STORE *store, int cmd, long i, void *p, void (*f)(void)); | ||
| 98 | |||
| 99 | /* A control to set the directory with keys and certificates. Used by the | ||
| 100 | built-in directory level method. */ | ||
| 101 | #define STORE_CTRL_SET_DIRECTORY 0x0001 | ||
| 102 | /* A control to set a file to load. Used by the built-in file level method. */ | ||
| 103 | #define STORE_CTRL_SET_FILE 0x0002 | ||
| 104 | /* A control to set a configuration file to load. Can be used by any method | ||
| 105 | that wishes to load a configuration file. */ | ||
| 106 | #define STORE_CTRL_SET_CONF_FILE 0x0003 | ||
| 107 | /* A control to set a the section of the loaded configuration file. Can be | ||
| 108 | used by any method that wishes to load a configuration file. */ | ||
| 109 | #define STORE_CTRL_SET_CONF_SECTION 0x0004 | ||
| 110 | |||
| 111 | |||
| 112 | /* Some methods may use extra data */ | ||
| 113 | #define STORE_set_app_data(s,arg) STORE_set_ex_data(s,0,arg) | ||
| 114 | #define STORE_get_app_data(s) STORE_get_ex_data(s,0) | ||
| 115 | int STORE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, | ||
| 116 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); | ||
| 117 | int STORE_set_ex_data(STORE *r,int idx,void *arg); | ||
| 118 | void *STORE_get_ex_data(STORE *r, int idx); | ||
| 119 | |||
| 120 | /* Use specific methods instead of the built-in one */ | ||
| 121 | const STORE_METHOD *STORE_get_method(STORE *store); | ||
| 122 | const STORE_METHOD *STORE_set_method(STORE *store, const STORE_METHOD *meth); | ||
| 123 | |||
| 124 | /* The standard OpenSSL methods. */ | ||
| 125 | /* This is the in-memory method. It does everything except revoking and updating, | ||
| 126 | and is of course volatile. It's used by other methods that have an in-memory | ||
| 127 | cache. */ | ||
| 128 | const STORE_METHOD *STORE_Memory(void); | ||
| 129 | #if 0 /* Not yet implemented */ | ||
| 130 | /* This is the directory store. It does everything except revoking and updating, | ||
| 131 | and uses STORE_Memory() to cache things in memory. */ | ||
| 132 | const STORE_METHOD *STORE_Directory(void); | ||
| 133 | /* This is the file store. It does everything except revoking and updating, | ||
| 134 | and uses STORE_Memory() to cache things in memory. Certificates are added | ||
| 135 | to it with the store operation, and it will only get cached certificates. */ | ||
| 136 | const STORE_METHOD *STORE_File(void); | ||
| 137 | #endif | ||
| 138 | |||
| 139 | /* Store functions take a type code for the type of data they should store | ||
| 140 | or fetch */ | ||
| 141 | typedef enum STORE_object_types | ||
| 142 | { | ||
| 143 | STORE_OBJECT_TYPE_X509_CERTIFICATE= 0x01, /* X509 * */ | ||
| 144 | STORE_OBJECT_TYPE_X509_CRL= 0x02, /* X509_CRL * */ | ||
| 145 | STORE_OBJECT_TYPE_PRIVATE_KEY= 0x03, /* EVP_PKEY * */ | ||
| 146 | STORE_OBJECT_TYPE_PUBLIC_KEY= 0x04, /* EVP_PKEY * */ | ||
| 147 | STORE_OBJECT_TYPE_NUMBER= 0x05, /* BIGNUM * */ | ||
| 148 | STORE_OBJECT_TYPE_ARBITRARY= 0x06, /* BUF_MEM * */ | ||
| 149 | STORE_OBJECT_TYPE_NUM= 0x06 /* The amount of known | ||
| 150 | object types */ | ||
| 151 | } STORE_OBJECT_TYPES; | ||
| 152 | /* List of text strings corresponding to the object types. */ | ||
| 153 | extern const char * const STORE_object_type_string[STORE_OBJECT_TYPE_NUM+1]; | ||
| 154 | |||
| 155 | /* Some store functions take a parameter list. Those parameters come with | ||
| 156 | one of the following codes. The comments following the codes below indicate | ||
| 157 | what type the value should be a pointer to. */ | ||
| 158 | typedef enum STORE_params | ||
| 159 | { | ||
| 160 | STORE_PARAM_EVP_TYPE= 0x01, /* int */ | ||
| 161 | STORE_PARAM_BITS= 0x02, /* size_t */ | ||
| 162 | STORE_PARAM_KEY_PARAMETERS= 0x03, /* ??? */ | ||
| 163 | STORE_PARAM_KEY_NO_PARAMETERS= 0x04, /* N/A */ | ||
| 164 | STORE_PARAM_AUTH_PASSPHRASE= 0x05, /* char * */ | ||
| 165 | STORE_PARAM_AUTH_KRB5_TICKET= 0x06, /* void * */ | ||
| 166 | STORE_PARAM_TYPE_NUM= 0x06 /* The amount of known | ||
| 167 | parameter types */ | ||
| 168 | } STORE_PARAM_TYPES; | ||
| 169 | /* Parameter value sizes. -1 means unknown, anything else is the required size. */ | ||
| 170 | extern const int STORE_param_sizes[STORE_PARAM_TYPE_NUM+1]; | ||
| 171 | |||
| 172 | /* Store functions take attribute lists. Those attributes come with codes. | ||
| 173 | The comments following the codes below indicate what type the value should | ||
| 174 | be a pointer to. */ | ||
| 175 | typedef enum STORE_attribs | ||
| 176 | { | ||
| 177 | STORE_ATTR_END= 0x00, | ||
| 178 | STORE_ATTR_FRIENDLYNAME= 0x01, /* C string */ | ||
| 179 | STORE_ATTR_KEYID= 0x02, /* 160 bit string (SHA1) */ | ||
| 180 | STORE_ATTR_ISSUERKEYID= 0x03, /* 160 bit string (SHA1) */ | ||
| 181 | STORE_ATTR_SUBJECTKEYID= 0x04, /* 160 bit string (SHA1) */ | ||
| 182 | STORE_ATTR_ISSUERSERIALHASH= 0x05, /* 160 bit string (SHA1) */ | ||
| 183 | STORE_ATTR_ISSUER= 0x06, /* X509_NAME * */ | ||
| 184 | STORE_ATTR_SERIAL= 0x07, /* BIGNUM * */ | ||
| 185 | STORE_ATTR_SUBJECT= 0x08, /* X509_NAME * */ | ||
| 186 | STORE_ATTR_CERTHASH= 0x09, /* 160 bit string (SHA1) */ | ||
| 187 | STORE_ATTR_EMAIL= 0x0a, /* C string */ | ||
| 188 | STORE_ATTR_FILENAME= 0x0b, /* C string */ | ||
| 189 | STORE_ATTR_TYPE_NUM= 0x0b, /* The amount of known | ||
| 190 | attribute types */ | ||
| 191 | STORE_ATTR_OR= 0xff /* This is a special | ||
| 192 | separator, which | ||
| 193 | expresses the OR | ||
| 194 | operation. */ | ||
| 195 | } STORE_ATTR_TYPES; | ||
| 196 | /* Attribute value sizes. -1 means unknown, anything else is the required size. */ | ||
| 197 | extern const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM+1]; | ||
| 198 | |||
| 199 | typedef enum STORE_certificate_status | ||
| 200 | { | ||
| 201 | STORE_X509_VALID= 0x00, | ||
| 202 | STORE_X509_EXPIRED= 0x01, | ||
| 203 | STORE_X509_SUSPENDED= 0x02, | ||
| 204 | STORE_X509_REVOKED= 0x03 | ||
| 205 | } STORE_CERTIFICATE_STATUS; | ||
| 206 | |||
| 207 | /* Engine store functions will return a structure that contains all the necessary | ||
| 208 | * information, including revokation status for certificates. This is really not | ||
| 209 | * needed for application authors, as the ENGINE framework functions will extract | ||
| 210 | * the OpenSSL-specific information when at all possible. However, for engine | ||
| 211 | * authors, it's crucial to know this structure. */ | ||
| 212 | typedef struct STORE_OBJECT_st | ||
| 213 | { | ||
| 214 | STORE_OBJECT_TYPES type; | ||
| 215 | union | ||
| 216 | { | ||
| 217 | struct | ||
| 218 | { | ||
| 219 | STORE_CERTIFICATE_STATUS status; | ||
| 220 | X509 *certificate; | ||
| 221 | } x509; | ||
| 222 | X509_CRL *crl; | ||
| 223 | EVP_PKEY *key; | ||
| 224 | BIGNUM *number; | ||
| 225 | BUF_MEM *arbitrary; | ||
| 226 | } data; | ||
| 227 | } STORE_OBJECT; | ||
| 228 | DECLARE_STACK_OF(STORE_OBJECT) | ||
| 229 | STORE_OBJECT *STORE_OBJECT_new(void); | ||
| 230 | void STORE_OBJECT_free(STORE_OBJECT *data); | ||
| 231 | |||
| 232 | |||
| 233 | |||
| 234 | /* The following functions handle the storage. They return 0, a negative number | ||
| 235 | or NULL on error, anything else on success. */ | ||
| 236 | X509 *STORE_get_certificate(STORE *e, OPENSSL_ITEM attributes[], | ||
| 237 | OPENSSL_ITEM parameters[]); | ||
| 238 | int STORE_store_certificate(STORE *e, X509 *data, OPENSSL_ITEM attributes[], | ||
| 239 | OPENSSL_ITEM parameters[]); | ||
| 240 | int STORE_modify_certificate(STORE *e, OPENSSL_ITEM search_attributes[], | ||
| 241 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | ||
| 242 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); | ||
| 243 | int STORE_revoke_certificate(STORE *e, OPENSSL_ITEM attributes[], | ||
| 244 | OPENSSL_ITEM parameters[]); | ||
| 245 | int STORE_delete_certificate(STORE *e, OPENSSL_ITEM attributes[], | ||
| 246 | OPENSSL_ITEM parameters[]); | ||
| 247 | void *STORE_list_certificate_start(STORE *e, OPENSSL_ITEM attributes[], | ||
| 248 | OPENSSL_ITEM parameters[]); | ||
| 249 | X509 *STORE_list_certificate_next(STORE *e, void *handle); | ||
| 250 | int STORE_list_certificate_end(STORE *e, void *handle); | ||
| 251 | int STORE_list_certificate_endp(STORE *e, void *handle); | ||
| 252 | EVP_PKEY *STORE_generate_key(STORE *e, OPENSSL_ITEM attributes[], | ||
| 253 | OPENSSL_ITEM parameters[]); | ||
| 254 | EVP_PKEY *STORE_get_private_key(STORE *e, OPENSSL_ITEM attributes[], | ||
| 255 | OPENSSL_ITEM parameters[]); | ||
| 256 | int STORE_store_private_key(STORE *e, EVP_PKEY *data, | ||
| 257 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | ||
| 258 | int STORE_modify_private_key(STORE *e, OPENSSL_ITEM search_attributes[], | ||
| 259 | OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], | ||
| 260 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); | ||
| 261 | int STORE_revoke_private_key(STORE *e, OPENSSL_ITEM attributes[], | ||
| 262 | OPENSSL_ITEM parameters[]); | ||
| 263 | int STORE_delete_private_key(STORE *e, OPENSSL_ITEM attributes[], | ||
| 264 | OPENSSL_ITEM parameters[]); | ||
| 265 | void *STORE_list_private_key_start(STORE *e, OPENSSL_ITEM attributes[], | ||
| 266 | OPENSSL_ITEM parameters[]); | ||
| 267 | EVP_PKEY *STORE_list_private_key_next(STORE *e, void *handle); | ||
| 268 | int STORE_list_private_key_end(STORE *e, void *handle); | ||
| 269 | int STORE_list_private_key_endp(STORE *e, void *handle); | ||
| 270 | EVP_PKEY *STORE_get_public_key(STORE *e, OPENSSL_ITEM attributes[], | ||
| 271 | OPENSSL_ITEM parameters[]); | ||
| 272 | int STORE_store_public_key(STORE *e, EVP_PKEY *data, OPENSSL_ITEM attributes[], | ||
| 273 | OPENSSL_ITEM parameters[]); | ||
| 274 | int STORE_modify_public_key(STORE *e, OPENSSL_ITEM search_attributes[], | ||
| 275 | OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], | ||
| 276 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); | ||
| 277 | int STORE_revoke_public_key(STORE *e, OPENSSL_ITEM attributes[], | ||
| 278 | OPENSSL_ITEM parameters[]); | ||
| 279 | int STORE_delete_public_key(STORE *e, OPENSSL_ITEM attributes[], | ||
| 280 | OPENSSL_ITEM parameters[]); | ||
| 281 | void *STORE_list_public_key_start(STORE *e, OPENSSL_ITEM attributes[], | ||
| 282 | OPENSSL_ITEM parameters[]); | ||
| 283 | EVP_PKEY *STORE_list_public_key_next(STORE *e, void *handle); | ||
| 284 | int STORE_list_public_key_end(STORE *e, void *handle); | ||
| 285 | int STORE_list_public_key_endp(STORE *e, void *handle); | ||
| 286 | X509_CRL *STORE_generate_crl(STORE *e, OPENSSL_ITEM attributes[], | ||
| 287 | OPENSSL_ITEM parameters[]); | ||
| 288 | X509_CRL *STORE_get_crl(STORE *e, OPENSSL_ITEM attributes[], | ||
| 289 | OPENSSL_ITEM parameters[]); | ||
| 290 | int STORE_store_crl(STORE *e, X509_CRL *data, OPENSSL_ITEM attributes[], | ||
| 291 | OPENSSL_ITEM parameters[]); | ||
| 292 | int STORE_modify_crl(STORE *e, OPENSSL_ITEM search_attributes[], | ||
| 293 | OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], | ||
| 294 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); | ||
| 295 | int STORE_delete_crl(STORE *e, OPENSSL_ITEM attributes[], | ||
| 296 | OPENSSL_ITEM parameters[]); | ||
| 297 | void *STORE_list_crl_start(STORE *e, OPENSSL_ITEM attributes[], | ||
| 298 | OPENSSL_ITEM parameters[]); | ||
| 299 | X509_CRL *STORE_list_crl_next(STORE *e, void *handle); | ||
| 300 | int STORE_list_crl_end(STORE *e, void *handle); | ||
| 301 | int STORE_list_crl_endp(STORE *e, void *handle); | ||
| 302 | int STORE_store_number(STORE *e, BIGNUM *data, OPENSSL_ITEM attributes[], | ||
| 303 | OPENSSL_ITEM parameters[]); | ||
| 304 | int STORE_modify_number(STORE *e, OPENSSL_ITEM search_attributes[], | ||
| 305 | OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], | ||
| 306 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); | ||
| 307 | BIGNUM *STORE_get_number(STORE *e, OPENSSL_ITEM attributes[], | ||
| 308 | OPENSSL_ITEM parameters[]); | ||
| 309 | int STORE_delete_number(STORE *e, OPENSSL_ITEM attributes[], | ||
| 310 | OPENSSL_ITEM parameters[]); | ||
| 311 | int STORE_store_arbitrary(STORE *e, BUF_MEM *data, OPENSSL_ITEM attributes[], | ||
| 312 | OPENSSL_ITEM parameters[]); | ||
| 313 | int STORE_modify_arbitrary(STORE *e, OPENSSL_ITEM search_attributes[], | ||
| 314 | OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], | ||
| 315 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); | ||
| 316 | BUF_MEM *STORE_get_arbitrary(STORE *e, OPENSSL_ITEM attributes[], | ||
| 317 | OPENSSL_ITEM parameters[]); | ||
| 318 | int STORE_delete_arbitrary(STORE *e, OPENSSL_ITEM attributes[], | ||
| 319 | OPENSSL_ITEM parameters[]); | ||
| 320 | |||
| 321 | |||
| 322 | /* Create and manipulate methods */ | ||
| 323 | STORE_METHOD *STORE_create_method(char *name); | ||
| 324 | void STORE_destroy_method(STORE_METHOD *store_method); | ||
| 325 | |||
| 326 | /* These callback types are use for store handlers */ | ||
| 327 | typedef int (*STORE_INITIALISE_FUNC_PTR)(STORE *); | ||
| 328 | typedef void (*STORE_CLEANUP_FUNC_PTR)(STORE *); | ||
| 329 | typedef STORE_OBJECT *(*STORE_GENERATE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | ||
| 330 | typedef STORE_OBJECT *(*STORE_GET_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | ||
| 331 | typedef void *(*STORE_START_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | ||
| 332 | typedef STORE_OBJECT *(*STORE_NEXT_OBJECT_FUNC_PTR)(STORE *, void *handle); | ||
| 333 | typedef int (*STORE_END_OBJECT_FUNC_PTR)(STORE *, void *handle); | ||
| 334 | typedef int (*STORE_HANDLE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | ||
| 335 | typedef int (*STORE_STORE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, STORE_OBJECT *data, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | ||
| 336 | typedef int (*STORE_MODIFY_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM search_attributes[], OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); | ||
| 337 | typedef int (*STORE_GENERIC_FUNC_PTR)(STORE *, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | ||
| 338 | typedef int (*STORE_CTRL_FUNC_PTR)(STORE *, int cmd, long l, void *p, void (*f)(void)); | ||
| 339 | |||
| 340 | int STORE_method_set_initialise_function(STORE_METHOD *sm, STORE_INITIALISE_FUNC_PTR init_f); | ||
| 341 | int STORE_method_set_cleanup_function(STORE_METHOD *sm, STORE_CLEANUP_FUNC_PTR clean_f); | ||
| 342 | int STORE_method_set_generate_function(STORE_METHOD *sm, STORE_GENERATE_OBJECT_FUNC_PTR generate_f); | ||
| 343 | int STORE_method_set_get_function(STORE_METHOD *sm, STORE_GET_OBJECT_FUNC_PTR get_f); | ||
| 344 | int STORE_method_set_store_function(STORE_METHOD *sm, STORE_STORE_OBJECT_FUNC_PTR store_f); | ||
| 345 | int STORE_method_set_modify_function(STORE_METHOD *sm, STORE_MODIFY_OBJECT_FUNC_PTR store_f); | ||
| 346 | int STORE_method_set_revoke_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR revoke_f); | ||
| 347 | int STORE_method_set_delete_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR delete_f); | ||
| 348 | int STORE_method_set_list_start_function(STORE_METHOD *sm, STORE_START_OBJECT_FUNC_PTR list_start_f); | ||
| 349 | int STORE_method_set_list_next_function(STORE_METHOD *sm, STORE_NEXT_OBJECT_FUNC_PTR list_next_f); | ||
| 350 | int STORE_method_set_list_end_function(STORE_METHOD *sm, STORE_END_OBJECT_FUNC_PTR list_end_f); | ||
| 351 | int STORE_method_set_update_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); | ||
| 352 | int STORE_method_set_lock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); | ||
| 353 | int STORE_method_set_unlock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); | ||
| 354 | int STORE_method_set_ctrl_function(STORE_METHOD *sm, STORE_CTRL_FUNC_PTR ctrl_f); | ||
| 355 | |||
| 356 | STORE_INITIALISE_FUNC_PTR STORE_method_get_initialise_function(STORE_METHOD *sm); | ||
| 357 | STORE_CLEANUP_FUNC_PTR STORE_method_get_cleanup_function(STORE_METHOD *sm); | ||
| 358 | STORE_GENERATE_OBJECT_FUNC_PTR STORE_method_get_generate_function(STORE_METHOD *sm); | ||
| 359 | STORE_GET_OBJECT_FUNC_PTR STORE_method_get_get_function(STORE_METHOD *sm); | ||
| 360 | STORE_STORE_OBJECT_FUNC_PTR STORE_method_get_store_function(STORE_METHOD *sm); | ||
| 361 | STORE_MODIFY_OBJECT_FUNC_PTR STORE_method_get_modify_function(STORE_METHOD *sm); | ||
| 362 | STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_revoke_function(STORE_METHOD *sm); | ||
| 363 | STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_delete_function(STORE_METHOD *sm); | ||
| 364 | STORE_START_OBJECT_FUNC_PTR STORE_method_get_list_start_function(STORE_METHOD *sm); | ||
| 365 | STORE_NEXT_OBJECT_FUNC_PTR STORE_method_get_list_next_function(STORE_METHOD *sm); | ||
| 366 | STORE_END_OBJECT_FUNC_PTR STORE_method_get_list_end_function(STORE_METHOD *sm); | ||
| 367 | STORE_GENERIC_FUNC_PTR STORE_method_get_update_store_function(STORE_METHOD *sm); | ||
| 368 | STORE_GENERIC_FUNC_PTR STORE_method_get_lock_store_function(STORE_METHOD *sm); | ||
| 369 | STORE_GENERIC_FUNC_PTR STORE_method_get_unlock_store_function(STORE_METHOD *sm); | ||
| 370 | STORE_CTRL_FUNC_PTR STORE_method_get_ctrl_function(STORE_METHOD *sm); | ||
| 371 | |||
| 372 | /* Method helper structures and functions. */ | ||
| 373 | |||
| 374 | /* This structure is the result of parsing through the information in a list | ||
| 375 | of OPENSSL_ITEMs. It stores all the necessary information in a structured | ||
| 376 | way.*/ | ||
| 377 | typedef struct STORE_attr_info_st STORE_ATTR_INFO; | ||
| 378 | |||
| 379 | /* Parse a list of OPENSSL_ITEMs and return a pointer to a STORE_ATTR_INFO. | ||
| 380 | Note that we do this in the list form, since the list of OPENSSL_ITEMs can | ||
| 381 | come in blocks separated with STORE_ATTR_OR. Note that the value returned | ||
| 382 | by STORE_parse_attrs_next() must be freed with STORE_ATTR_INFO_free(). */ | ||
| 383 | void *STORE_parse_attrs_start(OPENSSL_ITEM *attributes); | ||
| 384 | STORE_ATTR_INFO *STORE_parse_attrs_next(void *handle); | ||
| 385 | int STORE_parse_attrs_end(void *handle); | ||
| 386 | int STORE_parse_attrs_endp(void *handle); | ||
| 387 | |||
| 388 | /* Creator and destructor */ | ||
| 389 | STORE_ATTR_INFO *STORE_ATTR_INFO_new(void); | ||
| 390 | int STORE_ATTR_INFO_free(STORE_ATTR_INFO *attrs); | ||
| 391 | |||
| 392 | /* Manipulators */ | ||
| 393 | char *STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); | ||
| 394 | unsigned char *STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs, | ||
| 395 | STORE_ATTR_TYPES code); | ||
| 396 | X509_NAME *STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); | ||
| 397 | BIGNUM *STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); | ||
| 398 | int STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | ||
| 399 | char *cstr, size_t cstr_size); | ||
| 400 | int STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | ||
| 401 | unsigned char *sha1str, size_t sha1str_size); | ||
| 402 | int STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | ||
| 403 | X509_NAME *dn); | ||
| 404 | int STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | ||
| 405 | BIGNUM *number); | ||
| 406 | int STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | ||
| 407 | char *cstr, size_t cstr_size); | ||
| 408 | int STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | ||
| 409 | unsigned char *sha1str, size_t sha1str_size); | ||
| 410 | int STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | ||
| 411 | X509_NAME *dn); | ||
| 412 | int STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | ||
| 413 | BIGNUM *number); | ||
| 414 | |||
| 415 | /* Compare on basis of a bit pattern formed by the STORE_ATTR_TYPES values | ||
| 416 | in each contained attribute. */ | ||
| 417 | int STORE_ATTR_INFO_compare(const STORE_ATTR_INFO * const *a, | ||
| 418 | const STORE_ATTR_INFO * const *b); | ||
| 419 | /* Check if the set of attributes in a is within the range of attributes | ||
| 420 | set in b. */ | ||
| 421 | int STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); | ||
| 422 | /* Check if the set of attributes in a are also set in b. */ | ||
| 423 | int STORE_ATTR_INFO_in(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); | ||
| 424 | /* Same as STORE_ATTR_INFO_in(), but also checks the attribute values. */ | ||
| 425 | int STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); | ||
| 426 | |||
| 427 | |||
| 428 | /* BEGIN ERROR CODES */ | ||
| 429 | /* The following lines are auto generated by the script mkerr.pl. Any changes | ||
| 430 | * made after this point may be overwritten when the script is next run. | ||
| 431 | */ | ||
| 432 | void ERR_load_STORE_strings(void); | ||
| 433 | |||
| 434 | /* Error codes for the STORE functions. */ | ||
| 435 | |||
| 436 | /* Function codes. */ | ||
| 437 | #define STORE_F_MEM_DELETE 134 | ||
| 438 | #define STORE_F_MEM_GENERATE 135 | ||
| 439 | #define STORE_F_MEM_LIST_END 168 | ||
| 440 | #define STORE_F_MEM_LIST_NEXT 136 | ||
| 441 | #define STORE_F_MEM_LIST_START 137 | ||
| 442 | #define STORE_F_MEM_MODIFY 169 | ||
| 443 | #define STORE_F_MEM_STORE 138 | ||
| 444 | #define STORE_F_STORE_ATTR_INFO_GET0_CSTR 139 | ||
| 445 | #define STORE_F_STORE_ATTR_INFO_GET0_DN 140 | ||
| 446 | #define STORE_F_STORE_ATTR_INFO_GET0_NUMBER 141 | ||
| 447 | #define STORE_F_STORE_ATTR_INFO_GET0_SHA1STR 142 | ||
| 448 | #define STORE_F_STORE_ATTR_INFO_MODIFY_CSTR 143 | ||
| 449 | #define STORE_F_STORE_ATTR_INFO_MODIFY_DN 144 | ||
| 450 | #define STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER 145 | ||
| 451 | #define STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR 146 | ||
| 452 | #define STORE_F_STORE_ATTR_INFO_SET_CSTR 147 | ||
| 453 | #define STORE_F_STORE_ATTR_INFO_SET_DN 148 | ||
| 454 | #define STORE_F_STORE_ATTR_INFO_SET_NUMBER 149 | ||
| 455 | #define STORE_F_STORE_ATTR_INFO_SET_SHA1STR 150 | ||
| 456 | #define STORE_F_STORE_CERTIFICATE 170 | ||
| 457 | #define STORE_F_STORE_CTRL 161 | ||
| 458 | #define STORE_F_STORE_DELETE_ARBITRARY 158 | ||
| 459 | #define STORE_F_STORE_DELETE_CERTIFICATE 102 | ||
| 460 | #define STORE_F_STORE_DELETE_CRL 103 | ||
| 461 | #define STORE_F_STORE_DELETE_NUMBER 104 | ||
| 462 | #define STORE_F_STORE_DELETE_PRIVATE_KEY 105 | ||
| 463 | #define STORE_F_STORE_DELETE_PUBLIC_KEY 106 | ||
| 464 | #define STORE_F_STORE_GENERATE_CRL 107 | ||
| 465 | #define STORE_F_STORE_GENERATE_KEY 108 | ||
| 466 | #define STORE_F_STORE_GET_ARBITRARY 159 | ||
| 467 | #define STORE_F_STORE_GET_CERTIFICATE 109 | ||
| 468 | #define STORE_F_STORE_GET_CRL 110 | ||
| 469 | #define STORE_F_STORE_GET_NUMBER 111 | ||
| 470 | #define STORE_F_STORE_GET_PRIVATE_KEY 112 | ||
| 471 | #define STORE_F_STORE_GET_PUBLIC_KEY 113 | ||
| 472 | #define STORE_F_STORE_LIST_CERTIFICATE_END 114 | ||
| 473 | #define STORE_F_STORE_LIST_CERTIFICATE_ENDP 153 | ||
| 474 | #define STORE_F_STORE_LIST_CERTIFICATE_NEXT 115 | ||
| 475 | #define STORE_F_STORE_LIST_CERTIFICATE_START 116 | ||
| 476 | #define STORE_F_STORE_LIST_CRL_END 117 | ||
| 477 | #define STORE_F_STORE_LIST_CRL_ENDP 154 | ||
| 478 | #define STORE_F_STORE_LIST_CRL_NEXT 118 | ||
| 479 | #define STORE_F_STORE_LIST_CRL_START 119 | ||
| 480 | #define STORE_F_STORE_LIST_PRIVATE_KEY_END 120 | ||
| 481 | #define STORE_F_STORE_LIST_PRIVATE_KEY_ENDP 155 | ||
| 482 | #define STORE_F_STORE_LIST_PRIVATE_KEY_NEXT 121 | ||
| 483 | #define STORE_F_STORE_LIST_PRIVATE_KEY_START 122 | ||
| 484 | #define STORE_F_STORE_LIST_PUBLIC_KEY_END 123 | ||
| 485 | #define STORE_F_STORE_LIST_PUBLIC_KEY_ENDP 156 | ||
| 486 | #define STORE_F_STORE_LIST_PUBLIC_KEY_NEXT 124 | ||
| 487 | #define STORE_F_STORE_LIST_PUBLIC_KEY_START 125 | ||
| 488 | #define STORE_F_STORE_MODIFY_ARBITRARY 162 | ||
| 489 | #define STORE_F_STORE_MODIFY_CERTIFICATE 163 | ||
| 490 | #define STORE_F_STORE_MODIFY_CRL 164 | ||
| 491 | #define STORE_F_STORE_MODIFY_NUMBER 165 | ||
| 492 | #define STORE_F_STORE_MODIFY_PRIVATE_KEY 166 | ||
| 493 | #define STORE_F_STORE_MODIFY_PUBLIC_KEY 167 | ||
| 494 | #define STORE_F_STORE_NEW_ENGINE 133 | ||
| 495 | #define STORE_F_STORE_NEW_METHOD 132 | ||
| 496 | #define STORE_F_STORE_PARSE_ATTRS_END 151 | ||
| 497 | #define STORE_F_STORE_PARSE_ATTRS_ENDP 172 | ||
| 498 | #define STORE_F_STORE_PARSE_ATTRS_NEXT 152 | ||
| 499 | #define STORE_F_STORE_PARSE_ATTRS_START 171 | ||
| 500 | #define STORE_F_STORE_REVOKE_CERTIFICATE 129 | ||
| 501 | #define STORE_F_STORE_REVOKE_PRIVATE_KEY 130 | ||
| 502 | #define STORE_F_STORE_REVOKE_PUBLIC_KEY 131 | ||
| 503 | #define STORE_F_STORE_STORE_ARBITRARY 157 | ||
| 504 | #define STORE_F_STORE_STORE_CERTIFICATE 100 | ||
| 505 | #define STORE_F_STORE_STORE_CRL 101 | ||
| 506 | #define STORE_F_STORE_STORE_NUMBER 126 | ||
| 507 | #define STORE_F_STORE_STORE_PRIVATE_KEY 127 | ||
| 508 | #define STORE_F_STORE_STORE_PUBLIC_KEY 128 | ||
| 509 | |||
| 510 | /* Reason codes. */ | ||
| 511 | #define STORE_R_ALREADY_HAS_A_VALUE 127 | ||
| 512 | #define STORE_R_FAILED_DELETING_ARBITRARY 132 | ||
| 513 | #define STORE_R_FAILED_DELETING_CERTIFICATE 100 | ||
| 514 | #define STORE_R_FAILED_DELETING_KEY 101 | ||
| 515 | #define STORE_R_FAILED_DELETING_NUMBER 102 | ||
| 516 | #define STORE_R_FAILED_GENERATING_CRL 103 | ||
| 517 | #define STORE_R_FAILED_GENERATING_KEY 104 | ||
| 518 | #define STORE_R_FAILED_GETTING_ARBITRARY 133 | ||
| 519 | #define STORE_R_FAILED_GETTING_CERTIFICATE 105 | ||
| 520 | #define STORE_R_FAILED_GETTING_KEY 106 | ||
| 521 | #define STORE_R_FAILED_GETTING_NUMBER 107 | ||
| 522 | #define STORE_R_FAILED_LISTING_CERTIFICATES 108 | ||
| 523 | #define STORE_R_FAILED_LISTING_KEYS 109 | ||
| 524 | #define STORE_R_FAILED_MODIFYING_ARBITRARY 138 | ||
| 525 | #define STORE_R_FAILED_MODIFYING_CERTIFICATE 139 | ||
| 526 | #define STORE_R_FAILED_MODIFYING_CRL 140 | ||
| 527 | #define STORE_R_FAILED_MODIFYING_NUMBER 141 | ||
| 528 | #define STORE_R_FAILED_MODIFYING_PRIVATE_KEY 142 | ||
| 529 | #define STORE_R_FAILED_MODIFYING_PUBLIC_KEY 143 | ||
| 530 | #define STORE_R_FAILED_REVOKING_CERTIFICATE 110 | ||
| 531 | #define STORE_R_FAILED_REVOKING_KEY 111 | ||
| 532 | #define STORE_R_FAILED_STORING_ARBITRARY 134 | ||
| 533 | #define STORE_R_FAILED_STORING_CERTIFICATE 112 | ||
| 534 | #define STORE_R_FAILED_STORING_KEY 113 | ||
| 535 | #define STORE_R_FAILED_STORING_NUMBER 114 | ||
| 536 | #define STORE_R_NOT_IMPLEMENTED 128 | ||
| 537 | #define STORE_R_NO_CONTROL_FUNCTION 144 | ||
| 538 | #define STORE_R_NO_DELETE_ARBITRARY_FUNCTION 135 | ||
| 539 | #define STORE_R_NO_DELETE_NUMBER_FUNCTION 115 | ||
| 540 | #define STORE_R_NO_DELETE_OBJECT_FUNCTION 116 | ||
| 541 | #define STORE_R_NO_GENERATE_CRL_FUNCTION 117 | ||
| 542 | #define STORE_R_NO_GENERATE_OBJECT_FUNCTION 118 | ||
| 543 | #define STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION 136 | ||
| 544 | #define STORE_R_NO_GET_OBJECT_FUNCTION 119 | ||
| 545 | #define STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION 120 | ||
| 546 | #define STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION 131 | ||
| 547 | #define STORE_R_NO_LIST_OBJECT_END_FUNCTION 121 | ||
| 548 | #define STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION 122 | ||
| 549 | #define STORE_R_NO_LIST_OBJECT_START_FUNCTION 123 | ||
| 550 | #define STORE_R_NO_MODIFY_OBJECT_FUNCTION 145 | ||
| 551 | #define STORE_R_NO_REVOKE_OBJECT_FUNCTION 124 | ||
| 552 | #define STORE_R_NO_STORE 129 | ||
| 553 | #define STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION 137 | ||
| 554 | #define STORE_R_NO_STORE_OBJECT_FUNCTION 125 | ||
| 555 | #define STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION 126 | ||
| 556 | #define STORE_R_NO_VALUE 130 | ||
| 557 | |||
| 558 | #ifdef __cplusplus | ||
| 559 | } | ||
| 560 | #endif | ||
| 561 | #endif | ||
diff --git a/src/lib/libcrypto/store/str_err.c b/src/lib/libcrypto/store/str_err.c new file mode 100644 index 0000000000..924edf0505 --- /dev/null +++ b/src/lib/libcrypto/store/str_err.c  | |||
| @@ -0,0 +1,211 @@ | |||
| 1 | /* crypto/store/str_err.c */ | ||
| 2 | /* ==================================================================== | ||
| 3 | * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. | ||
| 4 | * | ||
| 5 | * Redistribution and use in source and binary forms, with or without | ||
| 6 | * modification, are permitted provided that the following conditions | ||
| 7 | * are met: | ||
| 8 | * | ||
| 9 | * 1. Redistributions of source code must retain the above copyright | ||
| 10 | * notice, this list of conditions and the following disclaimer. | ||
| 11 | * | ||
| 12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer in | ||
| 14 | * the documentation and/or other materials provided with the | ||
| 15 | * distribution. | ||
| 16 | * | ||
| 17 | * 3. All advertising materials mentioning features or use of this | ||
| 18 | * software must display the following acknowledgment: | ||
| 19 | * "This product includes software developed by the OpenSSL Project | ||
| 20 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 21 | * | ||
| 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 23 | * endorse or promote products derived from this software without | ||
| 24 | * prior written permission. For written permission, please contact | ||
| 25 | * openssl-core@OpenSSL.org. | ||
| 26 | * | ||
| 27 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 28 | * nor may "OpenSSL" appear in their names without prior written | ||
| 29 | * permission of the OpenSSL Project. | ||
| 30 | * | ||
| 31 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 32 | * acknowledgment: | ||
| 33 | * "This product includes software developed by the OpenSSL Project | ||
| 34 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 35 | * | ||
| 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 48 | * ==================================================================== | ||
| 49 | * | ||
| 50 | * This product includes cryptographic software written by Eric Young | ||
| 51 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 52 | * Hudson (tjh@cryptsoft.com). | ||
| 53 | * | ||
| 54 | */ | ||
| 55 | |||
| 56 | /* NOTE: this file was auto generated by the mkerr.pl script: any changes | ||
| 57 | * made to it will be overwritten when the script next updates this file, | ||
| 58 | * only reason strings will be preserved. | ||
| 59 | */ | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include <openssl/err.h> | ||
| 63 | #include <openssl/store.h> | ||
| 64 | |||
| 65 | /* BEGIN ERROR CODES */ | ||
| 66 | #ifndef OPENSSL_NO_ERR | ||
| 67 | |||
| 68 | #define ERR_FUNC(func) ERR_PACK(ERR_LIB_STORE,func,0) | ||
| 69 | #define ERR_REASON(reason) ERR_PACK(ERR_LIB_STORE,0,reason) | ||
| 70 | |||
| 71 | static ERR_STRING_DATA STORE_str_functs[]= | ||
| 72 | { | ||
| 73 | {ERR_FUNC(STORE_F_MEM_DELETE), "MEM_DELETE"}, | ||
| 74 | {ERR_FUNC(STORE_F_MEM_GENERATE), "MEM_GENERATE"}, | ||
| 75 | {ERR_FUNC(STORE_F_MEM_LIST_END), "MEM_LIST_END"}, | ||
| 76 | {ERR_FUNC(STORE_F_MEM_LIST_NEXT), "MEM_LIST_NEXT"}, | ||
| 77 | {ERR_FUNC(STORE_F_MEM_LIST_START), "MEM_LIST_START"}, | ||
| 78 | {ERR_FUNC(STORE_F_MEM_MODIFY), "MEM_MODIFY"}, | ||
| 79 | {ERR_FUNC(STORE_F_MEM_STORE), "MEM_STORE"}, | ||
| 80 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_GET0_CSTR), "STORE_ATTR_INFO_get0_cstr"}, | ||
| 81 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_GET0_DN), "STORE_ATTR_INFO_get0_dn"}, | ||
| 82 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_GET0_NUMBER), "STORE_ATTR_INFO_get0_number"}, | ||
| 83 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_GET0_SHA1STR), "STORE_ATTR_INFO_get0_sha1str"}, | ||
| 84 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_MODIFY_CSTR), "STORE_ATTR_INFO_modify_cstr"}, | ||
| 85 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_MODIFY_DN), "STORE_ATTR_INFO_modify_dn"}, | ||
| 86 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER), "STORE_ATTR_INFO_modify_number"}, | ||
| 87 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR), "STORE_ATTR_INFO_modify_sha1str"}, | ||
| 88 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_SET_CSTR), "STORE_ATTR_INFO_set_cstr"}, | ||
| 89 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_SET_DN), "STORE_ATTR_INFO_set_dn"}, | ||
| 90 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_SET_NUMBER), "STORE_ATTR_INFO_set_number"}, | ||
| 91 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_SET_SHA1STR), "STORE_ATTR_INFO_set_sha1str"}, | ||
| 92 | {ERR_FUNC(STORE_F_STORE_CERTIFICATE), "STORE_CERTIFICATE"}, | ||
| 93 | {ERR_FUNC(STORE_F_STORE_CTRL), "STORE_ctrl"}, | ||
| 94 | {ERR_FUNC(STORE_F_STORE_DELETE_ARBITRARY), "STORE_delete_arbitrary"}, | ||
| 95 | {ERR_FUNC(STORE_F_STORE_DELETE_CERTIFICATE), "STORE_delete_certificate"}, | ||
| 96 | {ERR_FUNC(STORE_F_STORE_DELETE_CRL), "STORE_delete_crl"}, | ||
| 97 | {ERR_FUNC(STORE_F_STORE_DELETE_NUMBER), "STORE_delete_number"}, | ||
| 98 | {ERR_FUNC(STORE_F_STORE_DELETE_PRIVATE_KEY), "STORE_delete_private_key"}, | ||
| 99 | {ERR_FUNC(STORE_F_STORE_DELETE_PUBLIC_KEY), "STORE_delete_public_key"}, | ||
| 100 | {ERR_FUNC(STORE_F_STORE_GENERATE_CRL), "STORE_generate_crl"}, | ||
| 101 | {ERR_FUNC(STORE_F_STORE_GENERATE_KEY), "STORE_generate_key"}, | ||
| 102 | {ERR_FUNC(STORE_F_STORE_GET_ARBITRARY), "STORE_get_arbitrary"}, | ||
| 103 | {ERR_FUNC(STORE_F_STORE_GET_CERTIFICATE), "STORE_get_certificate"}, | ||
| 104 | {ERR_FUNC(STORE_F_STORE_GET_CRL), "STORE_get_crl"}, | ||
| 105 | {ERR_FUNC(STORE_F_STORE_GET_NUMBER), "STORE_get_number"}, | ||
| 106 | {ERR_FUNC(STORE_F_STORE_GET_PRIVATE_KEY), "STORE_get_private_key"}, | ||
| 107 | {ERR_FUNC(STORE_F_STORE_GET_PUBLIC_KEY), "STORE_get_public_key"}, | ||
| 108 | {ERR_FUNC(STORE_F_STORE_LIST_CERTIFICATE_END), "STORE_list_certificate_end"}, | ||
| 109 | {ERR_FUNC(STORE_F_STORE_LIST_CERTIFICATE_ENDP), "STORE_list_certificate_endp"}, | ||
| 110 | {ERR_FUNC(STORE_F_STORE_LIST_CERTIFICATE_NEXT), "STORE_list_certificate_next"}, | ||
| 111 | {ERR_FUNC(STORE_F_STORE_LIST_CERTIFICATE_START), "STORE_list_certificate_start"}, | ||
| 112 | {ERR_FUNC(STORE_F_STORE_LIST_CRL_END), "STORE_list_crl_end"}, | ||
| 113 | {ERR_FUNC(STORE_F_STORE_LIST_CRL_ENDP), "STORE_list_crl_endp"}, | ||
| 114 | {ERR_FUNC(STORE_F_STORE_LIST_CRL_NEXT), "STORE_list_crl_next"}, | ||
| 115 | {ERR_FUNC(STORE_F_STORE_LIST_CRL_START), "STORE_list_crl_start"}, | ||
| 116 | {ERR_FUNC(STORE_F_STORE_LIST_PRIVATE_KEY_END), "STORE_list_private_key_end"}, | ||
| 117 | {ERR_FUNC(STORE_F_STORE_LIST_PRIVATE_KEY_ENDP), "STORE_list_private_key_endp"}, | ||
| 118 | {ERR_FUNC(STORE_F_STORE_LIST_PRIVATE_KEY_NEXT), "STORE_list_private_key_next"}, | ||
| 119 | {ERR_FUNC(STORE_F_STORE_LIST_PRIVATE_KEY_START), "STORE_list_private_key_start"}, | ||
| 120 | {ERR_FUNC(STORE_F_STORE_LIST_PUBLIC_KEY_END), "STORE_list_public_key_end"}, | ||
| 121 | {ERR_FUNC(STORE_F_STORE_LIST_PUBLIC_KEY_ENDP), "STORE_list_public_key_endp"}, | ||
| 122 | {ERR_FUNC(STORE_F_STORE_LIST_PUBLIC_KEY_NEXT), "STORE_list_public_key_next"}, | ||
| 123 | {ERR_FUNC(STORE_F_STORE_LIST_PUBLIC_KEY_START), "STORE_list_public_key_start"}, | ||
| 124 | {ERR_FUNC(STORE_F_STORE_MODIFY_ARBITRARY), "STORE_modify_arbitrary"}, | ||
| 125 | {ERR_FUNC(STORE_F_STORE_MODIFY_CERTIFICATE), "STORE_modify_certificate"}, | ||
| 126 | {ERR_FUNC(STORE_F_STORE_MODIFY_CRL), "STORE_modify_crl"}, | ||
| 127 | {ERR_FUNC(STORE_F_STORE_MODIFY_NUMBER), "STORE_modify_number"}, | ||
| 128 | {ERR_FUNC(STORE_F_STORE_MODIFY_PRIVATE_KEY), "STORE_modify_private_key"}, | ||
| 129 | {ERR_FUNC(STORE_F_STORE_MODIFY_PUBLIC_KEY), "STORE_modify_public_key"}, | ||
| 130 | {ERR_FUNC(STORE_F_STORE_NEW_ENGINE), "STORE_new_engine"}, | ||
| 131 | {ERR_FUNC(STORE_F_STORE_NEW_METHOD), "STORE_new_method"}, | ||
| 132 | {ERR_FUNC(STORE_F_STORE_PARSE_ATTRS_END), "STORE_parse_attrs_end"}, | ||
| 133 | {ERR_FUNC(STORE_F_STORE_PARSE_ATTRS_ENDP), "STORE_parse_attrs_endp"}, | ||
| 134 | {ERR_FUNC(STORE_F_STORE_PARSE_ATTRS_NEXT), "STORE_parse_attrs_next"}, | ||
| 135 | {ERR_FUNC(STORE_F_STORE_PARSE_ATTRS_START), "STORE_parse_attrs_start"}, | ||
| 136 | {ERR_FUNC(STORE_F_STORE_REVOKE_CERTIFICATE), "STORE_revoke_certificate"}, | ||
| 137 | {ERR_FUNC(STORE_F_STORE_REVOKE_PRIVATE_KEY), "STORE_revoke_private_key"}, | ||
| 138 | {ERR_FUNC(STORE_F_STORE_REVOKE_PUBLIC_KEY), "STORE_revoke_public_key"}, | ||
| 139 | {ERR_FUNC(STORE_F_STORE_STORE_ARBITRARY), "STORE_store_arbitrary"}, | ||
| 140 | {ERR_FUNC(STORE_F_STORE_STORE_CERTIFICATE), "STORE_store_certificate"}, | ||
| 141 | {ERR_FUNC(STORE_F_STORE_STORE_CRL), "STORE_store_crl"}, | ||
| 142 | {ERR_FUNC(STORE_F_STORE_STORE_NUMBER), "STORE_store_number"}, | ||
| 143 | {ERR_FUNC(STORE_F_STORE_STORE_PRIVATE_KEY), "STORE_store_private_key"}, | ||
| 144 | {ERR_FUNC(STORE_F_STORE_STORE_PUBLIC_KEY), "STORE_store_public_key"}, | ||
| 145 | {0,NULL} | ||
| 146 | }; | ||
| 147 | |||
| 148 | static ERR_STRING_DATA STORE_str_reasons[]= | ||
| 149 | { | ||
| 150 | {ERR_REASON(STORE_R_ALREADY_HAS_A_VALUE) ,"already has a value"}, | ||
| 151 | {ERR_REASON(STORE_R_FAILED_DELETING_ARBITRARY),"failed deleting arbitrary"}, | ||
| 152 | {ERR_REASON(STORE_R_FAILED_DELETING_CERTIFICATE),"failed deleting certificate"}, | ||
| 153 | {ERR_REASON(STORE_R_FAILED_DELETING_KEY) ,"failed deleting key"}, | ||
| 154 | {ERR_REASON(STORE_R_FAILED_DELETING_NUMBER),"failed deleting number"}, | ||
| 155 | {ERR_REASON(STORE_R_FAILED_GENERATING_CRL),"failed generating crl"}, | ||
| 156 | {ERR_REASON(STORE_R_FAILED_GENERATING_KEY),"failed generating key"}, | ||
| 157 | {ERR_REASON(STORE_R_FAILED_GETTING_ARBITRARY),"failed getting arbitrary"}, | ||
| 158 | {ERR_REASON(STORE_R_FAILED_GETTING_CERTIFICATE),"failed getting certificate"}, | ||
| 159 | {ERR_REASON(STORE_R_FAILED_GETTING_KEY) ,"failed getting key"}, | ||
| 160 | {ERR_REASON(STORE_R_FAILED_GETTING_NUMBER),"failed getting number"}, | ||
| 161 | {ERR_REASON(STORE_R_FAILED_LISTING_CERTIFICATES),"failed listing certificates"}, | ||
| 162 | {ERR_REASON(STORE_R_FAILED_LISTING_KEYS) ,"failed listing keys"}, | ||
| 163 | {ERR_REASON(STORE_R_FAILED_MODIFYING_ARBITRARY),"failed modifying arbitrary"}, | ||
| 164 | {ERR_REASON(STORE_R_FAILED_MODIFYING_CERTIFICATE),"failed modifying certificate"}, | ||
| 165 | {ERR_REASON(STORE_R_FAILED_MODIFYING_CRL),"failed modifying crl"}, | ||
| 166 | {ERR_REASON(STORE_R_FAILED_MODIFYING_NUMBER),"failed modifying number"}, | ||
| 167 | {ERR_REASON(STORE_R_FAILED_MODIFYING_PRIVATE_KEY),"failed modifying private key"}, | ||
| 168 | {ERR_REASON(STORE_R_FAILED_MODIFYING_PUBLIC_KEY),"failed modifying public key"}, | ||
| 169 | {ERR_REASON(STORE_R_FAILED_REVOKING_CERTIFICATE),"failed revoking certificate"}, | ||
| 170 | {ERR_REASON(STORE_R_FAILED_REVOKING_KEY) ,"failed revoking key"}, | ||
| 171 | {ERR_REASON(STORE_R_FAILED_STORING_ARBITRARY),"failed storing arbitrary"}, | ||
| 172 | {ERR_REASON(STORE_R_FAILED_STORING_CERTIFICATE),"failed storing certificate"}, | ||
| 173 | {ERR_REASON(STORE_R_FAILED_STORING_KEY) ,"failed storing key"}, | ||
| 174 | {ERR_REASON(STORE_R_FAILED_STORING_NUMBER),"failed storing number"}, | ||
| 175 | {ERR_REASON(STORE_R_NOT_IMPLEMENTED) ,"not implemented"}, | ||
| 176 | {ERR_REASON(STORE_R_NO_CONTROL_FUNCTION) ,"no control function"}, | ||
| 177 | {ERR_REASON(STORE_R_NO_DELETE_ARBITRARY_FUNCTION),"no delete arbitrary function"}, | ||
| 178 | {ERR_REASON(STORE_R_NO_DELETE_NUMBER_FUNCTION),"no delete number function"}, | ||
| 179 | {ERR_REASON(STORE_R_NO_DELETE_OBJECT_FUNCTION),"no delete object function"}, | ||
| 180 | {ERR_REASON(STORE_R_NO_GENERATE_CRL_FUNCTION),"no generate crl function"}, | ||
| 181 | {ERR_REASON(STORE_R_NO_GENERATE_OBJECT_FUNCTION),"no generate object function"}, | ||
| 182 | {ERR_REASON(STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION),"no get object arbitrary function"}, | ||
| 183 | {ERR_REASON(STORE_R_NO_GET_OBJECT_FUNCTION),"no get object function"}, | ||
| 184 | {ERR_REASON(STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION),"no get object number function"}, | ||
| 185 | {ERR_REASON(STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION),"no list object endp function"}, | ||
| 186 | {ERR_REASON(STORE_R_NO_LIST_OBJECT_END_FUNCTION),"no list object end function"}, | ||
| 187 | {ERR_REASON(STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION),"no list object next function"}, | ||
| 188 | {ERR_REASON(STORE_R_NO_LIST_OBJECT_START_FUNCTION),"no list object start function"}, | ||
| 189 | {ERR_REASON(STORE_R_NO_MODIFY_OBJECT_FUNCTION),"no modify object function"}, | ||
| 190 | {ERR_REASON(STORE_R_NO_REVOKE_OBJECT_FUNCTION),"no revoke object function"}, | ||
| 191 | {ERR_REASON(STORE_R_NO_STORE) ,"no store"}, | ||
| 192 | {ERR_REASON(STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION),"no store object arbitrary function"}, | ||
| 193 | {ERR_REASON(STORE_R_NO_STORE_OBJECT_FUNCTION),"no store object function"}, | ||
| 194 | {ERR_REASON(STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION),"no store object number function"}, | ||
| 195 | {ERR_REASON(STORE_R_NO_VALUE) ,"no value"}, | ||
| 196 | {0,NULL} | ||
| 197 | }; | ||
| 198 | |||
| 199 | #endif | ||
| 200 | |||
| 201 | void ERR_load_STORE_strings(void) | ||
| 202 | { | ||
| 203 | #ifndef OPENSSL_NO_ERR | ||
| 204 | |||
| 205 | if (ERR_func_error_string(STORE_str_functs[0].error) == NULL) | ||
| 206 | { | ||
| 207 | ERR_load_strings(0,STORE_str_functs); | ||
| 208 | ERR_load_strings(0,STORE_str_reasons); | ||
| 209 | } | ||
| 210 | #endif | ||
| 211 | } | ||
diff --git a/src/lib/libcrypto/store/str_lib.c b/src/lib/libcrypto/store/str_lib.c new file mode 100644 index 0000000000..f1dbcbd0e0 --- /dev/null +++ b/src/lib/libcrypto/store/str_lib.c  | |||
| @@ -0,0 +1,1828 @@ | |||
| 1 | /* crypto/store/str_lib.c -*- mode:C; c-file-style: "eay" -*- */ | ||
| 2 | /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL | ||
| 3 | * project 2003. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 2003 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 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 | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 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/)" | ||
| 24 | * | ||
| 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. | ||
| 29 | * | ||
| 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. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
| 38 | * | ||
| 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 | * ==================================================================== | ||
| 52 | * | ||
| 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). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <string.h> | ||
| 60 | #include <openssl/bn.h> | ||
| 61 | #include <openssl/err.h> | ||
| 62 | #ifndef OPENSSL_NO_ENGINE | ||
| 63 | #include <openssl/engine.h> | ||
| 64 | #endif | ||
| 65 | #include <openssl/sha.h> | ||
| 66 | #include <openssl/x509.h> | ||
| 67 | #include "str_locl.h" | ||
| 68 | |||
| 69 | const char * const STORE_object_type_string[STORE_OBJECT_TYPE_NUM+1] = | ||
| 70 | { | ||
| 71 | 0, | ||
| 72 | "X.509 Certificate", | ||
| 73 | "X.509 CRL", | ||
| 74 | "Private Key", | ||
| 75 | "Public Key", | ||
| 76 | "Number", | ||
| 77 | "Arbitrary Data" | ||
| 78 | }; | ||
| 79 | |||
| 80 | const int STORE_param_sizes[STORE_PARAM_TYPE_NUM+1] = | ||
| 81 | { | ||
| 82 | 0, | ||
| 83 | sizeof(int), /* EVP_TYPE */ | ||
| 84 | sizeof(size_t), /* BITS */ | ||
| 85 | -1, /* KEY_PARAMETERS */ | ||
| 86 | 0 /* KEY_NO_PARAMETERS */ | ||
| 87 | }; | ||
| 88 | |||
| 89 | const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM+1] = | ||
| 90 | { | ||
| 91 | 0, | ||
| 92 | -1, /* FRIENDLYNAME: C string */ | ||
| 93 | SHA_DIGEST_LENGTH, /* KEYID: SHA1 digest, 160 bits */ | ||
| 94 | SHA_DIGEST_LENGTH, /* ISSUERKEYID: SHA1 digest, 160 bits */ | ||
| 95 | SHA_DIGEST_LENGTH, /* SUBJECTKEYID: SHA1 digest, 160 bits */ | ||
| 96 | SHA_DIGEST_LENGTH, /* ISSUERSERIALHASH: SHA1 digest, 160 bits */ | ||
| 97 | sizeof(X509_NAME *), /* ISSUER: X509_NAME * */ | ||
| 98 | sizeof(BIGNUM *), /* SERIAL: BIGNUM * */ | ||
| 99 | sizeof(X509_NAME *), /* SUBJECT: X509_NAME * */ | ||
| 100 | SHA_DIGEST_LENGTH, /* CERTHASH: SHA1 digest, 160 bits */ | ||
| 101 | -1, /* EMAIL: C string */ | ||
| 102 | -1, /* FILENAME: C string */ | ||
| 103 | }; | ||
| 104 | |||
| 105 | STORE *STORE_new_method(const STORE_METHOD *method) | ||
| 106 | { | ||
| 107 | STORE *ret; | ||
| 108 | |||
| 109 | if (method == NULL) | ||
| 110 | { | ||
| 111 | STOREerr(STORE_F_STORE_NEW_METHOD,ERR_R_PASSED_NULL_PARAMETER); | ||
| 112 | return NULL; | ||
| 113 | } | ||
| 114 | |||
| 115 | ret=(STORE *)OPENSSL_malloc(sizeof(STORE)); | ||
| 116 | if (ret == NULL) | ||
| 117 | { | ||
| 118 | STOREerr(STORE_F_STORE_NEW_METHOD,ERR_R_MALLOC_FAILURE); | ||
| 119 | return NULL; | ||
| 120 | } | ||
| 121 | |||
| 122 | ret->meth=method; | ||
| 123 | |||
| 124 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_STORE, ret, &ret->ex_data); | ||
| 125 | if (ret->meth->init && !ret->meth->init(ret)) | ||
| 126 | { | ||
| 127 | STORE_free(ret); | ||
| 128 | ret = NULL; | ||
| 129 | } | ||
| 130 | return ret; | ||
| 131 | } | ||
| 132 | |||
| 133 | STORE *STORE_new_engine(ENGINE *engine) | ||
| 134 | { | ||
| 135 | STORE *ret = NULL; | ||
| 136 | ENGINE *e = engine; | ||
| 137 | const STORE_METHOD *meth = 0; | ||
| 138 | |||
| 139 | #ifdef OPENSSL_NO_ENGINE | ||
| 140 | e = NULL; | ||
| 141 | #else | ||
| 142 | if (engine) | ||
| 143 | { | ||
| 144 | if (!ENGINE_init(engine)) | ||
| 145 | { | ||
| 146 | STOREerr(STORE_F_STORE_NEW_ENGINE, ERR_R_ENGINE_LIB); | ||
| 147 | return NULL; | ||
| 148 | } | ||
| 149 | e = engine; | ||
| 150 | } | ||
| 151 | else | ||
| 152 | { | ||
| 153 | STOREerr(STORE_F_STORE_NEW_ENGINE,ERR_R_PASSED_NULL_PARAMETER); | ||
| 154 | return NULL; | ||
| 155 | } | ||
| 156 | if(e) | ||
| 157 | { | ||
| 158 | meth = ENGINE_get_STORE(e); | ||
| 159 | if(!meth) | ||
| 160 | { | ||
| 161 | STOREerr(STORE_F_STORE_NEW_ENGINE, | ||
| 162 | ERR_R_ENGINE_LIB); | ||
| 163 | ENGINE_finish(e); | ||
| 164 | return NULL; | ||
| 165 | } | ||
| 166 | } | ||
| 167 | #endif | ||
| 168 | |||
| 169 | ret = STORE_new_method(meth); | ||
| 170 | if (ret == NULL) | ||
| 171 | { | ||
| 172 | STOREerr(STORE_F_STORE_NEW_ENGINE,ERR_R_STORE_LIB); | ||
| 173 | return NULL; | ||
| 174 | } | ||
| 175 | |||
| 176 | ret->engine = e; | ||
| 177 | |||
| 178 | return(ret); | ||
| 179 | } | ||
| 180 | |||
| 181 | void STORE_free(STORE *store) | ||
| 182 | { | ||
| 183 | if (store == NULL) | ||
| 184 | return; | ||
| 185 | if (store->meth->clean) | ||
| 186 | store->meth->clean(store); | ||
| 187 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_STORE, store, &store->ex_data); | ||
| 188 | OPENSSL_free(store); | ||
| 189 | } | ||
| 190 | |||
| 191 | int STORE_ctrl(STORE *store, int cmd, long i, void *p, void (*f)(void)) | ||
| 192 | { | ||
| 193 | if (store == NULL) | ||
| 194 | { | ||
| 195 | STOREerr(STORE_F_STORE_CTRL,ERR_R_PASSED_NULL_PARAMETER); | ||
| 196 | return 0; | ||
| 197 | } | ||
| 198 | if (store->meth->ctrl) | ||
| 199 | return store->meth->ctrl(store, cmd, i, p, f); | ||
| 200 | STOREerr(STORE_F_STORE_CTRL,STORE_R_NO_CONTROL_FUNCTION); | ||
| 201 | return 0; | ||
| 202 | } | ||
| 203 | |||
| 204 | |||
| 205 | int STORE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, | ||
| 206 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) | ||
| 207 | { | ||
| 208 | return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_STORE, argl, argp, | ||
| 209 | new_func, dup_func, free_func); | ||
| 210 | } | ||
| 211 | |||
| 212 | int STORE_set_ex_data(STORE *r, int idx, void *arg) | ||
| 213 | { | ||
| 214 | return(CRYPTO_set_ex_data(&r->ex_data,idx,arg)); | ||
| 215 | } | ||
| 216 | |||
| 217 | void *STORE_get_ex_data(STORE *r, int idx) | ||
| 218 | { | ||
| 219 | return(CRYPTO_get_ex_data(&r->ex_data,idx)); | ||
| 220 | } | ||
| 221 | |||
| 222 | const STORE_METHOD *STORE_get_method(STORE *store) | ||
| 223 | { | ||
| 224 | return store->meth; | ||
| 225 | } | ||
| 226 | |||
| 227 | const STORE_METHOD *STORE_set_method(STORE *store, const STORE_METHOD *meth) | ||
| 228 | { | ||
| 229 | store->meth=meth; | ||
| 230 | return store->meth; | ||
| 231 | } | ||
| 232 | |||
| 233 | |||
| 234 | /* API helpers */ | ||
| 235 | |||
| 236 | #define check_store(s,fncode,fnname,fnerrcode) \ | ||
| 237 | do \ | ||
| 238 | { \ | ||
| 239 | if ((s) == NULL || (s)->meth == NULL) \ | ||
| 240 | { \ | ||
| 241 | STOREerr((fncode), ERR_R_PASSED_NULL_PARAMETER); \ | ||
| 242 | return 0; \ | ||
| 243 | } \ | ||
| 244 | if ((s)->meth->fnname == NULL) \ | ||
| 245 | { \ | ||
| 246 | STOREerr((fncode), (fnerrcode)); \ | ||
| 247 | return 0; \ | ||
| 248 | } \ | ||
| 249 | } \ | ||
| 250 | while(0) | ||
| 251 | |||
| 252 | /* API functions */ | ||
| 253 | |||
| 254 | X509 *STORE_get_certificate(STORE *s, OPENSSL_ITEM attributes[], | ||
| 255 | OPENSSL_ITEM parameters[]) | ||
| 256 | { | ||
| 257 | STORE_OBJECT *object; | ||
| 258 | X509 *x; | ||
| 259 | |||
| 260 | check_store(s,STORE_F_STORE_GET_CERTIFICATE, | ||
| 261 | get_object,STORE_R_NO_GET_OBJECT_FUNCTION); | ||
| 262 | |||
| 263 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, | ||
| 264 | attributes, parameters); | ||
| 265 | if (!object || !object->data.x509.certificate) | ||
| 266 | { | ||
| 267 | STOREerr(STORE_F_STORE_GET_CERTIFICATE, | ||
| 268 | STORE_R_FAILED_GETTING_CERTIFICATE); | ||
| 269 | return 0; | ||
| 270 | } | ||
| 271 | CRYPTO_add(&object->data.x509.certificate->references,1,CRYPTO_LOCK_X509); | ||
| 272 | #ifdef REF_PRINT | ||
| 273 | REF_PRINT("X509",data); | ||
| 274 | #endif | ||
| 275 | x = object->data.x509.certificate; | ||
| 276 | STORE_OBJECT_free(object); | ||
| 277 | return x; | ||
| 278 | } | ||
| 279 | |||
| 280 | int STORE_store_certificate(STORE *s, X509 *data, OPENSSL_ITEM attributes[], | ||
| 281 | OPENSSL_ITEM parameters[]) | ||
| 282 | { | ||
| 283 | STORE_OBJECT *object; | ||
| 284 | int i; | ||
| 285 | |||
| 286 | check_store(s,STORE_F_STORE_CERTIFICATE, | ||
| 287 | store_object,STORE_R_NO_STORE_OBJECT_FUNCTION); | ||
| 288 | |||
| 289 | object = STORE_OBJECT_new(); | ||
| 290 | if (!object) | ||
| 291 | { | ||
| 292 | STOREerr(STORE_F_STORE_STORE_CERTIFICATE, | ||
| 293 | ERR_R_MALLOC_FAILURE); | ||
| 294 | return 0; | ||
| 295 | } | ||
| 296 | |||
| 297 | CRYPTO_add(&data->references,1,CRYPTO_LOCK_X509); | ||
| 298 | #ifdef REF_PRINT | ||
| 299 | REF_PRINT("X509",data); | ||
| 300 | #endif | ||
| 301 | object->data.x509.certificate = data; | ||
| 302 | |||
| 303 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, | ||
| 304 | object, attributes, parameters); | ||
| 305 | |||
| 306 | STORE_OBJECT_free(object); | ||
| 307 | |||
| 308 | if (!i) | ||
| 309 | { | ||
| 310 | STOREerr(STORE_F_STORE_STORE_CERTIFICATE, | ||
| 311 | STORE_R_FAILED_STORING_CERTIFICATE); | ||
| 312 | return 0; | ||
| 313 | } | ||
| 314 | return 1; | ||
| 315 | } | ||
| 316 | |||
| 317 | int STORE_modify_certificate(STORE *s, OPENSSL_ITEM search_attributes[], | ||
| 318 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | ||
| 319 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) | ||
| 320 | { | ||
| 321 | check_store(s,STORE_F_STORE_MODIFY_CERTIFICATE, | ||
| 322 | modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION); | ||
| 323 | |||
| 324 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, | ||
| 325 | search_attributes, add_attributes, modify_attributes, | ||
| 326 | delete_attributes, parameters)) | ||
| 327 | { | ||
| 328 | STOREerr(STORE_F_STORE_MODIFY_CERTIFICATE, | ||
| 329 | STORE_R_FAILED_MODIFYING_CERTIFICATE); | ||
| 330 | return 0; | ||
| 331 | } | ||
| 332 | return 1; | ||
| 333 | } | ||
| 334 | |||
| 335 | int STORE_revoke_certificate(STORE *s, OPENSSL_ITEM attributes[], | ||
| 336 | OPENSSL_ITEM parameters[]) | ||
| 337 | { | ||
| 338 | check_store(s,STORE_F_STORE_REVOKE_CERTIFICATE, | ||
| 339 | revoke_object,STORE_R_NO_REVOKE_OBJECT_FUNCTION); | ||
| 340 | |||
| 341 | if (!s->meth->revoke_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, | ||
| 342 | attributes, parameters)) | ||
| 343 | { | ||
| 344 | STOREerr(STORE_F_STORE_REVOKE_CERTIFICATE, | ||
| 345 | STORE_R_FAILED_REVOKING_CERTIFICATE); | ||
| 346 | return 0; | ||
| 347 | } | ||
| 348 | return 1; | ||
| 349 | } | ||
| 350 | |||
| 351 | int STORE_delete_certificate(STORE *s, OPENSSL_ITEM attributes[], | ||
| 352 | OPENSSL_ITEM parameters[]) | ||
| 353 | { | ||
| 354 | check_store(s,STORE_F_STORE_DELETE_CERTIFICATE, | ||
| 355 | delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION); | ||
| 356 | |||
| 357 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, | ||
| 358 | attributes, parameters)) | ||
| 359 | { | ||
| 360 | STOREerr(STORE_F_STORE_DELETE_CERTIFICATE, | ||
| 361 | STORE_R_FAILED_DELETING_CERTIFICATE); | ||
| 362 | return 0; | ||
| 363 | } | ||
| 364 | return 1; | ||
| 365 | } | ||
| 366 | |||
| 367 | void *STORE_list_certificate_start(STORE *s, OPENSSL_ITEM attributes[], | ||
| 368 | OPENSSL_ITEM parameters[]) | ||
| 369 | { | ||
| 370 | void *handle; | ||
| 371 | |||
| 372 | check_store(s,STORE_F_STORE_LIST_CERTIFICATE_START, | ||
| 373 | list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION); | ||
| 374 | |||
| 375 | handle = s->meth->list_object_start(s, | ||
| 376 | STORE_OBJECT_TYPE_X509_CERTIFICATE, attributes, parameters); | ||
| 377 | if (!handle) | ||
| 378 | { | ||
| 379 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_START, | ||
| 380 | STORE_R_FAILED_LISTING_CERTIFICATES); | ||
| 381 | return 0; | ||
| 382 | } | ||
| 383 | return handle; | ||
| 384 | } | ||
| 385 | |||
| 386 | X509 *STORE_list_certificate_next(STORE *s, void *handle) | ||
| 387 | { | ||
| 388 | STORE_OBJECT *object; | ||
| 389 | X509 *x; | ||
| 390 | |||
| 391 | check_store(s,STORE_F_STORE_LIST_CERTIFICATE_NEXT, | ||
| 392 | list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); | ||
| 393 | |||
| 394 | object = s->meth->list_object_next(s, handle); | ||
| 395 | if (!object || !object->data.x509.certificate) | ||
| 396 | { | ||
| 397 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_NEXT, | ||
| 398 | STORE_R_FAILED_LISTING_CERTIFICATES); | ||
| 399 | return 0; | ||
| 400 | } | ||
| 401 | CRYPTO_add(&object->data.x509.certificate->references,1,CRYPTO_LOCK_X509); | ||
| 402 | #ifdef REF_PRINT | ||
| 403 | REF_PRINT("X509",data); | ||
| 404 | #endif | ||
| 405 | x = object->data.x509.certificate; | ||
| 406 | STORE_OBJECT_free(object); | ||
| 407 | return x; | ||
| 408 | } | ||
| 409 | |||
| 410 | int STORE_list_certificate_end(STORE *s, void *handle) | ||
| 411 | { | ||
| 412 | check_store(s,STORE_F_STORE_LIST_CERTIFICATE_END, | ||
| 413 | list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION); | ||
| 414 | |||
| 415 | if (!s->meth->list_object_end(s, handle)) | ||
| 416 | { | ||
| 417 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_END, | ||
| 418 | STORE_R_FAILED_LISTING_CERTIFICATES); | ||
| 419 | return 0; | ||
| 420 | } | ||
| 421 | return 1; | ||
| 422 | } | ||
| 423 | |||
| 424 | int STORE_list_certificate_endp(STORE *s, void *handle) | ||
| 425 | { | ||
| 426 | check_store(s,STORE_F_STORE_LIST_CERTIFICATE_ENDP, | ||
| 427 | list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | ||
| 428 | |||
| 429 | if (!s->meth->list_object_endp(s, handle)) | ||
| 430 | { | ||
| 431 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_ENDP, | ||
| 432 | STORE_R_FAILED_LISTING_CERTIFICATES); | ||
| 433 | return 0; | ||
| 434 | } | ||
| 435 | return 1; | ||
| 436 | } | ||
| 437 | |||
| 438 | EVP_PKEY *STORE_generate_key(STORE *s, OPENSSL_ITEM attributes[], | ||
| 439 | OPENSSL_ITEM parameters[]) | ||
| 440 | { | ||
| 441 | STORE_OBJECT *object; | ||
| 442 | EVP_PKEY *pkey; | ||
| 443 | |||
| 444 | check_store(s,STORE_F_STORE_GENERATE_KEY, | ||
| 445 | generate_object,STORE_R_NO_GENERATE_OBJECT_FUNCTION); | ||
| 446 | |||
| 447 | object = s->meth->generate_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, | ||
| 448 | attributes, parameters); | ||
| 449 | if (!object || !object->data.key) | ||
| 450 | { | ||
| 451 | STOREerr(STORE_F_STORE_GENERATE_KEY, | ||
| 452 | STORE_R_FAILED_GENERATING_KEY); | ||
| 453 | return 0; | ||
| 454 | } | ||
| 455 | CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY); | ||
| 456 | #ifdef REF_PRINT | ||
| 457 | REF_PRINT("EVP_PKEY",data); | ||
| 458 | #endif | ||
| 459 | pkey = object->data.key; | ||
| 460 | STORE_OBJECT_free(object); | ||
| 461 | return pkey; | ||
| 462 | } | ||
| 463 | |||
| 464 | EVP_PKEY *STORE_get_private_key(STORE *s, OPENSSL_ITEM attributes[], | ||
| 465 | OPENSSL_ITEM parameters[]) | ||
| 466 | { | ||
| 467 | STORE_OBJECT *object; | ||
| 468 | EVP_PKEY *pkey; | ||
| 469 | |||
| 470 | check_store(s,STORE_F_STORE_GET_PRIVATE_KEY, | ||
| 471 | get_object,STORE_R_NO_GET_OBJECT_FUNCTION); | ||
| 472 | |||
| 473 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, | ||
| 474 | attributes, parameters); | ||
| 475 | if (!object || !object->data.key || !object->data.key) | ||
| 476 | { | ||
| 477 | STOREerr(STORE_F_STORE_GET_PRIVATE_KEY, | ||
| 478 | STORE_R_FAILED_GETTING_KEY); | ||
| 479 | return 0; | ||
| 480 | } | ||
| 481 | CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY); | ||
| 482 | #ifdef REF_PRINT | ||
| 483 | REF_PRINT("EVP_PKEY",data); | ||
| 484 | #endif | ||
| 485 | pkey = object->data.key; | ||
| 486 | STORE_OBJECT_free(object); | ||
| 487 | return pkey; | ||
| 488 | } | ||
| 489 | |||
| 490 | int STORE_store_private_key(STORE *s, EVP_PKEY *data, OPENSSL_ITEM attributes[], | ||
| 491 | OPENSSL_ITEM parameters[]) | ||
| 492 | { | ||
| 493 | STORE_OBJECT *object; | ||
| 494 | int i; | ||
| 495 | |||
| 496 | check_store(s,STORE_F_STORE_STORE_PRIVATE_KEY, | ||
| 497 | store_object,STORE_R_NO_STORE_OBJECT_FUNCTION); | ||
| 498 | |||
| 499 | object = STORE_OBJECT_new(); | ||
| 500 | if (!object) | ||
| 501 | { | ||
| 502 | STOREerr(STORE_F_STORE_STORE_PRIVATE_KEY, | ||
| 503 | ERR_R_MALLOC_FAILURE); | ||
| 504 | return 0; | ||
| 505 | } | ||
| 506 | object->data.key = EVP_PKEY_new(); | ||
| 507 | if (!object->data.key) | ||
| 508 | { | ||
| 509 | STOREerr(STORE_F_STORE_STORE_PRIVATE_KEY, | ||
| 510 | ERR_R_MALLOC_FAILURE); | ||
| 511 | return 0; | ||
| 512 | } | ||
| 513 | |||
| 514 | CRYPTO_add(&data->references,1,CRYPTO_LOCK_EVP_PKEY); | ||
| 515 | #ifdef REF_PRINT | ||
| 516 | REF_PRINT("EVP_PKEY",data); | ||
| 517 | #endif | ||
| 518 | object->data.key = data; | ||
| 519 | |||
| 520 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, object, | ||
| 521 | attributes, parameters); | ||
| 522 | |||
| 523 | STORE_OBJECT_free(object); | ||
| 524 | |||
| 525 | if (!i) | ||
| 526 | { | ||
| 527 | STOREerr(STORE_F_STORE_STORE_PRIVATE_KEY, | ||
| 528 | STORE_R_FAILED_STORING_KEY); | ||
| 529 | return 0; | ||
| 530 | } | ||
| 531 | return i; | ||
| 532 | } | ||
| 533 | |||
| 534 | int STORE_modify_private_key(STORE *s, OPENSSL_ITEM search_attributes[], | ||
| 535 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | ||
| 536 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) | ||
| 537 | { | ||
| 538 | check_store(s,STORE_F_STORE_MODIFY_PRIVATE_KEY, | ||
| 539 | modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION); | ||
| 540 | |||
| 541 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, | ||
| 542 | search_attributes, add_attributes, modify_attributes, | ||
| 543 | delete_attributes, parameters)) | ||
| 544 | { | ||
| 545 | STOREerr(STORE_F_STORE_MODIFY_PRIVATE_KEY, | ||
| 546 | STORE_R_FAILED_MODIFYING_PRIVATE_KEY); | ||
| 547 | return 0; | ||
| 548 | } | ||
| 549 | return 1; | ||
| 550 | } | ||
| 551 | |||
| 552 | int STORE_revoke_private_key(STORE *s, OPENSSL_ITEM attributes[], | ||
| 553 | OPENSSL_ITEM parameters[]) | ||
| 554 | { | ||
| 555 | int i; | ||
| 556 | |||
| 557 | check_store(s,STORE_F_STORE_REVOKE_PRIVATE_KEY, | ||
| 558 | revoke_object,STORE_R_NO_REVOKE_OBJECT_FUNCTION); | ||
| 559 | |||
| 560 | i = s->meth->revoke_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, | ||
| 561 | attributes, parameters); | ||
| 562 | |||
| 563 | if (!i) | ||
| 564 | { | ||
| 565 | STOREerr(STORE_F_STORE_REVOKE_PRIVATE_KEY, | ||
| 566 | STORE_R_FAILED_REVOKING_KEY); | ||
| 567 | return 0; | ||
| 568 | } | ||
| 569 | return i; | ||
| 570 | } | ||
| 571 | |||
| 572 | int STORE_delete_private_key(STORE *s, OPENSSL_ITEM attributes[], | ||
| 573 | OPENSSL_ITEM parameters[]) | ||
| 574 | { | ||
| 575 | check_store(s,STORE_F_STORE_DELETE_PRIVATE_KEY, | ||
| 576 | delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION); | ||
| 577 | |||
| 578 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, | ||
| 579 | attributes, parameters)) | ||
| 580 | { | ||
| 581 | STOREerr(STORE_F_STORE_DELETE_PRIVATE_KEY, | ||
| 582 | STORE_R_FAILED_DELETING_KEY); | ||
| 583 | return 0; | ||
| 584 | } | ||
| 585 | return 1; | ||
| 586 | } | ||
| 587 | |||
| 588 | void *STORE_list_private_key_start(STORE *s, OPENSSL_ITEM attributes[], | ||
| 589 | OPENSSL_ITEM parameters[]) | ||
| 590 | { | ||
| 591 | void *handle; | ||
| 592 | |||
| 593 | check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_START, | ||
| 594 | list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION); | ||
| 595 | |||
| 596 | handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_PRIVATE_KEY, | ||
| 597 | attributes, parameters); | ||
| 598 | if (!handle) | ||
| 599 | { | ||
| 600 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_START, | ||
| 601 | STORE_R_FAILED_LISTING_KEYS); | ||
| 602 | return 0; | ||
| 603 | } | ||
| 604 | return handle; | ||
| 605 | } | ||
| 606 | |||
| 607 | EVP_PKEY *STORE_list_private_key_next(STORE *s, void *handle) | ||
| 608 | { | ||
| 609 | STORE_OBJECT *object; | ||
| 610 | EVP_PKEY *pkey; | ||
| 611 | |||
| 612 | check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_NEXT, | ||
| 613 | list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); | ||
| 614 | |||
| 615 | object = s->meth->list_object_next(s, handle); | ||
| 616 | if (!object || !object->data.key || !object->data.key) | ||
| 617 | { | ||
| 618 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_NEXT, | ||
| 619 | STORE_R_FAILED_LISTING_KEYS); | ||
| 620 | return 0; | ||
| 621 | } | ||
| 622 | CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY); | ||
| 623 | #ifdef REF_PRINT | ||
| 624 | REF_PRINT("EVP_PKEY",data); | ||
| 625 | #endif | ||
| 626 | pkey = object->data.key; | ||
| 627 | STORE_OBJECT_free(object); | ||
| 628 | return pkey; | ||
| 629 | } | ||
| 630 | |||
| 631 | int STORE_list_private_key_end(STORE *s, void *handle) | ||
| 632 | { | ||
| 633 | check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_END, | ||
| 634 | list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION); | ||
| 635 | |||
| 636 | if (!s->meth->list_object_end(s, handle)) | ||
| 637 | { | ||
| 638 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_END, | ||
| 639 | STORE_R_FAILED_LISTING_KEYS); | ||
| 640 | return 0; | ||
| 641 | } | ||
| 642 | return 1; | ||
| 643 | } | ||
| 644 | |||
| 645 | int STORE_list_private_key_endp(STORE *s, void *handle) | ||
| 646 | { | ||
| 647 | check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_ENDP, | ||
| 648 | list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | ||
| 649 | |||
| 650 | if (!s->meth->list_object_endp(s, handle)) | ||
| 651 | { | ||
| 652 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_ENDP, | ||
| 653 | STORE_R_FAILED_LISTING_KEYS); | ||
| 654 | return 0; | ||
| 655 | } | ||
| 656 | return 1; | ||
| 657 | } | ||
| 658 | |||
| 659 | EVP_PKEY *STORE_get_public_key(STORE *s, OPENSSL_ITEM attributes[], | ||
| 660 | OPENSSL_ITEM parameters[]) | ||
| 661 | { | ||
| 662 | STORE_OBJECT *object; | ||
| 663 | EVP_PKEY *pkey; | ||
| 664 | |||
| 665 | check_store(s,STORE_F_STORE_GET_PUBLIC_KEY, | ||
| 666 | get_object,STORE_R_NO_GET_OBJECT_FUNCTION); | ||
| 667 | |||
| 668 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, | ||
| 669 | attributes, parameters); | ||
| 670 | if (!object || !object->data.key || !object->data.key) | ||
| 671 | { | ||
| 672 | STOREerr(STORE_F_STORE_GET_PUBLIC_KEY, | ||
| 673 | STORE_R_FAILED_GETTING_KEY); | ||
| 674 | return 0; | ||
| 675 | } | ||
| 676 | CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY); | ||
| 677 | #ifdef REF_PRINT | ||
| 678 | REF_PRINT("EVP_PKEY",data); | ||
| 679 | #endif | ||
| 680 | pkey = object->data.key; | ||
| 681 | STORE_OBJECT_free(object); | ||
| 682 | return pkey; | ||
| 683 | } | ||
| 684 | |||
| 685 | int STORE_store_public_key(STORE *s, EVP_PKEY *data, OPENSSL_ITEM attributes[], | ||
| 686 | OPENSSL_ITEM parameters[]) | ||
| 687 | { | ||
| 688 | STORE_OBJECT *object; | ||
| 689 | int i; | ||
| 690 | |||
| 691 | check_store(s,STORE_F_STORE_STORE_PUBLIC_KEY, | ||
| 692 | store_object,STORE_R_NO_STORE_OBJECT_FUNCTION); | ||
| 693 | |||
| 694 | object = STORE_OBJECT_new(); | ||
| 695 | if (!object) | ||
| 696 | { | ||
| 697 | STOREerr(STORE_F_STORE_STORE_PUBLIC_KEY, | ||
| 698 | ERR_R_MALLOC_FAILURE); | ||
| 699 | return 0; | ||
| 700 | } | ||
| 701 | object->data.key = EVP_PKEY_new(); | ||
| 702 | if (!object->data.key) | ||
| 703 | { | ||
| 704 | STOREerr(STORE_F_STORE_STORE_PUBLIC_KEY, | ||
| 705 | ERR_R_MALLOC_FAILURE); | ||
| 706 | return 0; | ||
| 707 | } | ||
| 708 | |||
| 709 | CRYPTO_add(&data->references,1,CRYPTO_LOCK_EVP_PKEY); | ||
| 710 | #ifdef REF_PRINT | ||
| 711 | REF_PRINT("EVP_PKEY",data); | ||
| 712 | #endif | ||
| 713 | object->data.key = data; | ||
| 714 | |||
| 715 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, object, | ||
| 716 | attributes, parameters); | ||
| 717 | |||
| 718 | STORE_OBJECT_free(object); | ||
| 719 | |||
| 720 | if (!i) | ||
| 721 | { | ||
| 722 | STOREerr(STORE_F_STORE_STORE_PUBLIC_KEY, | ||
| 723 | STORE_R_FAILED_STORING_KEY); | ||
| 724 | return 0; | ||
| 725 | } | ||
| 726 | return i; | ||
| 727 | } | ||
| 728 | |||
| 729 | int STORE_modify_public_key(STORE *s, OPENSSL_ITEM search_attributes[], | ||
| 730 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | ||
| 731 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) | ||
| 732 | { | ||
| 733 | check_store(s,STORE_F_STORE_MODIFY_PUBLIC_KEY, | ||
| 734 | modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION); | ||
| 735 | |||
| 736 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, | ||
| 737 | search_attributes, add_attributes, modify_attributes, | ||
| 738 | delete_attributes, parameters)) | ||
| 739 | { | ||
| 740 | STOREerr(STORE_F_STORE_MODIFY_PUBLIC_KEY, | ||
| 741 | STORE_R_FAILED_MODIFYING_PUBLIC_KEY); | ||
| 742 | return 0; | ||
| 743 | } | ||
| 744 | return 1; | ||
| 745 | } | ||
| 746 | |||
| 747 | int STORE_revoke_public_key(STORE *s, OPENSSL_ITEM attributes[], | ||
| 748 | OPENSSL_ITEM parameters[]) | ||
| 749 | { | ||
| 750 | int i; | ||
| 751 | |||
| 752 | check_store(s,STORE_F_STORE_REVOKE_PUBLIC_KEY, | ||
| 753 | revoke_object,STORE_R_NO_REVOKE_OBJECT_FUNCTION); | ||
| 754 | |||
| 755 | i = s->meth->revoke_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, | ||
| 756 | attributes, parameters); | ||
| 757 | |||
| 758 | if (!i) | ||
| 759 | { | ||
| 760 | STOREerr(STORE_F_STORE_REVOKE_PUBLIC_KEY, | ||
| 761 | STORE_R_FAILED_REVOKING_KEY); | ||
| 762 | return 0; | ||
| 763 | } | ||
| 764 | return i; | ||
| 765 | } | ||
| 766 | |||
| 767 | int STORE_delete_public_key(STORE *s, OPENSSL_ITEM attributes[], | ||
| 768 | OPENSSL_ITEM parameters[]) | ||
| 769 | { | ||
| 770 | check_store(s,STORE_F_STORE_DELETE_PUBLIC_KEY, | ||
| 771 | delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION); | ||
| 772 | |||
| 773 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, | ||
| 774 | attributes, parameters)) | ||
| 775 | { | ||
| 776 | STOREerr(STORE_F_STORE_DELETE_PUBLIC_KEY, | ||
| 777 | STORE_R_FAILED_DELETING_KEY); | ||
| 778 | return 0; | ||
| 779 | } | ||
| 780 | return 1; | ||
| 781 | } | ||
| 782 | |||
| 783 | void *STORE_list_public_key_start(STORE *s, OPENSSL_ITEM attributes[], | ||
| 784 | OPENSSL_ITEM parameters[]) | ||
| 785 | { | ||
| 786 | void *handle; | ||
| 787 | |||
| 788 | check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_START, | ||
| 789 | list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION); | ||
| 790 | |||
| 791 | handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_PUBLIC_KEY, | ||
| 792 | attributes, parameters); | ||
| 793 | if (!handle) | ||
| 794 | { | ||
| 795 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_START, | ||
| 796 | STORE_R_FAILED_LISTING_KEYS); | ||
| 797 | return 0; | ||
| 798 | } | ||
| 799 | return handle; | ||
| 800 | } | ||
| 801 | |||
| 802 | EVP_PKEY *STORE_list_public_key_next(STORE *s, void *handle) | ||
| 803 | { | ||
| 804 | STORE_OBJECT *object; | ||
| 805 | EVP_PKEY *pkey; | ||
| 806 | |||
| 807 | check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_NEXT, | ||
| 808 | list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); | ||
| 809 | |||
| 810 | object = s->meth->list_object_next(s, handle); | ||
| 811 | if (!object || !object->data.key || !object->data.key) | ||
| 812 | { | ||
| 813 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_NEXT, | ||
| 814 | STORE_R_FAILED_LISTING_KEYS); | ||
| 815 | return 0; | ||
| 816 | } | ||
| 817 | CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY); | ||
| 818 | #ifdef REF_PRINT | ||
| 819 | REF_PRINT("EVP_PKEY",data); | ||
| 820 | #endif | ||
| 821 | pkey = object->data.key; | ||
| 822 | STORE_OBJECT_free(object); | ||
| 823 | return pkey; | ||
| 824 | } | ||
| 825 | |||
| 826 | int STORE_list_public_key_end(STORE *s, void *handle) | ||
| 827 | { | ||
| 828 | check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_END, | ||
| 829 | list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION); | ||
| 830 | |||
| 831 | if (!s->meth->list_object_end(s, handle)) | ||
| 832 | { | ||
| 833 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_END, | ||
| 834 | STORE_R_FAILED_LISTING_KEYS); | ||
| 835 | return 0; | ||
| 836 | } | ||
| 837 | return 1; | ||
| 838 | } | ||
| 839 | |||
| 840 | int STORE_list_public_key_endp(STORE *s, void *handle) | ||
| 841 | { | ||
| 842 | check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_ENDP, | ||
| 843 | list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | ||
| 844 | |||
| 845 | if (!s->meth->list_object_endp(s, handle)) | ||
| 846 | { | ||
| 847 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_ENDP, | ||
| 848 | STORE_R_FAILED_LISTING_KEYS); | ||
| 849 | return 0; | ||
| 850 | } | ||
| 851 | return 1; | ||
| 852 | } | ||
| 853 | |||
| 854 | X509_CRL *STORE_generate_crl(STORE *s, OPENSSL_ITEM attributes[], | ||
| 855 | OPENSSL_ITEM parameters[]) | ||
| 856 | { | ||
| 857 | STORE_OBJECT *object; | ||
| 858 | X509_CRL *crl; | ||
| 859 | |||
| 860 | check_store(s,STORE_F_STORE_GENERATE_CRL, | ||
| 861 | generate_object,STORE_R_NO_GENERATE_CRL_FUNCTION); | ||
| 862 | |||
| 863 | object = s->meth->generate_object(s, STORE_OBJECT_TYPE_X509_CRL, | ||
| 864 | attributes, parameters); | ||
| 865 | if (!object || !object->data.crl) | ||
| 866 | { | ||
| 867 | STOREerr(STORE_F_STORE_GENERATE_CRL, | ||
| 868 | STORE_R_FAILED_GENERATING_CRL); | ||
| 869 | return 0; | ||
| 870 | } | ||
| 871 | CRYPTO_add(&object->data.crl->references,1,CRYPTO_LOCK_X509_CRL); | ||
| 872 | #ifdef REF_PRINT | ||
| 873 | REF_PRINT("X509_CRL",data); | ||
| 874 | #endif | ||
| 875 | crl = object->data.crl; | ||
| 876 | STORE_OBJECT_free(object); | ||
| 877 | return crl; | ||
| 878 | } | ||
| 879 | |||
| 880 | X509_CRL *STORE_get_crl(STORE *s, OPENSSL_ITEM attributes[], | ||
| 881 | OPENSSL_ITEM parameters[]) | ||
| 882 | { | ||
| 883 | STORE_OBJECT *object; | ||
| 884 | X509_CRL *crl; | ||
| 885 | |||
| 886 | check_store(s,STORE_F_STORE_GET_CRL, | ||
| 887 | get_object,STORE_R_NO_GET_OBJECT_FUNCTION); | ||
| 888 | |||
| 889 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_X509_CRL, | ||
| 890 | attributes, parameters); | ||
| 891 | if (!object || !object->data.crl) | ||
| 892 | { | ||
| 893 | STOREerr(STORE_F_STORE_GET_CRL, | ||
| 894 | STORE_R_FAILED_GETTING_KEY); | ||
| 895 | return 0; | ||
| 896 | } | ||
| 897 | CRYPTO_add(&object->data.crl->references,1,CRYPTO_LOCK_X509_CRL); | ||
| 898 | #ifdef REF_PRINT | ||
| 899 | REF_PRINT("X509_CRL",data); | ||
| 900 | #endif | ||
| 901 | crl = object->data.crl; | ||
| 902 | STORE_OBJECT_free(object); | ||
| 903 | return crl; | ||
| 904 | } | ||
| 905 | |||
| 906 | int STORE_store_crl(STORE *s, X509_CRL *data, OPENSSL_ITEM attributes[], | ||
| 907 | OPENSSL_ITEM parameters[]) | ||
| 908 | { | ||
| 909 | STORE_OBJECT *object; | ||
| 910 | int i; | ||
| 911 | |||
| 912 | check_store(s,STORE_F_STORE_STORE_CRL, | ||
| 913 | store_object,STORE_R_NO_STORE_OBJECT_FUNCTION); | ||
| 914 | |||
| 915 | object = STORE_OBJECT_new(); | ||
| 916 | if (!object) | ||
| 917 | { | ||
| 918 | STOREerr(STORE_F_STORE_STORE_CRL, | ||
| 919 | ERR_R_MALLOC_FAILURE); | ||
| 920 | return 0; | ||
| 921 | } | ||
| 922 | |||
| 923 | CRYPTO_add(&data->references,1,CRYPTO_LOCK_X509_CRL); | ||
| 924 | #ifdef REF_PRINT | ||
| 925 | REF_PRINT("X509_CRL",data); | ||
| 926 | #endif | ||
| 927 | object->data.crl = data; | ||
| 928 | |||
| 929 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_X509_CRL, object, | ||
| 930 | attributes, parameters); | ||
| 931 | |||
| 932 | STORE_OBJECT_free(object); | ||
| 933 | |||
| 934 | if (!i) | ||
| 935 | { | ||
| 936 | STOREerr(STORE_F_STORE_STORE_CRL, | ||
| 937 | STORE_R_FAILED_STORING_KEY); | ||
| 938 | return 0; | ||
| 939 | } | ||
| 940 | return i; | ||
| 941 | } | ||
| 942 | |||
| 943 | int STORE_modify_crl(STORE *s, OPENSSL_ITEM search_attributes[], | ||
| 944 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | ||
| 945 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) | ||
| 946 | { | ||
| 947 | check_store(s,STORE_F_STORE_MODIFY_CRL, | ||
| 948 | modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION); | ||
| 949 | |||
| 950 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_X509_CRL, | ||
| 951 | search_attributes, add_attributes, modify_attributes, | ||
| 952 | delete_attributes, parameters)) | ||
| 953 | { | ||
| 954 | STOREerr(STORE_F_STORE_MODIFY_CRL, | ||
| 955 | STORE_R_FAILED_MODIFYING_CRL); | ||
| 956 | return 0; | ||
| 957 | } | ||
| 958 | return 1; | ||
| 959 | } | ||
| 960 | |||
| 961 | int STORE_delete_crl(STORE *s, OPENSSL_ITEM attributes[], | ||
| 962 | OPENSSL_ITEM parameters[]) | ||
| 963 | { | ||
| 964 | check_store(s,STORE_F_STORE_DELETE_CRL, | ||
| 965 | delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION); | ||
| 966 | |||
| 967 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_X509_CRL, | ||
| 968 | attributes, parameters)) | ||
| 969 | { | ||
| 970 | STOREerr(STORE_F_STORE_DELETE_CRL, | ||
| 971 | STORE_R_FAILED_DELETING_KEY); | ||
| 972 | return 0; | ||
| 973 | } | ||
| 974 | return 1; | ||
| 975 | } | ||
| 976 | |||
| 977 | void *STORE_list_crl_start(STORE *s, OPENSSL_ITEM attributes[], | ||
| 978 | OPENSSL_ITEM parameters[]) | ||
| 979 | { | ||
| 980 | void *handle; | ||
| 981 | |||
| 982 | check_store(s,STORE_F_STORE_LIST_CRL_START, | ||
| 983 | list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION); | ||
| 984 | |||
| 985 | handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_X509_CRL, | ||
| 986 | attributes, parameters); | ||
| 987 | if (!handle) | ||
| 988 | { | ||
| 989 | STOREerr(STORE_F_STORE_LIST_CRL_START, | ||
| 990 | STORE_R_FAILED_LISTING_KEYS); | ||
| 991 | return 0; | ||
| 992 | } | ||
| 993 | return handle; | ||
| 994 | } | ||
| 995 | |||
| 996 | X509_CRL *STORE_list_crl_next(STORE *s, void *handle) | ||
| 997 | { | ||
| 998 | STORE_OBJECT *object; | ||
| 999 | X509_CRL *crl; | ||
| 1000 | |||
| 1001 | check_store(s,STORE_F_STORE_LIST_CRL_NEXT, | ||
| 1002 | list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); | ||
| 1003 | |||
| 1004 | object = s->meth->list_object_next(s, handle); | ||
| 1005 | if (!object || !object->data.crl) | ||
| 1006 | { | ||
| 1007 | STOREerr(STORE_F_STORE_LIST_CRL_NEXT, | ||
| 1008 | STORE_R_FAILED_LISTING_KEYS); | ||
| 1009 | return 0; | ||
| 1010 | } | ||
| 1011 | CRYPTO_add(&object->data.crl->references,1,CRYPTO_LOCK_X509_CRL); | ||
| 1012 | #ifdef REF_PRINT | ||
| 1013 | REF_PRINT("X509_CRL",data); | ||
| 1014 | #endif | ||
| 1015 | crl = object->data.crl; | ||
| 1016 | STORE_OBJECT_free(object); | ||
| 1017 | return crl; | ||
| 1018 | } | ||
| 1019 | |||
| 1020 | int STORE_list_crl_end(STORE *s, void *handle) | ||
| 1021 | { | ||
| 1022 | check_store(s,STORE_F_STORE_LIST_CRL_END, | ||
| 1023 | list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION); | ||
| 1024 | |||
| 1025 | if (!s->meth->list_object_end(s, handle)) | ||
| 1026 | { | ||
| 1027 | STOREerr(STORE_F_STORE_LIST_CRL_END, | ||
| 1028 | STORE_R_FAILED_LISTING_KEYS); | ||
| 1029 | return 0; | ||
| 1030 | } | ||
| 1031 | return 1; | ||
| 1032 | } | ||
| 1033 | |||
| 1034 | int STORE_list_crl_endp(STORE *s, void *handle) | ||
| 1035 | { | ||
| 1036 | check_store(s,STORE_F_STORE_LIST_CRL_ENDP, | ||
| 1037 | list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | ||
| 1038 | |||
| 1039 | if (!s->meth->list_object_endp(s, handle)) | ||
| 1040 | { | ||
| 1041 | STOREerr(STORE_F_STORE_LIST_CRL_ENDP, | ||
| 1042 | STORE_R_FAILED_LISTING_KEYS); | ||
| 1043 | return 0; | ||
| 1044 | } | ||
| 1045 | return 1; | ||
| 1046 | } | ||
| 1047 | |||
| 1048 | int STORE_store_number(STORE *s, BIGNUM *data, OPENSSL_ITEM attributes[], | ||
| 1049 | OPENSSL_ITEM parameters[]) | ||
| 1050 | { | ||
| 1051 | STORE_OBJECT *object; | ||
| 1052 | int i; | ||
| 1053 | |||
| 1054 | check_store(s,STORE_F_STORE_STORE_NUMBER, | ||
| 1055 | store_object,STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION); | ||
| 1056 | |||
| 1057 | object = STORE_OBJECT_new(); | ||
| 1058 | if (!object) | ||
| 1059 | { | ||
| 1060 | STOREerr(STORE_F_STORE_STORE_NUMBER, | ||
| 1061 | ERR_R_MALLOC_FAILURE); | ||
| 1062 | return 0; | ||
| 1063 | } | ||
| 1064 | |||
| 1065 | object->data.number = data; | ||
| 1066 | |||
| 1067 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_NUMBER, object, | ||
| 1068 | attributes, parameters); | ||
| 1069 | |||
| 1070 | STORE_OBJECT_free(object); | ||
| 1071 | |||
| 1072 | if (!i) | ||
| 1073 | { | ||
| 1074 | STOREerr(STORE_F_STORE_STORE_NUMBER, | ||
| 1075 | STORE_R_FAILED_STORING_NUMBER); | ||
| 1076 | return 0; | ||
| 1077 | } | ||
| 1078 | return 1; | ||
| 1079 | } | ||
| 1080 | |||
| 1081 | int STORE_modify_number(STORE *s, OPENSSL_ITEM search_attributes[], | ||
| 1082 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | ||
| 1083 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) | ||
| 1084 | { | ||
| 1085 | check_store(s,STORE_F_STORE_MODIFY_NUMBER, | ||
| 1086 | modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION); | ||
| 1087 | |||
| 1088 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_NUMBER, | ||
| 1089 | search_attributes, add_attributes, modify_attributes, | ||
| 1090 | delete_attributes, parameters)) | ||
| 1091 | { | ||
| 1092 | STOREerr(STORE_F_STORE_MODIFY_NUMBER, | ||
| 1093 | STORE_R_FAILED_MODIFYING_NUMBER); | ||
| 1094 | return 0; | ||
| 1095 | } | ||
| 1096 | return 1; | ||
| 1097 | } | ||
| 1098 | |||
| 1099 | BIGNUM *STORE_get_number(STORE *s, OPENSSL_ITEM attributes[], | ||
| 1100 | OPENSSL_ITEM parameters[]) | ||
| 1101 | { | ||
| 1102 | STORE_OBJECT *object; | ||
| 1103 | BIGNUM *n; | ||
| 1104 | |||
| 1105 | check_store(s,STORE_F_STORE_GET_NUMBER, | ||
| 1106 | get_object,STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION); | ||
| 1107 | |||
| 1108 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_NUMBER, attributes, | ||
| 1109 | parameters); | ||
| 1110 | if (!object || !object->data.number) | ||
| 1111 | { | ||
| 1112 | STOREerr(STORE_F_STORE_GET_NUMBER, | ||
| 1113 | STORE_R_FAILED_GETTING_NUMBER); | ||
| 1114 | return 0; | ||
| 1115 | } | ||
| 1116 | n = object->data.number; | ||
| 1117 | object->data.number = NULL; | ||
| 1118 | STORE_OBJECT_free(object); | ||
| 1119 | return n; | ||
| 1120 | } | ||
| 1121 | |||
| 1122 | int STORE_delete_number(STORE *s, OPENSSL_ITEM attributes[], | ||
| 1123 | OPENSSL_ITEM parameters[]) | ||
| 1124 | { | ||
| 1125 | check_store(s,STORE_F_STORE_DELETE_NUMBER, | ||
| 1126 | delete_object,STORE_R_NO_DELETE_NUMBER_FUNCTION); | ||
| 1127 | |||
| 1128 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_NUMBER, attributes, | ||
| 1129 | parameters)) | ||
| 1130 | { | ||
| 1131 | STOREerr(STORE_F_STORE_DELETE_NUMBER, | ||
| 1132 | STORE_R_FAILED_DELETING_NUMBER); | ||
| 1133 | return 0; | ||
| 1134 | } | ||
| 1135 | return 1; | ||
| 1136 | } | ||
| 1137 | |||
| 1138 | int STORE_store_arbitrary(STORE *s, BUF_MEM *data, OPENSSL_ITEM attributes[], | ||
| 1139 | OPENSSL_ITEM parameters[]) | ||
| 1140 | { | ||
| 1141 | STORE_OBJECT *object; | ||
| 1142 | int i; | ||
| 1143 | |||
| 1144 | check_store(s,STORE_F_STORE_STORE_ARBITRARY, | ||
| 1145 | store_object,STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION); | ||
| 1146 | |||
| 1147 | object = STORE_OBJECT_new(); | ||
| 1148 | if (!object) | ||
| 1149 | { | ||
| 1150 | STOREerr(STORE_F_STORE_STORE_ARBITRARY, | ||
| 1151 | ERR_R_MALLOC_FAILURE); | ||
| 1152 | return 0; | ||
| 1153 | } | ||
| 1154 | |||
| 1155 | object->data.arbitrary = data; | ||
| 1156 | |||
| 1157 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_ARBITRARY, object, | ||
| 1158 | attributes, parameters); | ||
| 1159 | |||
| 1160 | STORE_OBJECT_free(object); | ||
| 1161 | |||
| 1162 | if (!i) | ||
| 1163 | { | ||
| 1164 | STOREerr(STORE_F_STORE_STORE_ARBITRARY, | ||
| 1165 | STORE_R_FAILED_STORING_ARBITRARY); | ||
| 1166 | return 0; | ||
| 1167 | } | ||
| 1168 | return 1; | ||
| 1169 | } | ||
| 1170 | |||
| 1171 | int STORE_modify_arbitrary(STORE *s, OPENSSL_ITEM search_attributes[], | ||
| 1172 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | ||
| 1173 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) | ||
| 1174 | { | ||
| 1175 | check_store(s,STORE_F_STORE_MODIFY_ARBITRARY, | ||
| 1176 | modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION); | ||
| 1177 | |||
| 1178 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_ARBITRARY, | ||
| 1179 | search_attributes, add_attributes, modify_attributes, | ||
| 1180 | delete_attributes, parameters)) | ||
| 1181 | { | ||
| 1182 | STOREerr(STORE_F_STORE_MODIFY_ARBITRARY, | ||
| 1183 | STORE_R_FAILED_MODIFYING_ARBITRARY); | ||
| 1184 | return 0; | ||
| 1185 | } | ||
| 1186 | return 1; | ||
| 1187 | } | ||
| 1188 | |||
| 1189 | BUF_MEM *STORE_get_arbitrary(STORE *s, OPENSSL_ITEM attributes[], | ||
| 1190 | OPENSSL_ITEM parameters[]) | ||
| 1191 | { | ||
| 1192 | STORE_OBJECT *object; | ||
| 1193 | BUF_MEM *b; | ||
| 1194 | |||
| 1195 | check_store(s,STORE_F_STORE_GET_ARBITRARY, | ||
| 1196 | get_object,STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION); | ||
| 1197 | |||
| 1198 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_ARBITRARY, | ||
| 1199 | attributes, parameters); | ||
| 1200 | if (!object || !object->data.arbitrary) | ||
| 1201 | { | ||
| 1202 | STOREerr(STORE_F_STORE_GET_ARBITRARY, | ||
| 1203 | STORE_R_FAILED_GETTING_ARBITRARY); | ||
| 1204 | return 0; | ||
| 1205 | } | ||
| 1206 | b = object->data.arbitrary; | ||
| 1207 | object->data.arbitrary = NULL; | ||
| 1208 | STORE_OBJECT_free(object); | ||
| 1209 | return b; | ||
| 1210 | } | ||
| 1211 | |||
| 1212 | int STORE_delete_arbitrary(STORE *s, OPENSSL_ITEM attributes[], | ||
| 1213 | OPENSSL_ITEM parameters[]) | ||
| 1214 | { | ||
| 1215 | check_store(s,STORE_F_STORE_DELETE_ARBITRARY, | ||
| 1216 | delete_object,STORE_R_NO_DELETE_ARBITRARY_FUNCTION); | ||
| 1217 | |||
| 1218 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_ARBITRARY, attributes, | ||
| 1219 | parameters)) | ||
| 1220 | { | ||
| 1221 | STOREerr(STORE_F_STORE_DELETE_ARBITRARY, | ||
| 1222 | STORE_R_FAILED_DELETING_ARBITRARY); | ||
| 1223 | return 0; | ||
| 1224 | } | ||
| 1225 | return 1; | ||
| 1226 | } | ||
| 1227 | |||
| 1228 | STORE_OBJECT *STORE_OBJECT_new(void) | ||
| 1229 | { | ||
| 1230 | STORE_OBJECT *object = OPENSSL_malloc(sizeof(STORE_OBJECT)); | ||
| 1231 | if (object) memset(object, 0, sizeof(STORE_OBJECT)); | ||
| 1232 | return object; | ||
| 1233 | } | ||
| 1234 | void STORE_OBJECT_free(STORE_OBJECT *data) | ||
| 1235 | { | ||
| 1236 | if (!data) return; | ||
| 1237 | switch (data->type) | ||
| 1238 | { | ||
| 1239 | case STORE_OBJECT_TYPE_X509_CERTIFICATE: | ||
| 1240 | X509_free(data->data.x509.certificate); | ||
| 1241 | break; | ||
| 1242 | case STORE_OBJECT_TYPE_X509_CRL: | ||
| 1243 | X509_CRL_free(data->data.crl); | ||
| 1244 | break; | ||
| 1245 | case STORE_OBJECT_TYPE_PRIVATE_KEY: | ||
| 1246 | case STORE_OBJECT_TYPE_PUBLIC_KEY: | ||
| 1247 | EVP_PKEY_free(data->data.key); | ||
| 1248 | break; | ||
| 1249 | case STORE_OBJECT_TYPE_NUMBER: | ||
| 1250 | BN_free(data->data.number); | ||
| 1251 | break; | ||
| 1252 | case STORE_OBJECT_TYPE_ARBITRARY: | ||
| 1253 | BUF_MEM_free(data->data.arbitrary); | ||
| 1254 | break; | ||
| 1255 | } | ||
| 1256 | OPENSSL_free(data); | ||
| 1257 | } | ||
| 1258 | |||
| 1259 | IMPLEMENT_STACK_OF(STORE_OBJECT*) | ||
| 1260 | |||
| 1261 | |||
| 1262 | struct STORE_attr_info_st | ||
| 1263 | { | ||
| 1264 | unsigned char set[(STORE_ATTR_TYPE_NUM + 8) / 8]; | ||
| 1265 | union | ||
| 1266 | { | ||
| 1267 | char *cstring; | ||
| 1268 | unsigned char *sha1string; | ||
| 1269 | X509_NAME *dn; | ||
| 1270 | BIGNUM *number; | ||
| 1271 | void *any; | ||
| 1272 | } values[STORE_ATTR_TYPE_NUM+1]; | ||
| 1273 | size_t value_sizes[STORE_ATTR_TYPE_NUM+1]; | ||
| 1274 | }; | ||
| 1275 | |||
| 1276 | #define ATTR_IS_SET(a,i) ((i) > 0 && (i) < STORE_ATTR_TYPE_NUM \ | ||
| 1277 | && ((a)->set[(i) / 8] & (1 << ((i) % 8)))) | ||
| 1278 | #define SET_ATTRBIT(a,i) ((a)->set[(i) / 8] |= (1 << ((i) % 8))) | ||
| 1279 | #define CLEAR_ATTRBIT(a,i) ((a)->set[(i) / 8] &= ~(1 << ((i) % 8))) | ||
| 1280 | |||
| 1281 | STORE_ATTR_INFO *STORE_ATTR_INFO_new(void) | ||
| 1282 | { | ||
| 1283 | return (STORE_ATTR_INFO *)OPENSSL_malloc(sizeof(STORE_ATTR_INFO)); | ||
| 1284 | } | ||
| 1285 | static void STORE_ATTR_INFO_attr_free(STORE_ATTR_INFO *attrs, | ||
| 1286 | STORE_ATTR_TYPES code) | ||
| 1287 | { | ||
| 1288 | if (ATTR_IS_SET(attrs,code)) | ||
| 1289 | { | ||
| 1290 | switch(code) | ||
| 1291 | { | ||
| 1292 | case STORE_ATTR_FRIENDLYNAME: | ||
| 1293 | case STORE_ATTR_EMAIL: | ||
| 1294 | case STORE_ATTR_FILENAME: | ||
| 1295 | STORE_ATTR_INFO_modify_cstr(attrs, code, NULL, 0); | ||
| 1296 | break; | ||
| 1297 | case STORE_ATTR_KEYID: | ||
| 1298 | case STORE_ATTR_ISSUERKEYID: | ||
| 1299 | case STORE_ATTR_SUBJECTKEYID: | ||
| 1300 | case STORE_ATTR_ISSUERSERIALHASH: | ||
| 1301 | case STORE_ATTR_CERTHASH: | ||
| 1302 | STORE_ATTR_INFO_modify_sha1str(attrs, code, NULL, 0); | ||
| 1303 | break; | ||
| 1304 | case STORE_ATTR_ISSUER: | ||
| 1305 | case STORE_ATTR_SUBJECT: | ||
| 1306 | STORE_ATTR_INFO_modify_dn(attrs, code, NULL); | ||
| 1307 | break; | ||
| 1308 | case STORE_ATTR_SERIAL: | ||
| 1309 | STORE_ATTR_INFO_modify_number(attrs, code, NULL); | ||
| 1310 | break; | ||
| 1311 | default: | ||
| 1312 | break; | ||
| 1313 | } | ||
| 1314 | } | ||
| 1315 | } | ||
| 1316 | int STORE_ATTR_INFO_free(STORE_ATTR_INFO *attrs) | ||
| 1317 | { | ||
| 1318 | if (attrs) | ||
| 1319 | { | ||
| 1320 | STORE_ATTR_TYPES i; | ||
| 1321 | for(i = 0; i++ < STORE_ATTR_TYPE_NUM;) | ||
| 1322 | STORE_ATTR_INFO_attr_free(attrs, i); | ||
| 1323 | OPENSSL_free(attrs); | ||
| 1324 | } | ||
| 1325 | return 1; | ||
| 1326 | } | ||
| 1327 | char *STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code) | ||
| 1328 | { | ||
| 1329 | if (!attrs) | ||
| 1330 | { | ||
| 1331 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_CSTR, | ||
| 1332 | ERR_R_PASSED_NULL_PARAMETER); | ||
| 1333 | return NULL; | ||
| 1334 | } | ||
| 1335 | if (ATTR_IS_SET(attrs,code)) | ||
| 1336 | return attrs->values[code].cstring; | ||
| 1337 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_CSTR, | ||
| 1338 | STORE_R_NO_VALUE); | ||
| 1339 | return NULL; | ||
| 1340 | } | ||
| 1341 | unsigned char *STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs, | ||
| 1342 | STORE_ATTR_TYPES code) | ||
| 1343 | { | ||
| 1344 | if (!attrs) | ||
| 1345 | { | ||
| 1346 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_SHA1STR, | ||
| 1347 | ERR_R_PASSED_NULL_PARAMETER); | ||
| 1348 | return NULL; | ||
| 1349 | } | ||
| 1350 | if (ATTR_IS_SET(attrs,code)) | ||
| 1351 | return attrs->values[code].sha1string; | ||
| 1352 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_SHA1STR, | ||
| 1353 | STORE_R_NO_VALUE); | ||
| 1354 | return NULL; | ||
| 1355 | } | ||
| 1356 | X509_NAME *STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code) | ||
| 1357 | { | ||
| 1358 | if (!attrs) | ||
| 1359 | { | ||
| 1360 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_DN, | ||
| 1361 | ERR_R_PASSED_NULL_PARAMETER); | ||
| 1362 | return NULL; | ||
| 1363 | } | ||
| 1364 | if (ATTR_IS_SET(attrs,code)) | ||
| 1365 | return attrs->values[code].dn; | ||
| 1366 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_DN, | ||
| 1367 | STORE_R_NO_VALUE); | ||
| 1368 | return NULL; | ||
| 1369 | } | ||
| 1370 | BIGNUM *STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code) | ||
| 1371 | { | ||
| 1372 | if (!attrs) | ||
| 1373 | { | ||
| 1374 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_NUMBER, | ||
| 1375 | ERR_R_PASSED_NULL_PARAMETER); | ||
| 1376 | return NULL; | ||
| 1377 | } | ||
| 1378 | if (ATTR_IS_SET(attrs,code)) | ||
| 1379 | return attrs->values[code].number; | ||
| 1380 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_NUMBER, | ||
| 1381 | STORE_R_NO_VALUE); | ||
| 1382 | return NULL; | ||
| 1383 | } | ||
| 1384 | int STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | ||
| 1385 | char *cstr, size_t cstr_size) | ||
| 1386 | { | ||
| 1387 | if (!attrs) | ||
| 1388 | { | ||
| 1389 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR, | ||
| 1390 | ERR_R_PASSED_NULL_PARAMETER); | ||
| 1391 | return 0; | ||
| 1392 | } | ||
| 1393 | if (!ATTR_IS_SET(attrs,code)) | ||
| 1394 | { | ||
| 1395 | if ((attrs->values[code].cstring = BUF_strndup(cstr, cstr_size))) | ||
| 1396 | return 1; | ||
| 1397 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR, | ||
| 1398 | ERR_R_MALLOC_FAILURE); | ||
| 1399 | return 0; | ||
| 1400 | } | ||
| 1401 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR, STORE_R_ALREADY_HAS_A_VALUE); | ||
| 1402 | return 0; | ||
| 1403 | } | ||
| 1404 | int STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | ||
| 1405 | unsigned char *sha1str, size_t sha1str_size) | ||
| 1406 | { | ||
| 1407 | if (!attrs) | ||
| 1408 | { | ||
| 1409 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR, | ||
| 1410 | ERR_R_PASSED_NULL_PARAMETER); | ||
| 1411 | return 0; | ||
| 1412 | } | ||
| 1413 | if (!ATTR_IS_SET(attrs,code)) | ||
| 1414 | { | ||
| 1415 | if ((attrs->values[code].sha1string = | ||
| 1416 | (unsigned char *)BUF_memdup(sha1str, | ||
| 1417 | sha1str_size))) | ||
| 1418 | return 1; | ||
| 1419 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR, | ||
| 1420 | ERR_R_MALLOC_FAILURE); | ||
| 1421 | return 0; | ||
| 1422 | } | ||
| 1423 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR, STORE_R_ALREADY_HAS_A_VALUE); | ||
| 1424 | return 0; | ||
| 1425 | } | ||
| 1426 | int STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | ||
| 1427 | X509_NAME *dn) | ||
| 1428 | { | ||
| 1429 | if (!attrs) | ||
| 1430 | { | ||
| 1431 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN, | ||
| 1432 | ERR_R_PASSED_NULL_PARAMETER); | ||
| 1433 | return 0; | ||
| 1434 | } | ||
| 1435 | if (!ATTR_IS_SET(attrs,code)) | ||
| 1436 | { | ||
| 1437 | if ((attrs->values[code].dn = X509_NAME_dup(dn))) | ||
| 1438 | return 1; | ||
| 1439 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN, | ||
| 1440 | ERR_R_MALLOC_FAILURE); | ||
| 1441 | return 0; | ||
| 1442 | } | ||
| 1443 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN, STORE_R_ALREADY_HAS_A_VALUE); | ||
| 1444 | return 0; | ||
| 1445 | } | ||
| 1446 | int STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | ||
| 1447 | BIGNUM *number) | ||
| 1448 | { | ||
| 1449 | if (!attrs) | ||
| 1450 | { | ||
| 1451 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER, | ||
| 1452 | ERR_R_PASSED_NULL_PARAMETER); | ||
| 1453 | return 0; | ||
| 1454 | } | ||
| 1455 | if (!ATTR_IS_SET(attrs,code)) | ||
| 1456 | { | ||
| 1457 | if ((attrs->values[code].number = BN_dup(number))) | ||
| 1458 | return 1; | ||
| 1459 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER, | ||
| 1460 | ERR_R_MALLOC_FAILURE); | ||
| 1461 | return 0; | ||
| 1462 | } | ||
| 1463 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER, STORE_R_ALREADY_HAS_A_VALUE); | ||
| 1464 | return 0; | ||
| 1465 | } | ||
| 1466 | int STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | ||
| 1467 | char *cstr, size_t cstr_size) | ||
| 1468 | { | ||
| 1469 | if (!attrs) | ||
| 1470 | { | ||
| 1471 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_CSTR, | ||
| 1472 | ERR_R_PASSED_NULL_PARAMETER); | ||
| 1473 | return 0; | ||
| 1474 | } | ||
| 1475 | if (ATTR_IS_SET(attrs,code)) | ||
| 1476 | { | ||
| 1477 | OPENSSL_free(attrs->values[code].cstring); | ||
| 1478 | attrs->values[code].cstring = NULL; | ||
| 1479 | CLEAR_ATTRBIT(attrs, code); | ||
| 1480 | } | ||
| 1481 | return STORE_ATTR_INFO_set_cstr(attrs, code, cstr, cstr_size); | ||
| 1482 | } | ||
| 1483 | int STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | ||
| 1484 | unsigned char *sha1str, size_t sha1str_size) | ||
| 1485 | { | ||
| 1486 | if (!attrs) | ||
| 1487 | { | ||
| 1488 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR, | ||
| 1489 | ERR_R_PASSED_NULL_PARAMETER); | ||
| 1490 | return 0; | ||
| 1491 | } | ||
| 1492 | if (ATTR_IS_SET(attrs,code)) | ||
| 1493 | { | ||
| 1494 | OPENSSL_free(attrs->values[code].sha1string); | ||
| 1495 | attrs->values[code].sha1string = NULL; | ||
| 1496 | CLEAR_ATTRBIT(attrs, code); | ||
| 1497 | } | ||
| 1498 | return STORE_ATTR_INFO_set_sha1str(attrs, code, sha1str, sha1str_size); | ||
| 1499 | } | ||
| 1500 | int STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | ||
| 1501 | X509_NAME *dn) | ||
| 1502 | { | ||
| 1503 | if (!attrs) | ||
| 1504 | { | ||
| 1505 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_DN, | ||
| 1506 | ERR_R_PASSED_NULL_PARAMETER); | ||
| 1507 | return 0; | ||
| 1508 | } | ||
| 1509 | if (ATTR_IS_SET(attrs,code)) | ||
| 1510 | { | ||
| 1511 | OPENSSL_free(attrs->values[code].dn); | ||
| 1512 | attrs->values[code].dn = NULL; | ||
| 1513 | CLEAR_ATTRBIT(attrs, code); | ||
| 1514 | } | ||
| 1515 | return STORE_ATTR_INFO_set_dn(attrs, code, dn); | ||
| 1516 | } | ||
| 1517 | int STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | ||
| 1518 | BIGNUM *number) | ||
| 1519 | { | ||
| 1520 | if (!attrs) | ||
| 1521 | { | ||
| 1522 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER, | ||
| 1523 | ERR_R_PASSED_NULL_PARAMETER); | ||
| 1524 | return 0; | ||
| 1525 | } | ||
| 1526 | if (ATTR_IS_SET(attrs,code)) | ||
| 1527 | { | ||
| 1528 | OPENSSL_free(attrs->values[code].number); | ||
| 1529 | attrs->values[code].number = NULL; | ||
| 1530 | CLEAR_ATTRBIT(attrs, code); | ||
| 1531 | } | ||
| 1532 | return STORE_ATTR_INFO_set_number(attrs, code, number); | ||
| 1533 | } | ||
| 1534 | |||
| 1535 | struct attr_list_ctx_st | ||
| 1536 | { | ||
| 1537 | OPENSSL_ITEM *attributes; | ||
| 1538 | }; | ||
| 1539 | void *STORE_parse_attrs_start(OPENSSL_ITEM *attributes) | ||
| 1540 | { | ||
| 1541 | if (attributes) | ||
| 1542 | { | ||
| 1543 | struct attr_list_ctx_st *context = | ||
| 1544 | (struct attr_list_ctx_st *)OPENSSL_malloc(sizeof(struct attr_list_ctx_st)); | ||
| 1545 | if (context) | ||
| 1546 | context->attributes = attributes; | ||
| 1547 | else | ||
| 1548 | STOREerr(STORE_F_STORE_PARSE_ATTRS_START, | ||
| 1549 | ERR_R_MALLOC_FAILURE); | ||
| 1550 | return context; | ||
| 1551 | } | ||
| 1552 | STOREerr(STORE_F_STORE_PARSE_ATTRS_START, ERR_R_PASSED_NULL_PARAMETER); | ||
| 1553 | return 0; | ||
| 1554 | } | ||
| 1555 | STORE_ATTR_INFO *STORE_parse_attrs_next(void *handle) | ||
| 1556 | { | ||
| 1557 | struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle; | ||
| 1558 | |||
| 1559 | if (context && context->attributes) | ||
| 1560 | { | ||
| 1561 | STORE_ATTR_INFO *attrs = NULL; | ||
| 1562 | |||
| 1563 | while(context->attributes | ||
| 1564 | && context->attributes->code != STORE_ATTR_OR | ||
| 1565 | && context->attributes->code != STORE_ATTR_END) | ||
| 1566 | { | ||
| 1567 | switch(context->attributes->code) | ||
| 1568 | { | ||
| 1569 | case STORE_ATTR_FRIENDLYNAME: | ||
| 1570 | case STORE_ATTR_EMAIL: | ||
| 1571 | case STORE_ATTR_FILENAME: | ||
| 1572 | if (!attrs) attrs = STORE_ATTR_INFO_new(); | ||
| 1573 | if (attrs == NULL) | ||
| 1574 | { | ||
| 1575 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, | ||
| 1576 | ERR_R_MALLOC_FAILURE); | ||
| 1577 | goto err; | ||
| 1578 | } | ||
| 1579 | STORE_ATTR_INFO_set_cstr(attrs, | ||
| 1580 | context->attributes->code, | ||
| 1581 | context->attributes->value, | ||
| 1582 | context->attributes->value_size); | ||
| 1583 | break; | ||
| 1584 | case STORE_ATTR_KEYID: | ||
| 1585 | case STORE_ATTR_ISSUERKEYID: | ||
| 1586 | case STORE_ATTR_SUBJECTKEYID: | ||
| 1587 | case STORE_ATTR_ISSUERSERIALHASH: | ||
| 1588 | case STORE_ATTR_CERTHASH: | ||
| 1589 | if (!attrs) attrs = STORE_ATTR_INFO_new(); | ||
| 1590 | if (attrs == NULL) | ||
| 1591 | { | ||
| 1592 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, | ||
| 1593 | ERR_R_MALLOC_FAILURE); | ||
| 1594 | goto err; | ||
| 1595 | } | ||
| 1596 | STORE_ATTR_INFO_set_sha1str(attrs, | ||
| 1597 | context->attributes->code, | ||
| 1598 | context->attributes->value, | ||
| 1599 | context->attributes->value_size); | ||
| 1600 | break; | ||
| 1601 | case STORE_ATTR_ISSUER: | ||
| 1602 | case STORE_ATTR_SUBJECT: | ||
| 1603 | if (!attrs) attrs = STORE_ATTR_INFO_new(); | ||
| 1604 | if (attrs == NULL) | ||
| 1605 | { | ||
| 1606 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, | ||
| 1607 | ERR_R_MALLOC_FAILURE); | ||
| 1608 | goto err; | ||
| 1609 | } | ||
| 1610 | STORE_ATTR_INFO_modify_dn(attrs, | ||
| 1611 | context->attributes->code, | ||
| 1612 | context->attributes->value); | ||
| 1613 | break; | ||
| 1614 | case STORE_ATTR_SERIAL: | ||
| 1615 | if (!attrs) attrs = STORE_ATTR_INFO_new(); | ||
| 1616 | if (attrs == NULL) | ||
| 1617 | { | ||
| 1618 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, | ||
| 1619 | ERR_R_MALLOC_FAILURE); | ||
| 1620 | goto err; | ||
| 1621 | } | ||
| 1622 | STORE_ATTR_INFO_modify_number(attrs, | ||
| 1623 | context->attributes->code, | ||
| 1624 | context->attributes->value); | ||
| 1625 | break; | ||
| 1626 | } | ||
| 1627 | context->attributes++; | ||
| 1628 | } | ||
| 1629 | if (context->attributes->code == STORE_ATTR_OR) | ||
| 1630 | context->attributes++; | ||
| 1631 | return attrs; | ||
| 1632 | err: | ||
| 1633 | while(context->attributes | ||
| 1634 | && context->attributes->code != STORE_ATTR_OR | ||
| 1635 | && context->attributes->code != STORE_ATTR_END) | ||
| 1636 | context->attributes++; | ||
| 1637 | if (context->attributes->code == STORE_ATTR_OR) | ||
| 1638 | context->attributes++; | ||
| 1639 | return NULL; | ||
| 1640 | } | ||
| 1641 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, ERR_R_PASSED_NULL_PARAMETER); | ||
| 1642 | return NULL; | ||
| 1643 | } | ||
| 1644 | int STORE_parse_attrs_end(void *handle) | ||
| 1645 | { | ||
| 1646 | struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle; | ||
| 1647 | |||
| 1648 | if (context && context->attributes) | ||
| 1649 | { | ||
| 1650 | #if 0 | ||
| 1651 | OPENSSL_ITEM *attributes = context->attributes; | ||
| 1652 | #endif | ||
| 1653 | OPENSSL_free(context); | ||
| 1654 | return 1; | ||
| 1655 | } | ||
| 1656 | STOREerr(STORE_F_STORE_PARSE_ATTRS_END, ERR_R_PASSED_NULL_PARAMETER); | ||
| 1657 | return 0; | ||
| 1658 | } | ||
| 1659 | |||
| 1660 | int STORE_parse_attrs_endp(void *handle) | ||
| 1661 | { | ||
| 1662 | struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle; | ||
| 1663 | |||
| 1664 | if (context && context->attributes) | ||
| 1665 | { | ||
| 1666 | return context->attributes->code == STORE_ATTR_END; | ||
| 1667 | } | ||
| 1668 | STOREerr(STORE_F_STORE_PARSE_ATTRS_ENDP, ERR_R_PASSED_NULL_PARAMETER); | ||
| 1669 | return 0; | ||
| 1670 | } | ||
| 1671 | |||
| 1672 | static int attr_info_compare_compute_range( | ||
| 1673 | const unsigned char *abits, const unsigned char *bbits, | ||
| 1674 | unsigned int *alowp, unsigned int *ahighp, | ||
| 1675 | unsigned int *blowp, unsigned int *bhighp) | ||
| 1676 | { | ||
| 1677 | unsigned int alow = (unsigned int)-1, ahigh = 0; | ||
| 1678 | unsigned int blow = (unsigned int)-1, bhigh = 0; | ||
| 1679 | int i, res = 0; | ||
| 1680 | |||
| 1681 | for (i = 0; i < (STORE_ATTR_TYPE_NUM + 8) / 8; i++, abits++, bbits++) | ||
| 1682 | { | ||
| 1683 | if (res == 0) | ||
| 1684 | { | ||
| 1685 | if (*abits < *bbits) res = -1; | ||
| 1686 | if (*abits > *bbits) res = 1; | ||
| 1687 | } | ||
| 1688 | if (*abits) | ||
| 1689 | { | ||
| 1690 | if (alow == (unsigned int)-1) | ||
| 1691 | { | ||
| 1692 | alow = i * 8; | ||
| 1693 | if (!(*abits & 0x01)) alow++; | ||
| 1694 | if (!(*abits & 0x02)) alow++; | ||
| 1695 | if (!(*abits & 0x04)) alow++; | ||
| 1696 | if (!(*abits & 0x08)) alow++; | ||
| 1697 | if (!(*abits & 0x10)) alow++; | ||
| 1698 | if (!(*abits & 0x20)) alow++; | ||
| 1699 | if (!(*abits & 0x40)) alow++; | ||
| 1700 | } | ||
| 1701 | ahigh = i * 8 + 7; | ||
| 1702 | if (!(*abits & 0x80)) ahigh++; | ||
| 1703 | if (!(*abits & 0x40)) ahigh++; | ||
| 1704 | if (!(*abits & 0x20)) ahigh++; | ||
| 1705 | if (!(*abits & 0x10)) ahigh++; | ||
| 1706 | if (!(*abits & 0x08)) ahigh++; | ||
| 1707 | if (!(*abits & 0x04)) ahigh++; | ||
| 1708 | if (!(*abits & 0x02)) ahigh++; | ||
| 1709 | } | ||
| 1710 | if (*bbits) | ||
| 1711 | { | ||
| 1712 | if (blow == (unsigned int)-1) | ||
| 1713 | { | ||
| 1714 | blow = i * 8; | ||
| 1715 | if (!(*bbits & 0x01)) blow++; | ||
| 1716 | if (!(*bbits & 0x02)) blow++; | ||
| 1717 | if (!(*bbits & 0x04)) blow++; | ||
| 1718 | if (!(*bbits & 0x08)) blow++; | ||
| 1719 | if (!(*bbits & 0x10)) blow++; | ||
| 1720 | if (!(*bbits & 0x20)) blow++; | ||
| 1721 | if (!(*bbits & 0x40)) blow++; | ||
| 1722 | } | ||
| 1723 | bhigh = i * 8 + 7; | ||
| 1724 | if (!(*bbits & 0x80)) bhigh++; | ||
| 1725 | if (!(*bbits & 0x40)) bhigh++; | ||
| 1726 | if (!(*bbits & 0x20)) bhigh++; | ||
| 1727 | if (!(*bbits & 0x10)) bhigh++; | ||
| 1728 | if (!(*bbits & 0x08)) bhigh++; | ||
| 1729 | if (!(*bbits & 0x04)) bhigh++; | ||
| 1730 | if (!(*bbits & 0x02)) bhigh++; | ||
| 1731 | } | ||
| 1732 | } | ||
| 1733 | if (ahigh + alow < bhigh + blow) res = -1; | ||
| 1734 | if (ahigh + alow > bhigh + blow) res = 1; | ||
| 1735 | if (alowp) *alowp = alow; | ||
| 1736 | if (ahighp) *ahighp = ahigh; | ||
| 1737 | if (blowp) *blowp = blow; | ||
| 1738 | if (bhighp) *bhighp = bhigh; | ||
| 1739 | return res; | ||
| 1740 | } | ||
| 1741 | |||
| 1742 | int STORE_ATTR_INFO_compare(const STORE_ATTR_INFO * const *a, | ||
| 1743 | const STORE_ATTR_INFO * const *b) | ||
| 1744 | { | ||
| 1745 | if (a == b) return 0; | ||
| 1746 | if (!a) return -1; | ||
| 1747 | if (!b) return 1; | ||
| 1748 | return attr_info_compare_compute_range((*a)->set, (*b)->set, 0, 0, 0, 0); | ||
| 1749 | } | ||
| 1750 | |||
| 1751 | int STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) | ||
| 1752 | { | ||
| 1753 | unsigned int alow, ahigh, blow, bhigh; | ||
| 1754 | |||
| 1755 | if (a == b) return 1; | ||
| 1756 | if (!a) return 0; | ||
| 1757 | if (!b) return 0; | ||
| 1758 | attr_info_compare_compute_range(a->set, b->set, | ||
| 1759 | &alow, &ahigh, &blow, &bhigh); | ||
| 1760 | if (alow >= blow && ahigh <= bhigh) | ||
| 1761 | return 1; | ||
| 1762 | return 0; | ||
| 1763 | } | ||
| 1764 | |||
| 1765 | int STORE_ATTR_INFO_in(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) | ||
| 1766 | { | ||
| 1767 | unsigned char *abits, *bbits; | ||
| 1768 | int i; | ||
| 1769 | |||
| 1770 | if (a == b) return 1; | ||
| 1771 | if (!a) return 0; | ||
| 1772 | if (!b) return 0; | ||
| 1773 | abits = a->set; | ||
| 1774 | bbits = b->set; | ||
| 1775 | for (i = 0; i < (STORE_ATTR_TYPE_NUM + 8) / 8; i++, abits++, bbits++) | ||
| 1776 | { | ||
| 1777 | if (*abits && (*bbits & *abits) != *abits) | ||
| 1778 | return 0; | ||
| 1779 | } | ||
| 1780 | return 1; | ||
| 1781 | } | ||
| 1782 | |||
| 1783 | int STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) | ||
| 1784 | { | ||
| 1785 | STORE_ATTR_TYPES i; | ||
| 1786 | |||
| 1787 | if (a == b) return 1; | ||
| 1788 | if (!STORE_ATTR_INFO_in(a, b)) return 0; | ||
| 1789 | for (i = 1; i < STORE_ATTR_TYPE_NUM; i++) | ||
| 1790 | if (ATTR_IS_SET(a, i)) | ||
| 1791 | { | ||
| 1792 | switch(i) | ||
| 1793 | { | ||
| 1794 | case STORE_ATTR_FRIENDLYNAME: | ||
| 1795 | case STORE_ATTR_EMAIL: | ||
| 1796 | case STORE_ATTR_FILENAME: | ||
| 1797 | if (strcmp(a->values[i].cstring, | ||
| 1798 | b->values[i].cstring)) | ||
| 1799 | return 0; | ||
| 1800 | break; | ||
| 1801 | case STORE_ATTR_KEYID: | ||
| 1802 | case STORE_ATTR_ISSUERKEYID: | ||
| 1803 | case STORE_ATTR_SUBJECTKEYID: | ||
| 1804 | case STORE_ATTR_ISSUERSERIALHASH: | ||
| 1805 | case STORE_ATTR_CERTHASH: | ||
| 1806 | if (memcmp(a->values[i].sha1string, | ||
| 1807 | b->values[i].sha1string, | ||
| 1808 | a->value_sizes[i])) | ||
| 1809 | return 0; | ||
| 1810 | break; | ||
| 1811 | case STORE_ATTR_ISSUER: | ||
| 1812 | case STORE_ATTR_SUBJECT: | ||
| 1813 | if (X509_NAME_cmp(a->values[i].dn, | ||
| 1814 | b->values[i].dn)) | ||
| 1815 | return 0; | ||
| 1816 | break; | ||
| 1817 | case STORE_ATTR_SERIAL: | ||
| 1818 | if (BN_cmp(a->values[i].number, | ||
| 1819 | b->values[i].number)) | ||
| 1820 | return 0; | ||
| 1821 | break; | ||
| 1822 | default: | ||
| 1823 | break; | ||
| 1824 | } | ||
| 1825 | } | ||
| 1826 | |||
| 1827 | return 1; | ||
| 1828 | } | ||
diff --git a/src/lib/libcrypto/store/str_locl.h b/src/lib/libcrypto/store/str_locl.h new file mode 100644 index 0000000000..3f8cb75619 --- /dev/null +++ b/src/lib/libcrypto/store/str_locl.h  | |||
| @@ -0,0 +1,124 @@ | |||
| 1 | /* crypto/store/str_locl.h -*- mode:C; c-file-style: "eay" -*- */ | ||
| 2 | /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL | ||
| 3 | * project 2003. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 2003 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 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 | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 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/)" | ||
| 24 | * | ||
| 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. | ||
| 29 | * | ||
| 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. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
| 38 | * | ||
| 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 | * ==================================================================== | ||
| 52 | * | ||
| 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). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef HEADER_STORE_LOCL_H | ||
| 60 | #define HEADER_STORE_LOCL_H | ||
| 61 | |||
| 62 | #include <openssl/crypto.h> | ||
| 63 | #include <openssl/store.h> | ||
| 64 | |||
| 65 | #ifdef __cplusplus | ||
| 66 | extern "C" { | ||
| 67 | #endif | ||
| 68 | |||
| 69 | struct store_method_st | ||
| 70 | { | ||
| 71 | char *name; | ||
| 72 | |||
| 73 | /* All the functions return a positive integer or non-NULL for success | ||
| 74 | and 0, a negative integer or NULL for failure */ | ||
| 75 | |||
| 76 | /* Initialise the STORE with private data */ | ||
| 77 | STORE_INITIALISE_FUNC_PTR init; | ||
| 78 | /* Initialise the STORE with private data */ | ||
| 79 | STORE_CLEANUP_FUNC_PTR clean; | ||
| 80 | /* Generate an object of a given type */ | ||
| 81 | STORE_GENERATE_OBJECT_FUNC_PTR generate_object; | ||
| 82 | /* Get an object of a given type. This function isn't really very | ||
| 83 | useful since the listing functions (below) can be used for the | ||
| 84 | same purpose and are much more general. */ | ||
| 85 | STORE_GET_OBJECT_FUNC_PTR get_object; | ||
| 86 | /* Store an object of a given type. */ | ||
| 87 | STORE_STORE_OBJECT_FUNC_PTR store_object; | ||
| 88 | /* Modify the attributes bound to an object of a given type. */ | ||
| 89 | STORE_MODIFY_OBJECT_FUNC_PTR modify_object; | ||
| 90 | /* Revoke an object of a given type. */ | ||
| 91 | STORE_HANDLE_OBJECT_FUNC_PTR revoke_object; | ||
| 92 | /* Delete an object of a given type. */ | ||
| 93 | STORE_HANDLE_OBJECT_FUNC_PTR delete_object; | ||
| 94 | /* List a bunch of objects of a given type and with the associated | ||
| 95 | attributes. */ | ||
| 96 | STORE_START_OBJECT_FUNC_PTR list_object_start; | ||
| 97 | STORE_NEXT_OBJECT_FUNC_PTR list_object_next; | ||
| 98 | STORE_END_OBJECT_FUNC_PTR list_object_end; | ||
| 99 | STORE_END_OBJECT_FUNC_PTR list_object_endp; | ||
| 100 | /* Store-level function to make any necessary update operations. */ | ||
| 101 | STORE_GENERIC_FUNC_PTR update_store; | ||
| 102 | /* Store-level function to get exclusive access to the store. */ | ||
| 103 | STORE_GENERIC_FUNC_PTR lock_store; | ||
| 104 | /* Store-level function to release exclusive access to the store. */ | ||
| 105 | STORE_GENERIC_FUNC_PTR unlock_store; | ||
| 106 | |||
| 107 | /* Generic control function */ | ||
| 108 | STORE_CTRL_FUNC_PTR ctrl; | ||
| 109 | }; | ||
| 110 | |||
| 111 | struct store_st | ||
| 112 | { | ||
| 113 | const STORE_METHOD *meth; | ||
| 114 | /* functional reference if 'meth' is ENGINE-provided */ | ||
| 115 | ENGINE *engine; | ||
| 116 | |||
| 117 | CRYPTO_EX_DATA ex_data; | ||
| 118 | int references; | ||
| 119 | }; | ||
| 120 | #ifdef __cplusplus | ||
| 121 | } | ||
| 122 | #endif | ||
| 123 | |||
| 124 | #endif | ||
diff --git a/src/lib/libcrypto/store/str_mem.c b/src/lib/libcrypto/store/str_mem.c new file mode 100644 index 0000000000..8ac4f7e55c --- /dev/null +++ b/src/lib/libcrypto/store/str_mem.c  | |||
| @@ -0,0 +1,365 @@ | |||
| 1 | /* crypto/store/str_mem.c -*- mode:C; c-file-style: "eay" -*- */ | ||
| 2 | /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL | ||
| 3 | * project 2003. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 2003 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 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 | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 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/)" | ||
| 24 | * | ||
| 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. | ||
| 29 | * | ||
| 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. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
| 38 | * | ||
| 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 | * ==================================================================== | ||
| 52 | * | ||
| 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). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <string.h> | ||
| 60 | #include <openssl/err.h> | ||
| 61 | #include "str_locl.h" | ||
| 62 | |||
| 63 | /* The memory store is currently highly experimental. It's meant to become | ||
| 64 | a base store used by other stores for internal caching (for full caching | ||
| 65 | support, aging needs to be added). | ||
| 66 | |||
| 67 | The database use is meant to support as much attribute association as | ||
| 68 | possible, while providing for as small search ranges as possible. | ||
| 69 | This is currently provided for by sorting the entries by numbers that | ||
| 70 | are composed of bits set at the positions indicated by attribute type | ||
| 71 | codes. This provides for ranges determined by the highest attribute | ||
| 72 | type code value. A better idea might be to sort by values computed | ||
| 73 | from the range of attributes associated with the object (basically, | ||
| 74 | the difference between the highest and lowest attribute type code) | ||
| 75 | and it's distance from a base (basically, the lowest associated | ||
| 76 | attribute type code). | ||
| 77 | */ | ||
| 78 | |||
| 79 | typedef struct mem_object_data_st | ||
| 80 | { | ||
| 81 | STORE_OBJECT *object; | ||
| 82 | STORE_ATTR_INFO *attr_info; | ||
| 83 | int references; | ||
| 84 | } MEM_OBJECT_DATA; | ||
| 85 | |||
| 86 | DECLARE_STACK_OF(MEM_OBJECT_DATA) | ||
| 87 | struct mem_data_st | ||
| 88 | { | ||
| 89 | STACK_OF(MEM_OBJECT_DATA) *data; /* sorted with | ||
| 90 | * STORE_ATTR_INFO_compare(). */ | ||
| 91 | unsigned int compute_components : 1; /* Currently unused, but can | ||
| 92 | be used to add attributes | ||
| 93 | from parts of the data. */ | ||
| 94 | }; | ||
| 95 | |||
| 96 | DECLARE_STACK_OF(STORE_ATTR_INFO) | ||
| 97 | struct mem_ctx_st | ||
| 98 | { | ||
| 99 | int type; /* The type we're searching for */ | ||
| 100 | STACK_OF(STORE_ATTR_INFO) *search_attributes; /* Sets of | ||
| 101 | attributes to search for. Each | ||
| 102 | element is a STORE_ATTR_INFO. */ | ||
| 103 | int search_index; /* which of the search attributes we | ||
| 104 | found a match for, -1 when we still | ||
| 105 | haven't found any */ | ||
| 106 | int index; /* -1 as long as we're searching for | ||
| 107 | the first */ | ||
| 108 | }; | ||
| 109 | |||
| 110 | static int mem_init(STORE *s); | ||
| 111 | static void mem_clean(STORE *s); | ||
| 112 | static STORE_OBJECT *mem_generate(STORE *s, STORE_OBJECT_TYPES type, | ||
| 113 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | ||
| 114 | static STORE_OBJECT *mem_get(STORE *s, STORE_OBJECT_TYPES type, | ||
| 115 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | ||
| 116 | static int mem_store(STORE *s, STORE_OBJECT_TYPES type, | ||
| 117 | STORE_OBJECT *data, OPENSSL_ITEM attributes[], | ||
| 118 | OPENSSL_ITEM parameters[]); | ||
| 119 | static int mem_modify(STORE *s, STORE_OBJECT_TYPES type, | ||
| 120 | OPENSSL_ITEM search_attributes[], OPENSSL_ITEM add_attributes[], | ||
| 121 | OPENSSL_ITEM modify_attributes[], OPENSSL_ITEM delete_attributes[], | ||
| 122 | OPENSSL_ITEM parameters[]); | ||
| 123 | static int mem_delete(STORE *s, STORE_OBJECT_TYPES type, | ||
| 124 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | ||
| 125 | static void *mem_list_start(STORE *s, STORE_OBJECT_TYPES type, | ||
| 126 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | ||
| 127 | static STORE_OBJECT *mem_list_next(STORE *s, void *handle); | ||
| 128 | static int mem_list_end(STORE *s, void *handle); | ||
| 129 | static int mem_list_endp(STORE *s, void *handle); | ||
| 130 | static int mem_lock(STORE *s, OPENSSL_ITEM attributes[], | ||
| 131 | OPENSSL_ITEM parameters[]); | ||
| 132 | static int mem_unlock(STORE *s, OPENSSL_ITEM attributes[], | ||
| 133 | OPENSSL_ITEM parameters[]); | ||
| 134 | static int mem_ctrl(STORE *s, int cmd, long l, void *p, void (*f)(void)); | ||
| 135 | |||
| 136 | static STORE_METHOD store_memory = | ||
| 137 | { | ||
| 138 | "OpenSSL memory store interface", | ||
| 139 | mem_init, | ||
| 140 | mem_clean, | ||
| 141 | mem_generate, | ||
| 142 | mem_get, | ||
| 143 | mem_store, | ||
| 144 | mem_modify, | ||
| 145 | NULL, /* revoke */ | ||
| 146 | mem_delete, | ||
| 147 | mem_list_start, | ||
| 148 | mem_list_next, | ||
| 149 | mem_list_end, | ||
| 150 | mem_list_endp, | ||
| 151 | NULL, /* update */ | ||
| 152 | mem_lock, | ||
| 153 | mem_unlock, | ||
| 154 | mem_ctrl | ||
| 155 | }; | ||
| 156 | |||
| 157 | const STORE_METHOD *STORE_Memory(void) | ||
| 158 | { | ||
| 159 | return &store_memory; | ||
| 160 | } | ||
| 161 | |||
| 162 | static int mem_init(STORE *s) | ||
| 163 | { | ||
| 164 | return 1; | ||
| 165 | } | ||
| 166 | |||
| 167 | static void mem_clean(STORE *s) | ||
| 168 | { | ||
| 169 | return; | ||
| 170 | } | ||
| 171 | |||
| 172 | static STORE_OBJECT *mem_generate(STORE *s, STORE_OBJECT_TYPES type, | ||
| 173 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]) | ||
| 174 | { | ||
| 175 | STOREerr(STORE_F_MEM_GENERATE, STORE_R_NOT_IMPLEMENTED); | ||
| 176 | return 0; | ||
| 177 | } | ||
| 178 | static STORE_OBJECT *mem_get(STORE *s, STORE_OBJECT_TYPES type, | ||
| 179 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]) | ||
| 180 | { | ||
| 181 | void *context = mem_list_start(s, type, attributes, parameters); | ||
| 182 | |||
| 183 | if (context) | ||
| 184 | { | ||
| 185 | STORE_OBJECT *object = mem_list_next(s, context); | ||
| 186 | |||
| 187 | if (mem_list_end(s, context)) | ||
| 188 | return object; | ||
| 189 | } | ||
| 190 | return NULL; | ||
| 191 | } | ||
| 192 | static int mem_store(STORE *s, STORE_OBJECT_TYPES type, | ||
| 193 | STORE_OBJECT *data, OPENSSL_ITEM attributes[], | ||
| 194 | OPENSSL_ITEM parameters[]) | ||
| 195 | { | ||
| 196 | STOREerr(STORE_F_MEM_STORE, STORE_R_NOT_IMPLEMENTED); | ||
| 197 | return 0; | ||
| 198 | } | ||
| 199 | static int mem_modify(STORE *s, STORE_OBJECT_TYPES type, | ||
| 200 | OPENSSL_ITEM search_attributes[], OPENSSL_ITEM add_attributes[], | ||
| 201 | OPENSSL_ITEM modify_attributes[], OPENSSL_ITEM delete_attributes[], | ||
| 202 | OPENSSL_ITEM parameters[]) | ||
| 203 | { | ||
| 204 | STOREerr(STORE_F_MEM_MODIFY, STORE_R_NOT_IMPLEMENTED); | ||
| 205 | return 0; | ||
| 206 | } | ||
| 207 | static int mem_delete(STORE *s, STORE_OBJECT_TYPES type, | ||
| 208 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]) | ||
| 209 | { | ||
| 210 | STOREerr(STORE_F_MEM_DELETE, STORE_R_NOT_IMPLEMENTED); | ||
| 211 | return 0; | ||
| 212 | } | ||
| 213 | |||
| 214 | /* The list functions may be the hardest to understand. Basically, | ||
| 215 | mem_list_start compiles a stack of attribute info elements, and | ||
| 216 | puts that stack into the context to be returned. mem_list_next | ||
| 217 | will then find the first matching element in the store, and then | ||
| 218 | walk all the way to the end of the store (since any combination | ||
| 219 | of attribute bits above the starting point may match the searched | ||
| 220 | for bit pattern...). */ | ||
| 221 | static void *mem_list_start(STORE *s, STORE_OBJECT_TYPES type, | ||
| 222 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]) | ||
| 223 | { | ||
| 224 | struct mem_ctx_st *context = | ||
| 225 | (struct mem_ctx_st *)OPENSSL_malloc(sizeof(struct mem_ctx_st)); | ||
| 226 | void *attribute_context = NULL; | ||
| 227 | STORE_ATTR_INFO *attrs = NULL; | ||
| 228 | |||
| 229 | if (!context) | ||
| 230 | { | ||
| 231 | STOREerr(STORE_F_MEM_LIST_START, ERR_R_MALLOC_FAILURE); | ||
| 232 | return 0; | ||
| 233 | } | ||
| 234 | memset(context, 0, sizeof(struct mem_ctx_st)); | ||
| 235 | |||
| 236 | attribute_context = STORE_parse_attrs_start(attributes); | ||
| 237 | if (!attribute_context) | ||
| 238 | { | ||
| 239 | STOREerr(STORE_F_MEM_LIST_START, ERR_R_STORE_LIB); | ||
| 240 | goto err; | ||
| 241 | } | ||
| 242 | |||
| 243 | while((attrs = STORE_parse_attrs_next(attribute_context))) | ||
| 244 | { | ||
| 245 | if (context->search_attributes == NULL) | ||
| 246 | { | ||
| 247 | context->search_attributes = | ||
| 248 | sk_STORE_ATTR_INFO_new(STORE_ATTR_INFO_compare); | ||
| 249 | if (!context->search_attributes) | ||
| 250 | { | ||
| 251 | STOREerr(STORE_F_MEM_LIST_START, | ||
| 252 | ERR_R_MALLOC_FAILURE); | ||
| 253 | goto err; | ||
| 254 | } | ||
| 255 | } | ||
| 256 | sk_STORE_ATTR_INFO_push(context->search_attributes,attrs); | ||
| 257 | } | ||
| 258 | if (!STORE_parse_attrs_endp(attribute_context)) | ||
| 259 | goto err; | ||
| 260 | STORE_parse_attrs_end(attribute_context); | ||
| 261 | context->search_index = -1; | ||
| 262 | context->index = -1; | ||
| 263 | return context; | ||
| 264 | err: | ||
| 265 | if (attribute_context) STORE_parse_attrs_end(attribute_context); | ||
| 266 | mem_list_end(s, context); | ||
| 267 | return NULL; | ||
| 268 | } | ||
| 269 | static STORE_OBJECT *mem_list_next(STORE *s, void *handle) | ||
| 270 | { | ||
| 271 | int i; | ||
| 272 | struct mem_ctx_st *context = (struct mem_ctx_st *)handle; | ||
| 273 | struct mem_object_data_st key = { 0, 0, 1 }; | ||
| 274 | struct mem_data_st *store = | ||
| 275 | (struct mem_data_st *)STORE_get_ex_data(s, 1); | ||
| 276 | int srch; | ||
| 277 | int cres = 0; | ||
| 278 | |||
| 279 | if (!context) | ||
| 280 | { | ||
| 281 | STOREerr(STORE_F_MEM_LIST_NEXT, ERR_R_PASSED_NULL_PARAMETER); | ||
| 282 | return NULL; | ||
| 283 | } | ||
| 284 | if (!store) | ||
| 285 | { | ||
| 286 | STOREerr(STORE_F_MEM_LIST_NEXT, STORE_R_NO_STORE); | ||
| 287 | return NULL; | ||
| 288 | } | ||
| 289 | |||
| 290 | if (context->search_index == -1) | ||
| 291 | { | ||
| 292 | for (i = 0; | ||
| 293 | i < sk_STORE_ATTR_INFO_num(context->search_attributes); | ||
| 294 | i++) | ||
| 295 | { | ||
| 296 | key.attr_info | ||
| 297 | = sk_STORE_ATTR_INFO_value(context->search_attributes, | ||
| 298 | i); | ||
| 299 | srch = sk_MEM_OBJECT_DATA_find_ex(store->data, &key); | ||
| 300 | |||
| 301 | if (srch >= 0) | ||
| 302 | { | ||
| 303 | context->search_index = srch; | ||
| 304 | break; | ||
| 305 | } | ||
| 306 | } | ||
| 307 | } | ||
| 308 | if (context->search_index < 0) | ||
| 309 | return NULL; | ||
| 310 | |||
| 311 | key.attr_info = | ||
| 312 | sk_STORE_ATTR_INFO_value(context->search_attributes, | ||
| 313 | context->search_index); | ||
| 314 | for(srch = context->search_index; | ||
| 315 | srch < sk_MEM_OBJECT_DATA_num(store->data) | ||
| 316 | && STORE_ATTR_INFO_in_range(key.attr_info, | ||
| 317 | sk_MEM_OBJECT_DATA_value(store->data, srch)->attr_info) | ||
| 318 | && !(cres = STORE_ATTR_INFO_in_ex(key.attr_info, | ||
| 319 | sk_MEM_OBJECT_DATA_value(store->data, srch)->attr_info)); | ||
| 320 | srch++) | ||
| 321 | ; | ||
| 322 | |||
| 323 | context->search_index = srch; | ||
| 324 | if (cres) | ||
| 325 | return (sk_MEM_OBJECT_DATA_value(store->data, srch))->object; | ||
| 326 | return NULL; | ||
| 327 | } | ||
| 328 | static int mem_list_end(STORE *s, void *handle) | ||
| 329 | { | ||
| 330 | struct mem_ctx_st *context = (struct mem_ctx_st *)handle; | ||
| 331 | |||
| 332 | if (!context) | ||
| 333 | { | ||
| 334 | STOREerr(STORE_F_MEM_LIST_END, ERR_R_PASSED_NULL_PARAMETER); | ||
| 335 | return 0; | ||
| 336 | } | ||
| 337 | if (context && context->search_attributes) | ||
| 338 | sk_STORE_ATTR_INFO_free(context->search_attributes); | ||
| 339 | if (context) OPENSSL_free(context); | ||
| 340 | return 1; | ||
| 341 | } | ||
| 342 | static int mem_list_endp(STORE *s, void *handle) | ||
| 343 | { | ||
| 344 | struct mem_ctx_st *context = (struct mem_ctx_st *)handle; | ||
| 345 | |||
| 346 | if (!context | ||
| 347 | || context->search_index | ||
| 348 | == sk_STORE_ATTR_INFO_num(context->search_attributes)) | ||
| 349 | return 1; | ||
| 350 | return 0; | ||
| 351 | } | ||
| 352 | static int mem_lock(STORE *s, OPENSSL_ITEM attributes[], | ||
| 353 | OPENSSL_ITEM parameters[]) | ||
| 354 | { | ||
| 355 | return 1; | ||
| 356 | } | ||
| 357 | static int mem_unlock(STORE *s, OPENSSL_ITEM attributes[], | ||
| 358 | OPENSSL_ITEM parameters[]) | ||
| 359 | { | ||
| 360 | return 1; | ||
| 361 | } | ||
| 362 | static int mem_ctrl(STORE *s, int cmd, long l, void *p, void (*f)(void)) | ||
| 363 | { | ||
| 364 | return 1; | ||
| 365 | } | ||
diff --git a/src/lib/libcrypto/store/str_meth.c b/src/lib/libcrypto/store/str_meth.c new file mode 100644 index 0000000000..a46de03a26 --- /dev/null +++ b/src/lib/libcrypto/store/str_meth.c  | |||
| @@ -0,0 +1,250 @@ | |||
| 1 | /* crypto/store/str_meth.c -*- mode:C; c-file-style: "eay" -*- */ | ||
| 2 | /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL | ||
| 3 | * project 2003. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 2003 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 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 | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 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/)" | ||
| 24 | * | ||
| 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. | ||
| 29 | * | ||
| 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. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
| 38 | * | ||
| 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 | * ==================================================================== | ||
| 52 | * | ||
| 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). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <string.h> | ||
| 60 | #include <openssl/buffer.h> | ||
| 61 | #include "str_locl.h" | ||
| 62 | |||
| 63 | STORE_METHOD *STORE_create_method(char *name) | ||
| 64 | { | ||
| 65 | STORE_METHOD *store_method = (STORE_METHOD *)OPENSSL_malloc(sizeof(STORE_METHOD)); | ||
| 66 | |||
| 67 | if (store_method) | ||
| 68 | { | ||
| 69 | memset(store_method, 0, sizeof(*store_method)); | ||
| 70 | store_method->name = BUF_strdup(name); | ||
| 71 | } | ||
| 72 | return store_method; | ||
| 73 | } | ||
| 74 | |||
| 75 | /* BIG FSCKING WARNING!!!! If you use this on a statically allocated method | ||
| 76 | (that is, it hasn't been allocated using STORE_create_method(), you deserve | ||
| 77 | anything Murphy can throw at you and more! You have been warned. */ | ||
| 78 | void STORE_destroy_method(STORE_METHOD *store_method) | ||
| 79 | { | ||
| 80 | if (!store_method) return; | ||
| 81 | OPENSSL_free(store_method->name); | ||
| 82 | store_method->name = NULL; | ||
| 83 | OPENSSL_free(store_method); | ||
| 84 | } | ||
| 85 | |||
| 86 | int STORE_method_set_initialise_function(STORE_METHOD *sm, STORE_INITIALISE_FUNC_PTR init_f) | ||
| 87 | { | ||
| 88 | sm->init = init_f; | ||
| 89 | return 1; | ||
| 90 | } | ||
| 91 | |||
| 92 | int STORE_method_set_cleanup_function(STORE_METHOD *sm, STORE_CLEANUP_FUNC_PTR clean_f) | ||
| 93 | { | ||
| 94 | sm->clean = clean_f; | ||
| 95 | return 1; | ||
| 96 | } | ||
| 97 | |||
| 98 | int STORE_method_set_generate_function(STORE_METHOD *sm, STORE_GENERATE_OBJECT_FUNC_PTR generate_f) | ||
| 99 | { | ||
| 100 | sm->generate_object = generate_f; | ||
| 101 | return 1; | ||
| 102 | } | ||
| 103 | |||
| 104 | int STORE_method_set_get_function(STORE_METHOD *sm, STORE_GET_OBJECT_FUNC_PTR get_f) | ||
| 105 | { | ||
| 106 | sm->get_object = get_f; | ||
| 107 | return 1; | ||
| 108 | } | ||
| 109 | |||
| 110 | int STORE_method_set_store_function(STORE_METHOD *sm, STORE_STORE_OBJECT_FUNC_PTR store_f) | ||
| 111 | { | ||
| 112 | sm->store_object = store_f; | ||
| 113 | return 1; | ||
| 114 | } | ||
| 115 | |||
| 116 | int STORE_method_set_modify_function(STORE_METHOD *sm, STORE_MODIFY_OBJECT_FUNC_PTR modify_f) | ||
| 117 | { | ||
| 118 | sm->modify_object = modify_f; | ||
| 119 | return 1; | ||
| 120 | } | ||
| 121 | |||
| 122 | int STORE_method_set_revoke_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR revoke_f) | ||
| 123 | { | ||
| 124 | sm->revoke_object = revoke_f; | ||
| 125 | return 1; | ||
| 126 | } | ||
| 127 | |||
| 128 | int STORE_method_set_delete_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR delete_f) | ||
| 129 | { | ||
| 130 | sm->delete_object = delete_f; | ||
| 131 | return 1; | ||
| 132 | } | ||
| 133 | |||
| 134 | int STORE_method_set_list_start_function(STORE_METHOD *sm, STORE_START_OBJECT_FUNC_PTR list_start_f) | ||
| 135 | { | ||
| 136 | sm->list_object_start = list_start_f; | ||
| 137 | return 1; | ||
| 138 | } | ||
| 139 | |||
| 140 | int STORE_method_set_list_next_function(STORE_METHOD *sm, STORE_NEXT_OBJECT_FUNC_PTR list_next_f) | ||
| 141 | { | ||
| 142 | sm->list_object_next = list_next_f; | ||
| 143 | return 1; | ||
| 144 | } | ||
| 145 | |||
| 146 | int STORE_method_set_list_end_function(STORE_METHOD *sm, STORE_END_OBJECT_FUNC_PTR list_end_f) | ||
| 147 | { | ||
| 148 | sm->list_object_end = list_end_f; | ||
| 149 | return 1; | ||
| 150 | } | ||
| 151 | |||
| 152 | int STORE_method_set_update_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR update_f) | ||
| 153 | { | ||
| 154 | sm->update_store = update_f; | ||
| 155 | return 1; | ||
| 156 | } | ||
| 157 | |||
| 158 | int STORE_method_set_lock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR lock_f) | ||
| 159 | { | ||
| 160 | sm->lock_store = lock_f; | ||
| 161 | return 1; | ||
| 162 | } | ||
| 163 | |||
| 164 | int STORE_method_set_unlock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR unlock_f) | ||
| 165 | { | ||
| 166 | sm->unlock_store = unlock_f; | ||
| 167 | return 1; | ||
| 168 | } | ||
| 169 | |||
| 170 | int STORE_method_set_ctrl_function(STORE_METHOD *sm, STORE_CTRL_FUNC_PTR ctrl_f) | ||
| 171 | { | ||
| 172 | sm->ctrl = ctrl_f; | ||
| 173 | return 1; | ||
| 174 | } | ||
| 175 | |||
| 176 | STORE_INITIALISE_FUNC_PTR STORE_method_get_initialise_function(STORE_METHOD *sm) | ||
| 177 | { | ||
| 178 | return sm->init; | ||
| 179 | } | ||
| 180 | |||
| 181 | STORE_CLEANUP_FUNC_PTR STORE_method_get_cleanup_function(STORE_METHOD *sm) | ||
| 182 | { | ||
| 183 | return sm->clean; | ||
| 184 | } | ||
| 185 | |||
| 186 | STORE_GENERATE_OBJECT_FUNC_PTR STORE_method_get_generate_function(STORE_METHOD *sm) | ||
| 187 | { | ||
| 188 | return sm->generate_object; | ||
| 189 | } | ||
| 190 | |||
| 191 | STORE_GET_OBJECT_FUNC_PTR STORE_method_get_get_function(STORE_METHOD *sm) | ||
| 192 | { | ||
| 193 | return sm->get_object; | ||
| 194 | } | ||
| 195 | |||
| 196 | STORE_STORE_OBJECT_FUNC_PTR STORE_method_get_store_function(STORE_METHOD *sm) | ||
| 197 | { | ||
| 198 | return sm->store_object; | ||
| 199 | } | ||
| 200 | |||
| 201 | STORE_MODIFY_OBJECT_FUNC_PTR STORE_method_get_modify_function(STORE_METHOD *sm) | ||
| 202 | { | ||
| 203 | return sm->modify_object; | ||
| 204 | } | ||
| 205 | |||
| 206 | STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_revoke_function(STORE_METHOD *sm) | ||
| 207 | { | ||
| 208 | return sm->revoke_object; | ||
| 209 | } | ||
| 210 | |||
| 211 | STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_delete_function(STORE_METHOD *sm) | ||
| 212 | { | ||
| 213 | return sm->delete_object; | ||
| 214 | } | ||
| 215 | |||
| 216 | STORE_START_OBJECT_FUNC_PTR STORE_method_get_list_start_function(STORE_METHOD *sm) | ||
| 217 | { | ||
| 218 | return sm->list_object_start; | ||
| 219 | } | ||
| 220 | |||
| 221 | STORE_NEXT_OBJECT_FUNC_PTR STORE_method_get_list_next_function(STORE_METHOD *sm) | ||
| 222 | { | ||
| 223 | return sm->list_object_next; | ||
| 224 | } | ||
| 225 | |||
| 226 | STORE_END_OBJECT_FUNC_PTR STORE_method_get_list_end_function(STORE_METHOD *sm) | ||
| 227 | { | ||
| 228 | return sm->list_object_end; | ||
| 229 | } | ||
| 230 | |||
| 231 | STORE_GENERIC_FUNC_PTR STORE_method_get_update_store_function(STORE_METHOD *sm) | ||
| 232 | { | ||
| 233 | return sm->update_store; | ||
| 234 | } | ||
| 235 | |||
| 236 | STORE_GENERIC_FUNC_PTR STORE_method_get_lock_store_function(STORE_METHOD *sm) | ||
| 237 | { | ||
| 238 | return sm->lock_store; | ||
| 239 | } | ||
| 240 | |||
| 241 | STORE_GENERIC_FUNC_PTR STORE_method_get_unlock_store_function(STORE_METHOD *sm) | ||
| 242 | { | ||
| 243 | return sm->unlock_store; | ||
| 244 | } | ||
| 245 | |||
| 246 | STORE_CTRL_FUNC_PTR STORE_method_get_ctrl_function(STORE_METHOD *sm) | ||
| 247 | { | ||
| 248 | return sm->ctrl; | ||
| 249 | } | ||
| 250 | |||
