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