diff options
| author | jsing <> | 2014-05-26 11:24:48 +0000 |
|---|---|---|
| committer | jsing <> | 2014-05-26 11:24:48 +0000 |
| commit | 1918fecccdef550d51f6267a095575731f873b2b (patch) | |
| tree | f3df1497c7d3c4533bdb1a09664b32b2c989b047 /src | |
| parent | 8ba2fea129dbe500a291768b0aec33a3fd015669 (diff) | |
| download | openbsd-1918fecccdef550d51f6267a095575731f873b2b.tar.gz openbsd-1918fecccdef550d51f6267a095575731f873b2b.tar.bz2 openbsd-1918fecccdef550d51f6267a095575731f873b2b.zip | |
KNF.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/store/store.h | 255 | ||||
| -rw-r--r-- | src/lib/libcrypto/store/str_err.c | 269 | ||||
| -rw-r--r-- | src/lib/libcrypto/store/str_lib.c | 1946 | ||||
| -rw-r--r-- | src/lib/libcrypto/store/str_locl.h | 12 | ||||
| -rw-r--r-- | src/lib/libcrypto/store/str_mem.c | 273 | ||||
| -rw-r--r-- | src/lib/libcrypto/store/str_meth.c | 243 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/store/store.h | 255 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/store/str_err.c | 269 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/store/str_lib.c | 1946 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/store/str_locl.h | 12 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/store/str_mem.c | 273 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/store/str_meth.c | 243 |
12 files changed, 3110 insertions, 2886 deletions
diff --git a/src/lib/libcrypto/store/store.h b/src/lib/libcrypto/store/store.h index 0a28c7d5a2..1a29ca2da5 100644 --- a/src/lib/libcrypto/store/store.h +++ b/src/lib/libcrypto/store/store.h | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | * are met: | 10 | * are met: |
| 11 | * | 11 | * |
| 12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * | 14 | * |
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
| @@ -113,8 +113,8 @@ int STORE_ctrl(STORE *store, int cmd, long i, void *p, void (*f)(void)); | |||
| 113 | #define STORE_set_app_data(s,arg) STORE_set_ex_data(s,0,arg) | 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) | 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, | 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); | 116 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); |
| 117 | int STORE_set_ex_data(STORE *r,int idx,void *arg); | 117 | int STORE_set_ex_data(STORE *r, int idx, void *arg); |
| 118 | void *STORE_get_ex_data(STORE *r, int idx); | 118 | void *STORE_get_ex_data(STORE *r, int idx); |
| 119 | 119 | ||
| 120 | /* Use specific methods instead of the built-in one */ | 120 | /* Use specific methods instead of the built-in one */ |
| @@ -138,8 +138,7 @@ const STORE_METHOD *STORE_File(void); | |||
| 138 | 138 | ||
| 139 | /* Store functions take a type code for the type of data they should store | 139 | /* Store functions take a type code for the type of data they should store |
| 140 | or fetch */ | 140 | or fetch */ |
| 141 | typedef enum STORE_object_types | 141 | typedef enum STORE_object_types { |
| 142 | { | ||
| 143 | STORE_OBJECT_TYPE_X509_CERTIFICATE= 0x01, /* X509 * */ | 142 | STORE_OBJECT_TYPE_X509_CERTIFICATE= 0x01, /* X509 * */ |
| 144 | STORE_OBJECT_TYPE_X509_CRL= 0x02, /* X509_CRL * */ | 143 | STORE_OBJECT_TYPE_X509_CRL= 0x02, /* X509_CRL * */ |
| 145 | STORE_OBJECT_TYPE_PRIVATE_KEY= 0x03, /* EVP_PKEY * */ | 144 | STORE_OBJECT_TYPE_PRIVATE_KEY= 0x03, /* EVP_PKEY * */ |
| @@ -148,15 +147,14 @@ typedef enum STORE_object_types | |||
| 148 | STORE_OBJECT_TYPE_ARBITRARY= 0x06, /* BUF_MEM * */ | 147 | STORE_OBJECT_TYPE_ARBITRARY= 0x06, /* BUF_MEM * */ |
| 149 | STORE_OBJECT_TYPE_NUM= 0x06 /* The amount of known | 148 | STORE_OBJECT_TYPE_NUM= 0x06 /* The amount of known |
| 150 | object types */ | 149 | object types */ |
| 151 | } STORE_OBJECT_TYPES; | 150 | } STORE_OBJECT_TYPES; |
| 152 | /* List of text strings corresponding to the object types. */ | 151 | /* List of text strings corresponding to the object types. */ |
| 153 | extern const char * const STORE_object_type_string[STORE_OBJECT_TYPE_NUM+1]; | 152 | extern const char * const STORE_object_type_string[STORE_OBJECT_TYPE_NUM + 1]; |
| 154 | 153 | ||
| 155 | /* Some store functions take a parameter list. Those parameters come with | 154 | /* Some store functions take a parameter list. Those parameters come with |
| 156 | one of the following codes. The comments following the codes below indicate | 155 | one of the following codes. The comments following the codes below indicate |
| 157 | what type the value should be a pointer to. */ | 156 | what type the value should be a pointer to. */ |
| 158 | typedef enum STORE_params | 157 | typedef enum STORE_params { |
| 159 | { | ||
| 160 | STORE_PARAM_EVP_TYPE= 0x01, /* int */ | 158 | STORE_PARAM_EVP_TYPE= 0x01, /* int */ |
| 161 | STORE_PARAM_BITS= 0x02, /* size_t */ | 159 | STORE_PARAM_BITS= 0x02, /* size_t */ |
| 162 | STORE_PARAM_KEY_PARAMETERS= 0x03, /* ??? */ | 160 | STORE_PARAM_KEY_PARAMETERS= 0x03, /* ??? */ |
| @@ -165,16 +163,15 @@ typedef enum STORE_params | |||
| 165 | STORE_PARAM_AUTH_KRB5_TICKET= 0x06, /* void * */ | 163 | STORE_PARAM_AUTH_KRB5_TICKET= 0x06, /* void * */ |
| 166 | STORE_PARAM_TYPE_NUM= 0x06 /* The amount of known | 164 | STORE_PARAM_TYPE_NUM= 0x06 /* The amount of known |
| 167 | parameter types */ | 165 | parameter types */ |
| 168 | } STORE_PARAM_TYPES; | 166 | } STORE_PARAM_TYPES; |
| 169 | /* Parameter value sizes. -1 means unknown, anything else is the required size. */ | 167 | /* Parameter value sizes. -1 means unknown, anything else is the required size. */ |
| 170 | extern const int STORE_param_sizes[STORE_PARAM_TYPE_NUM+1]; | 168 | extern const int STORE_param_sizes[STORE_PARAM_TYPE_NUM + 1]; |
| 171 | 169 | ||
| 172 | /* Store functions take attribute lists. Those attributes come with codes. | 170 | /* Store functions take attribute lists. Those attributes come with codes. |
| 173 | The comments following the codes below indicate what type the value should | 171 | The comments following the codes below indicate what type the value should |
| 174 | be a pointer to. */ | 172 | be a pointer to. */ |
| 175 | typedef enum STORE_attribs | 173 | typedef enum STORE_attribs { |
| 176 | { | 174 | STORE_ATTR_END = 0x00, |
| 177 | STORE_ATTR_END= 0x00, | ||
| 178 | STORE_ATTR_FRIENDLYNAME= 0x01, /* C string */ | 175 | STORE_ATTR_FRIENDLYNAME= 0x01, /* C string */ |
| 179 | STORE_ATTR_KEYID= 0x02, /* 160 bit string (SHA1) */ | 176 | STORE_ATTR_KEYID= 0x02, /* 160 bit string (SHA1) */ |
| 180 | STORE_ATTR_ISSUERKEYID= 0x03, /* 160 bit string (SHA1) */ | 177 | STORE_ATTR_ISSUERKEYID= 0x03, /* 160 bit string (SHA1) */ |
| @@ -192,132 +189,129 @@ typedef enum STORE_attribs | |||
| 192 | separator, which | 189 | separator, which |
| 193 | expresses the OR | 190 | expresses the OR |
| 194 | operation. */ | 191 | operation. */ |
| 195 | } STORE_ATTR_TYPES; | 192 | } STORE_ATTR_TYPES; |
| 193 | |||
| 196 | /* Attribute value sizes. -1 means unknown, anything else is the required size. */ | 194 | /* Attribute value sizes. -1 means unknown, anything else is the required size. */ |
| 197 | extern const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM+1]; | 195 | extern const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM + 1]; |
| 198 | 196 | ||
| 199 | typedef enum STORE_certificate_status | 197 | typedef enum STORE_certificate_status { |
| 200 | { | 198 | STORE_X509_VALID = 0x00, |
| 201 | STORE_X509_VALID= 0x00, | 199 | STORE_X509_EXPIRED = 0x01, |
| 202 | STORE_X509_EXPIRED= 0x01, | 200 | STORE_X509_SUSPENDED = 0x02, |
| 203 | STORE_X509_SUSPENDED= 0x02, | 201 | STORE_X509_REVOKED = 0x03 |
| 204 | STORE_X509_REVOKED= 0x03 | 202 | } STORE_CERTIFICATE_STATUS; |
| 205 | } STORE_CERTIFICATE_STATUS; | ||
| 206 | 203 | ||
| 207 | /* Engine store functions will return a structure that contains all the necessary | 204 | /* Engine store functions will return a structure that contains all the necessary |
| 208 | * information, including revokation status for certificates. This is really not | 205 | * information, including revokation status for certificates. This is really not |
| 209 | * needed for application authors, as the ENGINE framework functions will extract | 206 | * needed for application authors, as the ENGINE framework functions will extract |
| 210 | * the OpenSSL-specific information when at all possible. However, for engine | 207 | * the OpenSSL-specific information when at all possible. However, for engine |
| 211 | * authors, it's crucial to know this structure. */ | 208 | * authors, it's crucial to know this structure. */ |
| 212 | typedef struct STORE_OBJECT_st | 209 | typedef struct STORE_OBJECT_st { |
| 213 | { | ||
| 214 | STORE_OBJECT_TYPES type; | 210 | STORE_OBJECT_TYPES type; |
| 215 | union | 211 | union |
| 216 | { | 212 | { |
| 217 | struct | 213 | struct { |
| 218 | { | ||
| 219 | STORE_CERTIFICATE_STATUS status; | 214 | STORE_CERTIFICATE_STATUS status; |
| 220 | X509 *certificate; | 215 | X509 *certificate; |
| 221 | } x509; | 216 | } x509; |
| 222 | X509_CRL *crl; | 217 | X509_CRL *crl; |
| 223 | EVP_PKEY *key; | 218 | EVP_PKEY *key; |
| 224 | BIGNUM *number; | 219 | BIGNUM *number; |
| 225 | BUF_MEM *arbitrary; | 220 | BUF_MEM *arbitrary; |
| 226 | } data; | 221 | } data; |
| 227 | } STORE_OBJECT; | 222 | } STORE_OBJECT; |
| 223 | |||
| 228 | DECLARE_STACK_OF(STORE_OBJECT) | 224 | DECLARE_STACK_OF(STORE_OBJECT) |
| 229 | STORE_OBJECT *STORE_OBJECT_new(void); | 225 | STORE_OBJECT *STORE_OBJECT_new(void); |
| 230 | void STORE_OBJECT_free(STORE_OBJECT *data); | 226 | void STORE_OBJECT_free(STORE_OBJECT *data); |
| 231 | 227 | ||
| 232 | 228 | ||
| 233 | |||
| 234 | /* The following functions handle the storage. They return 0, a negative number | 229 | /* The following functions handle the storage. They return 0, a negative number |
| 235 | or NULL on error, anything else on success. */ | 230 | or NULL on error, anything else on success. */ |
| 236 | X509 *STORE_get_certificate(STORE *e, OPENSSL_ITEM attributes[], | 231 | X509 *STORE_get_certificate(STORE *e, OPENSSL_ITEM attributes[], |
| 237 | OPENSSL_ITEM parameters[]); | 232 | OPENSSL_ITEM parameters[]); |
| 238 | int STORE_store_certificate(STORE *e, X509 *data, OPENSSL_ITEM attributes[], | 233 | int STORE_store_certificate(STORE *e, X509 *data, OPENSSL_ITEM attributes[], |
| 239 | OPENSSL_ITEM parameters[]); | 234 | OPENSSL_ITEM parameters[]); |
| 240 | int STORE_modify_certificate(STORE *e, OPENSSL_ITEM search_attributes[], | 235 | int STORE_modify_certificate(STORE *e, OPENSSL_ITEM search_attributes[], |
| 241 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | 236 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], |
| 242 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); | 237 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); |
| 243 | int STORE_revoke_certificate(STORE *e, OPENSSL_ITEM attributes[], | 238 | int STORE_revoke_certificate(STORE *e, OPENSSL_ITEM attributes[], |
| 244 | OPENSSL_ITEM parameters[]); | 239 | OPENSSL_ITEM parameters[]); |
| 245 | int STORE_delete_certificate(STORE *e, OPENSSL_ITEM attributes[], | 240 | int STORE_delete_certificate(STORE *e, OPENSSL_ITEM attributes[], |
| 246 | OPENSSL_ITEM parameters[]); | 241 | OPENSSL_ITEM parameters[]); |
| 247 | void *STORE_list_certificate_start(STORE *e, OPENSSL_ITEM attributes[], | 242 | void *STORE_list_certificate_start(STORE *e, OPENSSL_ITEM attributes[], |
| 248 | OPENSSL_ITEM parameters[]); | 243 | OPENSSL_ITEM parameters[]); |
| 249 | X509 *STORE_list_certificate_next(STORE *e, void *handle); | 244 | X509 *STORE_list_certificate_next(STORE *e, void *handle); |
| 250 | int STORE_list_certificate_end(STORE *e, void *handle); | 245 | int STORE_list_certificate_end(STORE *e, void *handle); |
| 251 | int STORE_list_certificate_endp(STORE *e, void *handle); | 246 | int STORE_list_certificate_endp(STORE *e, void *handle); |
| 252 | EVP_PKEY *STORE_generate_key(STORE *e, OPENSSL_ITEM attributes[], | 247 | EVP_PKEY *STORE_generate_key(STORE *e, OPENSSL_ITEM attributes[], |
| 253 | OPENSSL_ITEM parameters[]); | 248 | OPENSSL_ITEM parameters[]); |
| 254 | EVP_PKEY *STORE_get_private_key(STORE *e, OPENSSL_ITEM attributes[], | 249 | EVP_PKEY *STORE_get_private_key(STORE *e, OPENSSL_ITEM attributes[], |
| 255 | OPENSSL_ITEM parameters[]); | 250 | OPENSSL_ITEM parameters[]); |
| 256 | int STORE_store_private_key(STORE *e, EVP_PKEY *data, | 251 | int STORE_store_private_key(STORE *e, EVP_PKEY *data, |
| 257 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | 252 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); |
| 258 | int STORE_modify_private_key(STORE *e, OPENSSL_ITEM search_attributes[], | 253 | int STORE_modify_private_key(STORE *e, OPENSSL_ITEM search_attributes[], |
| 259 | OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], | 254 | OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], |
| 260 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); | 255 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); |
| 261 | int STORE_revoke_private_key(STORE *e, OPENSSL_ITEM attributes[], | 256 | int STORE_revoke_private_key(STORE *e, OPENSSL_ITEM attributes[], |
| 262 | OPENSSL_ITEM parameters[]); | 257 | OPENSSL_ITEM parameters[]); |
| 263 | int STORE_delete_private_key(STORE *e, OPENSSL_ITEM attributes[], | 258 | int STORE_delete_private_key(STORE *e, OPENSSL_ITEM attributes[], |
| 264 | OPENSSL_ITEM parameters[]); | 259 | OPENSSL_ITEM parameters[]); |
| 265 | void *STORE_list_private_key_start(STORE *e, OPENSSL_ITEM attributes[], | 260 | void *STORE_list_private_key_start(STORE *e, OPENSSL_ITEM attributes[], |
| 266 | OPENSSL_ITEM parameters[]); | 261 | OPENSSL_ITEM parameters[]); |
| 267 | EVP_PKEY *STORE_list_private_key_next(STORE *e, void *handle); | 262 | EVP_PKEY *STORE_list_private_key_next(STORE *e, void *handle); |
| 268 | int STORE_list_private_key_end(STORE *e, void *handle); | 263 | int STORE_list_private_key_end(STORE *e, void *handle); |
| 269 | int STORE_list_private_key_endp(STORE *e, void *handle); | 264 | int STORE_list_private_key_endp(STORE *e, void *handle); |
| 270 | EVP_PKEY *STORE_get_public_key(STORE *e, OPENSSL_ITEM attributes[], | 265 | EVP_PKEY *STORE_get_public_key(STORE *e, OPENSSL_ITEM attributes[], |
| 271 | OPENSSL_ITEM parameters[]); | 266 | OPENSSL_ITEM parameters[]); |
| 272 | int STORE_store_public_key(STORE *e, EVP_PKEY *data, OPENSSL_ITEM attributes[], | 267 | int STORE_store_public_key(STORE *e, EVP_PKEY *data, OPENSSL_ITEM attributes[], |
| 273 | OPENSSL_ITEM parameters[]); | 268 | OPENSSL_ITEM parameters[]); |
| 274 | int STORE_modify_public_key(STORE *e, OPENSSL_ITEM search_attributes[], | 269 | int STORE_modify_public_key(STORE *e, OPENSSL_ITEM search_attributes[], |
| 275 | OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], | 270 | OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], |
| 276 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); | 271 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); |
| 277 | int STORE_revoke_public_key(STORE *e, OPENSSL_ITEM attributes[], | 272 | int STORE_revoke_public_key(STORE *e, OPENSSL_ITEM attributes[], |
| 278 | OPENSSL_ITEM parameters[]); | 273 | OPENSSL_ITEM parameters[]); |
| 279 | int STORE_delete_public_key(STORE *e, OPENSSL_ITEM attributes[], | 274 | int STORE_delete_public_key(STORE *e, OPENSSL_ITEM attributes[], |
| 280 | OPENSSL_ITEM parameters[]); | 275 | OPENSSL_ITEM parameters[]); |
| 281 | void *STORE_list_public_key_start(STORE *e, OPENSSL_ITEM attributes[], | 276 | void *STORE_list_public_key_start(STORE *e, OPENSSL_ITEM attributes[], |
| 282 | OPENSSL_ITEM parameters[]); | 277 | OPENSSL_ITEM parameters[]); |
| 283 | EVP_PKEY *STORE_list_public_key_next(STORE *e, void *handle); | 278 | EVP_PKEY *STORE_list_public_key_next(STORE *e, void *handle); |
| 284 | int STORE_list_public_key_end(STORE *e, void *handle); | 279 | int STORE_list_public_key_end(STORE *e, void *handle); |
| 285 | int STORE_list_public_key_endp(STORE *e, void *handle); | 280 | int STORE_list_public_key_endp(STORE *e, void *handle); |
| 286 | X509_CRL *STORE_generate_crl(STORE *e, OPENSSL_ITEM attributes[], | 281 | X509_CRL *STORE_generate_crl(STORE *e, OPENSSL_ITEM attributes[], |
| 287 | OPENSSL_ITEM parameters[]); | 282 | OPENSSL_ITEM parameters[]); |
| 288 | X509_CRL *STORE_get_crl(STORE *e, OPENSSL_ITEM attributes[], | 283 | X509_CRL *STORE_get_crl(STORE *e, OPENSSL_ITEM attributes[], |
| 289 | OPENSSL_ITEM parameters[]); | 284 | OPENSSL_ITEM parameters[]); |
| 290 | int STORE_store_crl(STORE *e, X509_CRL *data, OPENSSL_ITEM attributes[], | 285 | int STORE_store_crl(STORE *e, X509_CRL *data, OPENSSL_ITEM attributes[], |
| 291 | OPENSSL_ITEM parameters[]); | 286 | OPENSSL_ITEM parameters[]); |
| 292 | int STORE_modify_crl(STORE *e, OPENSSL_ITEM search_attributes[], | 287 | int STORE_modify_crl(STORE *e, OPENSSL_ITEM search_attributes[], |
| 293 | OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], | 288 | OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], |
| 294 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); | 289 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); |
| 295 | int STORE_delete_crl(STORE *e, OPENSSL_ITEM attributes[], | 290 | int STORE_delete_crl(STORE *e, OPENSSL_ITEM attributes[], |
| 296 | OPENSSL_ITEM parameters[]); | 291 | OPENSSL_ITEM parameters[]); |
| 297 | void *STORE_list_crl_start(STORE *e, OPENSSL_ITEM attributes[], | 292 | void *STORE_list_crl_start(STORE *e, OPENSSL_ITEM attributes[], |
| 298 | OPENSSL_ITEM parameters[]); | 293 | OPENSSL_ITEM parameters[]); |
| 299 | X509_CRL *STORE_list_crl_next(STORE *e, void *handle); | 294 | X509_CRL *STORE_list_crl_next(STORE *e, void *handle); |
| 300 | int STORE_list_crl_end(STORE *e, void *handle); | 295 | int STORE_list_crl_end(STORE *e, void *handle); |
| 301 | int STORE_list_crl_endp(STORE *e, void *handle); | 296 | int STORE_list_crl_endp(STORE *e, void *handle); |
| 302 | int STORE_store_number(STORE *e, BIGNUM *data, OPENSSL_ITEM attributes[], | 297 | int STORE_store_number(STORE *e, BIGNUM *data, OPENSSL_ITEM attributes[], |
| 303 | OPENSSL_ITEM parameters[]); | 298 | OPENSSL_ITEM parameters[]); |
| 304 | int STORE_modify_number(STORE *e, OPENSSL_ITEM search_attributes[], | 299 | int STORE_modify_number(STORE *e, OPENSSL_ITEM search_attributes[], |
| 305 | OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], | 300 | OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], |
| 306 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); | 301 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); |
| 307 | BIGNUM *STORE_get_number(STORE *e, OPENSSL_ITEM attributes[], | 302 | BIGNUM *STORE_get_number(STORE *e, OPENSSL_ITEM attributes[], |
| 308 | OPENSSL_ITEM parameters[]); | 303 | OPENSSL_ITEM parameters[]); |
| 309 | int STORE_delete_number(STORE *e, OPENSSL_ITEM attributes[], | 304 | int STORE_delete_number(STORE *e, OPENSSL_ITEM attributes[], |
| 310 | OPENSSL_ITEM parameters[]); | 305 | OPENSSL_ITEM parameters[]); |
| 311 | int STORE_store_arbitrary(STORE *e, BUF_MEM *data, OPENSSL_ITEM attributes[], | 306 | int STORE_store_arbitrary(STORE *e, BUF_MEM *data, OPENSSL_ITEM attributes[], |
| 312 | OPENSSL_ITEM parameters[]); | 307 | OPENSSL_ITEM parameters[]); |
| 313 | int STORE_modify_arbitrary(STORE *e, OPENSSL_ITEM search_attributes[], | 308 | int STORE_modify_arbitrary(STORE *e, OPENSSL_ITEM search_attributes[], |
| 314 | OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], | 309 | OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], |
| 315 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); | 310 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); |
| 316 | BUF_MEM *STORE_get_arbitrary(STORE *e, OPENSSL_ITEM attributes[], | 311 | BUF_MEM *STORE_get_arbitrary(STORE *e, OPENSSL_ITEM attributes[], |
| 317 | OPENSSL_ITEM parameters[]); | 312 | OPENSSL_ITEM parameters[]); |
| 318 | int STORE_delete_arbitrary(STORE *e, OPENSSL_ITEM attributes[], | 313 | int STORE_delete_arbitrary(STORE *e, OPENSSL_ITEM attributes[], |
| 319 | OPENSSL_ITEM parameters[]); | 314 | OPENSSL_ITEM parameters[]); |
| 320 | |||
| 321 | 315 | ||
| 322 | /* Create and manipulate methods */ | 316 | /* Create and manipulate methods */ |
| 323 | STORE_METHOD *STORE_create_method(char *name); | 317 | STORE_METHOD *STORE_create_method(char *name); |
| @@ -326,43 +320,74 @@ void STORE_destroy_method(STORE_METHOD *store_method); | |||
| 326 | /* These callback types are use for store handlers */ | 320 | /* These callback types are use for store handlers */ |
| 327 | typedef int (*STORE_INITIALISE_FUNC_PTR)(STORE *); | 321 | typedef int (*STORE_INITIALISE_FUNC_PTR)(STORE *); |
| 328 | typedef void (*STORE_CLEANUP_FUNC_PTR)(STORE *); | 322 | typedef void (*STORE_CLEANUP_FUNC_PTR)(STORE *); |
| 329 | typedef STORE_OBJECT *(*STORE_GENERATE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | 323 | typedef STORE_OBJECT *(*STORE_GENERATE_OBJECT_FUNC_PTR)(STORE *, |
| 330 | typedef STORE_OBJECT *(*STORE_GET_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | 324 | STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], |
| 331 | typedef void *(*STORE_START_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | 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[]); | ||
| 332 | typedef STORE_OBJECT *(*STORE_NEXT_OBJECT_FUNC_PTR)(STORE *, void *handle); | 331 | typedef STORE_OBJECT *(*STORE_NEXT_OBJECT_FUNC_PTR)(STORE *, void *handle); |
| 333 | typedef int (*STORE_END_OBJECT_FUNC_PTR)(STORE *, void *handle); | 332 | typedef int (*STORE_END_OBJECT_FUNC_PTR)(STORE *, void *handle); |
| 334 | typedef int (*STORE_HANDLE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | 333 | typedef int (*STORE_HANDLE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, |
| 335 | typedef int (*STORE_STORE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, STORE_OBJECT *data, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | 334 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); |
| 336 | typedef int (*STORE_MODIFY_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM search_attributes[], OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); | 335 | typedef int (*STORE_STORE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, |
| 337 | typedef int (*STORE_GENERIC_FUNC_PTR)(STORE *, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | 336 | STORE_OBJECT *data, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); |
| 338 | typedef int (*STORE_CTRL_FUNC_PTR)(STORE *, int cmd, long l, void *p, void (*f)(void)); | 337 | typedef int (*STORE_MODIFY_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, |
| 339 | 338 | OPENSSL_ITEM search_attributes[], OPENSSL_ITEM add_attributes[], | |
| 340 | int STORE_method_set_initialise_function(STORE_METHOD *sm, STORE_INITIALISE_FUNC_PTR init_f); | 339 | OPENSSL_ITEM modify_attributes[], OPENSSL_ITEM delete_attributes[], |
| 341 | int STORE_method_set_cleanup_function(STORE_METHOD *sm, STORE_CLEANUP_FUNC_PTR clean_f); | 340 | OPENSSL_ITEM parameters[]); |
| 342 | int STORE_method_set_generate_function(STORE_METHOD *sm, STORE_GENERATE_OBJECT_FUNC_PTR generate_f); | 341 | typedef int (*STORE_GENERIC_FUNC_PTR)(STORE *, OPENSSL_ITEM attributes[], |
| 343 | int STORE_method_set_get_function(STORE_METHOD *sm, STORE_GET_OBJECT_FUNC_PTR get_f); | 342 | OPENSSL_ITEM parameters[]); |
| 344 | int STORE_method_set_store_function(STORE_METHOD *sm, STORE_STORE_OBJECT_FUNC_PTR store_f); | 343 | typedef int (*STORE_CTRL_FUNC_PTR)(STORE *, int cmd, long l, void *p, |
| 345 | int STORE_method_set_modify_function(STORE_METHOD *sm, STORE_MODIFY_OBJECT_FUNC_PTR store_f); | 344 | void (*f)(void)); |
| 346 | int STORE_method_set_revoke_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR revoke_f); | 345 | |
| 347 | int STORE_method_set_delete_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR delete_f); | 346 | int STORE_method_set_initialise_function(STORE_METHOD *sm, |
| 348 | int STORE_method_set_list_start_function(STORE_METHOD *sm, STORE_START_OBJECT_FUNC_PTR list_start_f); | 347 | STORE_INITIALISE_FUNC_PTR init_f); |
| 349 | int STORE_method_set_list_next_function(STORE_METHOD *sm, STORE_NEXT_OBJECT_FUNC_PTR list_next_f); | 348 | int STORE_method_set_cleanup_function(STORE_METHOD *sm, |
| 350 | int STORE_method_set_list_end_function(STORE_METHOD *sm, STORE_END_OBJECT_FUNC_PTR list_end_f); | 349 | STORE_CLEANUP_FUNC_PTR clean_f); |
| 351 | int STORE_method_set_update_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); | 350 | int STORE_method_set_generate_function(STORE_METHOD *sm, |
| 352 | int STORE_method_set_lock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); | 351 | STORE_GENERATE_OBJECT_FUNC_PTR generate_f); |
| 353 | int STORE_method_set_unlock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); | 352 | int STORE_method_set_get_function(STORE_METHOD *sm, |
| 354 | int STORE_method_set_ctrl_function(STORE_METHOD *sm, STORE_CTRL_FUNC_PTR ctrl_f); | 353 | STORE_GET_OBJECT_FUNC_PTR get_f); |
| 355 | 354 | int STORE_method_set_store_function(STORE_METHOD *sm, | |
| 356 | STORE_INITIALISE_FUNC_PTR STORE_method_get_initialise_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); | ||
| 357 | STORE_CLEANUP_FUNC_PTR STORE_method_get_cleanup_function(STORE_METHOD *sm); | 379 | STORE_CLEANUP_FUNC_PTR STORE_method_get_cleanup_function(STORE_METHOD *sm); |
| 358 | STORE_GENERATE_OBJECT_FUNC_PTR STORE_method_get_generate_function(STORE_METHOD *sm); | 380 | STORE_GENERATE_OBJECT_FUNC_PTR STORE_method_get_generate_function( |
| 381 | STORE_METHOD *sm); | ||
| 359 | STORE_GET_OBJECT_FUNC_PTR STORE_method_get_get_function(STORE_METHOD *sm); | 382 | STORE_GET_OBJECT_FUNC_PTR STORE_method_get_get_function(STORE_METHOD *sm); |
| 360 | STORE_STORE_OBJECT_FUNC_PTR STORE_method_get_store_function(STORE_METHOD *sm); | 383 | STORE_STORE_OBJECT_FUNC_PTR STORE_method_get_store_function(STORE_METHOD *sm); |
| 361 | STORE_MODIFY_OBJECT_FUNC_PTR STORE_method_get_modify_function(STORE_METHOD *sm); | 384 | STORE_MODIFY_OBJECT_FUNC_PTR STORE_method_get_modify_function(STORE_METHOD *sm); |
| 362 | STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_revoke_function(STORE_METHOD *sm); | 385 | STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_revoke_function(STORE_METHOD *sm); |
| 363 | STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_delete_function(STORE_METHOD *sm); | 386 | STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_delete_function(STORE_METHOD *sm); |
| 364 | STORE_START_OBJECT_FUNC_PTR STORE_method_get_list_start_function(STORE_METHOD *sm); | 387 | STORE_START_OBJECT_FUNC_PTR STORE_method_get_list_start_function( |
| 365 | STORE_NEXT_OBJECT_FUNC_PTR STORE_method_get_list_next_function(STORE_METHOD *sm); | 388 | STORE_METHOD *sm); |
| 389 | STORE_NEXT_OBJECT_FUNC_PTR STORE_method_get_list_next_function( | ||
| 390 | STORE_METHOD *sm); | ||
| 366 | STORE_END_OBJECT_FUNC_PTR STORE_method_get_list_end_function(STORE_METHOD *sm); | 391 | STORE_END_OBJECT_FUNC_PTR STORE_method_get_list_end_function(STORE_METHOD *sm); |
| 367 | STORE_GENERIC_FUNC_PTR STORE_method_get_update_store_function(STORE_METHOD *sm); | 392 | STORE_GENERIC_FUNC_PTR STORE_method_get_update_store_function(STORE_METHOD *sm); |
| 368 | STORE_GENERIC_FUNC_PTR STORE_method_get_lock_store_function(STORE_METHOD *sm); | 393 | STORE_GENERIC_FUNC_PTR STORE_method_get_lock_store_function(STORE_METHOD *sm); |
| @@ -392,30 +417,32 @@ int STORE_ATTR_INFO_free(STORE_ATTR_INFO *attrs); | |||
| 392 | /* Manipulators */ | 417 | /* Manipulators */ |
| 393 | char *STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); | 418 | char *STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); |
| 394 | unsigned char *STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs, | 419 | unsigned char *STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs, |
| 395 | STORE_ATTR_TYPES code); | 420 | STORE_ATTR_TYPES code); |
| 396 | X509_NAME *STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); | 421 | X509_NAME *STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs, |
| 397 | BIGNUM *STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); | 422 | STORE_ATTR_TYPES code); |
| 423 | BIGNUM *STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs, | ||
| 424 | STORE_ATTR_TYPES code); | ||
| 398 | int STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 425 | int STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
| 399 | char *cstr, size_t cstr_size); | 426 | char *cstr, size_t cstr_size); |
| 400 | int STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 427 | int STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
| 401 | unsigned char *sha1str, size_t sha1str_size); | 428 | unsigned char *sha1str, size_t sha1str_size); |
| 402 | int STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 429 | int STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
| 403 | X509_NAME *dn); | 430 | X509_NAME *dn); |
| 404 | int STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 431 | int STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
| 405 | BIGNUM *number); | 432 | BIGNUM *number); |
| 406 | int STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 433 | int STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
| 407 | char *cstr, size_t cstr_size); | 434 | char *cstr, size_t cstr_size); |
| 408 | int STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 435 | int STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs, |
| 409 | unsigned char *sha1str, size_t sha1str_size); | 436 | STORE_ATTR_TYPES code, unsigned char *sha1str, size_t sha1str_size); |
| 410 | int STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 437 | int STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
| 411 | X509_NAME *dn); | 438 | X509_NAME *dn); |
| 412 | int STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 439 | int STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
| 413 | BIGNUM *number); | 440 | BIGNUM *number); |
| 414 | 441 | ||
| 415 | /* Compare on basis of a bit pattern formed by the STORE_ATTR_TYPES values | 442 | /* Compare on basis of a bit pattern formed by the STORE_ATTR_TYPES values |
| 416 | in each contained attribute. */ | 443 | in each contained attribute. */ |
| 417 | int STORE_ATTR_INFO_compare(const STORE_ATTR_INFO * const *a, | 444 | int STORE_ATTR_INFO_compare(const STORE_ATTR_INFO * const *a, |
| 418 | const STORE_ATTR_INFO * const *b); | 445 | const STORE_ATTR_INFO * const *b); |
| 419 | /* Check if the set of attributes in a is within the range of attributes | 446 | /* Check if the set of attributes in a is within the range of attributes |
| 420 | set in b. */ | 447 | set in b. */ |
| 421 | int STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); | 448 | int STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); |
diff --git a/src/lib/libcrypto/store/str_err.c b/src/lib/libcrypto/store/str_err.c index 924edf0505..82156ae0a1 100644 --- a/src/lib/libcrypto/store/str_err.c +++ b/src/lib/libcrypto/store/str_err.c | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | * are met: | 7 | * are met: |
| 8 | * | 8 | * |
| 9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. |
| 11 | * | 11 | * |
| 12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer in | 13 | * notice, this list of conditions and the following disclaimer in |
| @@ -68,144 +68,141 @@ | |||
| 68 | #define ERR_FUNC(func) ERR_PACK(ERR_LIB_STORE,func,0) | 68 | #define ERR_FUNC(func) ERR_PACK(ERR_LIB_STORE,func,0) |
| 69 | #define ERR_REASON(reason) ERR_PACK(ERR_LIB_STORE,0,reason) | 69 | #define ERR_REASON(reason) ERR_PACK(ERR_LIB_STORE,0,reason) |
| 70 | 70 | ||
| 71 | static ERR_STRING_DATA STORE_str_functs[]= | 71 | static ERR_STRING_DATA STORE_str_functs[]= { |
| 72 | { | 72 | {ERR_FUNC(STORE_F_MEM_DELETE), "MEM_DELETE"}, |
| 73 | {ERR_FUNC(STORE_F_MEM_DELETE), "MEM_DELETE"}, | 73 | {ERR_FUNC(STORE_F_MEM_GENERATE), "MEM_GENERATE"}, |
| 74 | {ERR_FUNC(STORE_F_MEM_GENERATE), "MEM_GENERATE"}, | 74 | {ERR_FUNC(STORE_F_MEM_LIST_END), "MEM_LIST_END"}, |
| 75 | {ERR_FUNC(STORE_F_MEM_LIST_END), "MEM_LIST_END"}, | 75 | {ERR_FUNC(STORE_F_MEM_LIST_NEXT), "MEM_LIST_NEXT"}, |
| 76 | {ERR_FUNC(STORE_F_MEM_LIST_NEXT), "MEM_LIST_NEXT"}, | 76 | {ERR_FUNC(STORE_F_MEM_LIST_START), "MEM_LIST_START"}, |
| 77 | {ERR_FUNC(STORE_F_MEM_LIST_START), "MEM_LIST_START"}, | 77 | {ERR_FUNC(STORE_F_MEM_MODIFY), "MEM_MODIFY"}, |
| 78 | {ERR_FUNC(STORE_F_MEM_MODIFY), "MEM_MODIFY"}, | 78 | {ERR_FUNC(STORE_F_MEM_STORE), "MEM_STORE"}, |
| 79 | {ERR_FUNC(STORE_F_MEM_STORE), "MEM_STORE"}, | 79 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_GET0_CSTR), "STORE_ATTR_INFO_get0_cstr"}, |
| 80 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_GET0_CSTR), "STORE_ATTR_INFO_get0_cstr"}, | 80 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_GET0_DN), "STORE_ATTR_INFO_get0_dn"}, |
| 81 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_GET0_DN), "STORE_ATTR_INFO_get0_dn"}, | 81 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_GET0_NUMBER), "STORE_ATTR_INFO_get0_number"}, |
| 82 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_GET0_NUMBER), "STORE_ATTR_INFO_get0_number"}, | 82 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_GET0_SHA1STR), "STORE_ATTR_INFO_get0_sha1str"}, |
| 83 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_GET0_SHA1STR), "STORE_ATTR_INFO_get0_sha1str"}, | 83 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_MODIFY_CSTR), "STORE_ATTR_INFO_modify_cstr"}, |
| 84 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_MODIFY_CSTR), "STORE_ATTR_INFO_modify_cstr"}, | 84 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_MODIFY_DN), "STORE_ATTR_INFO_modify_dn"}, |
| 85 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_MODIFY_DN), "STORE_ATTR_INFO_modify_dn"}, | 85 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER), "STORE_ATTR_INFO_modify_number"}, |
| 86 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER), "STORE_ATTR_INFO_modify_number"}, | 86 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR), "STORE_ATTR_INFO_modify_sha1str"}, |
| 87 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR), "STORE_ATTR_INFO_modify_sha1str"}, | 87 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_SET_CSTR), "STORE_ATTR_INFO_set_cstr"}, |
| 88 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_SET_CSTR), "STORE_ATTR_INFO_set_cstr"}, | 88 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_SET_DN), "STORE_ATTR_INFO_set_dn"}, |
| 89 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_SET_DN), "STORE_ATTR_INFO_set_dn"}, | 89 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_SET_NUMBER), "STORE_ATTR_INFO_set_number"}, |
| 90 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_SET_NUMBER), "STORE_ATTR_INFO_set_number"}, | 90 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_SET_SHA1STR), "STORE_ATTR_INFO_set_sha1str"}, |
| 91 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_SET_SHA1STR), "STORE_ATTR_INFO_set_sha1str"}, | 91 | {ERR_FUNC(STORE_F_STORE_CERTIFICATE), "STORE_CERTIFICATE"}, |
| 92 | {ERR_FUNC(STORE_F_STORE_CERTIFICATE), "STORE_CERTIFICATE"}, | 92 | {ERR_FUNC(STORE_F_STORE_CTRL), "STORE_ctrl"}, |
| 93 | {ERR_FUNC(STORE_F_STORE_CTRL), "STORE_ctrl"}, | 93 | {ERR_FUNC(STORE_F_STORE_DELETE_ARBITRARY), "STORE_delete_arbitrary"}, |
| 94 | {ERR_FUNC(STORE_F_STORE_DELETE_ARBITRARY), "STORE_delete_arbitrary"}, | 94 | {ERR_FUNC(STORE_F_STORE_DELETE_CERTIFICATE), "STORE_delete_certificate"}, |
| 95 | {ERR_FUNC(STORE_F_STORE_DELETE_CERTIFICATE), "STORE_delete_certificate"}, | 95 | {ERR_FUNC(STORE_F_STORE_DELETE_CRL), "STORE_delete_crl"}, |
| 96 | {ERR_FUNC(STORE_F_STORE_DELETE_CRL), "STORE_delete_crl"}, | 96 | {ERR_FUNC(STORE_F_STORE_DELETE_NUMBER), "STORE_delete_number"}, |
| 97 | {ERR_FUNC(STORE_F_STORE_DELETE_NUMBER), "STORE_delete_number"}, | 97 | {ERR_FUNC(STORE_F_STORE_DELETE_PRIVATE_KEY), "STORE_delete_private_key"}, |
| 98 | {ERR_FUNC(STORE_F_STORE_DELETE_PRIVATE_KEY), "STORE_delete_private_key"}, | 98 | {ERR_FUNC(STORE_F_STORE_DELETE_PUBLIC_KEY), "STORE_delete_public_key"}, |
| 99 | {ERR_FUNC(STORE_F_STORE_DELETE_PUBLIC_KEY), "STORE_delete_public_key"}, | 99 | {ERR_FUNC(STORE_F_STORE_GENERATE_CRL), "STORE_generate_crl"}, |
| 100 | {ERR_FUNC(STORE_F_STORE_GENERATE_CRL), "STORE_generate_crl"}, | 100 | {ERR_FUNC(STORE_F_STORE_GENERATE_KEY), "STORE_generate_key"}, |
| 101 | {ERR_FUNC(STORE_F_STORE_GENERATE_KEY), "STORE_generate_key"}, | 101 | {ERR_FUNC(STORE_F_STORE_GET_ARBITRARY), "STORE_get_arbitrary"}, |
| 102 | {ERR_FUNC(STORE_F_STORE_GET_ARBITRARY), "STORE_get_arbitrary"}, | 102 | {ERR_FUNC(STORE_F_STORE_GET_CERTIFICATE), "STORE_get_certificate"}, |
| 103 | {ERR_FUNC(STORE_F_STORE_GET_CERTIFICATE), "STORE_get_certificate"}, | 103 | {ERR_FUNC(STORE_F_STORE_GET_CRL), "STORE_get_crl"}, |
| 104 | {ERR_FUNC(STORE_F_STORE_GET_CRL), "STORE_get_crl"}, | 104 | {ERR_FUNC(STORE_F_STORE_GET_NUMBER), "STORE_get_number"}, |
| 105 | {ERR_FUNC(STORE_F_STORE_GET_NUMBER), "STORE_get_number"}, | 105 | {ERR_FUNC(STORE_F_STORE_GET_PRIVATE_KEY), "STORE_get_private_key"}, |
| 106 | {ERR_FUNC(STORE_F_STORE_GET_PRIVATE_KEY), "STORE_get_private_key"}, | 106 | {ERR_FUNC(STORE_F_STORE_GET_PUBLIC_KEY), "STORE_get_public_key"}, |
| 107 | {ERR_FUNC(STORE_F_STORE_GET_PUBLIC_KEY), "STORE_get_public_key"}, | 107 | {ERR_FUNC(STORE_F_STORE_LIST_CERTIFICATE_END), "STORE_list_certificate_end"}, |
| 108 | {ERR_FUNC(STORE_F_STORE_LIST_CERTIFICATE_END), "STORE_list_certificate_end"}, | 108 | {ERR_FUNC(STORE_F_STORE_LIST_CERTIFICATE_ENDP), "STORE_list_certificate_endp"}, |
| 109 | {ERR_FUNC(STORE_F_STORE_LIST_CERTIFICATE_ENDP), "STORE_list_certificate_endp"}, | 109 | {ERR_FUNC(STORE_F_STORE_LIST_CERTIFICATE_NEXT), "STORE_list_certificate_next"}, |
| 110 | {ERR_FUNC(STORE_F_STORE_LIST_CERTIFICATE_NEXT), "STORE_list_certificate_next"}, | 110 | {ERR_FUNC(STORE_F_STORE_LIST_CERTIFICATE_START), "STORE_list_certificate_start"}, |
| 111 | {ERR_FUNC(STORE_F_STORE_LIST_CERTIFICATE_START), "STORE_list_certificate_start"}, | 111 | {ERR_FUNC(STORE_F_STORE_LIST_CRL_END), "STORE_list_crl_end"}, |
| 112 | {ERR_FUNC(STORE_F_STORE_LIST_CRL_END), "STORE_list_crl_end"}, | 112 | {ERR_FUNC(STORE_F_STORE_LIST_CRL_ENDP), "STORE_list_crl_endp"}, |
| 113 | {ERR_FUNC(STORE_F_STORE_LIST_CRL_ENDP), "STORE_list_crl_endp"}, | 113 | {ERR_FUNC(STORE_F_STORE_LIST_CRL_NEXT), "STORE_list_crl_next"}, |
| 114 | {ERR_FUNC(STORE_F_STORE_LIST_CRL_NEXT), "STORE_list_crl_next"}, | 114 | {ERR_FUNC(STORE_F_STORE_LIST_CRL_START), "STORE_list_crl_start"}, |
| 115 | {ERR_FUNC(STORE_F_STORE_LIST_CRL_START), "STORE_list_crl_start"}, | 115 | {ERR_FUNC(STORE_F_STORE_LIST_PRIVATE_KEY_END), "STORE_list_private_key_end"}, |
| 116 | {ERR_FUNC(STORE_F_STORE_LIST_PRIVATE_KEY_END), "STORE_list_private_key_end"}, | 116 | {ERR_FUNC(STORE_F_STORE_LIST_PRIVATE_KEY_ENDP), "STORE_list_private_key_endp"}, |
| 117 | {ERR_FUNC(STORE_F_STORE_LIST_PRIVATE_KEY_ENDP), "STORE_list_private_key_endp"}, | 117 | {ERR_FUNC(STORE_F_STORE_LIST_PRIVATE_KEY_NEXT), "STORE_list_private_key_next"}, |
| 118 | {ERR_FUNC(STORE_F_STORE_LIST_PRIVATE_KEY_NEXT), "STORE_list_private_key_next"}, | 118 | {ERR_FUNC(STORE_F_STORE_LIST_PRIVATE_KEY_START), "STORE_list_private_key_start"}, |
| 119 | {ERR_FUNC(STORE_F_STORE_LIST_PRIVATE_KEY_START), "STORE_list_private_key_start"}, | 119 | {ERR_FUNC(STORE_F_STORE_LIST_PUBLIC_KEY_END), "STORE_list_public_key_end"}, |
| 120 | {ERR_FUNC(STORE_F_STORE_LIST_PUBLIC_KEY_END), "STORE_list_public_key_end"}, | 120 | {ERR_FUNC(STORE_F_STORE_LIST_PUBLIC_KEY_ENDP), "STORE_list_public_key_endp"}, |
| 121 | {ERR_FUNC(STORE_F_STORE_LIST_PUBLIC_KEY_ENDP), "STORE_list_public_key_endp"}, | 121 | {ERR_FUNC(STORE_F_STORE_LIST_PUBLIC_KEY_NEXT), "STORE_list_public_key_next"}, |
| 122 | {ERR_FUNC(STORE_F_STORE_LIST_PUBLIC_KEY_NEXT), "STORE_list_public_key_next"}, | 122 | {ERR_FUNC(STORE_F_STORE_LIST_PUBLIC_KEY_START), "STORE_list_public_key_start"}, |
| 123 | {ERR_FUNC(STORE_F_STORE_LIST_PUBLIC_KEY_START), "STORE_list_public_key_start"}, | 123 | {ERR_FUNC(STORE_F_STORE_MODIFY_ARBITRARY), "STORE_modify_arbitrary"}, |
| 124 | {ERR_FUNC(STORE_F_STORE_MODIFY_ARBITRARY), "STORE_modify_arbitrary"}, | 124 | {ERR_FUNC(STORE_F_STORE_MODIFY_CERTIFICATE), "STORE_modify_certificate"}, |
| 125 | {ERR_FUNC(STORE_F_STORE_MODIFY_CERTIFICATE), "STORE_modify_certificate"}, | 125 | {ERR_FUNC(STORE_F_STORE_MODIFY_CRL), "STORE_modify_crl"}, |
| 126 | {ERR_FUNC(STORE_F_STORE_MODIFY_CRL), "STORE_modify_crl"}, | 126 | {ERR_FUNC(STORE_F_STORE_MODIFY_NUMBER), "STORE_modify_number"}, |
| 127 | {ERR_FUNC(STORE_F_STORE_MODIFY_NUMBER), "STORE_modify_number"}, | 127 | {ERR_FUNC(STORE_F_STORE_MODIFY_PRIVATE_KEY), "STORE_modify_private_key"}, |
| 128 | {ERR_FUNC(STORE_F_STORE_MODIFY_PRIVATE_KEY), "STORE_modify_private_key"}, | 128 | {ERR_FUNC(STORE_F_STORE_MODIFY_PUBLIC_KEY), "STORE_modify_public_key"}, |
| 129 | {ERR_FUNC(STORE_F_STORE_MODIFY_PUBLIC_KEY), "STORE_modify_public_key"}, | 129 | {ERR_FUNC(STORE_F_STORE_NEW_ENGINE), "STORE_new_engine"}, |
| 130 | {ERR_FUNC(STORE_F_STORE_NEW_ENGINE), "STORE_new_engine"}, | 130 | {ERR_FUNC(STORE_F_STORE_NEW_METHOD), "STORE_new_method"}, |
| 131 | {ERR_FUNC(STORE_F_STORE_NEW_METHOD), "STORE_new_method"}, | 131 | {ERR_FUNC(STORE_F_STORE_PARSE_ATTRS_END), "STORE_parse_attrs_end"}, |
| 132 | {ERR_FUNC(STORE_F_STORE_PARSE_ATTRS_END), "STORE_parse_attrs_end"}, | 132 | {ERR_FUNC(STORE_F_STORE_PARSE_ATTRS_ENDP), "STORE_parse_attrs_endp"}, |
| 133 | {ERR_FUNC(STORE_F_STORE_PARSE_ATTRS_ENDP), "STORE_parse_attrs_endp"}, | 133 | {ERR_FUNC(STORE_F_STORE_PARSE_ATTRS_NEXT), "STORE_parse_attrs_next"}, |
| 134 | {ERR_FUNC(STORE_F_STORE_PARSE_ATTRS_NEXT), "STORE_parse_attrs_next"}, | 134 | {ERR_FUNC(STORE_F_STORE_PARSE_ATTRS_START), "STORE_parse_attrs_start"}, |
| 135 | {ERR_FUNC(STORE_F_STORE_PARSE_ATTRS_START), "STORE_parse_attrs_start"}, | 135 | {ERR_FUNC(STORE_F_STORE_REVOKE_CERTIFICATE), "STORE_revoke_certificate"}, |
| 136 | {ERR_FUNC(STORE_F_STORE_REVOKE_CERTIFICATE), "STORE_revoke_certificate"}, | 136 | {ERR_FUNC(STORE_F_STORE_REVOKE_PRIVATE_KEY), "STORE_revoke_private_key"}, |
| 137 | {ERR_FUNC(STORE_F_STORE_REVOKE_PRIVATE_KEY), "STORE_revoke_private_key"}, | 137 | {ERR_FUNC(STORE_F_STORE_REVOKE_PUBLIC_KEY), "STORE_revoke_public_key"}, |
| 138 | {ERR_FUNC(STORE_F_STORE_REVOKE_PUBLIC_KEY), "STORE_revoke_public_key"}, | 138 | {ERR_FUNC(STORE_F_STORE_STORE_ARBITRARY), "STORE_store_arbitrary"}, |
| 139 | {ERR_FUNC(STORE_F_STORE_STORE_ARBITRARY), "STORE_store_arbitrary"}, | 139 | {ERR_FUNC(STORE_F_STORE_STORE_CERTIFICATE), "STORE_store_certificate"}, |
| 140 | {ERR_FUNC(STORE_F_STORE_STORE_CERTIFICATE), "STORE_store_certificate"}, | 140 | {ERR_FUNC(STORE_F_STORE_STORE_CRL), "STORE_store_crl"}, |
| 141 | {ERR_FUNC(STORE_F_STORE_STORE_CRL), "STORE_store_crl"}, | 141 | {ERR_FUNC(STORE_F_STORE_STORE_NUMBER), "STORE_store_number"}, |
| 142 | {ERR_FUNC(STORE_F_STORE_STORE_NUMBER), "STORE_store_number"}, | 142 | {ERR_FUNC(STORE_F_STORE_STORE_PRIVATE_KEY), "STORE_store_private_key"}, |
| 143 | {ERR_FUNC(STORE_F_STORE_STORE_PRIVATE_KEY), "STORE_store_private_key"}, | 143 | {ERR_FUNC(STORE_F_STORE_STORE_PUBLIC_KEY), "STORE_store_public_key"}, |
| 144 | {ERR_FUNC(STORE_F_STORE_STORE_PUBLIC_KEY), "STORE_store_public_key"}, | 144 | {0, NULL} |
| 145 | {0,NULL} | 145 | }; |
| 146 | }; | ||
| 147 | 146 | ||
| 148 | static ERR_STRING_DATA STORE_str_reasons[]= | 147 | static ERR_STRING_DATA STORE_str_reasons[]= { |
| 149 | { | 148 | {ERR_REASON(STORE_R_ALREADY_HAS_A_VALUE) , "already has a value"}, |
| 150 | {ERR_REASON(STORE_R_ALREADY_HAS_A_VALUE) ,"already has a value"}, | 149 | {ERR_REASON(STORE_R_FAILED_DELETING_ARBITRARY), "failed deleting arbitrary"}, |
| 151 | {ERR_REASON(STORE_R_FAILED_DELETING_ARBITRARY),"failed deleting arbitrary"}, | 150 | {ERR_REASON(STORE_R_FAILED_DELETING_CERTIFICATE), "failed deleting certificate"}, |
| 152 | {ERR_REASON(STORE_R_FAILED_DELETING_CERTIFICATE),"failed deleting certificate"}, | 151 | {ERR_REASON(STORE_R_FAILED_DELETING_KEY) , "failed deleting key"}, |
| 153 | {ERR_REASON(STORE_R_FAILED_DELETING_KEY) ,"failed deleting key"}, | 152 | {ERR_REASON(STORE_R_FAILED_DELETING_NUMBER), "failed deleting number"}, |
| 154 | {ERR_REASON(STORE_R_FAILED_DELETING_NUMBER),"failed deleting number"}, | 153 | {ERR_REASON(STORE_R_FAILED_GENERATING_CRL), "failed generating crl"}, |
| 155 | {ERR_REASON(STORE_R_FAILED_GENERATING_CRL),"failed generating crl"}, | 154 | {ERR_REASON(STORE_R_FAILED_GENERATING_KEY), "failed generating key"}, |
| 156 | {ERR_REASON(STORE_R_FAILED_GENERATING_KEY),"failed generating key"}, | 155 | {ERR_REASON(STORE_R_FAILED_GETTING_ARBITRARY), "failed getting arbitrary"}, |
| 157 | {ERR_REASON(STORE_R_FAILED_GETTING_ARBITRARY),"failed getting arbitrary"}, | 156 | {ERR_REASON(STORE_R_FAILED_GETTING_CERTIFICATE), "failed getting certificate"}, |
| 158 | {ERR_REASON(STORE_R_FAILED_GETTING_CERTIFICATE),"failed getting certificate"}, | 157 | {ERR_REASON(STORE_R_FAILED_GETTING_KEY) , "failed getting key"}, |
| 159 | {ERR_REASON(STORE_R_FAILED_GETTING_KEY) ,"failed getting key"}, | 158 | {ERR_REASON(STORE_R_FAILED_GETTING_NUMBER), "failed getting number"}, |
| 160 | {ERR_REASON(STORE_R_FAILED_GETTING_NUMBER),"failed getting number"}, | 159 | {ERR_REASON(STORE_R_FAILED_LISTING_CERTIFICATES), "failed listing certificates"}, |
| 161 | {ERR_REASON(STORE_R_FAILED_LISTING_CERTIFICATES),"failed listing certificates"}, | 160 | {ERR_REASON(STORE_R_FAILED_LISTING_KEYS) , "failed listing keys"}, |
| 162 | {ERR_REASON(STORE_R_FAILED_LISTING_KEYS) ,"failed listing keys"}, | 161 | {ERR_REASON(STORE_R_FAILED_MODIFYING_ARBITRARY), "failed modifying arbitrary"}, |
| 163 | {ERR_REASON(STORE_R_FAILED_MODIFYING_ARBITRARY),"failed modifying arbitrary"}, | 162 | {ERR_REASON(STORE_R_FAILED_MODIFYING_CERTIFICATE), "failed modifying certificate"}, |
| 164 | {ERR_REASON(STORE_R_FAILED_MODIFYING_CERTIFICATE),"failed modifying certificate"}, | 163 | {ERR_REASON(STORE_R_FAILED_MODIFYING_CRL), "failed modifying crl"}, |
| 165 | {ERR_REASON(STORE_R_FAILED_MODIFYING_CRL),"failed modifying crl"}, | 164 | {ERR_REASON(STORE_R_FAILED_MODIFYING_NUMBER), "failed modifying number"}, |
| 166 | {ERR_REASON(STORE_R_FAILED_MODIFYING_NUMBER),"failed modifying number"}, | 165 | {ERR_REASON(STORE_R_FAILED_MODIFYING_PRIVATE_KEY), "failed modifying private key"}, |
| 167 | {ERR_REASON(STORE_R_FAILED_MODIFYING_PRIVATE_KEY),"failed modifying private key"}, | 166 | {ERR_REASON(STORE_R_FAILED_MODIFYING_PUBLIC_KEY), "failed modifying public key"}, |
| 168 | {ERR_REASON(STORE_R_FAILED_MODIFYING_PUBLIC_KEY),"failed modifying public key"}, | 167 | {ERR_REASON(STORE_R_FAILED_REVOKING_CERTIFICATE), "failed revoking certificate"}, |
| 169 | {ERR_REASON(STORE_R_FAILED_REVOKING_CERTIFICATE),"failed revoking certificate"}, | 168 | {ERR_REASON(STORE_R_FAILED_REVOKING_KEY) , "failed revoking key"}, |
| 170 | {ERR_REASON(STORE_R_FAILED_REVOKING_KEY) ,"failed revoking key"}, | 169 | {ERR_REASON(STORE_R_FAILED_STORING_ARBITRARY), "failed storing arbitrary"}, |
| 171 | {ERR_REASON(STORE_R_FAILED_STORING_ARBITRARY),"failed storing arbitrary"}, | 170 | {ERR_REASON(STORE_R_FAILED_STORING_CERTIFICATE), "failed storing certificate"}, |
| 172 | {ERR_REASON(STORE_R_FAILED_STORING_CERTIFICATE),"failed storing certificate"}, | 171 | {ERR_REASON(STORE_R_FAILED_STORING_KEY) , "failed storing key"}, |
| 173 | {ERR_REASON(STORE_R_FAILED_STORING_KEY) ,"failed storing key"}, | 172 | {ERR_REASON(STORE_R_FAILED_STORING_NUMBER), "failed storing number"}, |
| 174 | {ERR_REASON(STORE_R_FAILED_STORING_NUMBER),"failed storing number"}, | 173 | {ERR_REASON(STORE_R_NOT_IMPLEMENTED) , "not implemented"}, |
| 175 | {ERR_REASON(STORE_R_NOT_IMPLEMENTED) ,"not implemented"}, | 174 | {ERR_REASON(STORE_R_NO_CONTROL_FUNCTION) , "no control function"}, |
| 176 | {ERR_REASON(STORE_R_NO_CONTROL_FUNCTION) ,"no control function"}, | 175 | {ERR_REASON(STORE_R_NO_DELETE_ARBITRARY_FUNCTION), "no delete arbitrary function"}, |
| 177 | {ERR_REASON(STORE_R_NO_DELETE_ARBITRARY_FUNCTION),"no delete arbitrary function"}, | 176 | {ERR_REASON(STORE_R_NO_DELETE_NUMBER_FUNCTION), "no delete number function"}, |
| 178 | {ERR_REASON(STORE_R_NO_DELETE_NUMBER_FUNCTION),"no delete number function"}, | 177 | {ERR_REASON(STORE_R_NO_DELETE_OBJECT_FUNCTION), "no delete object function"}, |
| 179 | {ERR_REASON(STORE_R_NO_DELETE_OBJECT_FUNCTION),"no delete object function"}, | 178 | {ERR_REASON(STORE_R_NO_GENERATE_CRL_FUNCTION), "no generate crl function"}, |
| 180 | {ERR_REASON(STORE_R_NO_GENERATE_CRL_FUNCTION),"no generate crl function"}, | 179 | {ERR_REASON(STORE_R_NO_GENERATE_OBJECT_FUNCTION), "no generate object function"}, |
| 181 | {ERR_REASON(STORE_R_NO_GENERATE_OBJECT_FUNCTION),"no generate object function"}, | 180 | {ERR_REASON(STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION), "no get object arbitrary function"}, |
| 182 | {ERR_REASON(STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION),"no get object arbitrary function"}, | 181 | {ERR_REASON(STORE_R_NO_GET_OBJECT_FUNCTION), "no get object function"}, |
| 183 | {ERR_REASON(STORE_R_NO_GET_OBJECT_FUNCTION),"no get object function"}, | 182 | {ERR_REASON(STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION), "no get object number function"}, |
| 184 | {ERR_REASON(STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION),"no get object number function"}, | 183 | {ERR_REASON(STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION), "no list object endp function"}, |
| 185 | {ERR_REASON(STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION),"no list object endp function"}, | 184 | {ERR_REASON(STORE_R_NO_LIST_OBJECT_END_FUNCTION), "no list object end function"}, |
| 186 | {ERR_REASON(STORE_R_NO_LIST_OBJECT_END_FUNCTION),"no list object end function"}, | 185 | {ERR_REASON(STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION), "no list object next function"}, |
| 187 | {ERR_REASON(STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION),"no list object next function"}, | 186 | {ERR_REASON(STORE_R_NO_LIST_OBJECT_START_FUNCTION), "no list object start function"}, |
| 188 | {ERR_REASON(STORE_R_NO_LIST_OBJECT_START_FUNCTION),"no list object start function"}, | 187 | {ERR_REASON(STORE_R_NO_MODIFY_OBJECT_FUNCTION), "no modify object function"}, |
| 189 | {ERR_REASON(STORE_R_NO_MODIFY_OBJECT_FUNCTION),"no modify object function"}, | 188 | {ERR_REASON(STORE_R_NO_REVOKE_OBJECT_FUNCTION), "no revoke object function"}, |
| 190 | {ERR_REASON(STORE_R_NO_REVOKE_OBJECT_FUNCTION),"no revoke object function"}, | 189 | {ERR_REASON(STORE_R_NO_STORE) , "no store"}, |
| 191 | {ERR_REASON(STORE_R_NO_STORE) ,"no store"}, | 190 | {ERR_REASON(STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION), "no store object arbitrary function"}, |
| 192 | {ERR_REASON(STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION),"no store object arbitrary function"}, | 191 | {ERR_REASON(STORE_R_NO_STORE_OBJECT_FUNCTION), "no store object function"}, |
| 193 | {ERR_REASON(STORE_R_NO_STORE_OBJECT_FUNCTION),"no store object function"}, | 192 | {ERR_REASON(STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION), "no store object number function"}, |
| 194 | {ERR_REASON(STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION),"no store object number function"}, | 193 | {ERR_REASON(STORE_R_NO_VALUE) , "no value"}, |
| 195 | {ERR_REASON(STORE_R_NO_VALUE) ,"no value"}, | 194 | {0, NULL} |
| 196 | {0,NULL} | 195 | }; |
| 197 | }; | ||
| 198 | 196 | ||
| 199 | #endif | 197 | #endif |
| 200 | 198 | ||
| 201 | void ERR_load_STORE_strings(void) | 199 | void |
| 202 | { | 200 | ERR_load_STORE_strings(void) |
| 201 | { | ||
| 203 | #ifndef OPENSSL_NO_ERR | 202 | #ifndef OPENSSL_NO_ERR |
| 204 | 203 | if (ERR_func_error_string(STORE_str_functs[0].error) == NULL) { | |
| 205 | if (ERR_func_error_string(STORE_str_functs[0].error) == NULL) | 204 | ERR_load_strings(0, STORE_str_functs); |
| 206 | { | 205 | ERR_load_strings(0, STORE_str_reasons); |
| 207 | ERR_load_strings(0,STORE_str_functs); | ||
| 208 | ERR_load_strings(0,STORE_str_reasons); | ||
| 209 | } | ||
| 210 | #endif | ||
| 211 | } | 206 | } |
| 207 | #endif | ||
| 208 | } | ||
diff --git a/src/lib/libcrypto/store/str_lib.c b/src/lib/libcrypto/store/str_lib.c index 197f19e769..f9beab2952 100644 --- a/src/lib/libcrypto/store/str_lib.c +++ b/src/lib/libcrypto/store/str_lib.c | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | * are met: | 10 | * are met: |
| 11 | * | 11 | * |
| 12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * | 14 | * |
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
| @@ -66,8 +66,7 @@ | |||
| 66 | #include <openssl/x509.h> | 66 | #include <openssl/x509.h> |
| 67 | #include "str_locl.h" | 67 | #include "str_locl.h" |
| 68 | 68 | ||
| 69 | const char * const STORE_object_type_string[STORE_OBJECT_TYPE_NUM+1] = | 69 | const char * const STORE_object_type_string[STORE_OBJECT_TYPE_NUM + 1] = { |
| 70 | { | ||
| 71 | 0, | 70 | 0, |
| 72 | "X.509 Certificate", | 71 | "X.509 Certificate", |
| 73 | "X.509 CRL", | 72 | "X.509 CRL", |
| @@ -75,19 +74,17 @@ const char * const STORE_object_type_string[STORE_OBJECT_TYPE_NUM+1] = | |||
| 75 | "Public Key", | 74 | "Public Key", |
| 76 | "Number", | 75 | "Number", |
| 77 | "Arbitrary Data" | 76 | "Arbitrary Data" |
| 78 | }; | 77 | }; |
| 79 | 78 | ||
| 80 | const int STORE_param_sizes[STORE_PARAM_TYPE_NUM+1] = | 79 | const int STORE_param_sizes[STORE_PARAM_TYPE_NUM + 1] = { |
| 81 | { | ||
| 82 | 0, | 80 | 0, |
| 83 | sizeof(int), /* EVP_TYPE */ | 81 | sizeof(int), /* EVP_TYPE */ |
| 84 | sizeof(size_t), /* BITS */ | 82 | sizeof(size_t), /* BITS */ |
| 85 | -1, /* KEY_PARAMETERS */ | 83 | -1, /* KEY_PARAMETERS */ |
| 86 | 0 /* KEY_NO_PARAMETERS */ | 84 | 0 /* KEY_NO_PARAMETERS */ |
| 87 | }; | 85 | }; |
| 88 | 86 | ||
| 89 | const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM+1] = | 87 | const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM + 1] = { |
| 90 | { | ||
| 91 | 0, | 88 | 0, |
| 92 | -1, /* FRIENDLYNAME: C string */ | 89 | -1, /* FRIENDLYNAME: C string */ |
| 93 | SHA_DIGEST_LENGTH, /* KEYID: SHA1 digest, 160 bits */ | 90 | SHA_DIGEST_LENGTH, /* KEYID: SHA1 digest, 160 bits */ |
| @@ -100,38 +97,37 @@ const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM+1] = | |||
| 100 | SHA_DIGEST_LENGTH, /* CERTHASH: SHA1 digest, 160 bits */ | 97 | SHA_DIGEST_LENGTH, /* CERTHASH: SHA1 digest, 160 bits */ |
| 101 | -1, /* EMAIL: C string */ | 98 | -1, /* EMAIL: C string */ |
| 102 | -1, /* FILENAME: C string */ | 99 | -1, /* FILENAME: C string */ |
| 103 | }; | 100 | }; |
| 104 | 101 | ||
| 105 | STORE *STORE_new_method(const STORE_METHOD *method) | 102 | STORE * |
| 106 | { | 103 | STORE_new_method(const STORE_METHOD *method) |
| 104 | { | ||
| 107 | STORE *ret; | 105 | STORE *ret; |
| 108 | 106 | ||
| 109 | if (method == NULL) | 107 | if (method == NULL) { |
| 110 | { | 108 | STOREerr(STORE_F_STORE_NEW_METHOD, ERR_R_PASSED_NULL_PARAMETER); |
| 111 | STOREerr(STORE_F_STORE_NEW_METHOD,ERR_R_PASSED_NULL_PARAMETER); | ||
| 112 | return NULL; | 109 | return NULL; |
| 113 | } | 110 | } |
| 114 | 111 | ||
| 115 | ret=(STORE *)malloc(sizeof(STORE)); | 112 | ret = (STORE *)malloc(sizeof(STORE)); |
| 116 | if (ret == NULL) | 113 | if (ret == NULL) { |
| 117 | { | 114 | STOREerr(STORE_F_STORE_NEW_METHOD, ERR_R_MALLOC_FAILURE); |
| 118 | STOREerr(STORE_F_STORE_NEW_METHOD,ERR_R_MALLOC_FAILURE); | ||
| 119 | return NULL; | 115 | return NULL; |
| 120 | } | 116 | } |
| 121 | 117 | ||
| 122 | ret->meth=method; | 118 | ret->meth = method; |
| 123 | 119 | ||
| 124 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_STORE, ret, &ret->ex_data); | 120 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_STORE, ret, &ret->ex_data); |
| 125 | if (ret->meth->init && !ret->meth->init(ret)) | 121 | if (ret->meth->init && !ret->meth->init(ret)) { |
| 126 | { | ||
| 127 | STORE_free(ret); | 122 | STORE_free(ret); |
| 128 | ret = NULL; | 123 | ret = NULL; |
| 129 | } | ||
| 130 | return ret; | ||
| 131 | } | 124 | } |
| 125 | return ret; | ||
| 126 | } | ||
| 132 | 127 | ||
| 133 | STORE *STORE_new_engine(ENGINE *engine) | 128 | STORE * |
| 134 | { | 129 | STORE_new_engine(ENGINE *engine) |
| 130 | { | ||
| 135 | STORE *ret = NULL; | 131 | STORE *ret = NULL; |
| 136 | ENGINE *e = engine; | 132 | ENGINE *e = engine; |
| 137 | const STORE_METHOD *meth = 0; | 133 | const STORE_METHOD *meth = 0; |
| @@ -139,96 +135,95 @@ STORE *STORE_new_engine(ENGINE *engine) | |||
| 139 | #ifdef OPENSSL_NO_ENGINE | 135 | #ifdef OPENSSL_NO_ENGINE |
| 140 | e = NULL; | 136 | e = NULL; |
| 141 | #else | 137 | #else |
| 142 | if (engine) | 138 | if (engine) { |
| 143 | { | 139 | if (!ENGINE_init(engine)) { |
| 144 | if (!ENGINE_init(engine)) | ||
| 145 | { | ||
| 146 | STOREerr(STORE_F_STORE_NEW_ENGINE, ERR_R_ENGINE_LIB); | 140 | STOREerr(STORE_F_STORE_NEW_ENGINE, ERR_R_ENGINE_LIB); |
| 147 | return NULL; | 141 | return NULL; |
| 148 | } | ||
| 149 | e = engine; | ||
| 150 | } | 142 | } |
| 151 | else | 143 | e = engine; |
| 152 | { | 144 | } else { |
| 153 | STOREerr(STORE_F_STORE_NEW_ENGINE,ERR_R_PASSED_NULL_PARAMETER); | 145 | STOREerr(STORE_F_STORE_NEW_ENGINE, ERR_R_PASSED_NULL_PARAMETER); |
| 154 | return NULL; | 146 | return NULL; |
| 155 | } | 147 | } |
| 156 | if(e) | 148 | if (e) { |
| 157 | { | ||
| 158 | meth = ENGINE_get_STORE(e); | 149 | meth = ENGINE_get_STORE(e); |
| 159 | if(!meth) | 150 | if (!meth) { |
| 160 | { | ||
| 161 | STOREerr(STORE_F_STORE_NEW_ENGINE, | 151 | STOREerr(STORE_F_STORE_NEW_ENGINE, |
| 162 | ERR_R_ENGINE_LIB); | 152 | ERR_R_ENGINE_LIB); |
| 163 | ENGINE_finish(e); | 153 | ENGINE_finish(e); |
| 164 | return NULL; | 154 | return NULL; |
| 165 | } | ||
| 166 | } | 155 | } |
| 156 | } | ||
| 167 | #endif | 157 | #endif |
| 168 | 158 | ||
| 169 | ret = STORE_new_method(meth); | 159 | ret = STORE_new_method(meth); |
| 170 | if (ret == NULL) | 160 | if (ret == NULL) { |
| 171 | { | 161 | STOREerr(STORE_F_STORE_NEW_ENGINE, ERR_R_STORE_LIB); |
| 172 | STOREerr(STORE_F_STORE_NEW_ENGINE,ERR_R_STORE_LIB); | ||
| 173 | return NULL; | 162 | return NULL; |
| 174 | } | 163 | } |
| 175 | 164 | ||
| 176 | ret->engine = e; | 165 | ret->engine = e; |
| 177 | 166 | ||
| 178 | return(ret); | 167 | return (ret); |
| 179 | } | 168 | } |
| 180 | 169 | ||
| 181 | void STORE_free(STORE *store) | 170 | void |
| 182 | { | 171 | STORE_free(STORE *store) |
| 172 | { | ||
| 183 | if (store == NULL) | 173 | if (store == NULL) |
| 184 | return; | 174 | return; |
| 185 | if (store->meth->clean) | 175 | if (store->meth->clean) |
| 186 | store->meth->clean(store); | 176 | store->meth->clean(store); |
| 187 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_STORE, store, &store->ex_data); | 177 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_STORE, store, &store->ex_data); |
| 188 | free(store); | 178 | free(store); |
| 189 | } | 179 | } |
| 190 | 180 | ||
| 191 | int STORE_ctrl(STORE *store, int cmd, long i, void *p, void (*f)(void)) | 181 | int |
| 192 | { | 182 | STORE_ctrl(STORE *store, int cmd, long i, void *p, void (*f)(void)) |
| 193 | if (store == NULL) | 183 | { |
| 194 | { | 184 | if (store == NULL) { |
| 195 | STOREerr(STORE_F_STORE_CTRL,ERR_R_PASSED_NULL_PARAMETER); | 185 | STOREerr(STORE_F_STORE_CTRL, ERR_R_PASSED_NULL_PARAMETER); |
| 196 | return 0; | 186 | return 0; |
| 197 | } | 187 | } |
| 198 | if (store->meth->ctrl) | 188 | if (store->meth->ctrl) |
| 199 | return store->meth->ctrl(store, cmd, i, p, f); | 189 | return store->meth->ctrl(store, cmd, i, p, f); |
| 200 | STOREerr(STORE_F_STORE_CTRL,STORE_R_NO_CONTROL_FUNCTION); | 190 | STOREerr(STORE_F_STORE_CTRL, STORE_R_NO_CONTROL_FUNCTION); |
| 201 | return 0; | 191 | return 0; |
| 202 | } | 192 | } |
| 203 | 193 | ||
| 204 | 194 | ||
| 205 | int STORE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, | 195 | int |
| 206 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) | 196 | STORE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, |
| 207 | { | 197 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) |
| 198 | { | ||
| 208 | return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_STORE, argl, argp, | 199 | return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_STORE, argl, argp, |
| 209 | new_func, dup_func, free_func); | 200 | new_func, dup_func, free_func); |
| 210 | } | 201 | } |
| 211 | 202 | ||
| 212 | int STORE_set_ex_data(STORE *r, int idx, void *arg) | 203 | int |
| 213 | { | 204 | STORE_set_ex_data(STORE *r, int idx, void *arg) |
| 214 | return(CRYPTO_set_ex_data(&r->ex_data,idx,arg)); | 205 | { |
| 215 | } | 206 | return (CRYPTO_set_ex_data(&r->ex_data, idx, arg)); |
| 216 | 207 | } | |
| 217 | void *STORE_get_ex_data(STORE *r, int idx) | 208 | |
| 218 | { | 209 | void * |
| 219 | return(CRYPTO_get_ex_data(&r->ex_data,idx)); | 210 | STORE_get_ex_data(STORE *r, int idx) |
| 220 | } | 211 | { |
| 221 | 212 | return (CRYPTO_get_ex_data(&r->ex_data, idx)); | |
| 222 | const STORE_METHOD *STORE_get_method(STORE *store) | 213 | } |
| 223 | { | 214 | |
| 215 | const STORE_METHOD * | ||
| 216 | STORE_get_method(STORE *store) | ||
| 217 | { | ||
| 224 | return store->meth; | 218 | return store->meth; |
| 225 | } | 219 | } |
| 226 | 220 | ||
| 227 | const STORE_METHOD *STORE_set_method(STORE *store, const STORE_METHOD *meth) | 221 | const STORE_METHOD * |
| 228 | { | 222 | STORE_set_method(STORE *store, const STORE_METHOD *meth) |
| 229 | store->meth=meth; | 223 | { |
| 224 | store->meth = meth; | ||
| 230 | return store->meth; | 225 | return store->meth; |
| 231 | } | 226 | } |
| 232 | 227 | ||
| 233 | 228 | ||
| 234 | /* API helpers */ | 229 | /* API helpers */ |
| @@ -252,948 +247,946 @@ const STORE_METHOD *STORE_set_method(STORE *store, const STORE_METHOD *meth) | |||
| 252 | /* API functions */ | 247 | /* API functions */ |
| 253 | 248 | ||
| 254 | X509 *STORE_get_certificate(STORE *s, OPENSSL_ITEM attributes[], | 249 | X509 *STORE_get_certificate(STORE *s, OPENSSL_ITEM attributes[], |
| 255 | OPENSSL_ITEM parameters[]) | 250 | OPENSSL_ITEM parameters[]) |
| 256 | { | 251 | { |
| 257 | STORE_OBJECT *object; | 252 | STORE_OBJECT *object; |
| 258 | X509 *x; | 253 | X509 *x; |
| 259 | 254 | ||
| 260 | check_store(s,STORE_F_STORE_GET_CERTIFICATE, | 255 | check_store(s, STORE_F_STORE_GET_CERTIFICATE, |
| 261 | get_object,STORE_R_NO_GET_OBJECT_FUNCTION); | 256 | get_object, STORE_R_NO_GET_OBJECT_FUNCTION); |
| 262 | 257 | ||
| 263 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, | 258 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, |
| 264 | attributes, parameters); | 259 | attributes, parameters); |
| 265 | if (!object || !object->data.x509.certificate) | 260 | if (!object || !object->data.x509.certificate) { |
| 266 | { | ||
| 267 | STOREerr(STORE_F_STORE_GET_CERTIFICATE, | 261 | STOREerr(STORE_F_STORE_GET_CERTIFICATE, |
| 268 | STORE_R_FAILED_GETTING_CERTIFICATE); | 262 | STORE_R_FAILED_GETTING_CERTIFICATE); |
| 269 | return 0; | 263 | return 0; |
| 270 | } | 264 | } |
| 271 | CRYPTO_add(&object->data.x509.certificate->references,1,CRYPTO_LOCK_X509); | 265 | CRYPTO_add(&object->data.x509.certificate->references, |
| 266 | 1, CRYPTO_LOCK_X509); | ||
| 272 | x = object->data.x509.certificate; | 267 | x = object->data.x509.certificate; |
| 273 | STORE_OBJECT_free(object); | 268 | STORE_OBJECT_free(object); |
| 274 | return x; | 269 | return x; |
| 275 | } | 270 | } |
| 276 | 271 | ||
| 277 | int STORE_store_certificate(STORE *s, X509 *data, OPENSSL_ITEM attributes[], | 272 | int |
| 278 | OPENSSL_ITEM parameters[]) | 273 | STORE_store_certificate(STORE *s, X509 *data, OPENSSL_ITEM attributes[], |
| 279 | { | 274 | OPENSSL_ITEM parameters[]) |
| 275 | { | ||
| 280 | STORE_OBJECT *object; | 276 | STORE_OBJECT *object; |
| 281 | int i; | 277 | int i; |
| 282 | 278 | ||
| 283 | check_store(s,STORE_F_STORE_CERTIFICATE, | 279 | check_store(s, STORE_F_STORE_CERTIFICATE, |
| 284 | store_object,STORE_R_NO_STORE_OBJECT_FUNCTION); | 280 | store_object, STORE_R_NO_STORE_OBJECT_FUNCTION); |
| 285 | 281 | ||
| 286 | object = STORE_OBJECT_new(); | 282 | object = STORE_OBJECT_new(); |
| 287 | if (!object) | 283 | if (!object) { |
| 288 | { | ||
| 289 | STOREerr(STORE_F_STORE_STORE_CERTIFICATE, | 284 | STOREerr(STORE_F_STORE_STORE_CERTIFICATE, |
| 290 | ERR_R_MALLOC_FAILURE); | 285 | ERR_R_MALLOC_FAILURE); |
| 291 | return 0; | 286 | return 0; |
| 292 | } | 287 | } |
| 293 | 288 | ||
| 294 | CRYPTO_add(&data->references,1,CRYPTO_LOCK_X509); | 289 | CRYPTO_add(&data->references, 1, CRYPTO_LOCK_X509); |
| 295 | object->data.x509.certificate = data; | 290 | object->data.x509.certificate = data; |
| 296 | 291 | ||
| 297 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, | 292 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, |
| 298 | object, attributes, parameters); | 293 | object, attributes, parameters); |
| 299 | 294 | ||
| 300 | STORE_OBJECT_free(object); | 295 | STORE_OBJECT_free(object); |
| 301 | 296 | ||
| 302 | if (!i) | 297 | if (!i) { |
| 303 | { | ||
| 304 | STOREerr(STORE_F_STORE_STORE_CERTIFICATE, | 298 | STOREerr(STORE_F_STORE_STORE_CERTIFICATE, |
| 305 | STORE_R_FAILED_STORING_CERTIFICATE); | 299 | STORE_R_FAILED_STORING_CERTIFICATE); |
| 306 | return 0; | 300 | return 0; |
| 307 | } | ||
| 308 | return 1; | ||
| 309 | } | 301 | } |
| 302 | return 1; | ||
| 303 | } | ||
| 310 | 304 | ||
| 311 | int STORE_modify_certificate(STORE *s, OPENSSL_ITEM search_attributes[], | 305 | int |
| 312 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | 306 | STORE_modify_certificate(STORE *s, OPENSSL_ITEM search_attributes[], |
| 313 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) | 307 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], |
| 314 | { | 308 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) |
| 315 | check_store(s,STORE_F_STORE_MODIFY_CERTIFICATE, | 309 | { |
| 316 | modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION); | 310 | check_store(s, STORE_F_STORE_MODIFY_CERTIFICATE, |
| 311 | modify_object, STORE_R_NO_MODIFY_OBJECT_FUNCTION); | ||
| 317 | 312 | ||
| 318 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, | 313 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, |
| 319 | search_attributes, add_attributes, modify_attributes, | 314 | search_attributes, add_attributes, modify_attributes, |
| 320 | delete_attributes, parameters)) | 315 | delete_attributes, parameters)) { |
| 321 | { | ||
| 322 | STOREerr(STORE_F_STORE_MODIFY_CERTIFICATE, | 316 | STOREerr(STORE_F_STORE_MODIFY_CERTIFICATE, |
| 323 | STORE_R_FAILED_MODIFYING_CERTIFICATE); | 317 | STORE_R_FAILED_MODIFYING_CERTIFICATE); |
| 324 | return 0; | 318 | return 0; |
| 325 | } | ||
| 326 | return 1; | ||
| 327 | } | 319 | } |
| 320 | return 1; | ||
| 321 | } | ||
| 328 | 322 | ||
| 329 | int STORE_revoke_certificate(STORE *s, OPENSSL_ITEM attributes[], | 323 | int |
| 330 | OPENSSL_ITEM parameters[]) | 324 | STORE_revoke_certificate(STORE *s, OPENSSL_ITEM attributes[], |
| 331 | { | 325 | OPENSSL_ITEM parameters[]) |
| 332 | check_store(s,STORE_F_STORE_REVOKE_CERTIFICATE, | 326 | { |
| 333 | revoke_object,STORE_R_NO_REVOKE_OBJECT_FUNCTION); | 327 | check_store(s, STORE_F_STORE_REVOKE_CERTIFICATE, |
| 328 | revoke_object, STORE_R_NO_REVOKE_OBJECT_FUNCTION); | ||
| 334 | 329 | ||
| 335 | if (!s->meth->revoke_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, | 330 | if (!s->meth->revoke_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, |
| 336 | attributes, parameters)) | 331 | attributes, parameters)) { |
| 337 | { | ||
| 338 | STOREerr(STORE_F_STORE_REVOKE_CERTIFICATE, | 332 | STOREerr(STORE_F_STORE_REVOKE_CERTIFICATE, |
| 339 | STORE_R_FAILED_REVOKING_CERTIFICATE); | 333 | STORE_R_FAILED_REVOKING_CERTIFICATE); |
| 340 | return 0; | 334 | return 0; |
| 341 | } | ||
| 342 | return 1; | ||
| 343 | } | 335 | } |
| 336 | return 1; | ||
| 337 | } | ||
| 344 | 338 | ||
| 345 | int STORE_delete_certificate(STORE *s, OPENSSL_ITEM attributes[], | 339 | int |
| 346 | OPENSSL_ITEM parameters[]) | 340 | STORE_delete_certificate(STORE *s, OPENSSL_ITEM attributes[], |
| 347 | { | 341 | OPENSSL_ITEM parameters[]) |
| 348 | check_store(s,STORE_F_STORE_DELETE_CERTIFICATE, | 342 | { |
| 349 | delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION); | 343 | check_store(s, STORE_F_STORE_DELETE_CERTIFICATE, |
| 344 | delete_object, STORE_R_NO_DELETE_OBJECT_FUNCTION); | ||
| 350 | 345 | ||
| 351 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, | 346 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, |
| 352 | attributes, parameters)) | 347 | attributes, parameters)) { |
| 353 | { | ||
| 354 | STOREerr(STORE_F_STORE_DELETE_CERTIFICATE, | 348 | STOREerr(STORE_F_STORE_DELETE_CERTIFICATE, |
| 355 | STORE_R_FAILED_DELETING_CERTIFICATE); | 349 | STORE_R_FAILED_DELETING_CERTIFICATE); |
| 356 | return 0; | 350 | return 0; |
| 357 | } | ||
| 358 | return 1; | ||
| 359 | } | 351 | } |
| 352 | return 1; | ||
| 353 | } | ||
| 360 | 354 | ||
| 361 | void *STORE_list_certificate_start(STORE *s, OPENSSL_ITEM attributes[], | 355 | void * |
| 362 | OPENSSL_ITEM parameters[]) | 356 | STORE_list_certificate_start(STORE *s, OPENSSL_ITEM attributes[], |
| 363 | { | 357 | OPENSSL_ITEM parameters[]) |
| 358 | { | ||
| 364 | void *handle; | 359 | void *handle; |
| 365 | 360 | ||
| 366 | check_store(s,STORE_F_STORE_LIST_CERTIFICATE_START, | 361 | check_store(s, STORE_F_STORE_LIST_CERTIFICATE_START, |
| 367 | list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION); | 362 | list_object_start, STORE_R_NO_LIST_OBJECT_START_FUNCTION); |
| 368 | 363 | ||
| 369 | handle = s->meth->list_object_start(s, | 364 | handle = s->meth->list_object_start(s, |
| 370 | STORE_OBJECT_TYPE_X509_CERTIFICATE, attributes, parameters); | 365 | STORE_OBJECT_TYPE_X509_CERTIFICATE, attributes, parameters); |
| 371 | if (!handle) | 366 | if (!handle) { |
| 372 | { | ||
| 373 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_START, | 367 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_START, |
| 374 | STORE_R_FAILED_LISTING_CERTIFICATES); | 368 | STORE_R_FAILED_LISTING_CERTIFICATES); |
| 375 | return 0; | 369 | return 0; |
| 376 | } | ||
| 377 | return handle; | ||
| 378 | } | 370 | } |
| 371 | return handle; | ||
| 372 | } | ||
| 379 | 373 | ||
| 380 | X509 *STORE_list_certificate_next(STORE *s, void *handle) | 374 | X509 * |
| 381 | { | 375 | STORE_list_certificate_next(STORE *s, void *handle) |
| 376 | { | ||
| 382 | STORE_OBJECT *object; | 377 | STORE_OBJECT *object; |
| 383 | X509 *x; | 378 | X509 *x; |
| 384 | 379 | ||
| 385 | check_store(s,STORE_F_STORE_LIST_CERTIFICATE_NEXT, | 380 | check_store(s, STORE_F_STORE_LIST_CERTIFICATE_NEXT, |
| 386 | list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); | 381 | list_object_next, STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); |
| 387 | 382 | ||
| 388 | object = s->meth->list_object_next(s, handle); | 383 | object = s->meth->list_object_next(s, handle); |
| 389 | if (!object || !object->data.x509.certificate) | 384 | if (!object || !object->data.x509.certificate) { |
| 390 | { | ||
| 391 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_NEXT, | 385 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_NEXT, |
| 392 | STORE_R_FAILED_LISTING_CERTIFICATES); | 386 | STORE_R_FAILED_LISTING_CERTIFICATES); |
| 393 | return 0; | 387 | return 0; |
| 394 | } | 388 | } |
| 395 | CRYPTO_add(&object->data.x509.certificate->references,1,CRYPTO_LOCK_X509); | 389 | CRYPTO_add(&object->data.x509.certificate->references, |
| 390 | 1, CRYPTO_LOCK_X509); | ||
| 396 | x = object->data.x509.certificate; | 391 | x = object->data.x509.certificate; |
| 397 | STORE_OBJECT_free(object); | 392 | STORE_OBJECT_free(object); |
| 398 | return x; | 393 | return x; |
| 399 | } | 394 | } |
| 400 | 395 | ||
| 401 | int STORE_list_certificate_end(STORE *s, void *handle) | 396 | int |
| 402 | { | 397 | STORE_list_certificate_end(STORE *s, void *handle) |
| 403 | check_store(s,STORE_F_STORE_LIST_CERTIFICATE_END, | 398 | { |
| 404 | list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION); | 399 | check_store(s, STORE_F_STORE_LIST_CERTIFICATE_END, |
| 400 | list_object_end, STORE_R_NO_LIST_OBJECT_END_FUNCTION); | ||
| 405 | 401 | ||
| 406 | if (!s->meth->list_object_end(s, handle)) | 402 | if (!s->meth->list_object_end(s, handle)) { |
| 407 | { | ||
| 408 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_END, | 403 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_END, |
| 409 | STORE_R_FAILED_LISTING_CERTIFICATES); | 404 | STORE_R_FAILED_LISTING_CERTIFICATES); |
| 410 | return 0; | 405 | return 0; |
| 411 | } | ||
| 412 | return 1; | ||
| 413 | } | 406 | } |
| 407 | return 1; | ||
| 408 | } | ||
| 414 | 409 | ||
| 415 | int STORE_list_certificate_endp(STORE *s, void *handle) | 410 | int |
| 416 | { | 411 | STORE_list_certificate_endp(STORE *s, void *handle) |
| 417 | check_store(s,STORE_F_STORE_LIST_CERTIFICATE_ENDP, | 412 | { |
| 418 | list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | 413 | check_store(s, STORE_F_STORE_LIST_CERTIFICATE_ENDP, |
| 414 | list_object_endp, STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | ||
| 419 | 415 | ||
| 420 | if (!s->meth->list_object_endp(s, handle)) | 416 | if (!s->meth->list_object_endp(s, handle)) { |
| 421 | { | ||
| 422 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_ENDP, | 417 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_ENDP, |
| 423 | STORE_R_FAILED_LISTING_CERTIFICATES); | 418 | STORE_R_FAILED_LISTING_CERTIFICATES); |
| 424 | return 0; | 419 | return 0; |
| 425 | } | ||
| 426 | return 1; | ||
| 427 | } | 420 | } |
| 421 | return 1; | ||
| 422 | } | ||
| 428 | 423 | ||
| 429 | EVP_PKEY *STORE_generate_key(STORE *s, OPENSSL_ITEM attributes[], | 424 | EVP_PKEY * |
| 430 | OPENSSL_ITEM parameters[]) | 425 | STORE_generate_key(STORE *s, OPENSSL_ITEM attributes[], |
| 431 | { | 426 | OPENSSL_ITEM parameters[]) |
| 427 | { | ||
| 432 | STORE_OBJECT *object; | 428 | STORE_OBJECT *object; |
| 433 | EVP_PKEY *pkey; | 429 | EVP_PKEY *pkey; |
| 434 | 430 | ||
| 435 | check_store(s,STORE_F_STORE_GENERATE_KEY, | 431 | check_store(s, STORE_F_STORE_GENERATE_KEY, |
| 436 | generate_object,STORE_R_NO_GENERATE_OBJECT_FUNCTION); | 432 | generate_object, STORE_R_NO_GENERATE_OBJECT_FUNCTION); |
| 437 | 433 | ||
| 438 | object = s->meth->generate_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, | 434 | object = s->meth->generate_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, |
| 439 | attributes, parameters); | 435 | attributes, parameters); |
| 440 | if (!object || !object->data.key) | 436 | if (!object || !object->data.key) { |
| 441 | { | ||
| 442 | STOREerr(STORE_F_STORE_GENERATE_KEY, | 437 | STOREerr(STORE_F_STORE_GENERATE_KEY, |
| 443 | STORE_R_FAILED_GENERATING_KEY); | 438 | STORE_R_FAILED_GENERATING_KEY); |
| 444 | return 0; | 439 | return 0; |
| 445 | } | 440 | } |
| 446 | CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY); | 441 | CRYPTO_add(&object->data.key->references, 1, CRYPTO_LOCK_EVP_PKEY); |
| 447 | pkey = object->data.key; | 442 | pkey = object->data.key; |
| 448 | STORE_OBJECT_free(object); | 443 | STORE_OBJECT_free(object); |
| 449 | return pkey; | 444 | return pkey; |
| 450 | } | 445 | } |
| 451 | 446 | ||
| 452 | EVP_PKEY *STORE_get_private_key(STORE *s, OPENSSL_ITEM attributes[], | 447 | EVP_PKEY * |
| 453 | OPENSSL_ITEM parameters[]) | 448 | STORE_get_private_key(STORE *s, OPENSSL_ITEM attributes[], |
| 454 | { | 449 | OPENSSL_ITEM parameters[]) |
| 450 | { | ||
| 455 | STORE_OBJECT *object; | 451 | STORE_OBJECT *object; |
| 456 | EVP_PKEY *pkey; | 452 | EVP_PKEY *pkey; |
| 457 | 453 | ||
| 458 | check_store(s,STORE_F_STORE_GET_PRIVATE_KEY, | 454 | check_store(s, STORE_F_STORE_GET_PRIVATE_KEY, |
| 459 | get_object,STORE_R_NO_GET_OBJECT_FUNCTION); | 455 | get_object, STORE_R_NO_GET_OBJECT_FUNCTION); |
| 460 | 456 | ||
| 461 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, | 457 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, |
| 462 | attributes, parameters); | 458 | attributes, parameters); |
| 463 | if (!object || !object->data.key) | 459 | if (!object || !object->data.key) { |
| 464 | { | ||
| 465 | STOREerr(STORE_F_STORE_GET_PRIVATE_KEY, | 460 | STOREerr(STORE_F_STORE_GET_PRIVATE_KEY, |
| 466 | STORE_R_FAILED_GETTING_KEY); | 461 | STORE_R_FAILED_GETTING_KEY); |
| 467 | return 0; | 462 | return 0; |
| 468 | } | 463 | } |
| 469 | CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY); | 464 | CRYPTO_add(&object->data.key->references, 1, CRYPTO_LOCK_EVP_PKEY); |
| 470 | pkey = object->data.key; | 465 | pkey = object->data.key; |
| 471 | STORE_OBJECT_free(object); | 466 | STORE_OBJECT_free(object); |
| 472 | return pkey; | 467 | return pkey; |
| 473 | } | 468 | } |
| 474 | 469 | ||
| 475 | int STORE_store_private_key(STORE *s, EVP_PKEY *data, OPENSSL_ITEM attributes[], | 470 | int |
| 476 | OPENSSL_ITEM parameters[]) | 471 | STORE_store_private_key(STORE *s, EVP_PKEY *data, OPENSSL_ITEM attributes[], |
| 477 | { | 472 | OPENSSL_ITEM parameters[]) |
| 473 | { | ||
| 478 | STORE_OBJECT *object; | 474 | STORE_OBJECT *object; |
| 479 | int i; | 475 | int i; |
| 480 | 476 | ||
| 481 | check_store(s,STORE_F_STORE_STORE_PRIVATE_KEY, | 477 | check_store(s, STORE_F_STORE_STORE_PRIVATE_KEY, |
| 482 | store_object,STORE_R_NO_STORE_OBJECT_FUNCTION); | 478 | store_object, STORE_R_NO_STORE_OBJECT_FUNCTION); |
| 483 | 479 | ||
| 484 | object = STORE_OBJECT_new(); | 480 | object = STORE_OBJECT_new(); |
| 485 | if (!object) | 481 | if (!object) { |
| 486 | { | ||
| 487 | STOREerr(STORE_F_STORE_STORE_PRIVATE_KEY, | 482 | STOREerr(STORE_F_STORE_STORE_PRIVATE_KEY, |
| 488 | ERR_R_MALLOC_FAILURE); | 483 | ERR_R_MALLOC_FAILURE); |
| 489 | return 0; | 484 | return 0; |
| 490 | } | 485 | } |
| 491 | object->data.key = EVP_PKEY_new(); | 486 | object->data.key = EVP_PKEY_new(); |
| 492 | if (!object->data.key) | 487 | if (!object->data.key) { |
| 493 | { | ||
| 494 | STOREerr(STORE_F_STORE_STORE_PRIVATE_KEY, | 488 | STOREerr(STORE_F_STORE_STORE_PRIVATE_KEY, |
| 495 | ERR_R_MALLOC_FAILURE); | 489 | ERR_R_MALLOC_FAILURE); |
| 496 | return 0; | 490 | return 0; |
| 497 | } | 491 | } |
| 498 | 492 | ||
| 499 | CRYPTO_add(&data->references,1,CRYPTO_LOCK_EVP_PKEY); | 493 | CRYPTO_add(&data->references, 1, CRYPTO_LOCK_EVP_PKEY); |
| 500 | object->data.key = data; | 494 | object->data.key = data; |
| 501 | 495 | ||
| 502 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, object, | 496 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, object, |
| 503 | attributes, parameters); | 497 | attributes, parameters); |
| 504 | 498 | ||
| 505 | STORE_OBJECT_free(object); | 499 | STORE_OBJECT_free(object); |
| 506 | 500 | ||
| 507 | if (!i) | 501 | if (!i) { |
| 508 | { | ||
| 509 | STOREerr(STORE_F_STORE_STORE_PRIVATE_KEY, | 502 | STOREerr(STORE_F_STORE_STORE_PRIVATE_KEY, |
| 510 | STORE_R_FAILED_STORING_KEY); | 503 | STORE_R_FAILED_STORING_KEY); |
| 511 | return 0; | 504 | return 0; |
| 512 | } | ||
| 513 | return i; | ||
| 514 | } | 505 | } |
| 506 | return i; | ||
| 507 | } | ||
| 515 | 508 | ||
| 516 | int STORE_modify_private_key(STORE *s, OPENSSL_ITEM search_attributes[], | 509 | int |
| 517 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | 510 | STORE_modify_private_key(STORE *s, OPENSSL_ITEM search_attributes[], |
| 518 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) | 511 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], |
| 519 | { | 512 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) |
| 520 | check_store(s,STORE_F_STORE_MODIFY_PRIVATE_KEY, | 513 | { |
| 521 | modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION); | 514 | check_store(s, STORE_F_STORE_MODIFY_PRIVATE_KEY, |
| 515 | modify_object, STORE_R_NO_MODIFY_OBJECT_FUNCTION); | ||
| 522 | 516 | ||
| 523 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, | 517 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, |
| 524 | search_attributes, add_attributes, modify_attributes, | 518 | search_attributes, add_attributes, modify_attributes, |
| 525 | delete_attributes, parameters)) | 519 | delete_attributes, parameters)) { |
| 526 | { | ||
| 527 | STOREerr(STORE_F_STORE_MODIFY_PRIVATE_KEY, | 520 | STOREerr(STORE_F_STORE_MODIFY_PRIVATE_KEY, |
| 528 | STORE_R_FAILED_MODIFYING_PRIVATE_KEY); | 521 | STORE_R_FAILED_MODIFYING_PRIVATE_KEY); |
| 529 | return 0; | 522 | return 0; |
| 530 | } | ||
| 531 | return 1; | ||
| 532 | } | 523 | } |
| 524 | return 1; | ||
| 525 | } | ||
| 533 | 526 | ||
| 534 | int STORE_revoke_private_key(STORE *s, OPENSSL_ITEM attributes[], | 527 | int |
| 535 | OPENSSL_ITEM parameters[]) | 528 | STORE_revoke_private_key(STORE *s, OPENSSL_ITEM attributes[], |
| 536 | { | 529 | OPENSSL_ITEM parameters[]) |
| 530 | { | ||
| 537 | int i; | 531 | int i; |
| 538 | 532 | ||
| 539 | check_store(s,STORE_F_STORE_REVOKE_PRIVATE_KEY, | 533 | check_store(s, STORE_F_STORE_REVOKE_PRIVATE_KEY, |
| 540 | revoke_object,STORE_R_NO_REVOKE_OBJECT_FUNCTION); | 534 | revoke_object, STORE_R_NO_REVOKE_OBJECT_FUNCTION); |
| 541 | 535 | ||
| 542 | i = s->meth->revoke_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, | 536 | i = s->meth->revoke_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, |
| 543 | attributes, parameters); | 537 | attributes, parameters); |
| 544 | 538 | ||
| 545 | if (!i) | 539 | if (!i) { |
| 546 | { | ||
| 547 | STOREerr(STORE_F_STORE_REVOKE_PRIVATE_KEY, | 540 | STOREerr(STORE_F_STORE_REVOKE_PRIVATE_KEY, |
| 548 | STORE_R_FAILED_REVOKING_KEY); | 541 | STORE_R_FAILED_REVOKING_KEY); |
| 549 | return 0; | 542 | return 0; |
| 550 | } | ||
| 551 | return i; | ||
| 552 | } | 543 | } |
| 544 | return i; | ||
| 545 | } | ||
| 546 | |||
| 547 | int | ||
| 548 | STORE_delete_private_key(STORE *s, OPENSSL_ITEM attributes[], | ||
| 549 | OPENSSL_ITEM parameters[]) | ||
| 550 | { | ||
| 551 | check_store(s, STORE_F_STORE_DELETE_PRIVATE_KEY, | ||
| 552 | delete_object, STORE_R_NO_DELETE_OBJECT_FUNCTION); | ||
| 553 | 553 | ||
| 554 | int STORE_delete_private_key(STORE *s, OPENSSL_ITEM attributes[], | ||
| 555 | OPENSSL_ITEM parameters[]) | ||
| 556 | { | ||
| 557 | check_store(s,STORE_F_STORE_DELETE_PRIVATE_KEY, | ||
| 558 | delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION); | ||
| 559 | |||
| 560 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, | 554 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, |
| 561 | attributes, parameters)) | 555 | attributes, parameters)) { |
| 562 | { | ||
| 563 | STOREerr(STORE_F_STORE_DELETE_PRIVATE_KEY, | 556 | STOREerr(STORE_F_STORE_DELETE_PRIVATE_KEY, |
| 564 | STORE_R_FAILED_DELETING_KEY); | 557 | STORE_R_FAILED_DELETING_KEY); |
| 565 | return 0; | 558 | return 0; |
| 566 | } | ||
| 567 | return 1; | ||
| 568 | } | 559 | } |
| 560 | return 1; | ||
| 561 | } | ||
| 569 | 562 | ||
| 570 | void *STORE_list_private_key_start(STORE *s, OPENSSL_ITEM attributes[], | 563 | void * |
| 571 | OPENSSL_ITEM parameters[]) | 564 | STORE_list_private_key_start(STORE *s, OPENSSL_ITEM attributes[], |
| 572 | { | 565 | OPENSSL_ITEM parameters[]) |
| 566 | { | ||
| 573 | void *handle; | 567 | void *handle; |
| 574 | 568 | ||
| 575 | check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_START, | 569 | check_store(s, STORE_F_STORE_LIST_PRIVATE_KEY_START, |
| 576 | list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION); | 570 | list_object_start, STORE_R_NO_LIST_OBJECT_START_FUNCTION); |
| 577 | 571 | ||
| 578 | handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_PRIVATE_KEY, | 572 | handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_PRIVATE_KEY, |
| 579 | attributes, parameters); | 573 | attributes, parameters); |
| 580 | if (!handle) | 574 | if (!handle) { |
| 581 | { | ||
| 582 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_START, | 575 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_START, |
| 583 | STORE_R_FAILED_LISTING_KEYS); | 576 | STORE_R_FAILED_LISTING_KEYS); |
| 584 | return 0; | 577 | return 0; |
| 585 | } | ||
| 586 | return handle; | ||
| 587 | } | 578 | } |
| 579 | return handle; | ||
| 580 | } | ||
| 588 | 581 | ||
| 589 | EVP_PKEY *STORE_list_private_key_next(STORE *s, void *handle) | 582 | EVP_PKEY * |
| 590 | { | 583 | STORE_list_private_key_next(STORE *s, void *handle) |
| 584 | { | ||
| 591 | STORE_OBJECT *object; | 585 | STORE_OBJECT *object; |
| 592 | EVP_PKEY *pkey; | 586 | EVP_PKEY *pkey; |
| 593 | 587 | ||
| 594 | check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_NEXT, | 588 | check_store(s, STORE_F_STORE_LIST_PRIVATE_KEY_NEXT, |
| 595 | list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); | 589 | list_object_next, STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); |
| 596 | 590 | ||
| 597 | object = s->meth->list_object_next(s, handle); | 591 | object = s->meth->list_object_next(s, handle); |
| 598 | if (!object || !object->data.key) | 592 | if (!object || !object->data.key) { |
| 599 | { | ||
| 600 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_NEXT, | 593 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_NEXT, |
| 601 | STORE_R_FAILED_LISTING_KEYS); | 594 | STORE_R_FAILED_LISTING_KEYS); |
| 602 | return 0; | 595 | return 0; |
| 603 | } | 596 | } |
| 604 | CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY); | 597 | CRYPTO_add(&object->data.key->references, 1, CRYPTO_LOCK_EVP_PKEY); |
| 605 | pkey = object->data.key; | 598 | pkey = object->data.key; |
| 606 | STORE_OBJECT_free(object); | 599 | STORE_OBJECT_free(object); |
| 607 | return pkey; | 600 | return pkey; |
| 608 | } | 601 | } |
| 609 | 602 | ||
| 610 | int STORE_list_private_key_end(STORE *s, void *handle) | 603 | int |
| 611 | { | 604 | STORE_list_private_key_end(STORE *s, void *handle) |
| 612 | check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_END, | 605 | { |
| 613 | list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION); | 606 | check_store(s, STORE_F_STORE_LIST_PRIVATE_KEY_END, |
| 607 | list_object_end, STORE_R_NO_LIST_OBJECT_END_FUNCTION); | ||
| 614 | 608 | ||
| 615 | if (!s->meth->list_object_end(s, handle)) | 609 | if (!s->meth->list_object_end(s, handle)) { |
| 616 | { | ||
| 617 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_END, | 610 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_END, |
| 618 | STORE_R_FAILED_LISTING_KEYS); | 611 | STORE_R_FAILED_LISTING_KEYS); |
| 619 | return 0; | 612 | return 0; |
| 620 | } | ||
| 621 | return 1; | ||
| 622 | } | 613 | } |
| 614 | return 1; | ||
| 615 | } | ||
| 623 | 616 | ||
| 624 | int STORE_list_private_key_endp(STORE *s, void *handle) | 617 | int |
| 625 | { | 618 | STORE_list_private_key_endp(STORE *s, void *handle) |
| 626 | check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_ENDP, | 619 | { |
| 627 | list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | 620 | check_store(s, STORE_F_STORE_LIST_PRIVATE_KEY_ENDP, |
| 621 | list_object_endp, STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | ||
| 628 | 622 | ||
| 629 | if (!s->meth->list_object_endp(s, handle)) | 623 | if (!s->meth->list_object_endp(s, handle)) { |
| 630 | { | ||
| 631 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_ENDP, | 624 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_ENDP, |
| 632 | STORE_R_FAILED_LISTING_KEYS); | 625 | STORE_R_FAILED_LISTING_KEYS); |
| 633 | return 0; | 626 | return 0; |
| 634 | } | ||
| 635 | return 1; | ||
| 636 | } | 627 | } |
| 628 | return 1; | ||
| 629 | } | ||
| 637 | 630 | ||
| 638 | EVP_PKEY *STORE_get_public_key(STORE *s, OPENSSL_ITEM attributes[], | 631 | EVP_PKEY * |
| 639 | OPENSSL_ITEM parameters[]) | 632 | STORE_get_public_key(STORE *s, OPENSSL_ITEM attributes[], |
| 640 | { | 633 | OPENSSL_ITEM parameters[]) |
| 634 | { | ||
| 641 | STORE_OBJECT *object; | 635 | STORE_OBJECT *object; |
| 642 | EVP_PKEY *pkey; | 636 | EVP_PKEY *pkey; |
| 643 | 637 | ||
| 644 | check_store(s,STORE_F_STORE_GET_PUBLIC_KEY, | 638 | check_store(s, STORE_F_STORE_GET_PUBLIC_KEY, |
| 645 | get_object,STORE_R_NO_GET_OBJECT_FUNCTION); | 639 | get_object, STORE_R_NO_GET_OBJECT_FUNCTION); |
| 646 | 640 | ||
| 647 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, | 641 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, |
| 648 | attributes, parameters); | 642 | attributes, parameters); |
| 649 | if (!object || !object->data.key) | 643 | if (!object || !object->data.key) { |
| 650 | { | ||
| 651 | STOREerr(STORE_F_STORE_GET_PUBLIC_KEY, | 644 | STOREerr(STORE_F_STORE_GET_PUBLIC_KEY, |
| 652 | STORE_R_FAILED_GETTING_KEY); | 645 | STORE_R_FAILED_GETTING_KEY); |
| 653 | return 0; | 646 | return 0; |
| 654 | } | 647 | } |
| 655 | CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY); | 648 | CRYPTO_add(&object->data.key->references, 1, CRYPTO_LOCK_EVP_PKEY); |
| 656 | pkey = object->data.key; | 649 | pkey = object->data.key; |
| 657 | STORE_OBJECT_free(object); | 650 | STORE_OBJECT_free(object); |
| 658 | return pkey; | 651 | return pkey; |
| 659 | } | 652 | } |
| 660 | 653 | ||
| 661 | int STORE_store_public_key(STORE *s, EVP_PKEY *data, OPENSSL_ITEM attributes[], | 654 | int |
| 662 | OPENSSL_ITEM parameters[]) | 655 | STORE_store_public_key(STORE *s, EVP_PKEY *data, OPENSSL_ITEM attributes[], |
| 663 | { | 656 | OPENSSL_ITEM parameters[]) |
| 657 | { | ||
| 664 | STORE_OBJECT *object; | 658 | STORE_OBJECT *object; |
| 665 | int i; | 659 | int i; |
| 666 | 660 | ||
| 667 | check_store(s,STORE_F_STORE_STORE_PUBLIC_KEY, | 661 | check_store(s, STORE_F_STORE_STORE_PUBLIC_KEY, |
| 668 | store_object,STORE_R_NO_STORE_OBJECT_FUNCTION); | 662 | store_object, STORE_R_NO_STORE_OBJECT_FUNCTION); |
| 669 | 663 | ||
| 670 | object = STORE_OBJECT_new(); | 664 | object = STORE_OBJECT_new(); |
| 671 | if (!object) | 665 | if (!object) { |
| 672 | { | ||
| 673 | STOREerr(STORE_F_STORE_STORE_PUBLIC_KEY, | 666 | STOREerr(STORE_F_STORE_STORE_PUBLIC_KEY, |
| 674 | ERR_R_MALLOC_FAILURE); | 667 | ERR_R_MALLOC_FAILURE); |
| 675 | return 0; | 668 | return 0; |
| 676 | } | 669 | } |
| 677 | object->data.key = EVP_PKEY_new(); | 670 | object->data.key = EVP_PKEY_new(); |
| 678 | if (!object->data.key) | 671 | if (!object->data.key) { |
| 679 | { | ||
| 680 | STOREerr(STORE_F_STORE_STORE_PUBLIC_KEY, | 672 | STOREerr(STORE_F_STORE_STORE_PUBLIC_KEY, |
| 681 | ERR_R_MALLOC_FAILURE); | 673 | ERR_R_MALLOC_FAILURE); |
| 682 | return 0; | 674 | return 0; |
| 683 | } | 675 | } |
| 684 | 676 | ||
| 685 | CRYPTO_add(&data->references,1,CRYPTO_LOCK_EVP_PKEY); | 677 | CRYPTO_add(&data->references, 1, CRYPTO_LOCK_EVP_PKEY); |
| 686 | object->data.key = data; | 678 | object->data.key = data; |
| 687 | 679 | ||
| 688 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, object, | 680 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, object, |
| 689 | attributes, parameters); | 681 | attributes, parameters); |
| 690 | 682 | ||
| 691 | STORE_OBJECT_free(object); | 683 | STORE_OBJECT_free(object); |
| 692 | 684 | ||
| 693 | if (!i) | 685 | if (!i) { |
| 694 | { | ||
| 695 | STOREerr(STORE_F_STORE_STORE_PUBLIC_KEY, | 686 | STOREerr(STORE_F_STORE_STORE_PUBLIC_KEY, |
| 696 | STORE_R_FAILED_STORING_KEY); | 687 | STORE_R_FAILED_STORING_KEY); |
| 697 | return 0; | 688 | return 0; |
| 698 | } | ||
| 699 | return i; | ||
| 700 | } | 689 | } |
| 690 | return i; | ||
| 691 | } | ||
| 701 | 692 | ||
| 702 | int STORE_modify_public_key(STORE *s, OPENSSL_ITEM search_attributes[], | 693 | int |
| 703 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | 694 | STORE_modify_public_key(STORE *s, OPENSSL_ITEM search_attributes[], |
| 704 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) | 695 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], |
| 705 | { | 696 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) |
| 706 | check_store(s,STORE_F_STORE_MODIFY_PUBLIC_KEY, | 697 | { |
| 707 | modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION); | 698 | check_store(s, STORE_F_STORE_MODIFY_PUBLIC_KEY, |
| 699 | modify_object, STORE_R_NO_MODIFY_OBJECT_FUNCTION); | ||
| 708 | 700 | ||
| 709 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, | 701 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, |
| 710 | search_attributes, add_attributes, modify_attributes, | 702 | search_attributes, add_attributes, modify_attributes, |
| 711 | delete_attributes, parameters)) | 703 | delete_attributes, parameters)) { |
| 712 | { | ||
| 713 | STOREerr(STORE_F_STORE_MODIFY_PUBLIC_KEY, | 704 | STOREerr(STORE_F_STORE_MODIFY_PUBLIC_KEY, |
| 714 | STORE_R_FAILED_MODIFYING_PUBLIC_KEY); | 705 | STORE_R_FAILED_MODIFYING_PUBLIC_KEY); |
| 715 | return 0; | 706 | return 0; |
| 716 | } | ||
| 717 | return 1; | ||
| 718 | } | 707 | } |
| 708 | return 1; | ||
| 709 | } | ||
| 719 | 710 | ||
| 720 | int STORE_revoke_public_key(STORE *s, OPENSSL_ITEM attributes[], | 711 | int |
| 721 | OPENSSL_ITEM parameters[]) | 712 | STORE_revoke_public_key(STORE *s, OPENSSL_ITEM attributes[], |
| 722 | { | 713 | OPENSSL_ITEM parameters[]) |
| 714 | { | ||
| 723 | int i; | 715 | int i; |
| 724 | 716 | ||
| 725 | check_store(s,STORE_F_STORE_REVOKE_PUBLIC_KEY, | 717 | check_store(s, STORE_F_STORE_REVOKE_PUBLIC_KEY, |
| 726 | revoke_object,STORE_R_NO_REVOKE_OBJECT_FUNCTION); | 718 | revoke_object, STORE_R_NO_REVOKE_OBJECT_FUNCTION); |
| 727 | 719 | ||
| 728 | i = s->meth->revoke_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, | 720 | i = s->meth->revoke_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, |
| 729 | attributes, parameters); | 721 | attributes, parameters); |
| 730 | 722 | ||
| 731 | if (!i) | 723 | if (!i) { |
| 732 | { | ||
| 733 | STOREerr(STORE_F_STORE_REVOKE_PUBLIC_KEY, | 724 | STOREerr(STORE_F_STORE_REVOKE_PUBLIC_KEY, |
| 734 | STORE_R_FAILED_REVOKING_KEY); | 725 | STORE_R_FAILED_REVOKING_KEY); |
| 735 | return 0; | 726 | return 0; |
| 736 | } | ||
| 737 | return i; | ||
| 738 | } | 727 | } |
| 728 | return i; | ||
| 729 | } | ||
| 730 | |||
| 731 | int | ||
| 732 | STORE_delete_public_key(STORE *s, OPENSSL_ITEM attributes[], | ||
| 733 | OPENSSL_ITEM parameters[]) | ||
| 734 | { | ||
| 735 | check_store(s, STORE_F_STORE_DELETE_PUBLIC_KEY, | ||
| 736 | delete_object, STORE_R_NO_DELETE_OBJECT_FUNCTION); | ||
| 739 | 737 | ||
| 740 | int STORE_delete_public_key(STORE *s, OPENSSL_ITEM attributes[], | ||
| 741 | OPENSSL_ITEM parameters[]) | ||
| 742 | { | ||
| 743 | check_store(s,STORE_F_STORE_DELETE_PUBLIC_KEY, | ||
| 744 | delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION); | ||
| 745 | |||
| 746 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, | 738 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, |
| 747 | attributes, parameters)) | 739 | attributes, parameters)) { |
| 748 | { | ||
| 749 | STOREerr(STORE_F_STORE_DELETE_PUBLIC_KEY, | 740 | STOREerr(STORE_F_STORE_DELETE_PUBLIC_KEY, |
| 750 | STORE_R_FAILED_DELETING_KEY); | 741 | STORE_R_FAILED_DELETING_KEY); |
| 751 | return 0; | 742 | return 0; |
| 752 | } | ||
| 753 | return 1; | ||
| 754 | } | 743 | } |
| 744 | return 1; | ||
| 745 | } | ||
| 755 | 746 | ||
| 756 | void *STORE_list_public_key_start(STORE *s, OPENSSL_ITEM attributes[], | 747 | void * |
| 757 | OPENSSL_ITEM parameters[]) | 748 | STORE_list_public_key_start(STORE *s, OPENSSL_ITEM attributes[], |
| 758 | { | 749 | OPENSSL_ITEM parameters[]) |
| 750 | { | ||
| 759 | void *handle; | 751 | void *handle; |
| 760 | 752 | ||
| 761 | check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_START, | 753 | check_store(s, STORE_F_STORE_LIST_PUBLIC_KEY_START, |
| 762 | list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION); | 754 | list_object_start, STORE_R_NO_LIST_OBJECT_START_FUNCTION); |
| 763 | 755 | ||
| 764 | handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_PUBLIC_KEY, | 756 | handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_PUBLIC_KEY, |
| 765 | attributes, parameters); | 757 | attributes, parameters); |
| 766 | if (!handle) | 758 | if (!handle) { |
| 767 | { | ||
| 768 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_START, | 759 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_START, |
| 769 | STORE_R_FAILED_LISTING_KEYS); | 760 | STORE_R_FAILED_LISTING_KEYS); |
| 770 | return 0; | 761 | return 0; |
| 771 | } | ||
| 772 | return handle; | ||
| 773 | } | 762 | } |
| 763 | return handle; | ||
| 764 | } | ||
| 774 | 765 | ||
| 775 | EVP_PKEY *STORE_list_public_key_next(STORE *s, void *handle) | 766 | EVP_PKEY * |
| 776 | { | 767 | STORE_list_public_key_next(STORE *s, void *handle) |
| 768 | { | ||
| 777 | STORE_OBJECT *object; | 769 | STORE_OBJECT *object; |
| 778 | EVP_PKEY *pkey; | 770 | EVP_PKEY *pkey; |
| 779 | 771 | ||
| 780 | check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_NEXT, | 772 | check_store(s, STORE_F_STORE_LIST_PUBLIC_KEY_NEXT, |
| 781 | list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); | 773 | list_object_next, STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); |
| 782 | 774 | ||
| 783 | object = s->meth->list_object_next(s, handle); | 775 | object = s->meth->list_object_next(s, handle); |
| 784 | if (!object || !object->data.key) | 776 | if (!object || !object->data.key) { |
| 785 | { | ||
| 786 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_NEXT, | 777 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_NEXT, |
| 787 | STORE_R_FAILED_LISTING_KEYS); | 778 | STORE_R_FAILED_LISTING_KEYS); |
| 788 | return 0; | 779 | return 0; |
| 789 | } | 780 | } |
| 790 | CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY); | 781 | CRYPTO_add(&object->data.key->references, 1, CRYPTO_LOCK_EVP_PKEY); |
| 791 | pkey = object->data.key; | 782 | pkey = object->data.key; |
| 792 | STORE_OBJECT_free(object); | 783 | STORE_OBJECT_free(object); |
| 793 | return pkey; | 784 | return pkey; |
| 794 | } | 785 | } |
| 795 | 786 | ||
| 796 | int STORE_list_public_key_end(STORE *s, void *handle) | 787 | int |
| 797 | { | 788 | STORE_list_public_key_end(STORE *s, void *handle) |
| 798 | check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_END, | 789 | { |
| 799 | list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION); | 790 | check_store(s, STORE_F_STORE_LIST_PUBLIC_KEY_END, |
| 791 | list_object_end, STORE_R_NO_LIST_OBJECT_END_FUNCTION); | ||
| 800 | 792 | ||
| 801 | if (!s->meth->list_object_end(s, handle)) | 793 | if (!s->meth->list_object_end(s, handle)) { |
| 802 | { | ||
| 803 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_END, | 794 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_END, |
| 804 | STORE_R_FAILED_LISTING_KEYS); | 795 | STORE_R_FAILED_LISTING_KEYS); |
| 805 | return 0; | 796 | return 0; |
| 806 | } | ||
| 807 | return 1; | ||
| 808 | } | 797 | } |
| 798 | return 1; | ||
| 799 | } | ||
| 809 | 800 | ||
| 810 | int STORE_list_public_key_endp(STORE *s, void *handle) | 801 | int |
| 811 | { | 802 | STORE_list_public_key_endp(STORE *s, void *handle) |
| 812 | check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_ENDP, | 803 | { |
| 813 | list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | 804 | check_store(s, STORE_F_STORE_LIST_PUBLIC_KEY_ENDP, |
| 805 | list_object_endp, STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | ||
| 814 | 806 | ||
| 815 | if (!s->meth->list_object_endp(s, handle)) | 807 | if (!s->meth->list_object_endp(s, handle)) { |
| 816 | { | ||
| 817 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_ENDP, | 808 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_ENDP, |
| 818 | STORE_R_FAILED_LISTING_KEYS); | 809 | STORE_R_FAILED_LISTING_KEYS); |
| 819 | return 0; | 810 | return 0; |
| 820 | } | ||
| 821 | return 1; | ||
| 822 | } | 811 | } |
| 812 | return 1; | ||
| 813 | } | ||
| 823 | 814 | ||
| 824 | X509_CRL *STORE_generate_crl(STORE *s, OPENSSL_ITEM attributes[], | 815 | X509_CRL * |
| 825 | OPENSSL_ITEM parameters[]) | 816 | STORE_generate_crl(STORE *s, OPENSSL_ITEM attributes[], |
| 826 | { | 817 | OPENSSL_ITEM parameters[]) |
| 818 | { | ||
| 827 | STORE_OBJECT *object; | 819 | STORE_OBJECT *object; |
| 828 | X509_CRL *crl; | 820 | X509_CRL *crl; |
| 829 | 821 | ||
| 830 | check_store(s,STORE_F_STORE_GENERATE_CRL, | 822 | check_store(s, STORE_F_STORE_GENERATE_CRL, |
| 831 | generate_object,STORE_R_NO_GENERATE_CRL_FUNCTION); | 823 | generate_object, STORE_R_NO_GENERATE_CRL_FUNCTION); |
| 832 | 824 | ||
| 833 | object = s->meth->generate_object(s, STORE_OBJECT_TYPE_X509_CRL, | 825 | object = s->meth->generate_object(s, STORE_OBJECT_TYPE_X509_CRL, |
| 834 | attributes, parameters); | 826 | attributes, parameters); |
| 835 | if (!object || !object->data.crl) | 827 | if (!object || !object->data.crl) { |
| 836 | { | ||
| 837 | STOREerr(STORE_F_STORE_GENERATE_CRL, | 828 | STOREerr(STORE_F_STORE_GENERATE_CRL, |
| 838 | STORE_R_FAILED_GENERATING_CRL); | 829 | STORE_R_FAILED_GENERATING_CRL); |
| 839 | return 0; | 830 | return 0; |
| 840 | } | 831 | } |
| 841 | CRYPTO_add(&object->data.crl->references,1,CRYPTO_LOCK_X509_CRL); | 832 | CRYPTO_add(&object->data.crl->references, 1, CRYPTO_LOCK_X509_CRL); |
| 842 | crl = object->data.crl; | 833 | crl = object->data.crl; |
| 843 | STORE_OBJECT_free(object); | 834 | STORE_OBJECT_free(object); |
| 844 | return crl; | 835 | return crl; |
| 845 | } | 836 | } |
| 846 | 837 | ||
| 847 | X509_CRL *STORE_get_crl(STORE *s, OPENSSL_ITEM attributes[], | 838 | X509_CRL * |
| 848 | OPENSSL_ITEM parameters[]) | 839 | STORE_get_crl(STORE *s, OPENSSL_ITEM attributes[], |
| 849 | { | 840 | OPENSSL_ITEM parameters[]) |
| 841 | { | ||
| 850 | STORE_OBJECT *object; | 842 | STORE_OBJECT *object; |
| 851 | X509_CRL *crl; | 843 | X509_CRL *crl; |
| 852 | 844 | ||
| 853 | check_store(s,STORE_F_STORE_GET_CRL, | 845 | check_store(s, STORE_F_STORE_GET_CRL, |
| 854 | get_object,STORE_R_NO_GET_OBJECT_FUNCTION); | 846 | get_object, STORE_R_NO_GET_OBJECT_FUNCTION); |
| 855 | 847 | ||
| 856 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_X509_CRL, | 848 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_X509_CRL, |
| 857 | attributes, parameters); | 849 | attributes, parameters); |
| 858 | if (!object || !object->data.crl) | 850 | if (!object || !object->data.crl) { |
| 859 | { | ||
| 860 | STOREerr(STORE_F_STORE_GET_CRL, | 851 | STOREerr(STORE_F_STORE_GET_CRL, |
| 861 | STORE_R_FAILED_GETTING_KEY); | 852 | STORE_R_FAILED_GETTING_KEY); |
| 862 | return 0; | 853 | return 0; |
| 863 | } | 854 | } |
| 864 | CRYPTO_add(&object->data.crl->references,1,CRYPTO_LOCK_X509_CRL); | 855 | CRYPTO_add(&object->data.crl->references, 1, CRYPTO_LOCK_X509_CRL); |
| 865 | crl = object->data.crl; | 856 | crl = object->data.crl; |
| 866 | STORE_OBJECT_free(object); | 857 | STORE_OBJECT_free(object); |
| 867 | return crl; | 858 | return crl; |
| 868 | } | 859 | } |
| 869 | 860 | ||
| 870 | int STORE_store_crl(STORE *s, X509_CRL *data, OPENSSL_ITEM attributes[], | 861 | int |
| 871 | OPENSSL_ITEM parameters[]) | 862 | STORE_store_crl(STORE *s, X509_CRL *data, OPENSSL_ITEM attributes[], |
| 872 | { | 863 | OPENSSL_ITEM parameters[]) |
| 864 | { | ||
| 873 | STORE_OBJECT *object; | 865 | STORE_OBJECT *object; |
| 874 | int i; | 866 | int i; |
| 875 | 867 | ||
| 876 | check_store(s,STORE_F_STORE_STORE_CRL, | 868 | check_store(s, STORE_F_STORE_STORE_CRL, |
| 877 | store_object,STORE_R_NO_STORE_OBJECT_FUNCTION); | 869 | store_object, STORE_R_NO_STORE_OBJECT_FUNCTION); |
| 878 | 870 | ||
| 879 | object = STORE_OBJECT_new(); | 871 | object = STORE_OBJECT_new(); |
| 880 | if (!object) | 872 | if (!object) { |
| 881 | { | ||
| 882 | STOREerr(STORE_F_STORE_STORE_CRL, | 873 | STOREerr(STORE_F_STORE_STORE_CRL, |
| 883 | ERR_R_MALLOC_FAILURE); | 874 | ERR_R_MALLOC_FAILURE); |
| 884 | return 0; | 875 | return 0; |
| 885 | } | 876 | } |
| 886 | 877 | ||
| 887 | CRYPTO_add(&data->references,1,CRYPTO_LOCK_X509_CRL); | 878 | CRYPTO_add(&data->references, 1, CRYPTO_LOCK_X509_CRL); |
| 888 | object->data.crl = data; | 879 | object->data.crl = data; |
| 889 | 880 | ||
| 890 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_X509_CRL, object, | 881 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_X509_CRL, object, |
| 891 | attributes, parameters); | 882 | attributes, parameters); |
| 892 | 883 | ||
| 893 | STORE_OBJECT_free(object); | 884 | STORE_OBJECT_free(object); |
| 894 | 885 | ||
| 895 | if (!i) | 886 | if (!i) { |
| 896 | { | ||
| 897 | STOREerr(STORE_F_STORE_STORE_CRL, | 887 | STOREerr(STORE_F_STORE_STORE_CRL, |
| 898 | STORE_R_FAILED_STORING_KEY); | 888 | STORE_R_FAILED_STORING_KEY); |
| 899 | return 0; | 889 | return 0; |
| 900 | } | ||
| 901 | return i; | ||
| 902 | } | 890 | } |
| 891 | return i; | ||
| 892 | } | ||
| 903 | 893 | ||
| 904 | int STORE_modify_crl(STORE *s, OPENSSL_ITEM search_attributes[], | 894 | int |
| 905 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | 895 | STORE_modify_crl(STORE *s, OPENSSL_ITEM search_attributes[], |
| 906 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) | 896 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], |
| 907 | { | 897 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) |
| 908 | check_store(s,STORE_F_STORE_MODIFY_CRL, | 898 | { |
| 909 | modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION); | 899 | check_store(s, STORE_F_STORE_MODIFY_CRL, |
| 900 | modify_object, STORE_R_NO_MODIFY_OBJECT_FUNCTION); | ||
| 910 | 901 | ||
| 911 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_X509_CRL, | 902 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_X509_CRL, |
| 912 | search_attributes, add_attributes, modify_attributes, | 903 | search_attributes, add_attributes, modify_attributes, |
| 913 | delete_attributes, parameters)) | 904 | delete_attributes, parameters)) { |
| 914 | { | ||
| 915 | STOREerr(STORE_F_STORE_MODIFY_CRL, | 905 | STOREerr(STORE_F_STORE_MODIFY_CRL, |
| 916 | STORE_R_FAILED_MODIFYING_CRL); | 906 | STORE_R_FAILED_MODIFYING_CRL); |
| 917 | return 0; | 907 | return 0; |
| 918 | } | ||
| 919 | return 1; | ||
| 920 | } | 908 | } |
| 909 | return 1; | ||
| 910 | } | ||
| 911 | |||
| 912 | int | ||
| 913 | STORE_delete_crl(STORE *s, OPENSSL_ITEM attributes[], | ||
| 914 | OPENSSL_ITEM parameters[]) | ||
| 915 | { | ||
| 916 | check_store(s, STORE_F_STORE_DELETE_CRL, | ||
| 917 | delete_object, STORE_R_NO_DELETE_OBJECT_FUNCTION); | ||
| 921 | 918 | ||
| 922 | int STORE_delete_crl(STORE *s, OPENSSL_ITEM attributes[], | ||
| 923 | OPENSSL_ITEM parameters[]) | ||
| 924 | { | ||
| 925 | check_store(s,STORE_F_STORE_DELETE_CRL, | ||
| 926 | delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION); | ||
| 927 | |||
| 928 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_X509_CRL, | 919 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_X509_CRL, |
| 929 | attributes, parameters)) | 920 | attributes, parameters)) { |
| 930 | { | ||
| 931 | STOREerr(STORE_F_STORE_DELETE_CRL, | 921 | STOREerr(STORE_F_STORE_DELETE_CRL, |
| 932 | STORE_R_FAILED_DELETING_KEY); | 922 | STORE_R_FAILED_DELETING_KEY); |
| 933 | return 0; | 923 | return 0; |
| 934 | } | ||
| 935 | return 1; | ||
| 936 | } | 924 | } |
| 925 | return 1; | ||
| 926 | } | ||
| 937 | 927 | ||
| 938 | void *STORE_list_crl_start(STORE *s, OPENSSL_ITEM attributes[], | 928 | void * |
| 939 | OPENSSL_ITEM parameters[]) | 929 | STORE_list_crl_start(STORE *s, OPENSSL_ITEM attributes[], |
| 940 | { | 930 | OPENSSL_ITEM parameters[]) |
| 931 | { | ||
| 941 | void *handle; | 932 | void *handle; |
| 942 | 933 | ||
| 943 | check_store(s,STORE_F_STORE_LIST_CRL_START, | 934 | check_store(s, STORE_F_STORE_LIST_CRL_START, |
| 944 | list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION); | 935 | list_object_start, STORE_R_NO_LIST_OBJECT_START_FUNCTION); |
| 945 | 936 | ||
| 946 | handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_X509_CRL, | 937 | handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_X509_CRL, |
| 947 | attributes, parameters); | 938 | attributes, parameters); |
| 948 | if (!handle) | 939 | if (!handle) { |
| 949 | { | ||
| 950 | STOREerr(STORE_F_STORE_LIST_CRL_START, | 940 | STOREerr(STORE_F_STORE_LIST_CRL_START, |
| 951 | STORE_R_FAILED_LISTING_KEYS); | 941 | STORE_R_FAILED_LISTING_KEYS); |
| 952 | return 0; | 942 | return 0; |
| 953 | } | ||
| 954 | return handle; | ||
| 955 | } | 943 | } |
| 944 | return handle; | ||
| 945 | } | ||
| 956 | 946 | ||
| 957 | X509_CRL *STORE_list_crl_next(STORE *s, void *handle) | 947 | X509_CRL * |
| 958 | { | 948 | STORE_list_crl_next(STORE *s, void *handle) |
| 949 | { | ||
| 959 | STORE_OBJECT *object; | 950 | STORE_OBJECT *object; |
| 960 | X509_CRL *crl; | 951 | X509_CRL *crl; |
| 961 | 952 | ||
| 962 | check_store(s,STORE_F_STORE_LIST_CRL_NEXT, | 953 | check_store(s, STORE_F_STORE_LIST_CRL_NEXT, |
| 963 | list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); | 954 | list_object_next, STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); |
| 964 | 955 | ||
| 965 | object = s->meth->list_object_next(s, handle); | 956 | object = s->meth->list_object_next(s, handle); |
| 966 | if (!object || !object->data.crl) | 957 | if (!object || !object->data.crl) { |
| 967 | { | ||
| 968 | STOREerr(STORE_F_STORE_LIST_CRL_NEXT, | 958 | STOREerr(STORE_F_STORE_LIST_CRL_NEXT, |
| 969 | STORE_R_FAILED_LISTING_KEYS); | 959 | STORE_R_FAILED_LISTING_KEYS); |
| 970 | return 0; | 960 | return 0; |
| 971 | } | 961 | } |
| 972 | CRYPTO_add(&object->data.crl->references,1,CRYPTO_LOCK_X509_CRL); | 962 | CRYPTO_add(&object->data.crl->references, 1, CRYPTO_LOCK_X509_CRL); |
| 973 | crl = object->data.crl; | 963 | crl = object->data.crl; |
| 974 | STORE_OBJECT_free(object); | 964 | STORE_OBJECT_free(object); |
| 975 | return crl; | 965 | return crl; |
| 976 | } | 966 | } |
| 977 | 967 | ||
| 978 | int STORE_list_crl_end(STORE *s, void *handle) | 968 | int |
| 979 | { | 969 | STORE_list_crl_end(STORE *s, void *handle) |
| 980 | check_store(s,STORE_F_STORE_LIST_CRL_END, | 970 | { |
| 981 | list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION); | 971 | check_store(s, STORE_F_STORE_LIST_CRL_END, |
| 972 | list_object_end, STORE_R_NO_LIST_OBJECT_END_FUNCTION); | ||
| 982 | 973 | ||
| 983 | if (!s->meth->list_object_end(s, handle)) | 974 | if (!s->meth->list_object_end(s, handle)) { |
| 984 | { | ||
| 985 | STOREerr(STORE_F_STORE_LIST_CRL_END, | 975 | STOREerr(STORE_F_STORE_LIST_CRL_END, |
| 986 | STORE_R_FAILED_LISTING_KEYS); | 976 | STORE_R_FAILED_LISTING_KEYS); |
| 987 | return 0; | 977 | return 0; |
| 988 | } | ||
| 989 | return 1; | ||
| 990 | } | 978 | } |
| 979 | return 1; | ||
| 980 | } | ||
| 991 | 981 | ||
| 992 | int STORE_list_crl_endp(STORE *s, void *handle) | 982 | int |
| 993 | { | 983 | STORE_list_crl_endp(STORE *s, void *handle) |
| 994 | check_store(s,STORE_F_STORE_LIST_CRL_ENDP, | 984 | { |
| 995 | list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | 985 | check_store(s, STORE_F_STORE_LIST_CRL_ENDP, |
| 986 | list_object_endp, STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | ||
| 996 | 987 | ||
| 997 | if (!s->meth->list_object_endp(s, handle)) | 988 | if (!s->meth->list_object_endp(s, handle)) { |
| 998 | { | ||
| 999 | STOREerr(STORE_F_STORE_LIST_CRL_ENDP, | 989 | STOREerr(STORE_F_STORE_LIST_CRL_ENDP, |
| 1000 | STORE_R_FAILED_LISTING_KEYS); | 990 | STORE_R_FAILED_LISTING_KEYS); |
| 1001 | return 0; | 991 | return 0; |
| 1002 | } | ||
| 1003 | return 1; | ||
| 1004 | } | 992 | } |
| 993 | return 1; | ||
| 994 | } | ||
| 1005 | 995 | ||
| 1006 | int STORE_store_number(STORE *s, BIGNUM *data, OPENSSL_ITEM attributes[], | 996 | int |
| 1007 | OPENSSL_ITEM parameters[]) | 997 | STORE_store_number(STORE *s, BIGNUM *data, OPENSSL_ITEM attributes[], |
| 1008 | { | 998 | OPENSSL_ITEM parameters[]) |
| 999 | { | ||
| 1009 | STORE_OBJECT *object; | 1000 | STORE_OBJECT *object; |
| 1010 | int i; | 1001 | int i; |
| 1011 | 1002 | ||
| 1012 | check_store(s,STORE_F_STORE_STORE_NUMBER, | 1003 | check_store(s, STORE_F_STORE_STORE_NUMBER, |
| 1013 | store_object,STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION); | 1004 | store_object, STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION); |
| 1014 | 1005 | ||
| 1015 | object = STORE_OBJECT_new(); | 1006 | object = STORE_OBJECT_new(); |
| 1016 | if (!object) | 1007 | if (!object) { |
| 1017 | { | ||
| 1018 | STOREerr(STORE_F_STORE_STORE_NUMBER, | 1008 | STOREerr(STORE_F_STORE_STORE_NUMBER, |
| 1019 | ERR_R_MALLOC_FAILURE); | 1009 | ERR_R_MALLOC_FAILURE); |
| 1020 | return 0; | 1010 | return 0; |
| 1021 | } | 1011 | } |
| 1022 | 1012 | ||
| 1023 | object->data.number = data; | 1013 | object->data.number = data; |
| 1024 | 1014 | ||
| 1025 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_NUMBER, object, | 1015 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_NUMBER, object, |
| 1026 | attributes, parameters); | 1016 | attributes, parameters); |
| 1027 | 1017 | ||
| 1028 | STORE_OBJECT_free(object); | 1018 | STORE_OBJECT_free(object); |
| 1029 | 1019 | ||
| 1030 | if (!i) | 1020 | if (!i) { |
| 1031 | { | ||
| 1032 | STOREerr(STORE_F_STORE_STORE_NUMBER, | 1021 | STOREerr(STORE_F_STORE_STORE_NUMBER, |
| 1033 | STORE_R_FAILED_STORING_NUMBER); | 1022 | STORE_R_FAILED_STORING_NUMBER); |
| 1034 | return 0; | 1023 | return 0; |
| 1035 | } | ||
| 1036 | return 1; | ||
| 1037 | } | 1024 | } |
| 1025 | return 1; | ||
| 1026 | } | ||
| 1038 | 1027 | ||
| 1039 | int STORE_modify_number(STORE *s, OPENSSL_ITEM search_attributes[], | 1028 | int |
| 1040 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | 1029 | STORE_modify_number(STORE *s, OPENSSL_ITEM search_attributes[], |
| 1041 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) | 1030 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], |
| 1042 | { | 1031 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) |
| 1043 | check_store(s,STORE_F_STORE_MODIFY_NUMBER, | 1032 | { |
| 1044 | modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION); | 1033 | check_store(s, STORE_F_STORE_MODIFY_NUMBER, |
| 1034 | modify_object, STORE_R_NO_MODIFY_OBJECT_FUNCTION); | ||
| 1045 | 1035 | ||
| 1046 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_NUMBER, | 1036 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_NUMBER, |
| 1047 | search_attributes, add_attributes, modify_attributes, | 1037 | search_attributes, add_attributes, modify_attributes, |
| 1048 | delete_attributes, parameters)) | 1038 | delete_attributes, parameters)) { |
| 1049 | { | ||
| 1050 | STOREerr(STORE_F_STORE_MODIFY_NUMBER, | 1039 | STOREerr(STORE_F_STORE_MODIFY_NUMBER, |
| 1051 | STORE_R_FAILED_MODIFYING_NUMBER); | 1040 | STORE_R_FAILED_MODIFYING_NUMBER); |
| 1052 | return 0; | 1041 | return 0; |
| 1053 | } | ||
| 1054 | return 1; | ||
| 1055 | } | 1042 | } |
| 1043 | return 1; | ||
| 1044 | } | ||
| 1056 | 1045 | ||
| 1057 | BIGNUM *STORE_get_number(STORE *s, OPENSSL_ITEM attributes[], | 1046 | BIGNUM * |
| 1058 | OPENSSL_ITEM parameters[]) | 1047 | STORE_get_number(STORE *s, OPENSSL_ITEM attributes[], |
| 1059 | { | 1048 | OPENSSL_ITEM parameters[]) |
| 1049 | { | ||
| 1060 | STORE_OBJECT *object; | 1050 | STORE_OBJECT *object; |
| 1061 | BIGNUM *n; | 1051 | BIGNUM *n; |
| 1062 | 1052 | ||
| 1063 | check_store(s,STORE_F_STORE_GET_NUMBER, | 1053 | check_store(s, STORE_F_STORE_GET_NUMBER, |
| 1064 | get_object,STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION); | 1054 | get_object, STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION); |
| 1065 | 1055 | ||
| 1066 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_NUMBER, attributes, | 1056 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_NUMBER, attributes, |
| 1067 | parameters); | 1057 | parameters); |
| 1068 | if (!object || !object->data.number) | 1058 | if (!object || !object->data.number) { |
| 1069 | { | ||
| 1070 | STOREerr(STORE_F_STORE_GET_NUMBER, | 1059 | STOREerr(STORE_F_STORE_GET_NUMBER, |
| 1071 | STORE_R_FAILED_GETTING_NUMBER); | 1060 | STORE_R_FAILED_GETTING_NUMBER); |
| 1072 | return 0; | 1061 | return 0; |
| 1073 | } | 1062 | } |
| 1074 | n = object->data.number; | 1063 | n = object->data.number; |
| 1075 | object->data.number = NULL; | 1064 | object->data.number = NULL; |
| 1076 | STORE_OBJECT_free(object); | 1065 | STORE_OBJECT_free(object); |
| 1077 | return n; | 1066 | return n; |
| 1078 | } | 1067 | } |
| 1079 | 1068 | ||
| 1080 | int STORE_delete_number(STORE *s, OPENSSL_ITEM attributes[], | 1069 | int |
| 1081 | OPENSSL_ITEM parameters[]) | 1070 | STORE_delete_number(STORE *s, OPENSSL_ITEM attributes[], |
| 1082 | { | 1071 | OPENSSL_ITEM parameters[]) |
| 1083 | check_store(s,STORE_F_STORE_DELETE_NUMBER, | 1072 | { |
| 1084 | delete_object,STORE_R_NO_DELETE_NUMBER_FUNCTION); | 1073 | check_store(s, STORE_F_STORE_DELETE_NUMBER, |
| 1074 | delete_object, STORE_R_NO_DELETE_NUMBER_FUNCTION); | ||
| 1085 | 1075 | ||
| 1086 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_NUMBER, attributes, | 1076 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_NUMBER, attributes, |
| 1087 | parameters)) | 1077 | parameters)) { |
| 1088 | { | ||
| 1089 | STOREerr(STORE_F_STORE_DELETE_NUMBER, | 1078 | STOREerr(STORE_F_STORE_DELETE_NUMBER, |
| 1090 | STORE_R_FAILED_DELETING_NUMBER); | 1079 | STORE_R_FAILED_DELETING_NUMBER); |
| 1091 | return 0; | 1080 | return 0; |
| 1092 | } | ||
| 1093 | return 1; | ||
| 1094 | } | 1081 | } |
| 1082 | return 1; | ||
| 1083 | } | ||
| 1095 | 1084 | ||
| 1096 | int STORE_store_arbitrary(STORE *s, BUF_MEM *data, OPENSSL_ITEM attributes[], | 1085 | int |
| 1097 | OPENSSL_ITEM parameters[]) | 1086 | STORE_store_arbitrary(STORE *s, BUF_MEM *data, OPENSSL_ITEM attributes[], |
| 1098 | { | 1087 | OPENSSL_ITEM parameters[]) |
| 1088 | { | ||
| 1099 | STORE_OBJECT *object; | 1089 | STORE_OBJECT *object; |
| 1100 | int i; | 1090 | int i; |
| 1101 | 1091 | ||
| 1102 | check_store(s,STORE_F_STORE_STORE_ARBITRARY, | 1092 | check_store(s, STORE_F_STORE_STORE_ARBITRARY, |
| 1103 | store_object,STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION); | 1093 | store_object, STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION); |
| 1104 | 1094 | ||
| 1105 | object = STORE_OBJECT_new(); | 1095 | object = STORE_OBJECT_new(); |
| 1106 | if (!object) | 1096 | if (!object) { |
| 1107 | { | ||
| 1108 | STOREerr(STORE_F_STORE_STORE_ARBITRARY, | 1097 | STOREerr(STORE_F_STORE_STORE_ARBITRARY, |
| 1109 | ERR_R_MALLOC_FAILURE); | 1098 | ERR_R_MALLOC_FAILURE); |
| 1110 | return 0; | 1099 | return 0; |
| 1111 | } | 1100 | } |
| 1112 | 1101 | ||
| 1113 | object->data.arbitrary = data; | 1102 | object->data.arbitrary = data; |
| 1114 | 1103 | ||
| 1115 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_ARBITRARY, object, | 1104 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_ARBITRARY, object, |
| 1116 | attributes, parameters); | 1105 | attributes, parameters); |
| 1117 | 1106 | ||
| 1118 | STORE_OBJECT_free(object); | 1107 | STORE_OBJECT_free(object); |
| 1119 | 1108 | ||
| 1120 | if (!i) | 1109 | if (!i) { |
| 1121 | { | ||
| 1122 | STOREerr(STORE_F_STORE_STORE_ARBITRARY, | 1110 | STOREerr(STORE_F_STORE_STORE_ARBITRARY, |
| 1123 | STORE_R_FAILED_STORING_ARBITRARY); | 1111 | STORE_R_FAILED_STORING_ARBITRARY); |
| 1124 | return 0; | 1112 | return 0; |
| 1125 | } | ||
| 1126 | return 1; | ||
| 1127 | } | 1113 | } |
| 1114 | return 1; | ||
| 1115 | } | ||
| 1128 | 1116 | ||
| 1129 | int STORE_modify_arbitrary(STORE *s, OPENSSL_ITEM search_attributes[], | 1117 | int |
| 1130 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | 1118 | STORE_modify_arbitrary(STORE *s, OPENSSL_ITEM search_attributes[], |
| 1131 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) | 1119 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], |
| 1132 | { | 1120 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) |
| 1133 | check_store(s,STORE_F_STORE_MODIFY_ARBITRARY, | 1121 | { |
| 1134 | modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION); | 1122 | check_store(s, STORE_F_STORE_MODIFY_ARBITRARY, |
| 1123 | modify_object, STORE_R_NO_MODIFY_OBJECT_FUNCTION); | ||
| 1135 | 1124 | ||
| 1136 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_ARBITRARY, | 1125 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_ARBITRARY, |
| 1137 | search_attributes, add_attributes, modify_attributes, | 1126 | search_attributes, add_attributes, modify_attributes, |
| 1138 | delete_attributes, parameters)) | 1127 | delete_attributes, parameters)) { |
| 1139 | { | ||
| 1140 | STOREerr(STORE_F_STORE_MODIFY_ARBITRARY, | 1128 | STOREerr(STORE_F_STORE_MODIFY_ARBITRARY, |
| 1141 | STORE_R_FAILED_MODIFYING_ARBITRARY); | 1129 | STORE_R_FAILED_MODIFYING_ARBITRARY); |
| 1142 | return 0; | 1130 | return 0; |
| 1143 | } | ||
| 1144 | return 1; | ||
| 1145 | } | 1131 | } |
| 1132 | return 1; | ||
| 1133 | } | ||
| 1146 | 1134 | ||
| 1147 | BUF_MEM *STORE_get_arbitrary(STORE *s, OPENSSL_ITEM attributes[], | 1135 | BUF_MEM * |
| 1148 | OPENSSL_ITEM parameters[]) | 1136 | STORE_get_arbitrary(STORE *s, OPENSSL_ITEM attributes[], |
| 1149 | { | 1137 | OPENSSL_ITEM parameters[]) |
| 1138 | { | ||
| 1150 | STORE_OBJECT *object; | 1139 | STORE_OBJECT *object; |
| 1151 | BUF_MEM *b; | 1140 | BUF_MEM *b; |
| 1152 | 1141 | ||
| 1153 | check_store(s,STORE_F_STORE_GET_ARBITRARY, | 1142 | check_store(s, STORE_F_STORE_GET_ARBITRARY, |
| 1154 | get_object,STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION); | 1143 | get_object, STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION); |
| 1155 | 1144 | ||
| 1156 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_ARBITRARY, | 1145 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_ARBITRARY, |
| 1157 | attributes, parameters); | 1146 | attributes, parameters); |
| 1158 | if (!object || !object->data.arbitrary) | 1147 | if (!object || !object->data.arbitrary) { |
| 1159 | { | ||
| 1160 | STOREerr(STORE_F_STORE_GET_ARBITRARY, | 1148 | STOREerr(STORE_F_STORE_GET_ARBITRARY, |
| 1161 | STORE_R_FAILED_GETTING_ARBITRARY); | 1149 | STORE_R_FAILED_GETTING_ARBITRARY); |
| 1162 | return 0; | 1150 | return 0; |
| 1163 | } | 1151 | } |
| 1164 | b = object->data.arbitrary; | 1152 | b = object->data.arbitrary; |
| 1165 | object->data.arbitrary = NULL; | 1153 | object->data.arbitrary = NULL; |
| 1166 | STORE_OBJECT_free(object); | 1154 | STORE_OBJECT_free(object); |
| 1167 | return b; | 1155 | return b; |
| 1168 | } | 1156 | } |
| 1169 | 1157 | ||
| 1170 | int STORE_delete_arbitrary(STORE *s, OPENSSL_ITEM attributes[], | 1158 | int |
| 1171 | OPENSSL_ITEM parameters[]) | 1159 | STORE_delete_arbitrary(STORE *s, OPENSSL_ITEM attributes[], |
| 1172 | { | 1160 | OPENSSL_ITEM parameters[]) |
| 1173 | check_store(s,STORE_F_STORE_DELETE_ARBITRARY, | 1161 | { |
| 1174 | delete_object,STORE_R_NO_DELETE_ARBITRARY_FUNCTION); | 1162 | check_store(s, STORE_F_STORE_DELETE_ARBITRARY, |
| 1163 | delete_object, STORE_R_NO_DELETE_ARBITRARY_FUNCTION); | ||
| 1175 | 1164 | ||
| 1176 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_ARBITRARY, attributes, | 1165 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_ARBITRARY, attributes, |
| 1177 | parameters)) | 1166 | parameters)) { |
| 1178 | { | ||
| 1179 | STOREerr(STORE_F_STORE_DELETE_ARBITRARY, | 1167 | STOREerr(STORE_F_STORE_DELETE_ARBITRARY, |
| 1180 | STORE_R_FAILED_DELETING_ARBITRARY); | 1168 | STORE_R_FAILED_DELETING_ARBITRARY); |
| 1181 | return 0; | 1169 | return 0; |
| 1182 | } | ||
| 1183 | return 1; | ||
| 1184 | } | 1170 | } |
| 1171 | return 1; | ||
| 1172 | } | ||
| 1185 | 1173 | ||
| 1186 | STORE_OBJECT *STORE_OBJECT_new(void) | 1174 | STORE_OBJECT * |
| 1187 | { | 1175 | STORE_OBJECT_new(void) |
| 1176 | { | ||
| 1188 | STORE_OBJECT *object = malloc(sizeof(STORE_OBJECT)); | 1177 | STORE_OBJECT *object = malloc(sizeof(STORE_OBJECT)); |
| 1189 | if (object) memset(object, 0, sizeof(STORE_OBJECT)); | 1178 | |
| 1179 | if (object) | ||
| 1180 | memset(object, 0, sizeof(STORE_OBJECT)); | ||
| 1190 | return object; | 1181 | return object; |
| 1191 | } | 1182 | } |
| 1192 | void STORE_OBJECT_free(STORE_OBJECT *data) | 1183 | |
| 1193 | { | 1184 | void |
| 1194 | if (!data) return; | 1185 | STORE_OBJECT_free(STORE_OBJECT *data) |
| 1195 | switch (data->type) | 1186 | { |
| 1196 | { | 1187 | if (!data) |
| 1188 | return; | ||
| 1189 | switch (data->type) { | ||
| 1197 | case STORE_OBJECT_TYPE_X509_CERTIFICATE: | 1190 | case STORE_OBJECT_TYPE_X509_CERTIFICATE: |
| 1198 | X509_free(data->data.x509.certificate); | 1191 | X509_free(data->data.x509.certificate); |
| 1199 | break; | 1192 | break; |
| @@ -1210,43 +1203,42 @@ void STORE_OBJECT_free(STORE_OBJECT *data) | |||
| 1210 | case STORE_OBJECT_TYPE_ARBITRARY: | 1203 | case STORE_OBJECT_TYPE_ARBITRARY: |
| 1211 | BUF_MEM_free(data->data.arbitrary); | 1204 | BUF_MEM_free(data->data.arbitrary); |
| 1212 | break; | 1205 | break; |
| 1213 | } | ||
| 1214 | free(data); | ||
| 1215 | } | 1206 | } |
| 1207 | free(data); | ||
| 1208 | } | ||
| 1216 | 1209 | ||
| 1217 | IMPLEMENT_STACK_OF(STORE_OBJECT*) | 1210 | IMPLEMENT_STACK_OF(STORE_OBJECT*) |
| 1218 | 1211 | ||
| 1219 | 1212 | ||
| 1220 | struct STORE_attr_info_st | 1213 | struct STORE_attr_info_st { |
| 1221 | { | ||
| 1222 | unsigned char set[(STORE_ATTR_TYPE_NUM + 8) / 8]; | 1214 | unsigned char set[(STORE_ATTR_TYPE_NUM + 8) / 8]; |
| 1223 | union | 1215 | union { |
| 1224 | { | ||
| 1225 | char *cstring; | 1216 | char *cstring; |
| 1226 | unsigned char *sha1string; | 1217 | unsigned char *sha1string; |
| 1227 | X509_NAME *dn; | 1218 | X509_NAME *dn; |
| 1228 | BIGNUM *number; | 1219 | BIGNUM *number; |
| 1229 | void *any; | 1220 | void *any; |
| 1230 | } values[STORE_ATTR_TYPE_NUM+1]; | 1221 | } values[STORE_ATTR_TYPE_NUM + 1]; |
| 1231 | size_t value_sizes[STORE_ATTR_TYPE_NUM+1]; | 1222 | size_t value_sizes[STORE_ATTR_TYPE_NUM + 1]; |
| 1232 | }; | 1223 | }; |
| 1233 | 1224 | ||
| 1234 | #define ATTR_IS_SET(a,i) ((i) > 0 && (i) < STORE_ATTR_TYPE_NUM \ | 1225 | #define ATTR_IS_SET(a,i) ((i) > 0 && (i) < STORE_ATTR_TYPE_NUM \ |
| 1235 | && ((a)->set[(i) / 8] & (1 << ((i) % 8)))) | 1226 | && ((a)->set[(i) / 8] & (1 << ((i) % 8)))) |
| 1236 | #define SET_ATTRBIT(a,i) ((a)->set[(i) / 8] |= (1 << ((i) % 8))) | 1227 | #define SET_ATTRBIT(a,i) ((a)->set[(i) / 8] |= (1 << ((i) % 8))) |
| 1237 | #define CLEAR_ATTRBIT(a,i) ((a)->set[(i) / 8] &= ~(1 << ((i) % 8))) | 1228 | #define CLEAR_ATTRBIT(a,i) ((a)->set[(i) / 8] &= ~(1 << ((i) % 8))) |
| 1238 | 1229 | ||
| 1239 | STORE_ATTR_INFO *STORE_ATTR_INFO_new(void) | 1230 | STORE_ATTR_INFO * |
| 1240 | { | 1231 | STORE_ATTR_INFO_new(void) |
| 1232 | { | ||
| 1241 | return (STORE_ATTR_INFO *)malloc(sizeof(STORE_ATTR_INFO)); | 1233 | return (STORE_ATTR_INFO *)malloc(sizeof(STORE_ATTR_INFO)); |
| 1242 | } | 1234 | } |
| 1243 | static void STORE_ATTR_INFO_attr_free(STORE_ATTR_INFO *attrs, | 1235 | |
| 1244 | STORE_ATTR_TYPES code) | 1236 | static void |
| 1245 | { | 1237 | STORE_ATTR_INFO_attr_free(STORE_ATTR_INFO *attrs, |
| 1246 | if (ATTR_IS_SET(attrs,code)) | 1238 | STORE_ATTR_TYPES code) |
| 1247 | { | 1239 | { |
| 1248 | switch(code) | 1240 | if (ATTR_IS_SET(attrs, code)) { |
| 1249 | { | 1241 | switch (code) { |
| 1250 | case STORE_ATTR_FRIENDLYNAME: | 1242 | case STORE_ATTR_FRIENDLYNAME: |
| 1251 | case STORE_ATTR_EMAIL: | 1243 | case STORE_ATTR_EMAIL: |
| 1252 | case STORE_ATTR_FILENAME: | 1244 | case STORE_ATTR_FILENAME: |
| @@ -1268,492 +1260,538 @@ static void STORE_ATTR_INFO_attr_free(STORE_ATTR_INFO *attrs, | |||
| 1268 | break; | 1260 | break; |
| 1269 | default: | 1261 | default: |
| 1270 | break; | 1262 | break; |
| 1271 | } | ||
| 1272 | } | 1263 | } |
| 1273 | } | 1264 | } |
| 1274 | int STORE_ATTR_INFO_free(STORE_ATTR_INFO *attrs) | 1265 | } |
| 1275 | { | 1266 | |
| 1276 | if (attrs) | 1267 | int |
| 1277 | { | 1268 | STORE_ATTR_INFO_free(STORE_ATTR_INFO *attrs) |
| 1269 | { | ||
| 1270 | if (attrs) { | ||
| 1278 | STORE_ATTR_TYPES i; | 1271 | STORE_ATTR_TYPES i; |
| 1279 | for(i = 0; i++ < STORE_ATTR_TYPE_NUM;) | 1272 | for (i = 0; i++ < STORE_ATTR_TYPE_NUM; ) |
| 1280 | STORE_ATTR_INFO_attr_free(attrs, i); | 1273 | STORE_ATTR_INFO_attr_free(attrs, i); |
| 1281 | free(attrs); | 1274 | free(attrs); |
| 1282 | } | ||
| 1283 | return 1; | ||
| 1284 | } | 1275 | } |
| 1285 | char *STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code) | 1276 | return 1; |
| 1286 | { | 1277 | } |
| 1287 | if (!attrs) | 1278 | |
| 1288 | { | 1279 | char * |
| 1280 | STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code) | ||
| 1281 | { | ||
| 1282 | if (!attrs) { | ||
| 1289 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_CSTR, | 1283 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_CSTR, |
| 1290 | ERR_R_PASSED_NULL_PARAMETER); | 1284 | ERR_R_PASSED_NULL_PARAMETER); |
| 1291 | return NULL; | 1285 | return NULL; |
| 1292 | } | 1286 | } |
| 1293 | if (ATTR_IS_SET(attrs,code)) | 1287 | if (ATTR_IS_SET(attrs, code)) |
| 1294 | return attrs->values[code].cstring; | 1288 | return attrs->values[code].cstring; |
| 1295 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_CSTR, | 1289 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_CSTR, STORE_R_NO_VALUE); |
| 1296 | STORE_R_NO_VALUE); | ||
| 1297 | return NULL; | 1290 | return NULL; |
| 1298 | } | 1291 | } |
| 1299 | unsigned char *STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs, | 1292 | |
| 1300 | STORE_ATTR_TYPES code) | 1293 | unsigned char * |
| 1301 | { | 1294 | STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code) |
| 1302 | if (!attrs) | 1295 | { |
| 1303 | { | 1296 | if (!attrs) { |
| 1304 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_SHA1STR, | 1297 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_SHA1STR, |
| 1305 | ERR_R_PASSED_NULL_PARAMETER); | 1298 | ERR_R_PASSED_NULL_PARAMETER); |
| 1306 | return NULL; | 1299 | return NULL; |
| 1307 | } | 1300 | } |
| 1308 | if (ATTR_IS_SET(attrs,code)) | 1301 | if (ATTR_IS_SET(attrs, code)) |
| 1309 | return attrs->values[code].sha1string; | 1302 | return attrs->values[code].sha1string; |
| 1310 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_SHA1STR, | 1303 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_SHA1STR, STORE_R_NO_VALUE); |
| 1311 | STORE_R_NO_VALUE); | ||
| 1312 | return NULL; | 1304 | return NULL; |
| 1313 | } | 1305 | } |
| 1314 | X509_NAME *STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code) | 1306 | |
| 1315 | { | 1307 | X509_NAME * |
| 1316 | if (!attrs) | 1308 | STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code) |
| 1317 | { | 1309 | { |
| 1310 | if (!attrs) { | ||
| 1318 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_DN, | 1311 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_DN, |
| 1319 | ERR_R_PASSED_NULL_PARAMETER); | 1312 | ERR_R_PASSED_NULL_PARAMETER); |
| 1320 | return NULL; | 1313 | return NULL; |
| 1321 | } | 1314 | } |
| 1322 | if (ATTR_IS_SET(attrs,code)) | 1315 | if (ATTR_IS_SET(attrs, code)) |
| 1323 | return attrs->values[code].dn; | 1316 | return attrs->values[code].dn; |
| 1324 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_DN, | 1317 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_DN, STORE_R_NO_VALUE); |
| 1325 | STORE_R_NO_VALUE); | ||
| 1326 | return NULL; | 1318 | return NULL; |
| 1327 | } | 1319 | } |
| 1328 | BIGNUM *STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code) | 1320 | |
| 1329 | { | 1321 | BIGNUM * |
| 1330 | if (!attrs) | 1322 | STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code) |
| 1331 | { | 1323 | { |
| 1324 | if (!attrs) { | ||
| 1332 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_NUMBER, | 1325 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_NUMBER, |
| 1333 | ERR_R_PASSED_NULL_PARAMETER); | 1326 | ERR_R_PASSED_NULL_PARAMETER); |
| 1334 | return NULL; | 1327 | return NULL; |
| 1335 | } | 1328 | } |
| 1336 | if (ATTR_IS_SET(attrs,code)) | 1329 | if (ATTR_IS_SET(attrs, code)) |
| 1337 | return attrs->values[code].number; | 1330 | return attrs->values[code].number; |
| 1338 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_NUMBER, | 1331 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_NUMBER, STORE_R_NO_VALUE); |
| 1339 | STORE_R_NO_VALUE); | ||
| 1340 | return NULL; | 1332 | return NULL; |
| 1341 | } | 1333 | } |
| 1342 | int STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 1334 | |
| 1343 | char *cstr, size_t cstr_size) | 1335 | int |
| 1344 | { | 1336 | STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
| 1345 | if (!attrs) | 1337 | char *cstr, size_t cstr_size) |
| 1346 | { | 1338 | { |
| 1339 | if (!attrs) { | ||
| 1347 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR, | 1340 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR, |
| 1348 | ERR_R_PASSED_NULL_PARAMETER); | 1341 | ERR_R_PASSED_NULL_PARAMETER); |
| 1349 | return 0; | 1342 | return 0; |
| 1350 | } | 1343 | } |
| 1351 | if (!ATTR_IS_SET(attrs,code)) | 1344 | if (!ATTR_IS_SET(attrs, code)) { |
| 1352 | { | ||
| 1353 | if ((attrs->values[code].cstring = BUF_strndup(cstr, cstr_size))) | 1345 | if ((attrs->values[code].cstring = BUF_strndup(cstr, cstr_size))) |
| 1354 | return 1; | 1346 | return 1; |
| 1355 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR, | 1347 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR, |
| 1356 | ERR_R_MALLOC_FAILURE); | 1348 | ERR_R_MALLOC_FAILURE); |
| 1357 | return 0; | 1349 | return 0; |
| 1358 | } | 1350 | } |
| 1359 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR, STORE_R_ALREADY_HAS_A_VALUE); | 1351 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR, STORE_R_ALREADY_HAS_A_VALUE); |
| 1360 | return 0; | 1352 | return 0; |
| 1361 | } | 1353 | } |
| 1362 | int STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 1354 | |
| 1363 | unsigned char *sha1str, size_t sha1str_size) | 1355 | int |
| 1364 | { | 1356 | STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
| 1365 | if (!attrs) | 1357 | unsigned char *sha1str, size_t sha1str_size) |
| 1366 | { | 1358 | { |
| 1359 | if (!attrs) { | ||
| 1367 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR, | 1360 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR, |
| 1368 | ERR_R_PASSED_NULL_PARAMETER); | 1361 | ERR_R_PASSED_NULL_PARAMETER); |
| 1369 | return 0; | 1362 | return 0; |
| 1370 | } | 1363 | } |
| 1371 | if (!ATTR_IS_SET(attrs,code)) | 1364 | if (!ATTR_IS_SET(attrs, code)) { |
| 1372 | { | ||
| 1373 | if ((attrs->values[code].sha1string = | 1365 | if ((attrs->values[code].sha1string = |
| 1374 | (unsigned char *)BUF_memdup(sha1str, | 1366 | (unsigned char *)BUF_memdup(sha1str, |
| 1375 | sha1str_size))) | 1367 | sha1str_size))) |
| 1376 | return 1; | 1368 | return 1; |
| 1377 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR, | 1369 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR, |
| 1378 | ERR_R_MALLOC_FAILURE); | 1370 | ERR_R_MALLOC_FAILURE); |
| 1379 | return 0; | 1371 | return 0; |
| 1380 | } | ||
| 1381 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR, STORE_R_ALREADY_HAS_A_VALUE); | ||
| 1382 | return 0; | ||
| 1383 | } | 1372 | } |
| 1384 | int STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 1373 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR, |
| 1385 | X509_NAME *dn) | 1374 | STORE_R_ALREADY_HAS_A_VALUE); |
| 1386 | { | 1375 | return 0; |
| 1387 | if (!attrs) | 1376 | } |
| 1388 | { | 1377 | |
| 1378 | int | ||
| 1379 | STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | ||
| 1380 | X509_NAME *dn) | ||
| 1381 | { | ||
| 1382 | if (!attrs) { | ||
| 1389 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN, | 1383 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN, |
| 1390 | ERR_R_PASSED_NULL_PARAMETER); | 1384 | ERR_R_PASSED_NULL_PARAMETER); |
| 1391 | return 0; | 1385 | return 0; |
| 1392 | } | 1386 | } |
| 1393 | if (!ATTR_IS_SET(attrs,code)) | 1387 | if (!ATTR_IS_SET(attrs, code)) { |
| 1394 | { | ||
| 1395 | if ((attrs->values[code].dn = X509_NAME_dup(dn))) | 1388 | if ((attrs->values[code].dn = X509_NAME_dup(dn))) |
| 1396 | return 1; | 1389 | return 1; |
| 1397 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN, | 1390 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN, |
| 1398 | ERR_R_MALLOC_FAILURE); | 1391 | ERR_R_MALLOC_FAILURE); |
| 1399 | return 0; | 1392 | return 0; |
| 1400 | } | 1393 | } |
| 1401 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN, STORE_R_ALREADY_HAS_A_VALUE); | 1394 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN, STORE_R_ALREADY_HAS_A_VALUE); |
| 1402 | return 0; | 1395 | return 0; |
| 1403 | } | 1396 | } |
| 1404 | int STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 1397 | |
| 1405 | BIGNUM *number) | 1398 | int |
| 1406 | { | 1399 | STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
| 1407 | if (!attrs) | 1400 | BIGNUM *number) |
| 1408 | { | 1401 | { |
| 1402 | if (!attrs) { | ||
| 1409 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER, | 1403 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER, |
| 1410 | ERR_R_PASSED_NULL_PARAMETER); | 1404 | ERR_R_PASSED_NULL_PARAMETER); |
| 1411 | return 0; | 1405 | return 0; |
| 1412 | } | 1406 | } |
| 1413 | if (!ATTR_IS_SET(attrs,code)) | 1407 | if (!ATTR_IS_SET(attrs, code)) { |
| 1414 | { | ||
| 1415 | if ((attrs->values[code].number = BN_dup(number))) | 1408 | if ((attrs->values[code].number = BN_dup(number))) |
| 1416 | return 1; | 1409 | return 1; |
| 1417 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER, | 1410 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER, |
| 1418 | ERR_R_MALLOC_FAILURE); | 1411 | ERR_R_MALLOC_FAILURE); |
| 1419 | return 0; | 1412 | return 0; |
| 1420 | } | ||
| 1421 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER, STORE_R_ALREADY_HAS_A_VALUE); | ||
| 1422 | return 0; | ||
| 1423 | } | 1413 | } |
| 1424 | int STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 1414 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER, |
| 1425 | char *cstr, size_t cstr_size) | 1415 | STORE_R_ALREADY_HAS_A_VALUE); |
| 1426 | { | 1416 | return 0; |
| 1427 | if (!attrs) | 1417 | } |
| 1428 | { | 1418 | |
| 1419 | int | ||
| 1420 | STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | ||
| 1421 | char *cstr, size_t cstr_size) | ||
| 1422 | { | ||
| 1423 | if (!attrs) { | ||
| 1429 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_CSTR, | 1424 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_CSTR, |
| 1430 | ERR_R_PASSED_NULL_PARAMETER); | 1425 | ERR_R_PASSED_NULL_PARAMETER); |
| 1431 | return 0; | 1426 | return 0; |
| 1432 | } | 1427 | } |
| 1433 | if (ATTR_IS_SET(attrs,code)) | 1428 | if (ATTR_IS_SET(attrs, code)) { |
| 1434 | { | ||
| 1435 | free(attrs->values[code].cstring); | 1429 | free(attrs->values[code].cstring); |
| 1436 | attrs->values[code].cstring = NULL; | 1430 | attrs->values[code].cstring = NULL; |
| 1437 | CLEAR_ATTRBIT(attrs, code); | 1431 | CLEAR_ATTRBIT(attrs, code); |
| 1438 | } | ||
| 1439 | return STORE_ATTR_INFO_set_cstr(attrs, code, cstr, cstr_size); | ||
| 1440 | } | 1432 | } |
| 1441 | int STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 1433 | return STORE_ATTR_INFO_set_cstr(attrs, code, cstr, cstr_size); |
| 1442 | unsigned char *sha1str, size_t sha1str_size) | 1434 | } |
| 1443 | { | 1435 | |
| 1444 | if (!attrs) | 1436 | int |
| 1445 | { | 1437 | STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
| 1438 | unsigned char *sha1str, size_t sha1str_size) | ||
| 1439 | { | ||
| 1440 | if (!attrs) { | ||
| 1446 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR, | 1441 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR, |
| 1447 | ERR_R_PASSED_NULL_PARAMETER); | 1442 | ERR_R_PASSED_NULL_PARAMETER); |
| 1448 | return 0; | 1443 | return 0; |
| 1449 | } | 1444 | } |
| 1450 | if (ATTR_IS_SET(attrs,code)) | 1445 | if (ATTR_IS_SET(attrs, code)) { |
| 1451 | { | ||
| 1452 | free(attrs->values[code].sha1string); | 1446 | free(attrs->values[code].sha1string); |
| 1453 | attrs->values[code].sha1string = NULL; | 1447 | attrs->values[code].sha1string = NULL; |
| 1454 | CLEAR_ATTRBIT(attrs, code); | 1448 | CLEAR_ATTRBIT(attrs, code); |
| 1455 | } | ||
| 1456 | return STORE_ATTR_INFO_set_sha1str(attrs, code, sha1str, sha1str_size); | ||
| 1457 | } | 1449 | } |
| 1458 | int STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 1450 | return STORE_ATTR_INFO_set_sha1str(attrs, code, sha1str, sha1str_size); |
| 1459 | X509_NAME *dn) | 1451 | } |
| 1460 | { | 1452 | |
| 1461 | if (!attrs) | 1453 | int |
| 1462 | { | 1454 | STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
| 1455 | X509_NAME *dn) | ||
| 1456 | { | ||
| 1457 | if (!attrs) { | ||
| 1463 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_DN, | 1458 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_DN, |
| 1464 | ERR_R_PASSED_NULL_PARAMETER); | 1459 | ERR_R_PASSED_NULL_PARAMETER); |
| 1465 | return 0; | 1460 | return 0; |
| 1466 | } | 1461 | } |
| 1467 | if (ATTR_IS_SET(attrs,code)) | 1462 | if (ATTR_IS_SET(attrs, code)) { |
| 1468 | { | ||
| 1469 | free(attrs->values[code].dn); | 1463 | free(attrs->values[code].dn); |
| 1470 | attrs->values[code].dn = NULL; | 1464 | attrs->values[code].dn = NULL; |
| 1471 | CLEAR_ATTRBIT(attrs, code); | 1465 | CLEAR_ATTRBIT(attrs, code); |
| 1472 | } | ||
| 1473 | return STORE_ATTR_INFO_set_dn(attrs, code, dn); | ||
| 1474 | } | 1466 | } |
| 1475 | int STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 1467 | return STORE_ATTR_INFO_set_dn(attrs, code, dn); |
| 1476 | BIGNUM *number) | 1468 | } |
| 1477 | { | 1469 | |
| 1478 | if (!attrs) | 1470 | int |
| 1479 | { | 1471 | STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
| 1472 | BIGNUM *number) | ||
| 1473 | { | ||
| 1474 | if (!attrs) { | ||
| 1480 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER, | 1475 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER, |
| 1481 | ERR_R_PASSED_NULL_PARAMETER); | 1476 | ERR_R_PASSED_NULL_PARAMETER); |
| 1482 | return 0; | 1477 | return 0; |
| 1483 | } | 1478 | } |
| 1484 | if (ATTR_IS_SET(attrs,code)) | 1479 | if (ATTR_IS_SET(attrs, code)) { |
| 1485 | { | ||
| 1486 | free(attrs->values[code].number); | 1480 | free(attrs->values[code].number); |
| 1487 | attrs->values[code].number = NULL; | 1481 | attrs->values[code].number = NULL; |
| 1488 | CLEAR_ATTRBIT(attrs, code); | 1482 | CLEAR_ATTRBIT(attrs, code); |
| 1489 | } | ||
| 1490 | return STORE_ATTR_INFO_set_number(attrs, code, number); | ||
| 1491 | } | 1483 | } |
| 1484 | return STORE_ATTR_INFO_set_number(attrs, code, number); | ||
| 1485 | } | ||
| 1492 | 1486 | ||
| 1493 | struct attr_list_ctx_st | 1487 | struct attr_list_ctx_st { |
| 1494 | { | ||
| 1495 | OPENSSL_ITEM *attributes; | 1488 | OPENSSL_ITEM *attributes; |
| 1496 | }; | 1489 | }; |
| 1497 | void *STORE_parse_attrs_start(OPENSSL_ITEM *attributes) | 1490 | |
| 1498 | { | 1491 | void * |
| 1499 | if (attributes) | 1492 | STORE_parse_attrs_start(OPENSSL_ITEM *attributes) |
| 1500 | { | 1493 | { |
| 1494 | if (attributes) { | ||
| 1501 | struct attr_list_ctx_st *context = | 1495 | struct attr_list_ctx_st *context = |
| 1502 | (struct attr_list_ctx_st *)malloc(sizeof(struct attr_list_ctx_st)); | 1496 | (struct attr_list_ctx_st *)malloc(sizeof(struct attr_list_ctx_st)); |
| 1503 | if (context) | 1497 | if (context) |
| 1504 | context->attributes = attributes; | 1498 | context->attributes = attributes; |
| 1505 | else | 1499 | else |
| 1506 | STOREerr(STORE_F_STORE_PARSE_ATTRS_START, | 1500 | STOREerr(STORE_F_STORE_PARSE_ATTRS_START, |
| 1507 | ERR_R_MALLOC_FAILURE); | 1501 | ERR_R_MALLOC_FAILURE); |
| 1508 | return context; | 1502 | return context; |
| 1509 | } | 1503 | } |
| 1510 | STOREerr(STORE_F_STORE_PARSE_ATTRS_START, ERR_R_PASSED_NULL_PARAMETER); | 1504 | STOREerr(STORE_F_STORE_PARSE_ATTRS_START, ERR_R_PASSED_NULL_PARAMETER); |
| 1511 | return 0; | 1505 | return 0; |
| 1512 | } | 1506 | } |
| 1513 | STORE_ATTR_INFO *STORE_parse_attrs_next(void *handle) | 1507 | |
| 1514 | { | 1508 | STORE_ATTR_INFO * |
| 1509 | STORE_parse_attrs_next(void *handle) | ||
| 1510 | { | ||
| 1515 | struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle; | 1511 | struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle; |
| 1516 | 1512 | ||
| 1517 | if (context && context->attributes) | 1513 | if (context && context->attributes) { |
| 1518 | { | ||
| 1519 | STORE_ATTR_INFO *attrs = NULL; | 1514 | STORE_ATTR_INFO *attrs = NULL; |
| 1520 | 1515 | ||
| 1521 | while(context->attributes | 1516 | while (context->attributes && |
| 1522 | && context->attributes->code != STORE_ATTR_OR | 1517 | context->attributes->code != STORE_ATTR_OR && |
| 1523 | && context->attributes->code != STORE_ATTR_END) | 1518 | context->attributes->code != STORE_ATTR_END) { |
| 1524 | { | 1519 | switch (context->attributes->code) { |
| 1525 | switch(context->attributes->code) | ||
| 1526 | { | ||
| 1527 | case STORE_ATTR_FRIENDLYNAME: | 1520 | case STORE_ATTR_FRIENDLYNAME: |
| 1528 | case STORE_ATTR_EMAIL: | 1521 | case STORE_ATTR_EMAIL: |
| 1529 | case STORE_ATTR_FILENAME: | 1522 | case STORE_ATTR_FILENAME: |
| 1530 | if (!attrs) attrs = STORE_ATTR_INFO_new(); | 1523 | if (!attrs) |
| 1531 | if (attrs == NULL) | 1524 | attrs = STORE_ATTR_INFO_new(); |
| 1532 | { | 1525 | if (attrs == NULL) { |
| 1533 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, | 1526 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, |
| 1534 | ERR_R_MALLOC_FAILURE); | 1527 | ERR_R_MALLOC_FAILURE); |
| 1535 | goto err; | 1528 | goto err; |
| 1536 | } | 1529 | } |
| 1537 | STORE_ATTR_INFO_set_cstr(attrs, | 1530 | STORE_ATTR_INFO_set_cstr(attrs, |
| 1538 | context->attributes->code, | 1531 | context->attributes->code, |
| 1539 | context->attributes->value, | 1532 | context->attributes->value, |
| 1540 | context->attributes->value_size); | 1533 | context->attributes->value_size); |
| 1541 | break; | 1534 | break; |
| 1542 | case STORE_ATTR_KEYID: | 1535 | case STORE_ATTR_KEYID: |
| 1543 | case STORE_ATTR_ISSUERKEYID: | 1536 | case STORE_ATTR_ISSUERKEYID: |
| 1544 | case STORE_ATTR_SUBJECTKEYID: | 1537 | case STORE_ATTR_SUBJECTKEYID: |
| 1545 | case STORE_ATTR_ISSUERSERIALHASH: | 1538 | case STORE_ATTR_ISSUERSERIALHASH: |
| 1546 | case STORE_ATTR_CERTHASH: | 1539 | case STORE_ATTR_CERTHASH: |
| 1547 | if (!attrs) attrs = STORE_ATTR_INFO_new(); | 1540 | if (!attrs) |
| 1548 | if (attrs == NULL) | 1541 | attrs = STORE_ATTR_INFO_new(); |
| 1549 | { | 1542 | if (attrs == NULL) { |
| 1550 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, | 1543 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, |
| 1551 | ERR_R_MALLOC_FAILURE); | 1544 | ERR_R_MALLOC_FAILURE); |
| 1552 | goto err; | 1545 | goto err; |
| 1553 | } | 1546 | } |
| 1554 | STORE_ATTR_INFO_set_sha1str(attrs, | 1547 | STORE_ATTR_INFO_set_sha1str(attrs, |
| 1555 | context->attributes->code, | 1548 | context->attributes->code, |
| 1556 | context->attributes->value, | 1549 | context->attributes->value, |
| 1557 | context->attributes->value_size); | 1550 | context->attributes->value_size); |
| 1558 | break; | 1551 | break; |
| 1559 | case STORE_ATTR_ISSUER: | 1552 | case STORE_ATTR_ISSUER: |
| 1560 | case STORE_ATTR_SUBJECT: | 1553 | case STORE_ATTR_SUBJECT: |
| 1561 | if (!attrs) attrs = STORE_ATTR_INFO_new(); | 1554 | if (!attrs) |
| 1562 | if (attrs == NULL) | 1555 | attrs = STORE_ATTR_INFO_new(); |
| 1563 | { | 1556 | if (attrs == NULL) { |
| 1564 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, | 1557 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, |
| 1565 | ERR_R_MALLOC_FAILURE); | 1558 | ERR_R_MALLOC_FAILURE); |
| 1566 | goto err; | 1559 | goto err; |
| 1567 | } | 1560 | } |
| 1568 | STORE_ATTR_INFO_modify_dn(attrs, | 1561 | STORE_ATTR_INFO_modify_dn(attrs, |
| 1569 | context->attributes->code, | 1562 | context->attributes->code, |
| 1570 | context->attributes->value); | 1563 | context->attributes->value); |
| 1571 | break; | 1564 | break; |
| 1572 | case STORE_ATTR_SERIAL: | 1565 | case STORE_ATTR_SERIAL: |
| 1573 | if (!attrs) attrs = STORE_ATTR_INFO_new(); | 1566 | if (!attrs) |
| 1574 | if (attrs == NULL) | 1567 | attrs = STORE_ATTR_INFO_new(); |
| 1575 | { | 1568 | if (attrs == NULL) { |
| 1576 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, | 1569 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, |
| 1577 | ERR_R_MALLOC_FAILURE); | 1570 | ERR_R_MALLOC_FAILURE); |
| 1578 | goto err; | 1571 | goto err; |
| 1579 | } | 1572 | } |
| 1580 | STORE_ATTR_INFO_modify_number(attrs, | 1573 | STORE_ATTR_INFO_modify_number(attrs, |
| 1581 | context->attributes->code, | 1574 | context->attributes->code, |
| 1582 | context->attributes->value); | 1575 | context->attributes->value); |
| 1583 | break; | 1576 | break; |
| 1584 | } | ||
| 1585 | context->attributes++; | ||
| 1586 | } | 1577 | } |
| 1578 | context->attributes++; | ||
| 1579 | } | ||
| 1587 | if (context->attributes->code == STORE_ATTR_OR) | 1580 | if (context->attributes->code == STORE_ATTR_OR) |
| 1588 | context->attributes++; | 1581 | context->attributes++; |
| 1589 | return attrs; | 1582 | return attrs; |
| 1590 | err: | 1583 | |
| 1591 | while(context->attributes | 1584 | err: |
| 1592 | && context->attributes->code != STORE_ATTR_OR | 1585 | while (context->attributes && |
| 1593 | && context->attributes->code != STORE_ATTR_END) | 1586 | context->attributes->code != STORE_ATTR_OR && |
| 1587 | context->attributes->code != STORE_ATTR_END) | ||
| 1594 | context->attributes++; | 1588 | context->attributes++; |
| 1595 | if (context->attributes->code == STORE_ATTR_OR) | 1589 | if (context->attributes->code == STORE_ATTR_OR) |
| 1596 | context->attributes++; | 1590 | context->attributes++; |
| 1597 | return NULL; | 1591 | return NULL; |
| 1598 | } | 1592 | } |
| 1599 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, ERR_R_PASSED_NULL_PARAMETER); | 1593 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, ERR_R_PASSED_NULL_PARAMETER); |
| 1600 | return NULL; | 1594 | return NULL; |
| 1601 | } | 1595 | } |
| 1602 | int STORE_parse_attrs_end(void *handle) | 1596 | |
| 1603 | { | 1597 | int |
| 1598 | STORE_parse_attrs_end(void *handle) | ||
| 1599 | { | ||
| 1604 | struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle; | 1600 | struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle; |
| 1605 | 1601 | ||
| 1606 | if (context && context->attributes) | 1602 | if (context && context->attributes) { |
| 1607 | { | ||
| 1608 | #if 0 | 1603 | #if 0 |
| 1609 | OPENSSL_ITEM *attributes = context->attributes; | 1604 | OPENSSL_ITEM *attributes = context->attributes; |
| 1610 | #endif | 1605 | #endif |
| 1611 | free(context); | 1606 | free(context); |
| 1612 | return 1; | 1607 | return 1; |
| 1613 | } | 1608 | } |
| 1614 | STOREerr(STORE_F_STORE_PARSE_ATTRS_END, ERR_R_PASSED_NULL_PARAMETER); | 1609 | STOREerr(STORE_F_STORE_PARSE_ATTRS_END, ERR_R_PASSED_NULL_PARAMETER); |
| 1615 | return 0; | 1610 | return 0; |
| 1616 | } | 1611 | } |
| 1617 | 1612 | ||
| 1618 | int STORE_parse_attrs_endp(void *handle) | 1613 | int |
| 1619 | { | 1614 | STORE_parse_attrs_endp(void *handle) |
| 1615 | { | ||
| 1620 | struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle; | 1616 | struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle; |
| 1621 | 1617 | ||
| 1622 | if (context && context->attributes) | 1618 | if (context && context->attributes) { |
| 1623 | { | ||
| 1624 | return context->attributes->code == STORE_ATTR_END; | 1619 | return context->attributes->code == STORE_ATTR_END; |
| 1625 | } | 1620 | } |
| 1626 | STOREerr(STORE_F_STORE_PARSE_ATTRS_ENDP, ERR_R_PASSED_NULL_PARAMETER); | 1621 | STOREerr(STORE_F_STORE_PARSE_ATTRS_ENDP, ERR_R_PASSED_NULL_PARAMETER); |
| 1627 | return 0; | 1622 | return 0; |
| 1628 | } | 1623 | } |
| 1629 | 1624 | ||
| 1630 | static int attr_info_compare_compute_range( | 1625 | static int |
| 1631 | const unsigned char *abits, const unsigned char *bbits, | 1626 | attr_info_compare_compute_range(const unsigned char *abits, |
| 1632 | unsigned int *alowp, unsigned int *ahighp, | 1627 | const unsigned char *bbits, unsigned int *alowp, unsigned int *ahighp, |
| 1633 | unsigned int *blowp, unsigned int *bhighp) | 1628 | unsigned int *blowp, unsigned int *bhighp) |
| 1634 | { | 1629 | { |
| 1635 | unsigned int alow = (unsigned int)-1, ahigh = 0; | 1630 | unsigned int alow = (unsigned int) - 1, ahigh = 0; |
| 1636 | unsigned int blow = (unsigned int)-1, bhigh = 0; | 1631 | unsigned int blow = (unsigned int) - 1, bhigh = 0; |
| 1637 | int i, res = 0; | 1632 | int i, res = 0; |
| 1638 | 1633 | ||
| 1639 | for (i = 0; i < (STORE_ATTR_TYPE_NUM + 8) / 8; i++, abits++, bbits++) | 1634 | for (i = 0; i < (STORE_ATTR_TYPE_NUM + 8) / 8; i++, abits++, bbits++) { |
| 1640 | { | 1635 | if (res == 0) { |
| 1641 | if (res == 0) | 1636 | if (*abits < *bbits) |
| 1642 | { | 1637 | res = -1; |
| 1643 | if (*abits < *bbits) res = -1; | 1638 | if (*abits > *bbits) |
| 1644 | if (*abits > *bbits) res = 1; | 1639 | res = 1; |
| 1645 | } | 1640 | } |
| 1646 | if (*abits) | 1641 | if (*abits) { |
| 1647 | { | 1642 | if (alow == (unsigned int) - 1) { |
| 1648 | if (alow == (unsigned int)-1) | ||
| 1649 | { | ||
| 1650 | alow = i * 8; | 1643 | alow = i * 8; |
| 1651 | if (!(*abits & 0x01)) alow++; | 1644 | if (!(*abits & 0x01)) |
| 1652 | if (!(*abits & 0x02)) alow++; | 1645 | alow++; |
| 1653 | if (!(*abits & 0x04)) alow++; | 1646 | if (!(*abits & 0x02)) |
| 1654 | if (!(*abits & 0x08)) alow++; | 1647 | alow++; |
| 1655 | if (!(*abits & 0x10)) alow++; | 1648 | if (!(*abits & 0x04)) |
| 1656 | if (!(*abits & 0x20)) alow++; | 1649 | alow++; |
| 1657 | if (!(*abits & 0x40)) alow++; | 1650 | if (!(*abits & 0x08)) |
| 1658 | } | 1651 | alow++; |
| 1659 | ahigh = i * 8 + 7; | 1652 | if (!(*abits & 0x10)) |
| 1660 | if (!(*abits & 0x80)) ahigh++; | 1653 | alow++; |
| 1661 | if (!(*abits & 0x40)) ahigh++; | 1654 | if (!(*abits & 0x20)) |
| 1662 | if (!(*abits & 0x20)) ahigh++; | 1655 | alow++; |
| 1663 | if (!(*abits & 0x10)) ahigh++; | 1656 | if (!(*abits & 0x40)) |
| 1664 | if (!(*abits & 0x08)) ahigh++; | 1657 | alow++; |
| 1665 | if (!(*abits & 0x04)) ahigh++; | ||
| 1666 | if (!(*abits & 0x02)) ahigh++; | ||
| 1667 | } | 1658 | } |
| 1668 | if (*bbits) | 1659 | ahigh = i * 8 + 7; |
| 1669 | { | 1660 | if (!(*abits & 0x80)) |
| 1670 | if (blow == (unsigned int)-1) | 1661 | ahigh++; |
| 1671 | { | 1662 | if (!(*abits & 0x40)) |
| 1663 | ahigh++; | ||
| 1664 | if (!(*abits & 0x20)) | ||
| 1665 | ahigh++; | ||
| 1666 | if (!(*abits & 0x10)) | ||
| 1667 | ahigh++; | ||
| 1668 | if (!(*abits & 0x08)) | ||
| 1669 | ahigh++; | ||
| 1670 | if (!(*abits & 0x04)) | ||
| 1671 | ahigh++; | ||
| 1672 | if (!(*abits & 0x02)) | ||
| 1673 | ahigh++; | ||
| 1674 | } | ||
| 1675 | if (*bbits) { | ||
| 1676 | if (blow == (unsigned int) - 1) { | ||
| 1672 | blow = i * 8; | 1677 | blow = i * 8; |
| 1673 | if (!(*bbits & 0x01)) blow++; | 1678 | if (!(*bbits & 0x01)) |
| 1674 | if (!(*bbits & 0x02)) blow++; | 1679 | blow++; |
| 1675 | if (!(*bbits & 0x04)) blow++; | 1680 | if (!(*bbits & 0x02)) |
| 1676 | if (!(*bbits & 0x08)) blow++; | 1681 | blow++; |
| 1677 | if (!(*bbits & 0x10)) blow++; | 1682 | if (!(*bbits & 0x04)) |
| 1678 | if (!(*bbits & 0x20)) blow++; | 1683 | blow++; |
| 1679 | if (!(*bbits & 0x40)) blow++; | 1684 | if (!(*bbits & 0x08)) |
| 1680 | } | 1685 | blow++; |
| 1681 | bhigh = i * 8 + 7; | 1686 | if (!(*bbits & 0x10)) |
| 1682 | if (!(*bbits & 0x80)) bhigh++; | 1687 | blow++; |
| 1683 | if (!(*bbits & 0x40)) bhigh++; | 1688 | if (!(*bbits & 0x20)) |
| 1684 | if (!(*bbits & 0x20)) bhigh++; | 1689 | blow++; |
| 1685 | if (!(*bbits & 0x10)) bhigh++; | 1690 | if (!(*bbits & 0x40)) |
| 1686 | if (!(*bbits & 0x08)) bhigh++; | 1691 | blow++; |
| 1687 | if (!(*bbits & 0x04)) bhigh++; | ||
| 1688 | if (!(*bbits & 0x02)) bhigh++; | ||
| 1689 | } | 1692 | } |
| 1690 | } | 1693 | bhigh = i * 8 + 7; |
| 1691 | if (ahigh + alow < bhigh + blow) res = -1; | 1694 | if (!(*bbits & 0x80)) |
| 1692 | if (ahigh + alow > bhigh + blow) res = 1; | 1695 | bhigh++; |
| 1693 | if (alowp) *alowp = alow; | 1696 | if (!(*bbits & 0x40)) |
| 1694 | if (ahighp) *ahighp = ahigh; | 1697 | bhigh++; |
| 1695 | if (blowp) *blowp = blow; | 1698 | if (!(*bbits & 0x20)) |
| 1696 | if (bhighp) *bhighp = bhigh; | 1699 | bhigh++; |
| 1700 | if (!(*bbits & 0x10)) | ||
| 1701 | bhigh++; | ||
| 1702 | if (!(*bbits & 0x08)) | ||
| 1703 | bhigh++; | ||
| 1704 | if (!(*bbits & 0x04)) | ||
| 1705 | bhigh++; | ||
| 1706 | if (!(*bbits & 0x02)) | ||
| 1707 | bhigh++; | ||
| 1708 | } | ||
| 1709 | } | ||
| 1710 | if (ahigh + alow < bhigh + blow) | ||
| 1711 | res = -1; | ||
| 1712 | if (ahigh + alow > bhigh + blow) | ||
| 1713 | res = 1; | ||
| 1714 | if (alowp) | ||
| 1715 | *alowp = alow; | ||
| 1716 | if (ahighp) | ||
| 1717 | *ahighp = ahigh; | ||
| 1718 | if (blowp) | ||
| 1719 | *blowp = blow; | ||
| 1720 | if (bhighp) | ||
| 1721 | *bhighp = bhigh; | ||
| 1697 | return res; | 1722 | return res; |
| 1698 | } | 1723 | } |
| 1699 | 1724 | ||
| 1700 | int STORE_ATTR_INFO_compare(const STORE_ATTR_INFO * const *a, | 1725 | int |
| 1701 | const STORE_ATTR_INFO * const *b) | 1726 | STORE_ATTR_INFO_compare(const STORE_ATTR_INFO * const *a, |
| 1702 | { | 1727 | const STORE_ATTR_INFO * const *b) |
| 1703 | if (a == b) return 0; | 1728 | { |
| 1704 | if (!a) return -1; | 1729 | if (a == b) |
| 1705 | if (!b) return 1; | 1730 | return 0; |
| 1706 | return attr_info_compare_compute_range((*a)->set, (*b)->set, 0, 0, 0, 0); | 1731 | if (!a) |
| 1707 | } | 1732 | return -1; |
| 1733 | if (!b) | ||
| 1734 | return 1; | ||
| 1735 | return attr_info_compare_compute_range((*a)->set, (*b)->set, | ||
| 1736 | 0, 0, 0, 0); | ||
| 1737 | } | ||
| 1708 | 1738 | ||
| 1709 | int STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) | 1739 | int |
| 1710 | { | 1740 | STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) |
| 1741 | { | ||
| 1711 | unsigned int alow, ahigh, blow, bhigh; | 1742 | unsigned int alow, ahigh, blow, bhigh; |
| 1712 | 1743 | ||
| 1713 | if (a == b) return 1; | 1744 | if (a == b) |
| 1714 | if (!a) return 0; | 1745 | return 1; |
| 1715 | if (!b) return 0; | 1746 | if (!a) |
| 1747 | return 0; | ||
| 1748 | if (!b) | ||
| 1749 | return 0; | ||
| 1716 | attr_info_compare_compute_range(a->set, b->set, | 1750 | attr_info_compare_compute_range(a->set, b->set, |
| 1717 | &alow, &ahigh, &blow, &bhigh); | 1751 | &alow, &ahigh, &blow, &bhigh); |
| 1718 | if (alow >= blow && ahigh <= bhigh) | 1752 | if (alow >= blow && ahigh <= bhigh) |
| 1719 | return 1; | 1753 | return 1; |
| 1720 | return 0; | 1754 | return 0; |
| 1721 | } | 1755 | } |
| 1722 | 1756 | ||
| 1723 | int STORE_ATTR_INFO_in(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) | 1757 | int |
| 1724 | { | 1758 | STORE_ATTR_INFO_in(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) |
| 1759 | { | ||
| 1725 | unsigned char *abits, *bbits; | 1760 | unsigned char *abits, *bbits; |
| 1726 | int i; | 1761 | int i; |
| 1727 | 1762 | ||
| 1728 | if (a == b) return 1; | 1763 | if (a == b) |
| 1729 | if (!a) return 0; | 1764 | return 1; |
| 1730 | if (!b) return 0; | 1765 | if (!a) |
| 1766 | return 0; | ||
| 1767 | if (!b) | ||
| 1768 | return 0; | ||
| 1731 | abits = a->set; | 1769 | abits = a->set; |
| 1732 | bbits = b->set; | 1770 | bbits = b->set; |
| 1733 | for (i = 0; i < (STORE_ATTR_TYPE_NUM + 8) / 8; i++, abits++, bbits++) | 1771 | for (i = 0; i < (STORE_ATTR_TYPE_NUM + 8) / 8; i++, abits++, bbits++) { |
| 1734 | { | ||
| 1735 | if (*abits && (*bbits & *abits) != *abits) | 1772 | if (*abits && (*bbits & *abits) != *abits) |
| 1736 | return 0; | 1773 | return 0; |
| 1737 | } | ||
| 1738 | return 1; | ||
| 1739 | } | 1774 | } |
| 1775 | return 1; | ||
| 1776 | } | ||
| 1740 | 1777 | ||
| 1741 | int STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) | 1778 | int |
| 1742 | { | 1779 | STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) |
| 1780 | { | ||
| 1743 | STORE_ATTR_TYPES i; | 1781 | STORE_ATTR_TYPES i; |
| 1744 | 1782 | ||
| 1745 | if (a == b) return 1; | 1783 | if (a == b) |
| 1746 | if (!STORE_ATTR_INFO_in(a, b)) return 0; | 1784 | return 1; |
| 1785 | if (!STORE_ATTR_INFO_in(a, b)) | ||
| 1786 | return 0; | ||
| 1747 | for (i = 1; i < STORE_ATTR_TYPE_NUM; i++) | 1787 | for (i = 1; i < STORE_ATTR_TYPE_NUM; i++) |
| 1748 | if (ATTR_IS_SET(a, i)) | 1788 | if (ATTR_IS_SET(a, i)) { |
| 1749 | { | 1789 | switch (i) { |
| 1750 | switch(i) | ||
| 1751 | { | ||
| 1752 | case STORE_ATTR_FRIENDLYNAME: | 1790 | case STORE_ATTR_FRIENDLYNAME: |
| 1753 | case STORE_ATTR_EMAIL: | 1791 | case STORE_ATTR_EMAIL: |
| 1754 | case STORE_ATTR_FILENAME: | 1792 | case STORE_ATTR_FILENAME: |
| 1755 | if (strcmp(a->values[i].cstring, | 1793 | if (strcmp(a->values[i].cstring, |
| 1756 | b->values[i].cstring)) | 1794 | b->values[i].cstring)) |
| 1757 | return 0; | 1795 | return 0; |
| 1758 | break; | 1796 | break; |
| 1759 | case STORE_ATTR_KEYID: | 1797 | case STORE_ATTR_KEYID: |
| @@ -1762,25 +1800,25 @@ int STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) | |||
| 1762 | case STORE_ATTR_ISSUERSERIALHASH: | 1800 | case STORE_ATTR_ISSUERSERIALHASH: |
| 1763 | case STORE_ATTR_CERTHASH: | 1801 | case STORE_ATTR_CERTHASH: |
| 1764 | if (memcmp(a->values[i].sha1string, | 1802 | if (memcmp(a->values[i].sha1string, |
| 1765 | b->values[i].sha1string, | 1803 | b->values[i].sha1string, |
| 1766 | a->value_sizes[i])) | 1804 | a->value_sizes[i])) |
| 1767 | return 0; | 1805 | return 0; |
| 1768 | break; | 1806 | break; |
| 1769 | case STORE_ATTR_ISSUER: | 1807 | case STORE_ATTR_ISSUER: |
| 1770 | case STORE_ATTR_SUBJECT: | 1808 | case STORE_ATTR_SUBJECT: |
| 1771 | if (X509_NAME_cmp(a->values[i].dn, | 1809 | if (X509_NAME_cmp(a->values[i].dn, |
| 1772 | b->values[i].dn)) | 1810 | b->values[i].dn)) |
| 1773 | return 0; | 1811 | return 0; |
| 1774 | break; | 1812 | break; |
| 1775 | case STORE_ATTR_SERIAL: | 1813 | case STORE_ATTR_SERIAL: |
| 1776 | if (BN_cmp(a->values[i].number, | 1814 | if (BN_cmp(a->values[i].number, |
| 1777 | b->values[i].number)) | 1815 | b->values[i].number)) |
| 1778 | return 0; | 1816 | return 0; |
| 1779 | break; | 1817 | break; |
| 1780 | default: | 1818 | default: |
| 1781 | break; | 1819 | break; |
| 1782 | } | ||
| 1783 | } | 1820 | } |
| 1821 | } | ||
| 1784 | 1822 | ||
| 1785 | return 1; | 1823 | return 1; |
| 1786 | } | 1824 | } |
diff --git a/src/lib/libcrypto/store/str_locl.h b/src/lib/libcrypto/store/str_locl.h index 3f8cb75619..c58172c460 100644 --- a/src/lib/libcrypto/store/str_locl.h +++ b/src/lib/libcrypto/store/str_locl.h | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | * are met: | 10 | * are met: |
| 11 | * | 11 | * |
| 12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * | 14 | * |
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
| @@ -66,8 +66,7 @@ | |||
| 66 | extern "C" { | 66 | extern "C" { |
| 67 | #endif | 67 | #endif |
| 68 | 68 | ||
| 69 | struct store_method_st | 69 | struct store_method_st { |
| 70 | { | ||
| 71 | char *name; | 70 | char *name; |
| 72 | 71 | ||
| 73 | /* All the functions return a positive integer or non-NULL for success | 72 | /* All the functions return a positive integer or non-NULL for success |
| @@ -106,17 +105,16 @@ struct store_method_st | |||
| 106 | 105 | ||
| 107 | /* Generic control function */ | 106 | /* Generic control function */ |
| 108 | STORE_CTRL_FUNC_PTR ctrl; | 107 | STORE_CTRL_FUNC_PTR ctrl; |
| 109 | }; | 108 | }; |
| 110 | 109 | ||
| 111 | struct store_st | 110 | struct store_st { |
| 112 | { | ||
| 113 | const STORE_METHOD *meth; | 111 | const STORE_METHOD *meth; |
| 114 | /* functional reference if 'meth' is ENGINE-provided */ | 112 | /* functional reference if 'meth' is ENGINE-provided */ |
| 115 | ENGINE *engine; | 113 | ENGINE *engine; |
| 116 | 114 | ||
| 117 | CRYPTO_EX_DATA ex_data; | 115 | CRYPTO_EX_DATA ex_data; |
| 118 | int references; | 116 | int references; |
| 119 | }; | 117 | }; |
| 120 | #ifdef __cplusplus | 118 | #ifdef __cplusplus |
| 121 | } | 119 | } |
| 122 | #endif | 120 | #endif |
diff --git a/src/lib/libcrypto/store/str_mem.c b/src/lib/libcrypto/store/str_mem.c index 7e2346d93d..0409fd198d 100644 --- a/src/lib/libcrypto/store/str_mem.c +++ b/src/lib/libcrypto/store/str_mem.c | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | * are met: | 10 | * are met: |
| 11 | * | 11 | * |
| 12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * | 14 | * |
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
| @@ -76,26 +76,23 @@ | |||
| 76 | attribute type code). | 76 | attribute type code). |
| 77 | */ | 77 | */ |
| 78 | 78 | ||
| 79 | typedef struct mem_object_data_st | 79 | typedef struct mem_object_data_st { |
| 80 | { | ||
| 81 | STORE_OBJECT *object; | 80 | STORE_OBJECT *object; |
| 82 | STORE_ATTR_INFO *attr_info; | 81 | STORE_ATTR_INFO *attr_info; |
| 83 | int references; | 82 | int references; |
| 84 | } MEM_OBJECT_DATA; | 83 | } MEM_OBJECT_DATA; |
| 85 | 84 | ||
| 86 | DECLARE_STACK_OF(MEM_OBJECT_DATA) | 85 | DECLARE_STACK_OF(MEM_OBJECT_DATA) |
| 87 | struct mem_data_st | 86 | struct mem_data_st { |
| 88 | { | ||
| 89 | STACK_OF(MEM_OBJECT_DATA) *data; /* sorted with | 87 | STACK_OF(MEM_OBJECT_DATA) *data; /* sorted with |
| 90 | * STORE_ATTR_INFO_compare(). */ | 88 | * STORE_ATTR_INFO_compare(). */ |
| 91 | unsigned int compute_components : 1; /* Currently unused, but can | 89 | unsigned int compute_components : 1; /* Currently unused, but can |
| 92 | be used to add attributes | 90 | be used to add attributes |
| 93 | from parts of the data. */ | 91 | from parts of the data. */ |
| 94 | }; | 92 | }; |
| 95 | 93 | ||
| 96 | DECLARE_STACK_OF(STORE_ATTR_INFO) | 94 | DECLARE_STACK_OF(STORE_ATTR_INFO) |
| 97 | struct mem_ctx_st | 95 | struct mem_ctx_st { |
| 98 | { | ||
| 99 | int type; /* The type we're searching for */ | 96 | int type; /* The type we're searching for */ |
| 100 | STACK_OF(STORE_ATTR_INFO) *search_attributes; /* Sets of | 97 | STACK_OF(STORE_ATTR_INFO) *search_attributes; /* Sets of |
| 101 | attributes to search for. Each | 98 | attributes to search for. Each |
| @@ -105,32 +102,31 @@ struct mem_ctx_st | |||
| 105 | haven't found any */ | 102 | haven't found any */ |
| 106 | int index; /* -1 as long as we're searching for | 103 | int index; /* -1 as long as we're searching for |
| 107 | the first */ | 104 | the first */ |
| 108 | }; | 105 | }; |
| 109 | 106 | ||
| 110 | static int mem_init(STORE *s); | 107 | static int mem_init(STORE *s); |
| 111 | static void mem_clean(STORE *s); | 108 | static void mem_clean(STORE *s); |
| 112 | static STORE_OBJECT *mem_generate(STORE *s, STORE_OBJECT_TYPES type, | 109 | static STORE_OBJECT *mem_generate(STORE *s, STORE_OBJECT_TYPES type, |
| 113 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | 110 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); |
| 114 | static STORE_OBJECT *mem_get(STORE *s, STORE_OBJECT_TYPES type, | 111 | static STORE_OBJECT *mem_get(STORE *s, STORE_OBJECT_TYPES type, |
| 115 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | 112 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); |
| 116 | static int mem_store(STORE *s, STORE_OBJECT_TYPES type, | 113 | static int mem_store(STORE *s, STORE_OBJECT_TYPES type, STORE_OBJECT *data, |
| 117 | STORE_OBJECT *data, OPENSSL_ITEM attributes[], | 114 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); |
| 118 | OPENSSL_ITEM parameters[]); | ||
| 119 | static int mem_modify(STORE *s, STORE_OBJECT_TYPES type, | 115 | static int mem_modify(STORE *s, STORE_OBJECT_TYPES type, |
| 120 | OPENSSL_ITEM search_attributes[], OPENSSL_ITEM add_attributes[], | 116 | OPENSSL_ITEM search_attributes[], OPENSSL_ITEM add_attributes[], |
| 121 | OPENSSL_ITEM modify_attributes[], OPENSSL_ITEM delete_attributes[], | 117 | OPENSSL_ITEM modify_attributes[], OPENSSL_ITEM delete_attributes[], |
| 122 | OPENSSL_ITEM parameters[]); | 118 | OPENSSL_ITEM parameters[]); |
| 123 | static int mem_delete(STORE *s, STORE_OBJECT_TYPES type, | 119 | static int mem_delete(STORE *s, STORE_OBJECT_TYPES type, |
| 124 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | 120 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); |
| 125 | static void *mem_list_start(STORE *s, STORE_OBJECT_TYPES type, | 121 | static void *mem_list_start(STORE *s, STORE_OBJECT_TYPES type, |
| 126 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | 122 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); |
| 127 | static STORE_OBJECT *mem_list_next(STORE *s, void *handle); | 123 | static STORE_OBJECT *mem_list_next(STORE *s, void *handle); |
| 128 | static int mem_list_end(STORE *s, void *handle); | 124 | static int mem_list_end(STORE *s, void *handle); |
| 129 | static int mem_list_endp(STORE *s, void *handle); | 125 | static int mem_list_endp(STORE *s, void *handle); |
| 130 | static int mem_lock(STORE *s, OPENSSL_ITEM attributes[], | 126 | static int mem_lock(STORE *s, OPENSSL_ITEM attributes[], |
| 131 | OPENSSL_ITEM parameters[]); | 127 | OPENSSL_ITEM parameters[]); |
| 132 | static int mem_unlock(STORE *s, OPENSSL_ITEM attributes[], | 128 | static int mem_unlock(STORE *s, OPENSSL_ITEM attributes[], |
| 133 | OPENSSL_ITEM parameters[]); | 129 | OPENSSL_ITEM parameters[]); |
| 134 | static int mem_ctrl(STORE *s, int cmd, long l, void *p, void (*f)(void)); | 130 | static int mem_ctrl(STORE *s, int cmd, long l, void *p, void (*f)(void)); |
| 135 | 131 | ||
| 136 | static STORE_METHOD store_memory = { | 132 | static STORE_METHOD store_memory = { |
| @@ -149,64 +145,73 @@ static STORE_METHOD store_memory = { | |||
| 149 | .lock_store = mem_lock, | 145 | .lock_store = mem_lock, |
| 150 | .unlock_store = mem_unlock, | 146 | .unlock_store = mem_unlock, |
| 151 | .ctrl = mem_ctrl | 147 | .ctrl = mem_ctrl |
| 152 | }; | 148 | }; |
| 153 | 149 | ||
| 154 | const STORE_METHOD *STORE_Memory(void) | 150 | const STORE_METHOD * |
| 155 | { | 151 | STORE_Memory(void) |
| 152 | { | ||
| 156 | return &store_memory; | 153 | return &store_memory; |
| 157 | } | 154 | } |
| 158 | 155 | ||
| 159 | static int mem_init(STORE *s) | 156 | static int |
| 160 | { | 157 | mem_init(STORE *s) |
| 158 | { | ||
| 161 | return 1; | 159 | return 1; |
| 162 | } | 160 | } |
| 163 | 161 | ||
| 164 | static void mem_clean(STORE *s) | 162 | static void |
| 165 | { | 163 | mem_clean(STORE *s) |
| 164 | { | ||
| 166 | return; | 165 | return; |
| 167 | } | 166 | } |
| 168 | 167 | ||
| 169 | static STORE_OBJECT *mem_generate(STORE *s, STORE_OBJECT_TYPES type, | 168 | static STORE_OBJECT * |
| 170 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]) | 169 | mem_generate(STORE *s, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], |
| 171 | { | 170 | OPENSSL_ITEM parameters[]) |
| 171 | { | ||
| 172 | STOREerr(STORE_F_MEM_GENERATE, STORE_R_NOT_IMPLEMENTED); | 172 | STOREerr(STORE_F_MEM_GENERATE, STORE_R_NOT_IMPLEMENTED); |
| 173 | return 0; | 173 | return 0; |
| 174 | } | 174 | } |
| 175 | static STORE_OBJECT *mem_get(STORE *s, STORE_OBJECT_TYPES type, | 175 | |
| 176 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]) | 176 | static STORE_OBJECT * |
| 177 | { | 177 | mem_get(STORE *s, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], |
| 178 | OPENSSL_ITEM parameters[]) | ||
| 179 | { | ||
| 178 | void *context = mem_list_start(s, type, attributes, parameters); | 180 | void *context = mem_list_start(s, type, attributes, parameters); |
| 179 | 181 | ||
| 180 | if (context) | 182 | if (context) { |
| 181 | { | ||
| 182 | STORE_OBJECT *object = mem_list_next(s, context); | 183 | STORE_OBJECT *object = mem_list_next(s, context); |
| 183 | 184 | ||
| 184 | if (mem_list_end(s, context)) | 185 | if (mem_list_end(s, context)) |
| 185 | return object; | 186 | return object; |
| 186 | } | ||
| 187 | return NULL; | ||
| 188 | } | 187 | } |
| 189 | static int mem_store(STORE *s, STORE_OBJECT_TYPES type, | 188 | return NULL; |
| 190 | STORE_OBJECT *data, OPENSSL_ITEM attributes[], | 189 | } |
| 191 | OPENSSL_ITEM parameters[]) | 190 | |
| 192 | { | 191 | static int |
| 192 | mem_store(STORE *s, STORE_OBJECT_TYPES type, STORE_OBJECT *data, | ||
| 193 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]) | ||
| 194 | { | ||
| 193 | STOREerr(STORE_F_MEM_STORE, STORE_R_NOT_IMPLEMENTED); | 195 | STOREerr(STORE_F_MEM_STORE, STORE_R_NOT_IMPLEMENTED); |
| 194 | return 0; | 196 | return 0; |
| 195 | } | 197 | } |
| 196 | static int mem_modify(STORE *s, STORE_OBJECT_TYPES type, | 198 | |
| 197 | OPENSSL_ITEM search_attributes[], OPENSSL_ITEM add_attributes[], | 199 | static int |
| 198 | OPENSSL_ITEM modify_attributes[], OPENSSL_ITEM delete_attributes[], | 200 | mem_modify(STORE *s, STORE_OBJECT_TYPES type, OPENSSL_ITEM search_attributes[], |
| 199 | OPENSSL_ITEM parameters[]) | 201 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], |
| 200 | { | 202 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) |
| 203 | { | ||
| 201 | STOREerr(STORE_F_MEM_MODIFY, STORE_R_NOT_IMPLEMENTED); | 204 | STOREerr(STORE_F_MEM_MODIFY, STORE_R_NOT_IMPLEMENTED); |
| 202 | return 0; | 205 | return 0; |
| 203 | } | 206 | } |
| 204 | static int mem_delete(STORE *s, STORE_OBJECT_TYPES type, | 207 | |
| 205 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]) | 208 | static int |
| 206 | { | 209 | mem_delete(STORE *s, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], |
| 210 | OPENSSL_ITEM parameters[]) | ||
| 211 | { | ||
| 207 | STOREerr(STORE_F_MEM_DELETE, STORE_R_NOT_IMPLEMENTED); | 212 | STOREerr(STORE_F_MEM_DELETE, STORE_R_NOT_IMPLEMENTED); |
| 208 | return 0; | 213 | return 0; |
| 209 | } | 214 | } |
| 210 | 215 | ||
| 211 | /* The list functions may be the hardest to understand. Basically, | 216 | /* The list functions may be the hardest to understand. Basically, |
| 212 | mem_list_start compiles a stack of attribute info elements, and | 217 | mem_list_start compiles a stack of attribute info elements, and |
| @@ -215,105 +220,99 @@ static int mem_delete(STORE *s, STORE_OBJECT_TYPES type, | |||
| 215 | walk all the way to the end of the store (since any combination | 220 | walk all the way to the end of the store (since any combination |
| 216 | of attribute bits above the starting point may match the searched | 221 | of attribute bits above the starting point may match the searched |
| 217 | for bit pattern...). */ | 222 | for bit pattern...). */ |
| 218 | static void *mem_list_start(STORE *s, STORE_OBJECT_TYPES type, | 223 | static void * |
| 219 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]) | 224 | mem_list_start(STORE *s, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], |
| 220 | { | 225 | OPENSSL_ITEM parameters[]) |
| 226 | { | ||
| 221 | struct mem_ctx_st *context = | 227 | struct mem_ctx_st *context = |
| 222 | (struct mem_ctx_st *)malloc(sizeof(struct mem_ctx_st)); | 228 | (struct mem_ctx_st *)malloc(sizeof(struct mem_ctx_st)); |
| 223 | void *attribute_context = NULL; | 229 | void *attribute_context = NULL; |
| 224 | STORE_ATTR_INFO *attrs = NULL; | 230 | STORE_ATTR_INFO *attrs = NULL; |
| 225 | 231 | ||
| 226 | if (!context) | 232 | if (!context) { |
| 227 | { | ||
| 228 | STOREerr(STORE_F_MEM_LIST_START, ERR_R_MALLOC_FAILURE); | 233 | STOREerr(STORE_F_MEM_LIST_START, ERR_R_MALLOC_FAILURE); |
| 229 | return 0; | 234 | return 0; |
| 230 | } | 235 | } |
| 231 | memset(context, 0, sizeof(struct mem_ctx_st)); | 236 | memset(context, 0, sizeof(struct mem_ctx_st)); |
| 232 | 237 | ||
| 233 | attribute_context = STORE_parse_attrs_start(attributes); | 238 | attribute_context = STORE_parse_attrs_start(attributes); |
| 234 | if (!attribute_context) | 239 | if (!attribute_context) { |
| 235 | { | ||
| 236 | STOREerr(STORE_F_MEM_LIST_START, ERR_R_STORE_LIB); | 240 | STOREerr(STORE_F_MEM_LIST_START, ERR_R_STORE_LIB); |
| 237 | goto err; | 241 | goto err; |
| 238 | } | 242 | } |
| 239 | 243 | ||
| 240 | while((attrs = STORE_parse_attrs_next(attribute_context))) | 244 | while ((attrs = STORE_parse_attrs_next(attribute_context))) { |
| 241 | { | 245 | if (context->search_attributes == NULL) { |
| 242 | if (context->search_attributes == NULL) | ||
| 243 | { | ||
| 244 | context->search_attributes = | 246 | context->search_attributes = |
| 245 | sk_STORE_ATTR_INFO_new(STORE_ATTR_INFO_compare); | 247 | sk_STORE_ATTR_INFO_new(STORE_ATTR_INFO_compare); |
| 246 | if (!context->search_attributes) | 248 | if (!context->search_attributes) { |
| 247 | { | ||
| 248 | STOREerr(STORE_F_MEM_LIST_START, | 249 | STOREerr(STORE_F_MEM_LIST_START, |
| 249 | ERR_R_MALLOC_FAILURE); | 250 | ERR_R_MALLOC_FAILURE); |
| 250 | goto err; | 251 | goto err; |
| 251 | } | ||
| 252 | } | 252 | } |
| 253 | sk_STORE_ATTR_INFO_push(context->search_attributes,attrs); | ||
| 254 | } | 253 | } |
| 254 | sk_STORE_ATTR_INFO_push(context->search_attributes, attrs); | ||
| 255 | } | ||
| 255 | if (!STORE_parse_attrs_endp(attribute_context)) | 256 | if (!STORE_parse_attrs_endp(attribute_context)) |
| 256 | goto err; | 257 | goto err; |
| 257 | STORE_parse_attrs_end(attribute_context); | 258 | STORE_parse_attrs_end(attribute_context); |
| 258 | context->search_index = -1; | 259 | context->search_index = -1; |
| 259 | context->index = -1; | 260 | context->index = -1; |
| 260 | return context; | 261 | return context; |
| 261 | err: | 262 | |
| 262 | if (attribute_context) STORE_parse_attrs_end(attribute_context); | 263 | err: |
| 264 | if (attribute_context) | ||
| 265 | STORE_parse_attrs_end(attribute_context); | ||
| 263 | mem_list_end(s, context); | 266 | mem_list_end(s, context); |
| 264 | return NULL; | 267 | return NULL; |
| 265 | } | 268 | } |
| 266 | static STORE_OBJECT *mem_list_next(STORE *s, void *handle) | 269 | |
| 267 | { | 270 | static STORE_OBJECT * |
| 271 | mem_list_next(STORE *s, void *handle) | ||
| 272 | { | ||
| 268 | int i; | 273 | int i; |
| 269 | struct mem_ctx_st *context = (struct mem_ctx_st *)handle; | 274 | struct mem_ctx_st *context = (struct mem_ctx_st *)handle; |
| 270 | struct mem_object_data_st key = { 0, 0, 1 }; | 275 | struct mem_object_data_st key = { 0, 0, 1 }; |
| 271 | struct mem_data_st *store = | 276 | struct mem_data_st *store = |
| 272 | (struct mem_data_st *)STORE_get_ex_data(s, 1); | 277 | (struct mem_data_st *)STORE_get_ex_data(s, 1); |
| 273 | int srch; | 278 | int srch; |
| 274 | int cres = 0; | 279 | int cres = 0; |
| 275 | 280 | ||
| 276 | if (!context) | 281 | if (!context) { |
| 277 | { | ||
| 278 | STOREerr(STORE_F_MEM_LIST_NEXT, ERR_R_PASSED_NULL_PARAMETER); | 282 | STOREerr(STORE_F_MEM_LIST_NEXT, ERR_R_PASSED_NULL_PARAMETER); |
| 279 | return NULL; | 283 | return NULL; |
| 280 | } | 284 | } |
| 281 | if (!store) | 285 | if (!store) { |
| 282 | { | ||
| 283 | STOREerr(STORE_F_MEM_LIST_NEXT, STORE_R_NO_STORE); | 286 | STOREerr(STORE_F_MEM_LIST_NEXT, STORE_R_NO_STORE); |
| 284 | return NULL; | 287 | return NULL; |
| 285 | } | 288 | } |
| 286 | 289 | ||
| 287 | if (context->search_index == -1) | 290 | if (context->search_index == -1) { |
| 288 | { | ||
| 289 | for (i = 0; | 291 | for (i = 0; |
| 290 | i < sk_STORE_ATTR_INFO_num(context->search_attributes); | 292 | i < sk_STORE_ATTR_INFO_num(context->search_attributes); |
| 291 | i++) | 293 | i++) { |
| 292 | { | ||
| 293 | key.attr_info | 294 | key.attr_info |
| 294 | = sk_STORE_ATTR_INFO_value(context->search_attributes, | 295 | = sk_STORE_ATTR_INFO_value(context->search_attributes, |
| 295 | i); | 296 | i); |
| 296 | srch = sk_MEM_OBJECT_DATA_find_ex(store->data, &key); | 297 | srch = sk_MEM_OBJECT_DATA_find_ex(store->data, &key); |
| 297 | 298 | ||
| 298 | if (srch >= 0) | 299 | if (srch >= 0) { |
| 299 | { | ||
| 300 | context->search_index = srch; | 300 | context->search_index = srch; |
| 301 | break; | 301 | break; |
| 302 | } | ||
| 303 | } | 302 | } |
| 304 | } | 303 | } |
| 304 | } | ||
| 305 | if (context->search_index < 0) | 305 | if (context->search_index < 0) |
| 306 | return NULL; | 306 | return NULL; |
| 307 | 307 | ||
| 308 | key.attr_info = | 308 | key.attr_info = sk_STORE_ATTR_INFO_value(context->search_attributes, |
| 309 | sk_STORE_ATTR_INFO_value(context->search_attributes, | 309 | context->search_index); |
| 310 | context->search_index); | ||
| 311 | for(srch = context->search_index; | 310 | for(srch = context->search_index; |
| 312 | srch < sk_MEM_OBJECT_DATA_num(store->data) | 311 | srch < sk_MEM_OBJECT_DATA_num(store->data) && |
| 313 | && STORE_ATTR_INFO_in_range(key.attr_info, | 312 | STORE_ATTR_INFO_in_range(key.attr_info, |
| 314 | sk_MEM_OBJECT_DATA_value(store->data, srch)->attr_info) | 313 | sk_MEM_OBJECT_DATA_value(store->data, srch)->attr_info) && |
| 315 | && !(cres = STORE_ATTR_INFO_in_ex(key.attr_info, | 314 | !(cres = STORE_ATTR_INFO_in_ex(key.attr_info, |
| 316 | sk_MEM_OBJECT_DATA_value(store->data, srch)->attr_info)); | 315 | sk_MEM_OBJECT_DATA_value(store->data, srch)->attr_info)); |
| 317 | srch++) | 316 | srch++) |
| 318 | ; | 317 | ; |
| 319 | 318 | ||
| @@ -321,42 +320,48 @@ static STORE_OBJECT *mem_list_next(STORE *s, void *handle) | |||
| 321 | if (cres) | 320 | if (cres) |
| 322 | return (sk_MEM_OBJECT_DATA_value(store->data, srch))->object; | 321 | return (sk_MEM_OBJECT_DATA_value(store->data, srch))->object; |
| 323 | return NULL; | 322 | return NULL; |
| 324 | } | 323 | } |
| 325 | static int mem_list_end(STORE *s, void *handle) | 324 | |
| 326 | { | 325 | static int |
| 326 | mem_list_end(STORE *s, void *handle) | ||
| 327 | { | ||
| 327 | struct mem_ctx_st *context = (struct mem_ctx_st *)handle; | 328 | struct mem_ctx_st *context = (struct mem_ctx_st *)handle; |
| 328 | 329 | ||
| 329 | if (!context) | 330 | if (!context) { |
| 330 | { | ||
| 331 | STOREerr(STORE_F_MEM_LIST_END, ERR_R_PASSED_NULL_PARAMETER); | 331 | STOREerr(STORE_F_MEM_LIST_END, ERR_R_PASSED_NULL_PARAMETER); |
| 332 | return 0; | 332 | return 0; |
| 333 | } | 333 | } |
| 334 | if (context && context->search_attributes) | 334 | if (context && context->search_attributes) |
| 335 | sk_STORE_ATTR_INFO_free(context->search_attributes); | 335 | sk_STORE_ATTR_INFO_free(context->search_attributes); |
| 336 | free(context); | 336 | free(context); |
| 337 | return 1; | 337 | return 1; |
| 338 | } | 338 | } |
| 339 | static int mem_list_endp(STORE *s, void *handle) | 339 | |
| 340 | { | 340 | static int |
| 341 | mem_list_endp(STORE *s, void *handle) | ||
| 342 | { | ||
| 341 | struct mem_ctx_st *context = (struct mem_ctx_st *)handle; | 343 | struct mem_ctx_st *context = (struct mem_ctx_st *)handle; |
| 342 | 344 | ||
| 343 | if (!context | 345 | if (!context || context->search_index == |
| 344 | || context->search_index | 346 | sk_STORE_ATTR_INFO_num(context->search_attributes)) |
| 345 | == sk_STORE_ATTR_INFO_num(context->search_attributes)) | ||
| 346 | return 1; | 347 | return 1; |
| 347 | return 0; | 348 | return 0; |
| 348 | } | 349 | } |
| 349 | static int mem_lock(STORE *s, OPENSSL_ITEM attributes[], | 350 | |
| 350 | OPENSSL_ITEM parameters[]) | 351 | static int |
| 351 | { | 352 | mem_lock(STORE *s, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]) |
| 353 | { | ||
| 352 | return 1; | 354 | return 1; |
| 353 | } | 355 | } |
| 354 | static int mem_unlock(STORE *s, OPENSSL_ITEM attributes[], | 356 | |
| 355 | OPENSSL_ITEM parameters[]) | 357 | static int |
| 356 | { | 358 | mem_unlock(STORE *s, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]) |
| 359 | { | ||
| 357 | return 1; | 360 | return 1; |
| 358 | } | 361 | } |
| 359 | static int mem_ctrl(STORE *s, int cmd, long l, void *p, void (*f)(void)) | 362 | |
| 360 | { | 363 | static int |
| 364 | mem_ctrl(STORE *s, int cmd, long l, void *p, void (*f)(void)) | ||
| 365 | { | ||
| 361 | return 1; | 366 | return 1; |
| 362 | } | 367 | } |
diff --git a/src/lib/libcrypto/store/str_meth.c b/src/lib/libcrypto/store/str_meth.c index 0401aaa129..9457087757 100644 --- a/src/lib/libcrypto/store/str_meth.c +++ b/src/lib/libcrypto/store/str_meth.c | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | * are met: | 10 | * are met: |
| 11 | * | 11 | * |
| 12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * | 14 | * |
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
| @@ -60,189 +60,236 @@ | |||
| 60 | #include <openssl/buffer.h> | 60 | #include <openssl/buffer.h> |
| 61 | #include "str_locl.h" | 61 | #include "str_locl.h" |
| 62 | 62 | ||
| 63 | STORE_METHOD *STORE_create_method(char *name) | 63 | STORE_METHOD * |
| 64 | { | 64 | STORE_create_method(char *name) |
| 65 | { | ||
| 65 | STORE_METHOD *store_method = calloc(1, sizeof(STORE_METHOD)); | 66 | STORE_METHOD *store_method = calloc(1, sizeof(STORE_METHOD)); |
| 66 | 67 | ||
| 67 | if (store_method) | 68 | if (store_method) |
| 68 | store_method->name = BUF_strdup(name); | 69 | store_method->name = BUF_strdup(name); |
| 69 | 70 | ||
| 70 | return store_method; | 71 | return store_method; |
| 71 | } | 72 | } |
| 72 | 73 | ||
| 73 | /* BIG FSCKING WARNING!!!! If you use this on a statically allocated method | 74 | /* BIG FSCKING WARNING!!!! If you use this on a statically allocated method |
| 74 | (that is, it hasn't been allocated using STORE_create_method(), you deserve | 75 | (that is, it hasn't been allocated using STORE_create_method(), you deserve |
| 75 | anything Murphy can throw at you and more! You have been warned. */ | 76 | anything Murphy can throw at you and more! You have been warned. */ |
| 76 | void STORE_destroy_method(STORE_METHOD *store_method) | 77 | void |
| 77 | { | 78 | STORE_destroy_method(STORE_METHOD *store_method) |
| 78 | if (!store_method) return; | 79 | { |
| 80 | if (!store_method) | ||
| 81 | return; | ||
| 79 | free(store_method->name); | 82 | free(store_method->name); |
| 80 | store_method->name = NULL; | 83 | store_method->name = NULL; |
| 81 | free(store_method); | 84 | free(store_method); |
| 82 | } | 85 | } |
| 83 | 86 | ||
| 84 | int STORE_method_set_initialise_function(STORE_METHOD *sm, STORE_INITIALISE_FUNC_PTR init_f) | 87 | int |
| 85 | { | 88 | STORE_method_set_initialise_function(STORE_METHOD *sm, |
| 89 | STORE_INITIALISE_FUNC_PTR init_f) | ||
| 90 | { | ||
| 86 | sm->init = init_f; | 91 | sm->init = init_f; |
| 87 | return 1; | 92 | return 1; |
| 88 | } | 93 | } |
| 89 | 94 | ||
| 90 | int STORE_method_set_cleanup_function(STORE_METHOD *sm, STORE_CLEANUP_FUNC_PTR clean_f) | 95 | int |
| 91 | { | 96 | STORE_method_set_cleanup_function(STORE_METHOD *sm, |
| 97 | STORE_CLEANUP_FUNC_PTR clean_f) | ||
| 98 | { | ||
| 92 | sm->clean = clean_f; | 99 | sm->clean = clean_f; |
| 93 | return 1; | 100 | return 1; |
| 94 | } | 101 | } |
| 95 | 102 | ||
| 96 | int STORE_method_set_generate_function(STORE_METHOD *sm, STORE_GENERATE_OBJECT_FUNC_PTR generate_f) | 103 | int |
| 97 | { | 104 | STORE_method_set_generate_function(STORE_METHOD *sm, |
| 105 | STORE_GENERATE_OBJECT_FUNC_PTR generate_f) | ||
| 106 | { | ||
| 98 | sm->generate_object = generate_f; | 107 | sm->generate_object = generate_f; |
| 99 | return 1; | 108 | return 1; |
| 100 | } | 109 | } |
| 101 | 110 | ||
| 102 | int STORE_method_set_get_function(STORE_METHOD *sm, STORE_GET_OBJECT_FUNC_PTR get_f) | 111 | int |
| 103 | { | 112 | STORE_method_set_get_function(STORE_METHOD *sm, |
| 113 | STORE_GET_OBJECT_FUNC_PTR get_f) | ||
| 114 | { | ||
| 104 | sm->get_object = get_f; | 115 | sm->get_object = get_f; |
| 105 | return 1; | 116 | return 1; |
| 106 | } | 117 | } |
| 107 | 118 | ||
| 108 | int STORE_method_set_store_function(STORE_METHOD *sm, STORE_STORE_OBJECT_FUNC_PTR store_f) | 119 | int |
| 109 | { | 120 | STORE_method_set_store_function(STORE_METHOD *sm, |
| 121 | STORE_STORE_OBJECT_FUNC_PTR store_f) | ||
| 122 | { | ||
| 110 | sm->store_object = store_f; | 123 | sm->store_object = store_f; |
| 111 | return 1; | 124 | return 1; |
| 112 | } | 125 | } |
| 113 | 126 | ||
| 114 | int STORE_method_set_modify_function(STORE_METHOD *sm, STORE_MODIFY_OBJECT_FUNC_PTR modify_f) | 127 | int |
| 115 | { | 128 | STORE_method_set_modify_function(STORE_METHOD *sm, |
| 129 | STORE_MODIFY_OBJECT_FUNC_PTR modify_f) | ||
| 130 | { | ||
| 116 | sm->modify_object = modify_f; | 131 | sm->modify_object = modify_f; |
| 117 | return 1; | 132 | return 1; |
| 118 | } | 133 | } |
| 119 | 134 | ||
| 120 | int STORE_method_set_revoke_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR revoke_f) | 135 | int |
| 121 | { | 136 | STORE_method_set_revoke_function(STORE_METHOD *sm, |
| 137 | STORE_HANDLE_OBJECT_FUNC_PTR revoke_f) | ||
| 138 | { | ||
| 122 | sm->revoke_object = revoke_f; | 139 | sm->revoke_object = revoke_f; |
| 123 | return 1; | 140 | return 1; |
| 124 | } | 141 | } |
| 125 | 142 | ||
| 126 | int STORE_method_set_delete_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR delete_f) | 143 | int |
| 127 | { | 144 | STORE_method_set_delete_function(STORE_METHOD *sm, |
| 145 | STORE_HANDLE_OBJECT_FUNC_PTR delete_f) | ||
| 146 | { | ||
| 128 | sm->delete_object = delete_f; | 147 | sm->delete_object = delete_f; |
| 129 | return 1; | 148 | return 1; |
| 130 | } | 149 | } |
| 131 | 150 | ||
| 132 | int STORE_method_set_list_start_function(STORE_METHOD *sm, STORE_START_OBJECT_FUNC_PTR list_start_f) | 151 | int |
| 133 | { | 152 | STORE_method_set_list_start_function(STORE_METHOD *sm, |
| 153 | STORE_START_OBJECT_FUNC_PTR list_start_f) | ||
| 154 | { | ||
| 134 | sm->list_object_start = list_start_f; | 155 | sm->list_object_start = list_start_f; |
| 135 | return 1; | 156 | return 1; |
| 136 | } | 157 | } |
| 137 | 158 | ||
| 138 | int STORE_method_set_list_next_function(STORE_METHOD *sm, STORE_NEXT_OBJECT_FUNC_PTR list_next_f) | 159 | int |
| 139 | { | 160 | STORE_method_set_list_next_function(STORE_METHOD *sm, |
| 161 | STORE_NEXT_OBJECT_FUNC_PTR list_next_f) | ||
| 162 | { | ||
| 140 | sm->list_object_next = list_next_f; | 163 | sm->list_object_next = list_next_f; |
| 141 | return 1; | 164 | return 1; |
| 142 | } | 165 | } |
| 143 | 166 | ||
| 144 | int STORE_method_set_list_end_function(STORE_METHOD *sm, STORE_END_OBJECT_FUNC_PTR list_end_f) | 167 | int |
| 145 | { | 168 | STORE_method_set_list_end_function(STORE_METHOD *sm, |
| 169 | STORE_END_OBJECT_FUNC_PTR list_end_f) | ||
| 170 | { | ||
| 146 | sm->list_object_end = list_end_f; | 171 | sm->list_object_end = list_end_f; |
| 147 | return 1; | 172 | return 1; |
| 148 | } | 173 | } |
| 149 | 174 | ||
| 150 | int STORE_method_set_update_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR update_f) | 175 | int |
| 151 | { | 176 | STORE_method_set_update_store_function(STORE_METHOD *sm, |
| 177 | STORE_GENERIC_FUNC_PTR update_f) | ||
| 178 | { | ||
| 152 | sm->update_store = update_f; | 179 | sm->update_store = update_f; |
| 153 | return 1; | 180 | return 1; |
| 154 | } | 181 | } |
| 155 | 182 | ||
| 156 | int STORE_method_set_lock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR lock_f) | 183 | int |
| 157 | { | 184 | STORE_method_set_lock_store_function(STORE_METHOD *sm, |
| 185 | STORE_GENERIC_FUNC_PTR lock_f) | ||
| 186 | { | ||
| 158 | sm->lock_store = lock_f; | 187 | sm->lock_store = lock_f; |
| 159 | return 1; | 188 | return 1; |
| 160 | } | 189 | } |
| 161 | 190 | ||
| 162 | int STORE_method_set_unlock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR unlock_f) | 191 | int |
| 163 | { | 192 | STORE_method_set_unlock_store_function(STORE_METHOD *sm, |
| 193 | STORE_GENERIC_FUNC_PTR unlock_f) | ||
| 194 | { | ||
| 164 | sm->unlock_store = unlock_f; | 195 | sm->unlock_store = unlock_f; |
| 165 | return 1; | 196 | return 1; |
| 166 | } | 197 | } |
| 167 | 198 | ||
| 168 | int STORE_method_set_ctrl_function(STORE_METHOD *sm, STORE_CTRL_FUNC_PTR ctrl_f) | 199 | int |
| 169 | { | 200 | STORE_method_set_ctrl_function(STORE_METHOD *sm, STORE_CTRL_FUNC_PTR ctrl_f) |
| 201 | { | ||
| 170 | sm->ctrl = ctrl_f; | 202 | sm->ctrl = ctrl_f; |
| 171 | return 1; | 203 | return 1; |
| 172 | } | 204 | } |
| 173 | 205 | ||
| 174 | STORE_INITIALISE_FUNC_PTR STORE_method_get_initialise_function(STORE_METHOD *sm) | 206 | STORE_INITIALISE_FUNC_PTR |
| 175 | { | 207 | STORE_method_get_initialise_function(STORE_METHOD *sm) |
| 208 | { | ||
| 176 | return sm->init; | 209 | return sm->init; |
| 177 | } | 210 | } |
| 178 | 211 | ||
| 179 | STORE_CLEANUP_FUNC_PTR STORE_method_get_cleanup_function(STORE_METHOD *sm) | 212 | STORE_CLEANUP_FUNC_PTR |
| 180 | { | 213 | STORE_method_get_cleanup_function(STORE_METHOD *sm) |
| 214 | { | ||
| 181 | return sm->clean; | 215 | return sm->clean; |
| 182 | } | 216 | } |
| 183 | 217 | ||
| 184 | STORE_GENERATE_OBJECT_FUNC_PTR STORE_method_get_generate_function(STORE_METHOD *sm) | 218 | STORE_GENERATE_OBJECT_FUNC_PTR |
| 185 | { | 219 | STORE_method_get_generate_function(STORE_METHOD *sm) |
| 220 | { | ||
| 186 | return sm->generate_object; | 221 | return sm->generate_object; |
| 187 | } | 222 | } |
| 188 | 223 | ||
| 189 | STORE_GET_OBJECT_FUNC_PTR STORE_method_get_get_function(STORE_METHOD *sm) | 224 | STORE_GET_OBJECT_FUNC_PTR |
| 190 | { | 225 | STORE_method_get_get_function(STORE_METHOD *sm) |
| 226 | { | ||
| 191 | return sm->get_object; | 227 | return sm->get_object; |
| 192 | } | 228 | } |
| 193 | 229 | ||
| 194 | STORE_STORE_OBJECT_FUNC_PTR STORE_method_get_store_function(STORE_METHOD *sm) | 230 | STORE_STORE_OBJECT_FUNC_PTR |
| 195 | { | 231 | STORE_method_get_store_function(STORE_METHOD *sm) |
| 232 | { | ||
| 196 | return sm->store_object; | 233 | return sm->store_object; |
| 197 | } | 234 | } |
| 198 | 235 | ||
| 199 | STORE_MODIFY_OBJECT_FUNC_PTR STORE_method_get_modify_function(STORE_METHOD *sm) | 236 | STORE_MODIFY_OBJECT_FUNC_PTR |
| 200 | { | 237 | STORE_method_get_modify_function(STORE_METHOD *sm) |
| 238 | { | ||
| 201 | return sm->modify_object; | 239 | return sm->modify_object; |
| 202 | } | 240 | } |
| 203 | 241 | ||
| 204 | STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_revoke_function(STORE_METHOD *sm) | 242 | STORE_HANDLE_OBJECT_FUNC_PTR |
| 205 | { | 243 | STORE_method_get_revoke_function(STORE_METHOD *sm) |
| 244 | { | ||
| 206 | return sm->revoke_object; | 245 | return sm->revoke_object; |
| 207 | } | 246 | } |
| 208 | 247 | ||
| 209 | STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_delete_function(STORE_METHOD *sm) | 248 | STORE_HANDLE_OBJECT_FUNC_PTR |
| 210 | { | 249 | STORE_method_get_delete_function(STORE_METHOD *sm) |
| 250 | { | ||
| 211 | return sm->delete_object; | 251 | return sm->delete_object; |
| 212 | } | 252 | } |
| 213 | 253 | ||
| 214 | STORE_START_OBJECT_FUNC_PTR STORE_method_get_list_start_function(STORE_METHOD *sm) | 254 | STORE_START_OBJECT_FUNC_PTR |
| 215 | { | 255 | STORE_method_get_list_start_function(STORE_METHOD *sm) |
| 256 | { | ||
| 216 | return sm->list_object_start; | 257 | return sm->list_object_start; |
| 217 | } | 258 | } |
| 218 | 259 | ||
| 219 | STORE_NEXT_OBJECT_FUNC_PTR STORE_method_get_list_next_function(STORE_METHOD *sm) | 260 | STORE_NEXT_OBJECT_FUNC_PTR |
| 220 | { | 261 | STORE_method_get_list_next_function(STORE_METHOD *sm) |
| 262 | { | ||
| 221 | return sm->list_object_next; | 263 | return sm->list_object_next; |
| 222 | } | 264 | } |
| 223 | 265 | ||
| 224 | STORE_END_OBJECT_FUNC_PTR STORE_method_get_list_end_function(STORE_METHOD *sm) | 266 | STORE_END_OBJECT_FUNC_PTR |
| 225 | { | 267 | STORE_method_get_list_end_function(STORE_METHOD *sm) |
| 268 | { | ||
| 226 | return sm->list_object_end; | 269 | return sm->list_object_end; |
| 227 | } | 270 | } |
| 228 | 271 | ||
| 229 | STORE_GENERIC_FUNC_PTR STORE_method_get_update_store_function(STORE_METHOD *sm) | 272 | STORE_GENERIC_FUNC_PTR |
| 230 | { | 273 | STORE_method_get_update_store_function(STORE_METHOD *sm) |
| 274 | { | ||
| 231 | return sm->update_store; | 275 | return sm->update_store; |
| 232 | } | 276 | } |
| 233 | 277 | ||
| 234 | STORE_GENERIC_FUNC_PTR STORE_method_get_lock_store_function(STORE_METHOD *sm) | 278 | STORE_GENERIC_FUNC_PTR |
| 235 | { | 279 | STORE_method_get_lock_store_function(STORE_METHOD *sm) |
| 280 | { | ||
| 236 | return sm->lock_store; | 281 | return sm->lock_store; |
| 237 | } | 282 | } |
| 238 | 283 | ||
| 239 | STORE_GENERIC_FUNC_PTR STORE_method_get_unlock_store_function(STORE_METHOD *sm) | 284 | STORE_GENERIC_FUNC_PTR |
| 240 | { | 285 | STORE_method_get_unlock_store_function(STORE_METHOD *sm) |
| 286 | { | ||
| 241 | return sm->unlock_store; | 287 | return sm->unlock_store; |
| 242 | } | 288 | } |
| 243 | 289 | ||
| 244 | STORE_CTRL_FUNC_PTR STORE_method_get_ctrl_function(STORE_METHOD *sm) | 290 | STORE_CTRL_FUNC_PTR |
| 245 | { | 291 | STORE_method_get_ctrl_function(STORE_METHOD *sm) |
| 292 | { | ||
| 246 | return sm->ctrl; | 293 | return sm->ctrl; |
| 247 | } | 294 | } |
| 248 | 295 | ||
diff --git a/src/lib/libssl/src/crypto/store/store.h b/src/lib/libssl/src/crypto/store/store.h index 0a28c7d5a2..1a29ca2da5 100644 --- a/src/lib/libssl/src/crypto/store/store.h +++ b/src/lib/libssl/src/crypto/store/store.h | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | * are met: | 10 | * are met: |
| 11 | * | 11 | * |
| 12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * | 14 | * |
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
| @@ -113,8 +113,8 @@ int STORE_ctrl(STORE *store, int cmd, long i, void *p, void (*f)(void)); | |||
| 113 | #define STORE_set_app_data(s,arg) STORE_set_ex_data(s,0,arg) | 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) | 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, | 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); | 116 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); |
| 117 | int STORE_set_ex_data(STORE *r,int idx,void *arg); | 117 | int STORE_set_ex_data(STORE *r, int idx, void *arg); |
| 118 | void *STORE_get_ex_data(STORE *r, int idx); | 118 | void *STORE_get_ex_data(STORE *r, int idx); |
| 119 | 119 | ||
| 120 | /* Use specific methods instead of the built-in one */ | 120 | /* Use specific methods instead of the built-in one */ |
| @@ -138,8 +138,7 @@ const STORE_METHOD *STORE_File(void); | |||
| 138 | 138 | ||
| 139 | /* Store functions take a type code for the type of data they should store | 139 | /* Store functions take a type code for the type of data they should store |
| 140 | or fetch */ | 140 | or fetch */ |
| 141 | typedef enum STORE_object_types | 141 | typedef enum STORE_object_types { |
| 142 | { | ||
| 143 | STORE_OBJECT_TYPE_X509_CERTIFICATE= 0x01, /* X509 * */ | 142 | STORE_OBJECT_TYPE_X509_CERTIFICATE= 0x01, /* X509 * */ |
| 144 | STORE_OBJECT_TYPE_X509_CRL= 0x02, /* X509_CRL * */ | 143 | STORE_OBJECT_TYPE_X509_CRL= 0x02, /* X509_CRL * */ |
| 145 | STORE_OBJECT_TYPE_PRIVATE_KEY= 0x03, /* EVP_PKEY * */ | 144 | STORE_OBJECT_TYPE_PRIVATE_KEY= 0x03, /* EVP_PKEY * */ |
| @@ -148,15 +147,14 @@ typedef enum STORE_object_types | |||
| 148 | STORE_OBJECT_TYPE_ARBITRARY= 0x06, /* BUF_MEM * */ | 147 | STORE_OBJECT_TYPE_ARBITRARY= 0x06, /* BUF_MEM * */ |
| 149 | STORE_OBJECT_TYPE_NUM= 0x06 /* The amount of known | 148 | STORE_OBJECT_TYPE_NUM= 0x06 /* The amount of known |
| 150 | object types */ | 149 | object types */ |
| 151 | } STORE_OBJECT_TYPES; | 150 | } STORE_OBJECT_TYPES; |
| 152 | /* List of text strings corresponding to the object types. */ | 151 | /* List of text strings corresponding to the object types. */ |
| 153 | extern const char * const STORE_object_type_string[STORE_OBJECT_TYPE_NUM+1]; | 152 | extern const char * const STORE_object_type_string[STORE_OBJECT_TYPE_NUM + 1]; |
| 154 | 153 | ||
| 155 | /* Some store functions take a parameter list. Those parameters come with | 154 | /* Some store functions take a parameter list. Those parameters come with |
| 156 | one of the following codes. The comments following the codes below indicate | 155 | one of the following codes. The comments following the codes below indicate |
| 157 | what type the value should be a pointer to. */ | 156 | what type the value should be a pointer to. */ |
| 158 | typedef enum STORE_params | 157 | typedef enum STORE_params { |
| 159 | { | ||
| 160 | STORE_PARAM_EVP_TYPE= 0x01, /* int */ | 158 | STORE_PARAM_EVP_TYPE= 0x01, /* int */ |
| 161 | STORE_PARAM_BITS= 0x02, /* size_t */ | 159 | STORE_PARAM_BITS= 0x02, /* size_t */ |
| 162 | STORE_PARAM_KEY_PARAMETERS= 0x03, /* ??? */ | 160 | STORE_PARAM_KEY_PARAMETERS= 0x03, /* ??? */ |
| @@ -165,16 +163,15 @@ typedef enum STORE_params | |||
| 165 | STORE_PARAM_AUTH_KRB5_TICKET= 0x06, /* void * */ | 163 | STORE_PARAM_AUTH_KRB5_TICKET= 0x06, /* void * */ |
| 166 | STORE_PARAM_TYPE_NUM= 0x06 /* The amount of known | 164 | STORE_PARAM_TYPE_NUM= 0x06 /* The amount of known |
| 167 | parameter types */ | 165 | parameter types */ |
| 168 | } STORE_PARAM_TYPES; | 166 | } STORE_PARAM_TYPES; |
| 169 | /* Parameter value sizes. -1 means unknown, anything else is the required size. */ | 167 | /* Parameter value sizes. -1 means unknown, anything else is the required size. */ |
| 170 | extern const int STORE_param_sizes[STORE_PARAM_TYPE_NUM+1]; | 168 | extern const int STORE_param_sizes[STORE_PARAM_TYPE_NUM + 1]; |
| 171 | 169 | ||
| 172 | /* Store functions take attribute lists. Those attributes come with codes. | 170 | /* Store functions take attribute lists. Those attributes come with codes. |
| 173 | The comments following the codes below indicate what type the value should | 171 | The comments following the codes below indicate what type the value should |
| 174 | be a pointer to. */ | 172 | be a pointer to. */ |
| 175 | typedef enum STORE_attribs | 173 | typedef enum STORE_attribs { |
| 176 | { | 174 | STORE_ATTR_END = 0x00, |
| 177 | STORE_ATTR_END= 0x00, | ||
| 178 | STORE_ATTR_FRIENDLYNAME= 0x01, /* C string */ | 175 | STORE_ATTR_FRIENDLYNAME= 0x01, /* C string */ |
| 179 | STORE_ATTR_KEYID= 0x02, /* 160 bit string (SHA1) */ | 176 | STORE_ATTR_KEYID= 0x02, /* 160 bit string (SHA1) */ |
| 180 | STORE_ATTR_ISSUERKEYID= 0x03, /* 160 bit string (SHA1) */ | 177 | STORE_ATTR_ISSUERKEYID= 0x03, /* 160 bit string (SHA1) */ |
| @@ -192,132 +189,129 @@ typedef enum STORE_attribs | |||
| 192 | separator, which | 189 | separator, which |
| 193 | expresses the OR | 190 | expresses the OR |
| 194 | operation. */ | 191 | operation. */ |
| 195 | } STORE_ATTR_TYPES; | 192 | } STORE_ATTR_TYPES; |
| 193 | |||
| 196 | /* Attribute value sizes. -1 means unknown, anything else is the required size. */ | 194 | /* Attribute value sizes. -1 means unknown, anything else is the required size. */ |
| 197 | extern const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM+1]; | 195 | extern const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM + 1]; |
| 198 | 196 | ||
| 199 | typedef enum STORE_certificate_status | 197 | typedef enum STORE_certificate_status { |
| 200 | { | 198 | STORE_X509_VALID = 0x00, |
| 201 | STORE_X509_VALID= 0x00, | 199 | STORE_X509_EXPIRED = 0x01, |
| 202 | STORE_X509_EXPIRED= 0x01, | 200 | STORE_X509_SUSPENDED = 0x02, |
| 203 | STORE_X509_SUSPENDED= 0x02, | 201 | STORE_X509_REVOKED = 0x03 |
| 204 | STORE_X509_REVOKED= 0x03 | 202 | } STORE_CERTIFICATE_STATUS; |
| 205 | } STORE_CERTIFICATE_STATUS; | ||
| 206 | 203 | ||
| 207 | /* Engine store functions will return a structure that contains all the necessary | 204 | /* Engine store functions will return a structure that contains all the necessary |
| 208 | * information, including revokation status for certificates. This is really not | 205 | * information, including revokation status for certificates. This is really not |
| 209 | * needed for application authors, as the ENGINE framework functions will extract | 206 | * needed for application authors, as the ENGINE framework functions will extract |
| 210 | * the OpenSSL-specific information when at all possible. However, for engine | 207 | * the OpenSSL-specific information when at all possible. However, for engine |
| 211 | * authors, it's crucial to know this structure. */ | 208 | * authors, it's crucial to know this structure. */ |
| 212 | typedef struct STORE_OBJECT_st | 209 | typedef struct STORE_OBJECT_st { |
| 213 | { | ||
| 214 | STORE_OBJECT_TYPES type; | 210 | STORE_OBJECT_TYPES type; |
| 215 | union | 211 | union |
| 216 | { | 212 | { |
| 217 | struct | 213 | struct { |
| 218 | { | ||
| 219 | STORE_CERTIFICATE_STATUS status; | 214 | STORE_CERTIFICATE_STATUS status; |
| 220 | X509 *certificate; | 215 | X509 *certificate; |
| 221 | } x509; | 216 | } x509; |
| 222 | X509_CRL *crl; | 217 | X509_CRL *crl; |
| 223 | EVP_PKEY *key; | 218 | EVP_PKEY *key; |
| 224 | BIGNUM *number; | 219 | BIGNUM *number; |
| 225 | BUF_MEM *arbitrary; | 220 | BUF_MEM *arbitrary; |
| 226 | } data; | 221 | } data; |
| 227 | } STORE_OBJECT; | 222 | } STORE_OBJECT; |
| 223 | |||
| 228 | DECLARE_STACK_OF(STORE_OBJECT) | 224 | DECLARE_STACK_OF(STORE_OBJECT) |
| 229 | STORE_OBJECT *STORE_OBJECT_new(void); | 225 | STORE_OBJECT *STORE_OBJECT_new(void); |
| 230 | void STORE_OBJECT_free(STORE_OBJECT *data); | 226 | void STORE_OBJECT_free(STORE_OBJECT *data); |
| 231 | 227 | ||
| 232 | 228 | ||
| 233 | |||
| 234 | /* The following functions handle the storage. They return 0, a negative number | 229 | /* The following functions handle the storage. They return 0, a negative number |
| 235 | or NULL on error, anything else on success. */ | 230 | or NULL on error, anything else on success. */ |
| 236 | X509 *STORE_get_certificate(STORE *e, OPENSSL_ITEM attributes[], | 231 | X509 *STORE_get_certificate(STORE *e, OPENSSL_ITEM attributes[], |
| 237 | OPENSSL_ITEM parameters[]); | 232 | OPENSSL_ITEM parameters[]); |
| 238 | int STORE_store_certificate(STORE *e, X509 *data, OPENSSL_ITEM attributes[], | 233 | int STORE_store_certificate(STORE *e, X509 *data, OPENSSL_ITEM attributes[], |
| 239 | OPENSSL_ITEM parameters[]); | 234 | OPENSSL_ITEM parameters[]); |
| 240 | int STORE_modify_certificate(STORE *e, OPENSSL_ITEM search_attributes[], | 235 | int STORE_modify_certificate(STORE *e, OPENSSL_ITEM search_attributes[], |
| 241 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | 236 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], |
| 242 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); | 237 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); |
| 243 | int STORE_revoke_certificate(STORE *e, OPENSSL_ITEM attributes[], | 238 | int STORE_revoke_certificate(STORE *e, OPENSSL_ITEM attributes[], |
| 244 | OPENSSL_ITEM parameters[]); | 239 | OPENSSL_ITEM parameters[]); |
| 245 | int STORE_delete_certificate(STORE *e, OPENSSL_ITEM attributes[], | 240 | int STORE_delete_certificate(STORE *e, OPENSSL_ITEM attributes[], |
| 246 | OPENSSL_ITEM parameters[]); | 241 | OPENSSL_ITEM parameters[]); |
| 247 | void *STORE_list_certificate_start(STORE *e, OPENSSL_ITEM attributes[], | 242 | void *STORE_list_certificate_start(STORE *e, OPENSSL_ITEM attributes[], |
| 248 | OPENSSL_ITEM parameters[]); | 243 | OPENSSL_ITEM parameters[]); |
| 249 | X509 *STORE_list_certificate_next(STORE *e, void *handle); | 244 | X509 *STORE_list_certificate_next(STORE *e, void *handle); |
| 250 | int STORE_list_certificate_end(STORE *e, void *handle); | 245 | int STORE_list_certificate_end(STORE *e, void *handle); |
| 251 | int STORE_list_certificate_endp(STORE *e, void *handle); | 246 | int STORE_list_certificate_endp(STORE *e, void *handle); |
| 252 | EVP_PKEY *STORE_generate_key(STORE *e, OPENSSL_ITEM attributes[], | 247 | EVP_PKEY *STORE_generate_key(STORE *e, OPENSSL_ITEM attributes[], |
| 253 | OPENSSL_ITEM parameters[]); | 248 | OPENSSL_ITEM parameters[]); |
| 254 | EVP_PKEY *STORE_get_private_key(STORE *e, OPENSSL_ITEM attributes[], | 249 | EVP_PKEY *STORE_get_private_key(STORE *e, OPENSSL_ITEM attributes[], |
| 255 | OPENSSL_ITEM parameters[]); | 250 | OPENSSL_ITEM parameters[]); |
| 256 | int STORE_store_private_key(STORE *e, EVP_PKEY *data, | 251 | int STORE_store_private_key(STORE *e, EVP_PKEY *data, |
| 257 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | 252 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); |
| 258 | int STORE_modify_private_key(STORE *e, OPENSSL_ITEM search_attributes[], | 253 | int STORE_modify_private_key(STORE *e, OPENSSL_ITEM search_attributes[], |
| 259 | OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], | 254 | OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], |
| 260 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); | 255 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); |
| 261 | int STORE_revoke_private_key(STORE *e, OPENSSL_ITEM attributes[], | 256 | int STORE_revoke_private_key(STORE *e, OPENSSL_ITEM attributes[], |
| 262 | OPENSSL_ITEM parameters[]); | 257 | OPENSSL_ITEM parameters[]); |
| 263 | int STORE_delete_private_key(STORE *e, OPENSSL_ITEM attributes[], | 258 | int STORE_delete_private_key(STORE *e, OPENSSL_ITEM attributes[], |
| 264 | OPENSSL_ITEM parameters[]); | 259 | OPENSSL_ITEM parameters[]); |
| 265 | void *STORE_list_private_key_start(STORE *e, OPENSSL_ITEM attributes[], | 260 | void *STORE_list_private_key_start(STORE *e, OPENSSL_ITEM attributes[], |
| 266 | OPENSSL_ITEM parameters[]); | 261 | OPENSSL_ITEM parameters[]); |
| 267 | EVP_PKEY *STORE_list_private_key_next(STORE *e, void *handle); | 262 | EVP_PKEY *STORE_list_private_key_next(STORE *e, void *handle); |
| 268 | int STORE_list_private_key_end(STORE *e, void *handle); | 263 | int STORE_list_private_key_end(STORE *e, void *handle); |
| 269 | int STORE_list_private_key_endp(STORE *e, void *handle); | 264 | int STORE_list_private_key_endp(STORE *e, void *handle); |
| 270 | EVP_PKEY *STORE_get_public_key(STORE *e, OPENSSL_ITEM attributes[], | 265 | EVP_PKEY *STORE_get_public_key(STORE *e, OPENSSL_ITEM attributes[], |
| 271 | OPENSSL_ITEM parameters[]); | 266 | OPENSSL_ITEM parameters[]); |
| 272 | int STORE_store_public_key(STORE *e, EVP_PKEY *data, OPENSSL_ITEM attributes[], | 267 | int STORE_store_public_key(STORE *e, EVP_PKEY *data, OPENSSL_ITEM attributes[], |
| 273 | OPENSSL_ITEM parameters[]); | 268 | OPENSSL_ITEM parameters[]); |
| 274 | int STORE_modify_public_key(STORE *e, OPENSSL_ITEM search_attributes[], | 269 | int STORE_modify_public_key(STORE *e, OPENSSL_ITEM search_attributes[], |
| 275 | OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], | 270 | OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], |
| 276 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); | 271 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); |
| 277 | int STORE_revoke_public_key(STORE *e, OPENSSL_ITEM attributes[], | 272 | int STORE_revoke_public_key(STORE *e, OPENSSL_ITEM attributes[], |
| 278 | OPENSSL_ITEM parameters[]); | 273 | OPENSSL_ITEM parameters[]); |
| 279 | int STORE_delete_public_key(STORE *e, OPENSSL_ITEM attributes[], | 274 | int STORE_delete_public_key(STORE *e, OPENSSL_ITEM attributes[], |
| 280 | OPENSSL_ITEM parameters[]); | 275 | OPENSSL_ITEM parameters[]); |
| 281 | void *STORE_list_public_key_start(STORE *e, OPENSSL_ITEM attributes[], | 276 | void *STORE_list_public_key_start(STORE *e, OPENSSL_ITEM attributes[], |
| 282 | OPENSSL_ITEM parameters[]); | 277 | OPENSSL_ITEM parameters[]); |
| 283 | EVP_PKEY *STORE_list_public_key_next(STORE *e, void *handle); | 278 | EVP_PKEY *STORE_list_public_key_next(STORE *e, void *handle); |
| 284 | int STORE_list_public_key_end(STORE *e, void *handle); | 279 | int STORE_list_public_key_end(STORE *e, void *handle); |
| 285 | int STORE_list_public_key_endp(STORE *e, void *handle); | 280 | int STORE_list_public_key_endp(STORE *e, void *handle); |
| 286 | X509_CRL *STORE_generate_crl(STORE *e, OPENSSL_ITEM attributes[], | 281 | X509_CRL *STORE_generate_crl(STORE *e, OPENSSL_ITEM attributes[], |
| 287 | OPENSSL_ITEM parameters[]); | 282 | OPENSSL_ITEM parameters[]); |
| 288 | X509_CRL *STORE_get_crl(STORE *e, OPENSSL_ITEM attributes[], | 283 | X509_CRL *STORE_get_crl(STORE *e, OPENSSL_ITEM attributes[], |
| 289 | OPENSSL_ITEM parameters[]); | 284 | OPENSSL_ITEM parameters[]); |
| 290 | int STORE_store_crl(STORE *e, X509_CRL *data, OPENSSL_ITEM attributes[], | 285 | int STORE_store_crl(STORE *e, X509_CRL *data, OPENSSL_ITEM attributes[], |
| 291 | OPENSSL_ITEM parameters[]); | 286 | OPENSSL_ITEM parameters[]); |
| 292 | int STORE_modify_crl(STORE *e, OPENSSL_ITEM search_attributes[], | 287 | int STORE_modify_crl(STORE *e, OPENSSL_ITEM search_attributes[], |
| 293 | OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], | 288 | OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], |
| 294 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); | 289 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); |
| 295 | int STORE_delete_crl(STORE *e, OPENSSL_ITEM attributes[], | 290 | int STORE_delete_crl(STORE *e, OPENSSL_ITEM attributes[], |
| 296 | OPENSSL_ITEM parameters[]); | 291 | OPENSSL_ITEM parameters[]); |
| 297 | void *STORE_list_crl_start(STORE *e, OPENSSL_ITEM attributes[], | 292 | void *STORE_list_crl_start(STORE *e, OPENSSL_ITEM attributes[], |
| 298 | OPENSSL_ITEM parameters[]); | 293 | OPENSSL_ITEM parameters[]); |
| 299 | X509_CRL *STORE_list_crl_next(STORE *e, void *handle); | 294 | X509_CRL *STORE_list_crl_next(STORE *e, void *handle); |
| 300 | int STORE_list_crl_end(STORE *e, void *handle); | 295 | int STORE_list_crl_end(STORE *e, void *handle); |
| 301 | int STORE_list_crl_endp(STORE *e, void *handle); | 296 | int STORE_list_crl_endp(STORE *e, void *handle); |
| 302 | int STORE_store_number(STORE *e, BIGNUM *data, OPENSSL_ITEM attributes[], | 297 | int STORE_store_number(STORE *e, BIGNUM *data, OPENSSL_ITEM attributes[], |
| 303 | OPENSSL_ITEM parameters[]); | 298 | OPENSSL_ITEM parameters[]); |
| 304 | int STORE_modify_number(STORE *e, OPENSSL_ITEM search_attributes[], | 299 | int STORE_modify_number(STORE *e, OPENSSL_ITEM search_attributes[], |
| 305 | OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], | 300 | OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], |
| 306 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); | 301 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); |
| 307 | BIGNUM *STORE_get_number(STORE *e, OPENSSL_ITEM attributes[], | 302 | BIGNUM *STORE_get_number(STORE *e, OPENSSL_ITEM attributes[], |
| 308 | OPENSSL_ITEM parameters[]); | 303 | OPENSSL_ITEM parameters[]); |
| 309 | int STORE_delete_number(STORE *e, OPENSSL_ITEM attributes[], | 304 | int STORE_delete_number(STORE *e, OPENSSL_ITEM attributes[], |
| 310 | OPENSSL_ITEM parameters[]); | 305 | OPENSSL_ITEM parameters[]); |
| 311 | int STORE_store_arbitrary(STORE *e, BUF_MEM *data, OPENSSL_ITEM attributes[], | 306 | int STORE_store_arbitrary(STORE *e, BUF_MEM *data, OPENSSL_ITEM attributes[], |
| 312 | OPENSSL_ITEM parameters[]); | 307 | OPENSSL_ITEM parameters[]); |
| 313 | int STORE_modify_arbitrary(STORE *e, OPENSSL_ITEM search_attributes[], | 308 | int STORE_modify_arbitrary(STORE *e, OPENSSL_ITEM search_attributes[], |
| 314 | OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], | 309 | OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], |
| 315 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); | 310 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); |
| 316 | BUF_MEM *STORE_get_arbitrary(STORE *e, OPENSSL_ITEM attributes[], | 311 | BUF_MEM *STORE_get_arbitrary(STORE *e, OPENSSL_ITEM attributes[], |
| 317 | OPENSSL_ITEM parameters[]); | 312 | OPENSSL_ITEM parameters[]); |
| 318 | int STORE_delete_arbitrary(STORE *e, OPENSSL_ITEM attributes[], | 313 | int STORE_delete_arbitrary(STORE *e, OPENSSL_ITEM attributes[], |
| 319 | OPENSSL_ITEM parameters[]); | 314 | OPENSSL_ITEM parameters[]); |
| 320 | |||
| 321 | 315 | ||
| 322 | /* Create and manipulate methods */ | 316 | /* Create and manipulate methods */ |
| 323 | STORE_METHOD *STORE_create_method(char *name); | 317 | STORE_METHOD *STORE_create_method(char *name); |
| @@ -326,43 +320,74 @@ void STORE_destroy_method(STORE_METHOD *store_method); | |||
| 326 | /* These callback types are use for store handlers */ | 320 | /* These callback types are use for store handlers */ |
| 327 | typedef int (*STORE_INITIALISE_FUNC_PTR)(STORE *); | 321 | typedef int (*STORE_INITIALISE_FUNC_PTR)(STORE *); |
| 328 | typedef void (*STORE_CLEANUP_FUNC_PTR)(STORE *); | 322 | typedef void (*STORE_CLEANUP_FUNC_PTR)(STORE *); |
| 329 | typedef STORE_OBJECT *(*STORE_GENERATE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | 323 | typedef STORE_OBJECT *(*STORE_GENERATE_OBJECT_FUNC_PTR)(STORE *, |
| 330 | typedef STORE_OBJECT *(*STORE_GET_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | 324 | STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], |
| 331 | typedef void *(*STORE_START_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | 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[]); | ||
| 332 | typedef STORE_OBJECT *(*STORE_NEXT_OBJECT_FUNC_PTR)(STORE *, void *handle); | 331 | typedef STORE_OBJECT *(*STORE_NEXT_OBJECT_FUNC_PTR)(STORE *, void *handle); |
| 333 | typedef int (*STORE_END_OBJECT_FUNC_PTR)(STORE *, void *handle); | 332 | typedef int (*STORE_END_OBJECT_FUNC_PTR)(STORE *, void *handle); |
| 334 | typedef int (*STORE_HANDLE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | 333 | typedef int (*STORE_HANDLE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, |
| 335 | typedef int (*STORE_STORE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, STORE_OBJECT *data, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | 334 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); |
| 336 | typedef int (*STORE_MODIFY_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM search_attributes[], OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); | 335 | typedef int (*STORE_STORE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, |
| 337 | typedef int (*STORE_GENERIC_FUNC_PTR)(STORE *, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | 336 | STORE_OBJECT *data, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); |
| 338 | typedef int (*STORE_CTRL_FUNC_PTR)(STORE *, int cmd, long l, void *p, void (*f)(void)); | 337 | typedef int (*STORE_MODIFY_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, |
| 339 | 338 | OPENSSL_ITEM search_attributes[], OPENSSL_ITEM add_attributes[], | |
| 340 | int STORE_method_set_initialise_function(STORE_METHOD *sm, STORE_INITIALISE_FUNC_PTR init_f); | 339 | OPENSSL_ITEM modify_attributes[], OPENSSL_ITEM delete_attributes[], |
| 341 | int STORE_method_set_cleanup_function(STORE_METHOD *sm, STORE_CLEANUP_FUNC_PTR clean_f); | 340 | OPENSSL_ITEM parameters[]); |
| 342 | int STORE_method_set_generate_function(STORE_METHOD *sm, STORE_GENERATE_OBJECT_FUNC_PTR generate_f); | 341 | typedef int (*STORE_GENERIC_FUNC_PTR)(STORE *, OPENSSL_ITEM attributes[], |
| 343 | int STORE_method_set_get_function(STORE_METHOD *sm, STORE_GET_OBJECT_FUNC_PTR get_f); | 342 | OPENSSL_ITEM parameters[]); |
| 344 | int STORE_method_set_store_function(STORE_METHOD *sm, STORE_STORE_OBJECT_FUNC_PTR store_f); | 343 | typedef int (*STORE_CTRL_FUNC_PTR)(STORE *, int cmd, long l, void *p, |
| 345 | int STORE_method_set_modify_function(STORE_METHOD *sm, STORE_MODIFY_OBJECT_FUNC_PTR store_f); | 344 | void (*f)(void)); |
| 346 | int STORE_method_set_revoke_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR revoke_f); | 345 | |
| 347 | int STORE_method_set_delete_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR delete_f); | 346 | int STORE_method_set_initialise_function(STORE_METHOD *sm, |
| 348 | int STORE_method_set_list_start_function(STORE_METHOD *sm, STORE_START_OBJECT_FUNC_PTR list_start_f); | 347 | STORE_INITIALISE_FUNC_PTR init_f); |
| 349 | int STORE_method_set_list_next_function(STORE_METHOD *sm, STORE_NEXT_OBJECT_FUNC_PTR list_next_f); | 348 | int STORE_method_set_cleanup_function(STORE_METHOD *sm, |
| 350 | int STORE_method_set_list_end_function(STORE_METHOD *sm, STORE_END_OBJECT_FUNC_PTR list_end_f); | 349 | STORE_CLEANUP_FUNC_PTR clean_f); |
| 351 | int STORE_method_set_update_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); | 350 | int STORE_method_set_generate_function(STORE_METHOD *sm, |
| 352 | int STORE_method_set_lock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); | 351 | STORE_GENERATE_OBJECT_FUNC_PTR generate_f); |
| 353 | int STORE_method_set_unlock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); | 352 | int STORE_method_set_get_function(STORE_METHOD *sm, |
| 354 | int STORE_method_set_ctrl_function(STORE_METHOD *sm, STORE_CTRL_FUNC_PTR ctrl_f); | 353 | STORE_GET_OBJECT_FUNC_PTR get_f); |
| 355 | 354 | int STORE_method_set_store_function(STORE_METHOD *sm, | |
| 356 | STORE_INITIALISE_FUNC_PTR STORE_method_get_initialise_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); | ||
| 357 | STORE_CLEANUP_FUNC_PTR STORE_method_get_cleanup_function(STORE_METHOD *sm); | 379 | STORE_CLEANUP_FUNC_PTR STORE_method_get_cleanup_function(STORE_METHOD *sm); |
| 358 | STORE_GENERATE_OBJECT_FUNC_PTR STORE_method_get_generate_function(STORE_METHOD *sm); | 380 | STORE_GENERATE_OBJECT_FUNC_PTR STORE_method_get_generate_function( |
| 381 | STORE_METHOD *sm); | ||
| 359 | STORE_GET_OBJECT_FUNC_PTR STORE_method_get_get_function(STORE_METHOD *sm); | 382 | STORE_GET_OBJECT_FUNC_PTR STORE_method_get_get_function(STORE_METHOD *sm); |
| 360 | STORE_STORE_OBJECT_FUNC_PTR STORE_method_get_store_function(STORE_METHOD *sm); | 383 | STORE_STORE_OBJECT_FUNC_PTR STORE_method_get_store_function(STORE_METHOD *sm); |
| 361 | STORE_MODIFY_OBJECT_FUNC_PTR STORE_method_get_modify_function(STORE_METHOD *sm); | 384 | STORE_MODIFY_OBJECT_FUNC_PTR STORE_method_get_modify_function(STORE_METHOD *sm); |
| 362 | STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_revoke_function(STORE_METHOD *sm); | 385 | STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_revoke_function(STORE_METHOD *sm); |
| 363 | STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_delete_function(STORE_METHOD *sm); | 386 | STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_delete_function(STORE_METHOD *sm); |
| 364 | STORE_START_OBJECT_FUNC_PTR STORE_method_get_list_start_function(STORE_METHOD *sm); | 387 | STORE_START_OBJECT_FUNC_PTR STORE_method_get_list_start_function( |
| 365 | STORE_NEXT_OBJECT_FUNC_PTR STORE_method_get_list_next_function(STORE_METHOD *sm); | 388 | STORE_METHOD *sm); |
| 389 | STORE_NEXT_OBJECT_FUNC_PTR STORE_method_get_list_next_function( | ||
| 390 | STORE_METHOD *sm); | ||
| 366 | STORE_END_OBJECT_FUNC_PTR STORE_method_get_list_end_function(STORE_METHOD *sm); | 391 | STORE_END_OBJECT_FUNC_PTR STORE_method_get_list_end_function(STORE_METHOD *sm); |
| 367 | STORE_GENERIC_FUNC_PTR STORE_method_get_update_store_function(STORE_METHOD *sm); | 392 | STORE_GENERIC_FUNC_PTR STORE_method_get_update_store_function(STORE_METHOD *sm); |
| 368 | STORE_GENERIC_FUNC_PTR STORE_method_get_lock_store_function(STORE_METHOD *sm); | 393 | STORE_GENERIC_FUNC_PTR STORE_method_get_lock_store_function(STORE_METHOD *sm); |
| @@ -392,30 +417,32 @@ int STORE_ATTR_INFO_free(STORE_ATTR_INFO *attrs); | |||
| 392 | /* Manipulators */ | 417 | /* Manipulators */ |
| 393 | char *STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); | 418 | char *STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); |
| 394 | unsigned char *STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs, | 419 | unsigned char *STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs, |
| 395 | STORE_ATTR_TYPES code); | 420 | STORE_ATTR_TYPES code); |
| 396 | X509_NAME *STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); | 421 | X509_NAME *STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs, |
| 397 | BIGNUM *STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); | 422 | STORE_ATTR_TYPES code); |
| 423 | BIGNUM *STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs, | ||
| 424 | STORE_ATTR_TYPES code); | ||
| 398 | int STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 425 | int STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
| 399 | char *cstr, size_t cstr_size); | 426 | char *cstr, size_t cstr_size); |
| 400 | int STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 427 | int STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
| 401 | unsigned char *sha1str, size_t sha1str_size); | 428 | unsigned char *sha1str, size_t sha1str_size); |
| 402 | int STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 429 | int STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
| 403 | X509_NAME *dn); | 430 | X509_NAME *dn); |
| 404 | int STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 431 | int STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
| 405 | BIGNUM *number); | 432 | BIGNUM *number); |
| 406 | int STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 433 | int STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
| 407 | char *cstr, size_t cstr_size); | 434 | char *cstr, size_t cstr_size); |
| 408 | int STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 435 | int STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs, |
| 409 | unsigned char *sha1str, size_t sha1str_size); | 436 | STORE_ATTR_TYPES code, unsigned char *sha1str, size_t sha1str_size); |
| 410 | int STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 437 | int STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
| 411 | X509_NAME *dn); | 438 | X509_NAME *dn); |
| 412 | int STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 439 | int STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
| 413 | BIGNUM *number); | 440 | BIGNUM *number); |
| 414 | 441 | ||
| 415 | /* Compare on basis of a bit pattern formed by the STORE_ATTR_TYPES values | 442 | /* Compare on basis of a bit pattern formed by the STORE_ATTR_TYPES values |
| 416 | in each contained attribute. */ | 443 | in each contained attribute. */ |
| 417 | int STORE_ATTR_INFO_compare(const STORE_ATTR_INFO * const *a, | 444 | int STORE_ATTR_INFO_compare(const STORE_ATTR_INFO * const *a, |
| 418 | const STORE_ATTR_INFO * const *b); | 445 | const STORE_ATTR_INFO * const *b); |
| 419 | /* Check if the set of attributes in a is within the range of attributes | 446 | /* Check if the set of attributes in a is within the range of attributes |
| 420 | set in b. */ | 447 | set in b. */ |
| 421 | int STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); | 448 | int STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); |
diff --git a/src/lib/libssl/src/crypto/store/str_err.c b/src/lib/libssl/src/crypto/store/str_err.c index 924edf0505..82156ae0a1 100644 --- a/src/lib/libssl/src/crypto/store/str_err.c +++ b/src/lib/libssl/src/crypto/store/str_err.c | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | * are met: | 7 | * are met: |
| 8 | * | 8 | * |
| 9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. |
| 11 | * | 11 | * |
| 12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer in | 13 | * notice, this list of conditions and the following disclaimer in |
| @@ -68,144 +68,141 @@ | |||
| 68 | #define ERR_FUNC(func) ERR_PACK(ERR_LIB_STORE,func,0) | 68 | #define ERR_FUNC(func) ERR_PACK(ERR_LIB_STORE,func,0) |
| 69 | #define ERR_REASON(reason) ERR_PACK(ERR_LIB_STORE,0,reason) | 69 | #define ERR_REASON(reason) ERR_PACK(ERR_LIB_STORE,0,reason) |
| 70 | 70 | ||
| 71 | static ERR_STRING_DATA STORE_str_functs[]= | 71 | static ERR_STRING_DATA STORE_str_functs[]= { |
| 72 | { | 72 | {ERR_FUNC(STORE_F_MEM_DELETE), "MEM_DELETE"}, |
| 73 | {ERR_FUNC(STORE_F_MEM_DELETE), "MEM_DELETE"}, | 73 | {ERR_FUNC(STORE_F_MEM_GENERATE), "MEM_GENERATE"}, |
| 74 | {ERR_FUNC(STORE_F_MEM_GENERATE), "MEM_GENERATE"}, | 74 | {ERR_FUNC(STORE_F_MEM_LIST_END), "MEM_LIST_END"}, |
| 75 | {ERR_FUNC(STORE_F_MEM_LIST_END), "MEM_LIST_END"}, | 75 | {ERR_FUNC(STORE_F_MEM_LIST_NEXT), "MEM_LIST_NEXT"}, |
| 76 | {ERR_FUNC(STORE_F_MEM_LIST_NEXT), "MEM_LIST_NEXT"}, | 76 | {ERR_FUNC(STORE_F_MEM_LIST_START), "MEM_LIST_START"}, |
| 77 | {ERR_FUNC(STORE_F_MEM_LIST_START), "MEM_LIST_START"}, | 77 | {ERR_FUNC(STORE_F_MEM_MODIFY), "MEM_MODIFY"}, |
| 78 | {ERR_FUNC(STORE_F_MEM_MODIFY), "MEM_MODIFY"}, | 78 | {ERR_FUNC(STORE_F_MEM_STORE), "MEM_STORE"}, |
| 79 | {ERR_FUNC(STORE_F_MEM_STORE), "MEM_STORE"}, | 79 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_GET0_CSTR), "STORE_ATTR_INFO_get0_cstr"}, |
| 80 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_GET0_CSTR), "STORE_ATTR_INFO_get0_cstr"}, | 80 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_GET0_DN), "STORE_ATTR_INFO_get0_dn"}, |
| 81 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_GET0_DN), "STORE_ATTR_INFO_get0_dn"}, | 81 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_GET0_NUMBER), "STORE_ATTR_INFO_get0_number"}, |
| 82 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_GET0_NUMBER), "STORE_ATTR_INFO_get0_number"}, | 82 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_GET0_SHA1STR), "STORE_ATTR_INFO_get0_sha1str"}, |
| 83 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_GET0_SHA1STR), "STORE_ATTR_INFO_get0_sha1str"}, | 83 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_MODIFY_CSTR), "STORE_ATTR_INFO_modify_cstr"}, |
| 84 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_MODIFY_CSTR), "STORE_ATTR_INFO_modify_cstr"}, | 84 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_MODIFY_DN), "STORE_ATTR_INFO_modify_dn"}, |
| 85 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_MODIFY_DN), "STORE_ATTR_INFO_modify_dn"}, | 85 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER), "STORE_ATTR_INFO_modify_number"}, |
| 86 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER), "STORE_ATTR_INFO_modify_number"}, | 86 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR), "STORE_ATTR_INFO_modify_sha1str"}, |
| 87 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR), "STORE_ATTR_INFO_modify_sha1str"}, | 87 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_SET_CSTR), "STORE_ATTR_INFO_set_cstr"}, |
| 88 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_SET_CSTR), "STORE_ATTR_INFO_set_cstr"}, | 88 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_SET_DN), "STORE_ATTR_INFO_set_dn"}, |
| 89 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_SET_DN), "STORE_ATTR_INFO_set_dn"}, | 89 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_SET_NUMBER), "STORE_ATTR_INFO_set_number"}, |
| 90 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_SET_NUMBER), "STORE_ATTR_INFO_set_number"}, | 90 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_SET_SHA1STR), "STORE_ATTR_INFO_set_sha1str"}, |
| 91 | {ERR_FUNC(STORE_F_STORE_ATTR_INFO_SET_SHA1STR), "STORE_ATTR_INFO_set_sha1str"}, | 91 | {ERR_FUNC(STORE_F_STORE_CERTIFICATE), "STORE_CERTIFICATE"}, |
| 92 | {ERR_FUNC(STORE_F_STORE_CERTIFICATE), "STORE_CERTIFICATE"}, | 92 | {ERR_FUNC(STORE_F_STORE_CTRL), "STORE_ctrl"}, |
| 93 | {ERR_FUNC(STORE_F_STORE_CTRL), "STORE_ctrl"}, | 93 | {ERR_FUNC(STORE_F_STORE_DELETE_ARBITRARY), "STORE_delete_arbitrary"}, |
| 94 | {ERR_FUNC(STORE_F_STORE_DELETE_ARBITRARY), "STORE_delete_arbitrary"}, | 94 | {ERR_FUNC(STORE_F_STORE_DELETE_CERTIFICATE), "STORE_delete_certificate"}, |
| 95 | {ERR_FUNC(STORE_F_STORE_DELETE_CERTIFICATE), "STORE_delete_certificate"}, | 95 | {ERR_FUNC(STORE_F_STORE_DELETE_CRL), "STORE_delete_crl"}, |
| 96 | {ERR_FUNC(STORE_F_STORE_DELETE_CRL), "STORE_delete_crl"}, | 96 | {ERR_FUNC(STORE_F_STORE_DELETE_NUMBER), "STORE_delete_number"}, |
| 97 | {ERR_FUNC(STORE_F_STORE_DELETE_NUMBER), "STORE_delete_number"}, | 97 | {ERR_FUNC(STORE_F_STORE_DELETE_PRIVATE_KEY), "STORE_delete_private_key"}, |
| 98 | {ERR_FUNC(STORE_F_STORE_DELETE_PRIVATE_KEY), "STORE_delete_private_key"}, | 98 | {ERR_FUNC(STORE_F_STORE_DELETE_PUBLIC_KEY), "STORE_delete_public_key"}, |
| 99 | {ERR_FUNC(STORE_F_STORE_DELETE_PUBLIC_KEY), "STORE_delete_public_key"}, | 99 | {ERR_FUNC(STORE_F_STORE_GENERATE_CRL), "STORE_generate_crl"}, |
| 100 | {ERR_FUNC(STORE_F_STORE_GENERATE_CRL), "STORE_generate_crl"}, | 100 | {ERR_FUNC(STORE_F_STORE_GENERATE_KEY), "STORE_generate_key"}, |
| 101 | {ERR_FUNC(STORE_F_STORE_GENERATE_KEY), "STORE_generate_key"}, | 101 | {ERR_FUNC(STORE_F_STORE_GET_ARBITRARY), "STORE_get_arbitrary"}, |
| 102 | {ERR_FUNC(STORE_F_STORE_GET_ARBITRARY), "STORE_get_arbitrary"}, | 102 | {ERR_FUNC(STORE_F_STORE_GET_CERTIFICATE), "STORE_get_certificate"}, |
| 103 | {ERR_FUNC(STORE_F_STORE_GET_CERTIFICATE), "STORE_get_certificate"}, | 103 | {ERR_FUNC(STORE_F_STORE_GET_CRL), "STORE_get_crl"}, |
| 104 | {ERR_FUNC(STORE_F_STORE_GET_CRL), "STORE_get_crl"}, | 104 | {ERR_FUNC(STORE_F_STORE_GET_NUMBER), "STORE_get_number"}, |
| 105 | {ERR_FUNC(STORE_F_STORE_GET_NUMBER), "STORE_get_number"}, | 105 | {ERR_FUNC(STORE_F_STORE_GET_PRIVATE_KEY), "STORE_get_private_key"}, |
| 106 | {ERR_FUNC(STORE_F_STORE_GET_PRIVATE_KEY), "STORE_get_private_key"}, | 106 | {ERR_FUNC(STORE_F_STORE_GET_PUBLIC_KEY), "STORE_get_public_key"}, |
| 107 | {ERR_FUNC(STORE_F_STORE_GET_PUBLIC_KEY), "STORE_get_public_key"}, | 107 | {ERR_FUNC(STORE_F_STORE_LIST_CERTIFICATE_END), "STORE_list_certificate_end"}, |
| 108 | {ERR_FUNC(STORE_F_STORE_LIST_CERTIFICATE_END), "STORE_list_certificate_end"}, | 108 | {ERR_FUNC(STORE_F_STORE_LIST_CERTIFICATE_ENDP), "STORE_list_certificate_endp"}, |
| 109 | {ERR_FUNC(STORE_F_STORE_LIST_CERTIFICATE_ENDP), "STORE_list_certificate_endp"}, | 109 | {ERR_FUNC(STORE_F_STORE_LIST_CERTIFICATE_NEXT), "STORE_list_certificate_next"}, |
| 110 | {ERR_FUNC(STORE_F_STORE_LIST_CERTIFICATE_NEXT), "STORE_list_certificate_next"}, | 110 | {ERR_FUNC(STORE_F_STORE_LIST_CERTIFICATE_START), "STORE_list_certificate_start"}, |
| 111 | {ERR_FUNC(STORE_F_STORE_LIST_CERTIFICATE_START), "STORE_list_certificate_start"}, | 111 | {ERR_FUNC(STORE_F_STORE_LIST_CRL_END), "STORE_list_crl_end"}, |
| 112 | {ERR_FUNC(STORE_F_STORE_LIST_CRL_END), "STORE_list_crl_end"}, | 112 | {ERR_FUNC(STORE_F_STORE_LIST_CRL_ENDP), "STORE_list_crl_endp"}, |
| 113 | {ERR_FUNC(STORE_F_STORE_LIST_CRL_ENDP), "STORE_list_crl_endp"}, | 113 | {ERR_FUNC(STORE_F_STORE_LIST_CRL_NEXT), "STORE_list_crl_next"}, |
| 114 | {ERR_FUNC(STORE_F_STORE_LIST_CRL_NEXT), "STORE_list_crl_next"}, | 114 | {ERR_FUNC(STORE_F_STORE_LIST_CRL_START), "STORE_list_crl_start"}, |
| 115 | {ERR_FUNC(STORE_F_STORE_LIST_CRL_START), "STORE_list_crl_start"}, | 115 | {ERR_FUNC(STORE_F_STORE_LIST_PRIVATE_KEY_END), "STORE_list_private_key_end"}, |
| 116 | {ERR_FUNC(STORE_F_STORE_LIST_PRIVATE_KEY_END), "STORE_list_private_key_end"}, | 116 | {ERR_FUNC(STORE_F_STORE_LIST_PRIVATE_KEY_ENDP), "STORE_list_private_key_endp"}, |
| 117 | {ERR_FUNC(STORE_F_STORE_LIST_PRIVATE_KEY_ENDP), "STORE_list_private_key_endp"}, | 117 | {ERR_FUNC(STORE_F_STORE_LIST_PRIVATE_KEY_NEXT), "STORE_list_private_key_next"}, |
| 118 | {ERR_FUNC(STORE_F_STORE_LIST_PRIVATE_KEY_NEXT), "STORE_list_private_key_next"}, | 118 | {ERR_FUNC(STORE_F_STORE_LIST_PRIVATE_KEY_START), "STORE_list_private_key_start"}, |
| 119 | {ERR_FUNC(STORE_F_STORE_LIST_PRIVATE_KEY_START), "STORE_list_private_key_start"}, | 119 | {ERR_FUNC(STORE_F_STORE_LIST_PUBLIC_KEY_END), "STORE_list_public_key_end"}, |
| 120 | {ERR_FUNC(STORE_F_STORE_LIST_PUBLIC_KEY_END), "STORE_list_public_key_end"}, | 120 | {ERR_FUNC(STORE_F_STORE_LIST_PUBLIC_KEY_ENDP), "STORE_list_public_key_endp"}, |
| 121 | {ERR_FUNC(STORE_F_STORE_LIST_PUBLIC_KEY_ENDP), "STORE_list_public_key_endp"}, | 121 | {ERR_FUNC(STORE_F_STORE_LIST_PUBLIC_KEY_NEXT), "STORE_list_public_key_next"}, |
| 122 | {ERR_FUNC(STORE_F_STORE_LIST_PUBLIC_KEY_NEXT), "STORE_list_public_key_next"}, | 122 | {ERR_FUNC(STORE_F_STORE_LIST_PUBLIC_KEY_START), "STORE_list_public_key_start"}, |
| 123 | {ERR_FUNC(STORE_F_STORE_LIST_PUBLIC_KEY_START), "STORE_list_public_key_start"}, | 123 | {ERR_FUNC(STORE_F_STORE_MODIFY_ARBITRARY), "STORE_modify_arbitrary"}, |
| 124 | {ERR_FUNC(STORE_F_STORE_MODIFY_ARBITRARY), "STORE_modify_arbitrary"}, | 124 | {ERR_FUNC(STORE_F_STORE_MODIFY_CERTIFICATE), "STORE_modify_certificate"}, |
| 125 | {ERR_FUNC(STORE_F_STORE_MODIFY_CERTIFICATE), "STORE_modify_certificate"}, | 125 | {ERR_FUNC(STORE_F_STORE_MODIFY_CRL), "STORE_modify_crl"}, |
| 126 | {ERR_FUNC(STORE_F_STORE_MODIFY_CRL), "STORE_modify_crl"}, | 126 | {ERR_FUNC(STORE_F_STORE_MODIFY_NUMBER), "STORE_modify_number"}, |
| 127 | {ERR_FUNC(STORE_F_STORE_MODIFY_NUMBER), "STORE_modify_number"}, | 127 | {ERR_FUNC(STORE_F_STORE_MODIFY_PRIVATE_KEY), "STORE_modify_private_key"}, |
| 128 | {ERR_FUNC(STORE_F_STORE_MODIFY_PRIVATE_KEY), "STORE_modify_private_key"}, | 128 | {ERR_FUNC(STORE_F_STORE_MODIFY_PUBLIC_KEY), "STORE_modify_public_key"}, |
| 129 | {ERR_FUNC(STORE_F_STORE_MODIFY_PUBLIC_KEY), "STORE_modify_public_key"}, | 129 | {ERR_FUNC(STORE_F_STORE_NEW_ENGINE), "STORE_new_engine"}, |
| 130 | {ERR_FUNC(STORE_F_STORE_NEW_ENGINE), "STORE_new_engine"}, | 130 | {ERR_FUNC(STORE_F_STORE_NEW_METHOD), "STORE_new_method"}, |
| 131 | {ERR_FUNC(STORE_F_STORE_NEW_METHOD), "STORE_new_method"}, | 131 | {ERR_FUNC(STORE_F_STORE_PARSE_ATTRS_END), "STORE_parse_attrs_end"}, |
| 132 | {ERR_FUNC(STORE_F_STORE_PARSE_ATTRS_END), "STORE_parse_attrs_end"}, | 132 | {ERR_FUNC(STORE_F_STORE_PARSE_ATTRS_ENDP), "STORE_parse_attrs_endp"}, |
| 133 | {ERR_FUNC(STORE_F_STORE_PARSE_ATTRS_ENDP), "STORE_parse_attrs_endp"}, | 133 | {ERR_FUNC(STORE_F_STORE_PARSE_ATTRS_NEXT), "STORE_parse_attrs_next"}, |
| 134 | {ERR_FUNC(STORE_F_STORE_PARSE_ATTRS_NEXT), "STORE_parse_attrs_next"}, | 134 | {ERR_FUNC(STORE_F_STORE_PARSE_ATTRS_START), "STORE_parse_attrs_start"}, |
| 135 | {ERR_FUNC(STORE_F_STORE_PARSE_ATTRS_START), "STORE_parse_attrs_start"}, | 135 | {ERR_FUNC(STORE_F_STORE_REVOKE_CERTIFICATE), "STORE_revoke_certificate"}, |
| 136 | {ERR_FUNC(STORE_F_STORE_REVOKE_CERTIFICATE), "STORE_revoke_certificate"}, | 136 | {ERR_FUNC(STORE_F_STORE_REVOKE_PRIVATE_KEY), "STORE_revoke_private_key"}, |
| 137 | {ERR_FUNC(STORE_F_STORE_REVOKE_PRIVATE_KEY), "STORE_revoke_private_key"}, | 137 | {ERR_FUNC(STORE_F_STORE_REVOKE_PUBLIC_KEY), "STORE_revoke_public_key"}, |
| 138 | {ERR_FUNC(STORE_F_STORE_REVOKE_PUBLIC_KEY), "STORE_revoke_public_key"}, | 138 | {ERR_FUNC(STORE_F_STORE_STORE_ARBITRARY), "STORE_store_arbitrary"}, |
| 139 | {ERR_FUNC(STORE_F_STORE_STORE_ARBITRARY), "STORE_store_arbitrary"}, | 139 | {ERR_FUNC(STORE_F_STORE_STORE_CERTIFICATE), "STORE_store_certificate"}, |
| 140 | {ERR_FUNC(STORE_F_STORE_STORE_CERTIFICATE), "STORE_store_certificate"}, | 140 | {ERR_FUNC(STORE_F_STORE_STORE_CRL), "STORE_store_crl"}, |
| 141 | {ERR_FUNC(STORE_F_STORE_STORE_CRL), "STORE_store_crl"}, | 141 | {ERR_FUNC(STORE_F_STORE_STORE_NUMBER), "STORE_store_number"}, |
| 142 | {ERR_FUNC(STORE_F_STORE_STORE_NUMBER), "STORE_store_number"}, | 142 | {ERR_FUNC(STORE_F_STORE_STORE_PRIVATE_KEY), "STORE_store_private_key"}, |
| 143 | {ERR_FUNC(STORE_F_STORE_STORE_PRIVATE_KEY), "STORE_store_private_key"}, | 143 | {ERR_FUNC(STORE_F_STORE_STORE_PUBLIC_KEY), "STORE_store_public_key"}, |
| 144 | {ERR_FUNC(STORE_F_STORE_STORE_PUBLIC_KEY), "STORE_store_public_key"}, | 144 | {0, NULL} |
| 145 | {0,NULL} | 145 | }; |
| 146 | }; | ||
| 147 | 146 | ||
| 148 | static ERR_STRING_DATA STORE_str_reasons[]= | 147 | static ERR_STRING_DATA STORE_str_reasons[]= { |
| 149 | { | 148 | {ERR_REASON(STORE_R_ALREADY_HAS_A_VALUE) , "already has a value"}, |
| 150 | {ERR_REASON(STORE_R_ALREADY_HAS_A_VALUE) ,"already has a value"}, | 149 | {ERR_REASON(STORE_R_FAILED_DELETING_ARBITRARY), "failed deleting arbitrary"}, |
| 151 | {ERR_REASON(STORE_R_FAILED_DELETING_ARBITRARY),"failed deleting arbitrary"}, | 150 | {ERR_REASON(STORE_R_FAILED_DELETING_CERTIFICATE), "failed deleting certificate"}, |
| 152 | {ERR_REASON(STORE_R_FAILED_DELETING_CERTIFICATE),"failed deleting certificate"}, | 151 | {ERR_REASON(STORE_R_FAILED_DELETING_KEY) , "failed deleting key"}, |
| 153 | {ERR_REASON(STORE_R_FAILED_DELETING_KEY) ,"failed deleting key"}, | 152 | {ERR_REASON(STORE_R_FAILED_DELETING_NUMBER), "failed deleting number"}, |
| 154 | {ERR_REASON(STORE_R_FAILED_DELETING_NUMBER),"failed deleting number"}, | 153 | {ERR_REASON(STORE_R_FAILED_GENERATING_CRL), "failed generating crl"}, |
| 155 | {ERR_REASON(STORE_R_FAILED_GENERATING_CRL),"failed generating crl"}, | 154 | {ERR_REASON(STORE_R_FAILED_GENERATING_KEY), "failed generating key"}, |
| 156 | {ERR_REASON(STORE_R_FAILED_GENERATING_KEY),"failed generating key"}, | 155 | {ERR_REASON(STORE_R_FAILED_GETTING_ARBITRARY), "failed getting arbitrary"}, |
| 157 | {ERR_REASON(STORE_R_FAILED_GETTING_ARBITRARY),"failed getting arbitrary"}, | 156 | {ERR_REASON(STORE_R_FAILED_GETTING_CERTIFICATE), "failed getting certificate"}, |
| 158 | {ERR_REASON(STORE_R_FAILED_GETTING_CERTIFICATE),"failed getting certificate"}, | 157 | {ERR_REASON(STORE_R_FAILED_GETTING_KEY) , "failed getting key"}, |
| 159 | {ERR_REASON(STORE_R_FAILED_GETTING_KEY) ,"failed getting key"}, | 158 | {ERR_REASON(STORE_R_FAILED_GETTING_NUMBER), "failed getting number"}, |
| 160 | {ERR_REASON(STORE_R_FAILED_GETTING_NUMBER),"failed getting number"}, | 159 | {ERR_REASON(STORE_R_FAILED_LISTING_CERTIFICATES), "failed listing certificates"}, |
| 161 | {ERR_REASON(STORE_R_FAILED_LISTING_CERTIFICATES),"failed listing certificates"}, | 160 | {ERR_REASON(STORE_R_FAILED_LISTING_KEYS) , "failed listing keys"}, |
| 162 | {ERR_REASON(STORE_R_FAILED_LISTING_KEYS) ,"failed listing keys"}, | 161 | {ERR_REASON(STORE_R_FAILED_MODIFYING_ARBITRARY), "failed modifying arbitrary"}, |
| 163 | {ERR_REASON(STORE_R_FAILED_MODIFYING_ARBITRARY),"failed modifying arbitrary"}, | 162 | {ERR_REASON(STORE_R_FAILED_MODIFYING_CERTIFICATE), "failed modifying certificate"}, |
| 164 | {ERR_REASON(STORE_R_FAILED_MODIFYING_CERTIFICATE),"failed modifying certificate"}, | 163 | {ERR_REASON(STORE_R_FAILED_MODIFYING_CRL), "failed modifying crl"}, |
| 165 | {ERR_REASON(STORE_R_FAILED_MODIFYING_CRL),"failed modifying crl"}, | 164 | {ERR_REASON(STORE_R_FAILED_MODIFYING_NUMBER), "failed modifying number"}, |
| 166 | {ERR_REASON(STORE_R_FAILED_MODIFYING_NUMBER),"failed modifying number"}, | 165 | {ERR_REASON(STORE_R_FAILED_MODIFYING_PRIVATE_KEY), "failed modifying private key"}, |
| 167 | {ERR_REASON(STORE_R_FAILED_MODIFYING_PRIVATE_KEY),"failed modifying private key"}, | 166 | {ERR_REASON(STORE_R_FAILED_MODIFYING_PUBLIC_KEY), "failed modifying public key"}, |
| 168 | {ERR_REASON(STORE_R_FAILED_MODIFYING_PUBLIC_KEY),"failed modifying public key"}, | 167 | {ERR_REASON(STORE_R_FAILED_REVOKING_CERTIFICATE), "failed revoking certificate"}, |
| 169 | {ERR_REASON(STORE_R_FAILED_REVOKING_CERTIFICATE),"failed revoking certificate"}, | 168 | {ERR_REASON(STORE_R_FAILED_REVOKING_KEY) , "failed revoking key"}, |
| 170 | {ERR_REASON(STORE_R_FAILED_REVOKING_KEY) ,"failed revoking key"}, | 169 | {ERR_REASON(STORE_R_FAILED_STORING_ARBITRARY), "failed storing arbitrary"}, |
| 171 | {ERR_REASON(STORE_R_FAILED_STORING_ARBITRARY),"failed storing arbitrary"}, | 170 | {ERR_REASON(STORE_R_FAILED_STORING_CERTIFICATE), "failed storing certificate"}, |
| 172 | {ERR_REASON(STORE_R_FAILED_STORING_CERTIFICATE),"failed storing certificate"}, | 171 | {ERR_REASON(STORE_R_FAILED_STORING_KEY) , "failed storing key"}, |
| 173 | {ERR_REASON(STORE_R_FAILED_STORING_KEY) ,"failed storing key"}, | 172 | {ERR_REASON(STORE_R_FAILED_STORING_NUMBER), "failed storing number"}, |
| 174 | {ERR_REASON(STORE_R_FAILED_STORING_NUMBER),"failed storing number"}, | 173 | {ERR_REASON(STORE_R_NOT_IMPLEMENTED) , "not implemented"}, |
| 175 | {ERR_REASON(STORE_R_NOT_IMPLEMENTED) ,"not implemented"}, | 174 | {ERR_REASON(STORE_R_NO_CONTROL_FUNCTION) , "no control function"}, |
| 176 | {ERR_REASON(STORE_R_NO_CONTROL_FUNCTION) ,"no control function"}, | 175 | {ERR_REASON(STORE_R_NO_DELETE_ARBITRARY_FUNCTION), "no delete arbitrary function"}, |
| 177 | {ERR_REASON(STORE_R_NO_DELETE_ARBITRARY_FUNCTION),"no delete arbitrary function"}, | 176 | {ERR_REASON(STORE_R_NO_DELETE_NUMBER_FUNCTION), "no delete number function"}, |
| 178 | {ERR_REASON(STORE_R_NO_DELETE_NUMBER_FUNCTION),"no delete number function"}, | 177 | {ERR_REASON(STORE_R_NO_DELETE_OBJECT_FUNCTION), "no delete object function"}, |
| 179 | {ERR_REASON(STORE_R_NO_DELETE_OBJECT_FUNCTION),"no delete object function"}, | 178 | {ERR_REASON(STORE_R_NO_GENERATE_CRL_FUNCTION), "no generate crl function"}, |
| 180 | {ERR_REASON(STORE_R_NO_GENERATE_CRL_FUNCTION),"no generate crl function"}, | 179 | {ERR_REASON(STORE_R_NO_GENERATE_OBJECT_FUNCTION), "no generate object function"}, |
| 181 | {ERR_REASON(STORE_R_NO_GENERATE_OBJECT_FUNCTION),"no generate object function"}, | 180 | {ERR_REASON(STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION), "no get object arbitrary function"}, |
| 182 | {ERR_REASON(STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION),"no get object arbitrary function"}, | 181 | {ERR_REASON(STORE_R_NO_GET_OBJECT_FUNCTION), "no get object function"}, |
| 183 | {ERR_REASON(STORE_R_NO_GET_OBJECT_FUNCTION),"no get object function"}, | 182 | {ERR_REASON(STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION), "no get object number function"}, |
| 184 | {ERR_REASON(STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION),"no get object number function"}, | 183 | {ERR_REASON(STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION), "no list object endp function"}, |
| 185 | {ERR_REASON(STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION),"no list object endp function"}, | 184 | {ERR_REASON(STORE_R_NO_LIST_OBJECT_END_FUNCTION), "no list object end function"}, |
| 186 | {ERR_REASON(STORE_R_NO_LIST_OBJECT_END_FUNCTION),"no list object end function"}, | 185 | {ERR_REASON(STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION), "no list object next function"}, |
| 187 | {ERR_REASON(STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION),"no list object next function"}, | 186 | {ERR_REASON(STORE_R_NO_LIST_OBJECT_START_FUNCTION), "no list object start function"}, |
| 188 | {ERR_REASON(STORE_R_NO_LIST_OBJECT_START_FUNCTION),"no list object start function"}, | 187 | {ERR_REASON(STORE_R_NO_MODIFY_OBJECT_FUNCTION), "no modify object function"}, |
| 189 | {ERR_REASON(STORE_R_NO_MODIFY_OBJECT_FUNCTION),"no modify object function"}, | 188 | {ERR_REASON(STORE_R_NO_REVOKE_OBJECT_FUNCTION), "no revoke object function"}, |
| 190 | {ERR_REASON(STORE_R_NO_REVOKE_OBJECT_FUNCTION),"no revoke object function"}, | 189 | {ERR_REASON(STORE_R_NO_STORE) , "no store"}, |
| 191 | {ERR_REASON(STORE_R_NO_STORE) ,"no store"}, | 190 | {ERR_REASON(STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION), "no store object arbitrary function"}, |
| 192 | {ERR_REASON(STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION),"no store object arbitrary function"}, | 191 | {ERR_REASON(STORE_R_NO_STORE_OBJECT_FUNCTION), "no store object function"}, |
| 193 | {ERR_REASON(STORE_R_NO_STORE_OBJECT_FUNCTION),"no store object function"}, | 192 | {ERR_REASON(STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION), "no store object number function"}, |
| 194 | {ERR_REASON(STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION),"no store object number function"}, | 193 | {ERR_REASON(STORE_R_NO_VALUE) , "no value"}, |
| 195 | {ERR_REASON(STORE_R_NO_VALUE) ,"no value"}, | 194 | {0, NULL} |
| 196 | {0,NULL} | 195 | }; |
| 197 | }; | ||
| 198 | 196 | ||
| 199 | #endif | 197 | #endif |
| 200 | 198 | ||
| 201 | void ERR_load_STORE_strings(void) | 199 | void |
| 202 | { | 200 | ERR_load_STORE_strings(void) |
| 201 | { | ||
| 203 | #ifndef OPENSSL_NO_ERR | 202 | #ifndef OPENSSL_NO_ERR |
| 204 | 203 | if (ERR_func_error_string(STORE_str_functs[0].error) == NULL) { | |
| 205 | if (ERR_func_error_string(STORE_str_functs[0].error) == NULL) | 204 | ERR_load_strings(0, STORE_str_functs); |
| 206 | { | 205 | ERR_load_strings(0, STORE_str_reasons); |
| 207 | ERR_load_strings(0,STORE_str_functs); | ||
| 208 | ERR_load_strings(0,STORE_str_reasons); | ||
| 209 | } | ||
| 210 | #endif | ||
| 211 | } | 206 | } |
| 207 | #endif | ||
| 208 | } | ||
diff --git a/src/lib/libssl/src/crypto/store/str_lib.c b/src/lib/libssl/src/crypto/store/str_lib.c index 197f19e769..f9beab2952 100644 --- a/src/lib/libssl/src/crypto/store/str_lib.c +++ b/src/lib/libssl/src/crypto/store/str_lib.c | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | * are met: | 10 | * are met: |
| 11 | * | 11 | * |
| 12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * | 14 | * |
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
| @@ -66,8 +66,7 @@ | |||
| 66 | #include <openssl/x509.h> | 66 | #include <openssl/x509.h> |
| 67 | #include "str_locl.h" | 67 | #include "str_locl.h" |
| 68 | 68 | ||
| 69 | const char * const STORE_object_type_string[STORE_OBJECT_TYPE_NUM+1] = | 69 | const char * const STORE_object_type_string[STORE_OBJECT_TYPE_NUM + 1] = { |
| 70 | { | ||
| 71 | 0, | 70 | 0, |
| 72 | "X.509 Certificate", | 71 | "X.509 Certificate", |
| 73 | "X.509 CRL", | 72 | "X.509 CRL", |
| @@ -75,19 +74,17 @@ const char * const STORE_object_type_string[STORE_OBJECT_TYPE_NUM+1] = | |||
| 75 | "Public Key", | 74 | "Public Key", |
| 76 | "Number", | 75 | "Number", |
| 77 | "Arbitrary Data" | 76 | "Arbitrary Data" |
| 78 | }; | 77 | }; |
| 79 | 78 | ||
| 80 | const int STORE_param_sizes[STORE_PARAM_TYPE_NUM+1] = | 79 | const int STORE_param_sizes[STORE_PARAM_TYPE_NUM + 1] = { |
| 81 | { | ||
| 82 | 0, | 80 | 0, |
| 83 | sizeof(int), /* EVP_TYPE */ | 81 | sizeof(int), /* EVP_TYPE */ |
| 84 | sizeof(size_t), /* BITS */ | 82 | sizeof(size_t), /* BITS */ |
| 85 | -1, /* KEY_PARAMETERS */ | 83 | -1, /* KEY_PARAMETERS */ |
| 86 | 0 /* KEY_NO_PARAMETERS */ | 84 | 0 /* KEY_NO_PARAMETERS */ |
| 87 | }; | 85 | }; |
| 88 | 86 | ||
| 89 | const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM+1] = | 87 | const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM + 1] = { |
| 90 | { | ||
| 91 | 0, | 88 | 0, |
| 92 | -1, /* FRIENDLYNAME: C string */ | 89 | -1, /* FRIENDLYNAME: C string */ |
| 93 | SHA_DIGEST_LENGTH, /* KEYID: SHA1 digest, 160 bits */ | 90 | SHA_DIGEST_LENGTH, /* KEYID: SHA1 digest, 160 bits */ |
| @@ -100,38 +97,37 @@ const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM+1] = | |||
| 100 | SHA_DIGEST_LENGTH, /* CERTHASH: SHA1 digest, 160 bits */ | 97 | SHA_DIGEST_LENGTH, /* CERTHASH: SHA1 digest, 160 bits */ |
| 101 | -1, /* EMAIL: C string */ | 98 | -1, /* EMAIL: C string */ |
| 102 | -1, /* FILENAME: C string */ | 99 | -1, /* FILENAME: C string */ |
| 103 | }; | 100 | }; |
| 104 | 101 | ||
| 105 | STORE *STORE_new_method(const STORE_METHOD *method) | 102 | STORE * |
| 106 | { | 103 | STORE_new_method(const STORE_METHOD *method) |
| 104 | { | ||
| 107 | STORE *ret; | 105 | STORE *ret; |
| 108 | 106 | ||
| 109 | if (method == NULL) | 107 | if (method == NULL) { |
| 110 | { | 108 | STOREerr(STORE_F_STORE_NEW_METHOD, ERR_R_PASSED_NULL_PARAMETER); |
| 111 | STOREerr(STORE_F_STORE_NEW_METHOD,ERR_R_PASSED_NULL_PARAMETER); | ||
| 112 | return NULL; | 109 | return NULL; |
| 113 | } | 110 | } |
| 114 | 111 | ||
| 115 | ret=(STORE *)malloc(sizeof(STORE)); | 112 | ret = (STORE *)malloc(sizeof(STORE)); |
| 116 | if (ret == NULL) | 113 | if (ret == NULL) { |
| 117 | { | 114 | STOREerr(STORE_F_STORE_NEW_METHOD, ERR_R_MALLOC_FAILURE); |
| 118 | STOREerr(STORE_F_STORE_NEW_METHOD,ERR_R_MALLOC_FAILURE); | ||
| 119 | return NULL; | 115 | return NULL; |
| 120 | } | 116 | } |
| 121 | 117 | ||
| 122 | ret->meth=method; | 118 | ret->meth = method; |
| 123 | 119 | ||
| 124 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_STORE, ret, &ret->ex_data); | 120 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_STORE, ret, &ret->ex_data); |
| 125 | if (ret->meth->init && !ret->meth->init(ret)) | 121 | if (ret->meth->init && !ret->meth->init(ret)) { |
| 126 | { | ||
| 127 | STORE_free(ret); | 122 | STORE_free(ret); |
| 128 | ret = NULL; | 123 | ret = NULL; |
| 129 | } | ||
| 130 | return ret; | ||
| 131 | } | 124 | } |
| 125 | return ret; | ||
| 126 | } | ||
| 132 | 127 | ||
| 133 | STORE *STORE_new_engine(ENGINE *engine) | 128 | STORE * |
| 134 | { | 129 | STORE_new_engine(ENGINE *engine) |
| 130 | { | ||
| 135 | STORE *ret = NULL; | 131 | STORE *ret = NULL; |
| 136 | ENGINE *e = engine; | 132 | ENGINE *e = engine; |
| 137 | const STORE_METHOD *meth = 0; | 133 | const STORE_METHOD *meth = 0; |
| @@ -139,96 +135,95 @@ STORE *STORE_new_engine(ENGINE *engine) | |||
| 139 | #ifdef OPENSSL_NO_ENGINE | 135 | #ifdef OPENSSL_NO_ENGINE |
| 140 | e = NULL; | 136 | e = NULL; |
| 141 | #else | 137 | #else |
| 142 | if (engine) | 138 | if (engine) { |
| 143 | { | 139 | if (!ENGINE_init(engine)) { |
| 144 | if (!ENGINE_init(engine)) | ||
| 145 | { | ||
| 146 | STOREerr(STORE_F_STORE_NEW_ENGINE, ERR_R_ENGINE_LIB); | 140 | STOREerr(STORE_F_STORE_NEW_ENGINE, ERR_R_ENGINE_LIB); |
| 147 | return NULL; | 141 | return NULL; |
| 148 | } | ||
| 149 | e = engine; | ||
| 150 | } | 142 | } |
| 151 | else | 143 | e = engine; |
| 152 | { | 144 | } else { |
| 153 | STOREerr(STORE_F_STORE_NEW_ENGINE,ERR_R_PASSED_NULL_PARAMETER); | 145 | STOREerr(STORE_F_STORE_NEW_ENGINE, ERR_R_PASSED_NULL_PARAMETER); |
| 154 | return NULL; | 146 | return NULL; |
| 155 | } | 147 | } |
| 156 | if(e) | 148 | if (e) { |
| 157 | { | ||
| 158 | meth = ENGINE_get_STORE(e); | 149 | meth = ENGINE_get_STORE(e); |
| 159 | if(!meth) | 150 | if (!meth) { |
| 160 | { | ||
| 161 | STOREerr(STORE_F_STORE_NEW_ENGINE, | 151 | STOREerr(STORE_F_STORE_NEW_ENGINE, |
| 162 | ERR_R_ENGINE_LIB); | 152 | ERR_R_ENGINE_LIB); |
| 163 | ENGINE_finish(e); | 153 | ENGINE_finish(e); |
| 164 | return NULL; | 154 | return NULL; |
| 165 | } | ||
| 166 | } | 155 | } |
| 156 | } | ||
| 167 | #endif | 157 | #endif |
| 168 | 158 | ||
| 169 | ret = STORE_new_method(meth); | 159 | ret = STORE_new_method(meth); |
| 170 | if (ret == NULL) | 160 | if (ret == NULL) { |
| 171 | { | 161 | STOREerr(STORE_F_STORE_NEW_ENGINE, ERR_R_STORE_LIB); |
| 172 | STOREerr(STORE_F_STORE_NEW_ENGINE,ERR_R_STORE_LIB); | ||
| 173 | return NULL; | 162 | return NULL; |
| 174 | } | 163 | } |
| 175 | 164 | ||
| 176 | ret->engine = e; | 165 | ret->engine = e; |
| 177 | 166 | ||
| 178 | return(ret); | 167 | return (ret); |
| 179 | } | 168 | } |
| 180 | 169 | ||
| 181 | void STORE_free(STORE *store) | 170 | void |
| 182 | { | 171 | STORE_free(STORE *store) |
| 172 | { | ||
| 183 | if (store == NULL) | 173 | if (store == NULL) |
| 184 | return; | 174 | return; |
| 185 | if (store->meth->clean) | 175 | if (store->meth->clean) |
| 186 | store->meth->clean(store); | 176 | store->meth->clean(store); |
| 187 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_STORE, store, &store->ex_data); | 177 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_STORE, store, &store->ex_data); |
| 188 | free(store); | 178 | free(store); |
| 189 | } | 179 | } |
| 190 | 180 | ||
| 191 | int STORE_ctrl(STORE *store, int cmd, long i, void *p, void (*f)(void)) | 181 | int |
| 192 | { | 182 | STORE_ctrl(STORE *store, int cmd, long i, void *p, void (*f)(void)) |
| 193 | if (store == NULL) | 183 | { |
| 194 | { | 184 | if (store == NULL) { |
| 195 | STOREerr(STORE_F_STORE_CTRL,ERR_R_PASSED_NULL_PARAMETER); | 185 | STOREerr(STORE_F_STORE_CTRL, ERR_R_PASSED_NULL_PARAMETER); |
| 196 | return 0; | 186 | return 0; |
| 197 | } | 187 | } |
| 198 | if (store->meth->ctrl) | 188 | if (store->meth->ctrl) |
| 199 | return store->meth->ctrl(store, cmd, i, p, f); | 189 | return store->meth->ctrl(store, cmd, i, p, f); |
| 200 | STOREerr(STORE_F_STORE_CTRL,STORE_R_NO_CONTROL_FUNCTION); | 190 | STOREerr(STORE_F_STORE_CTRL, STORE_R_NO_CONTROL_FUNCTION); |
| 201 | return 0; | 191 | return 0; |
| 202 | } | 192 | } |
| 203 | 193 | ||
| 204 | 194 | ||
| 205 | int STORE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, | 195 | int |
| 206 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) | 196 | STORE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, |
| 207 | { | 197 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) |
| 198 | { | ||
| 208 | return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_STORE, argl, argp, | 199 | return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_STORE, argl, argp, |
| 209 | new_func, dup_func, free_func); | 200 | new_func, dup_func, free_func); |
| 210 | } | 201 | } |
| 211 | 202 | ||
| 212 | int STORE_set_ex_data(STORE *r, int idx, void *arg) | 203 | int |
| 213 | { | 204 | STORE_set_ex_data(STORE *r, int idx, void *arg) |
| 214 | return(CRYPTO_set_ex_data(&r->ex_data,idx,arg)); | 205 | { |
| 215 | } | 206 | return (CRYPTO_set_ex_data(&r->ex_data, idx, arg)); |
| 216 | 207 | } | |
| 217 | void *STORE_get_ex_data(STORE *r, int idx) | 208 | |
| 218 | { | 209 | void * |
| 219 | return(CRYPTO_get_ex_data(&r->ex_data,idx)); | 210 | STORE_get_ex_data(STORE *r, int idx) |
| 220 | } | 211 | { |
| 221 | 212 | return (CRYPTO_get_ex_data(&r->ex_data, idx)); | |
| 222 | const STORE_METHOD *STORE_get_method(STORE *store) | 213 | } |
| 223 | { | 214 | |
| 215 | const STORE_METHOD * | ||
| 216 | STORE_get_method(STORE *store) | ||
| 217 | { | ||
| 224 | return store->meth; | 218 | return store->meth; |
| 225 | } | 219 | } |
| 226 | 220 | ||
| 227 | const STORE_METHOD *STORE_set_method(STORE *store, const STORE_METHOD *meth) | 221 | const STORE_METHOD * |
| 228 | { | 222 | STORE_set_method(STORE *store, const STORE_METHOD *meth) |
| 229 | store->meth=meth; | 223 | { |
| 224 | store->meth = meth; | ||
| 230 | return store->meth; | 225 | return store->meth; |
| 231 | } | 226 | } |
| 232 | 227 | ||
| 233 | 228 | ||
| 234 | /* API helpers */ | 229 | /* API helpers */ |
| @@ -252,948 +247,946 @@ const STORE_METHOD *STORE_set_method(STORE *store, const STORE_METHOD *meth) | |||
| 252 | /* API functions */ | 247 | /* API functions */ |
| 253 | 248 | ||
| 254 | X509 *STORE_get_certificate(STORE *s, OPENSSL_ITEM attributes[], | 249 | X509 *STORE_get_certificate(STORE *s, OPENSSL_ITEM attributes[], |
| 255 | OPENSSL_ITEM parameters[]) | 250 | OPENSSL_ITEM parameters[]) |
| 256 | { | 251 | { |
| 257 | STORE_OBJECT *object; | 252 | STORE_OBJECT *object; |
| 258 | X509 *x; | 253 | X509 *x; |
| 259 | 254 | ||
| 260 | check_store(s,STORE_F_STORE_GET_CERTIFICATE, | 255 | check_store(s, STORE_F_STORE_GET_CERTIFICATE, |
| 261 | get_object,STORE_R_NO_GET_OBJECT_FUNCTION); | 256 | get_object, STORE_R_NO_GET_OBJECT_FUNCTION); |
| 262 | 257 | ||
| 263 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, | 258 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, |
| 264 | attributes, parameters); | 259 | attributes, parameters); |
| 265 | if (!object || !object->data.x509.certificate) | 260 | if (!object || !object->data.x509.certificate) { |
| 266 | { | ||
| 267 | STOREerr(STORE_F_STORE_GET_CERTIFICATE, | 261 | STOREerr(STORE_F_STORE_GET_CERTIFICATE, |
| 268 | STORE_R_FAILED_GETTING_CERTIFICATE); | 262 | STORE_R_FAILED_GETTING_CERTIFICATE); |
| 269 | return 0; | 263 | return 0; |
| 270 | } | 264 | } |
| 271 | CRYPTO_add(&object->data.x509.certificate->references,1,CRYPTO_LOCK_X509); | 265 | CRYPTO_add(&object->data.x509.certificate->references, |
| 266 | 1, CRYPTO_LOCK_X509); | ||
| 272 | x = object->data.x509.certificate; | 267 | x = object->data.x509.certificate; |
| 273 | STORE_OBJECT_free(object); | 268 | STORE_OBJECT_free(object); |
| 274 | return x; | 269 | return x; |
| 275 | } | 270 | } |
| 276 | 271 | ||
| 277 | int STORE_store_certificate(STORE *s, X509 *data, OPENSSL_ITEM attributes[], | 272 | int |
| 278 | OPENSSL_ITEM parameters[]) | 273 | STORE_store_certificate(STORE *s, X509 *data, OPENSSL_ITEM attributes[], |
| 279 | { | 274 | OPENSSL_ITEM parameters[]) |
| 275 | { | ||
| 280 | STORE_OBJECT *object; | 276 | STORE_OBJECT *object; |
| 281 | int i; | 277 | int i; |
| 282 | 278 | ||
| 283 | check_store(s,STORE_F_STORE_CERTIFICATE, | 279 | check_store(s, STORE_F_STORE_CERTIFICATE, |
| 284 | store_object,STORE_R_NO_STORE_OBJECT_FUNCTION); | 280 | store_object, STORE_R_NO_STORE_OBJECT_FUNCTION); |
| 285 | 281 | ||
| 286 | object = STORE_OBJECT_new(); | 282 | object = STORE_OBJECT_new(); |
| 287 | if (!object) | 283 | if (!object) { |
| 288 | { | ||
| 289 | STOREerr(STORE_F_STORE_STORE_CERTIFICATE, | 284 | STOREerr(STORE_F_STORE_STORE_CERTIFICATE, |
| 290 | ERR_R_MALLOC_FAILURE); | 285 | ERR_R_MALLOC_FAILURE); |
| 291 | return 0; | 286 | return 0; |
| 292 | } | 287 | } |
| 293 | 288 | ||
| 294 | CRYPTO_add(&data->references,1,CRYPTO_LOCK_X509); | 289 | CRYPTO_add(&data->references, 1, CRYPTO_LOCK_X509); |
| 295 | object->data.x509.certificate = data; | 290 | object->data.x509.certificate = data; |
| 296 | 291 | ||
| 297 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, | 292 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, |
| 298 | object, attributes, parameters); | 293 | object, attributes, parameters); |
| 299 | 294 | ||
| 300 | STORE_OBJECT_free(object); | 295 | STORE_OBJECT_free(object); |
| 301 | 296 | ||
| 302 | if (!i) | 297 | if (!i) { |
| 303 | { | ||
| 304 | STOREerr(STORE_F_STORE_STORE_CERTIFICATE, | 298 | STOREerr(STORE_F_STORE_STORE_CERTIFICATE, |
| 305 | STORE_R_FAILED_STORING_CERTIFICATE); | 299 | STORE_R_FAILED_STORING_CERTIFICATE); |
| 306 | return 0; | 300 | return 0; |
| 307 | } | ||
| 308 | return 1; | ||
| 309 | } | 301 | } |
| 302 | return 1; | ||
| 303 | } | ||
| 310 | 304 | ||
| 311 | int STORE_modify_certificate(STORE *s, OPENSSL_ITEM search_attributes[], | 305 | int |
| 312 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | 306 | STORE_modify_certificate(STORE *s, OPENSSL_ITEM search_attributes[], |
| 313 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) | 307 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], |
| 314 | { | 308 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) |
| 315 | check_store(s,STORE_F_STORE_MODIFY_CERTIFICATE, | 309 | { |
| 316 | modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION); | 310 | check_store(s, STORE_F_STORE_MODIFY_CERTIFICATE, |
| 311 | modify_object, STORE_R_NO_MODIFY_OBJECT_FUNCTION); | ||
| 317 | 312 | ||
| 318 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, | 313 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, |
| 319 | search_attributes, add_attributes, modify_attributes, | 314 | search_attributes, add_attributes, modify_attributes, |
| 320 | delete_attributes, parameters)) | 315 | delete_attributes, parameters)) { |
| 321 | { | ||
| 322 | STOREerr(STORE_F_STORE_MODIFY_CERTIFICATE, | 316 | STOREerr(STORE_F_STORE_MODIFY_CERTIFICATE, |
| 323 | STORE_R_FAILED_MODIFYING_CERTIFICATE); | 317 | STORE_R_FAILED_MODIFYING_CERTIFICATE); |
| 324 | return 0; | 318 | return 0; |
| 325 | } | ||
| 326 | return 1; | ||
| 327 | } | 319 | } |
| 320 | return 1; | ||
| 321 | } | ||
| 328 | 322 | ||
| 329 | int STORE_revoke_certificate(STORE *s, OPENSSL_ITEM attributes[], | 323 | int |
| 330 | OPENSSL_ITEM parameters[]) | 324 | STORE_revoke_certificate(STORE *s, OPENSSL_ITEM attributes[], |
| 331 | { | 325 | OPENSSL_ITEM parameters[]) |
| 332 | check_store(s,STORE_F_STORE_REVOKE_CERTIFICATE, | 326 | { |
| 333 | revoke_object,STORE_R_NO_REVOKE_OBJECT_FUNCTION); | 327 | check_store(s, STORE_F_STORE_REVOKE_CERTIFICATE, |
| 328 | revoke_object, STORE_R_NO_REVOKE_OBJECT_FUNCTION); | ||
| 334 | 329 | ||
| 335 | if (!s->meth->revoke_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, | 330 | if (!s->meth->revoke_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, |
| 336 | attributes, parameters)) | 331 | attributes, parameters)) { |
| 337 | { | ||
| 338 | STOREerr(STORE_F_STORE_REVOKE_CERTIFICATE, | 332 | STOREerr(STORE_F_STORE_REVOKE_CERTIFICATE, |
| 339 | STORE_R_FAILED_REVOKING_CERTIFICATE); | 333 | STORE_R_FAILED_REVOKING_CERTIFICATE); |
| 340 | return 0; | 334 | return 0; |
| 341 | } | ||
| 342 | return 1; | ||
| 343 | } | 335 | } |
| 336 | return 1; | ||
| 337 | } | ||
| 344 | 338 | ||
| 345 | int STORE_delete_certificate(STORE *s, OPENSSL_ITEM attributes[], | 339 | int |
| 346 | OPENSSL_ITEM parameters[]) | 340 | STORE_delete_certificate(STORE *s, OPENSSL_ITEM attributes[], |
| 347 | { | 341 | OPENSSL_ITEM parameters[]) |
| 348 | check_store(s,STORE_F_STORE_DELETE_CERTIFICATE, | 342 | { |
| 349 | delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION); | 343 | check_store(s, STORE_F_STORE_DELETE_CERTIFICATE, |
| 344 | delete_object, STORE_R_NO_DELETE_OBJECT_FUNCTION); | ||
| 350 | 345 | ||
| 351 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, | 346 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE, |
| 352 | attributes, parameters)) | 347 | attributes, parameters)) { |
| 353 | { | ||
| 354 | STOREerr(STORE_F_STORE_DELETE_CERTIFICATE, | 348 | STOREerr(STORE_F_STORE_DELETE_CERTIFICATE, |
| 355 | STORE_R_FAILED_DELETING_CERTIFICATE); | 349 | STORE_R_FAILED_DELETING_CERTIFICATE); |
| 356 | return 0; | 350 | return 0; |
| 357 | } | ||
| 358 | return 1; | ||
| 359 | } | 351 | } |
| 352 | return 1; | ||
| 353 | } | ||
| 360 | 354 | ||
| 361 | void *STORE_list_certificate_start(STORE *s, OPENSSL_ITEM attributes[], | 355 | void * |
| 362 | OPENSSL_ITEM parameters[]) | 356 | STORE_list_certificate_start(STORE *s, OPENSSL_ITEM attributes[], |
| 363 | { | 357 | OPENSSL_ITEM parameters[]) |
| 358 | { | ||
| 364 | void *handle; | 359 | void *handle; |
| 365 | 360 | ||
| 366 | check_store(s,STORE_F_STORE_LIST_CERTIFICATE_START, | 361 | check_store(s, STORE_F_STORE_LIST_CERTIFICATE_START, |
| 367 | list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION); | 362 | list_object_start, STORE_R_NO_LIST_OBJECT_START_FUNCTION); |
| 368 | 363 | ||
| 369 | handle = s->meth->list_object_start(s, | 364 | handle = s->meth->list_object_start(s, |
| 370 | STORE_OBJECT_TYPE_X509_CERTIFICATE, attributes, parameters); | 365 | STORE_OBJECT_TYPE_X509_CERTIFICATE, attributes, parameters); |
| 371 | if (!handle) | 366 | if (!handle) { |
| 372 | { | ||
| 373 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_START, | 367 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_START, |
| 374 | STORE_R_FAILED_LISTING_CERTIFICATES); | 368 | STORE_R_FAILED_LISTING_CERTIFICATES); |
| 375 | return 0; | 369 | return 0; |
| 376 | } | ||
| 377 | return handle; | ||
| 378 | } | 370 | } |
| 371 | return handle; | ||
| 372 | } | ||
| 379 | 373 | ||
| 380 | X509 *STORE_list_certificate_next(STORE *s, void *handle) | 374 | X509 * |
| 381 | { | 375 | STORE_list_certificate_next(STORE *s, void *handle) |
| 376 | { | ||
| 382 | STORE_OBJECT *object; | 377 | STORE_OBJECT *object; |
| 383 | X509 *x; | 378 | X509 *x; |
| 384 | 379 | ||
| 385 | check_store(s,STORE_F_STORE_LIST_CERTIFICATE_NEXT, | 380 | check_store(s, STORE_F_STORE_LIST_CERTIFICATE_NEXT, |
| 386 | list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); | 381 | list_object_next, STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); |
| 387 | 382 | ||
| 388 | object = s->meth->list_object_next(s, handle); | 383 | object = s->meth->list_object_next(s, handle); |
| 389 | if (!object || !object->data.x509.certificate) | 384 | if (!object || !object->data.x509.certificate) { |
| 390 | { | ||
| 391 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_NEXT, | 385 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_NEXT, |
| 392 | STORE_R_FAILED_LISTING_CERTIFICATES); | 386 | STORE_R_FAILED_LISTING_CERTIFICATES); |
| 393 | return 0; | 387 | return 0; |
| 394 | } | 388 | } |
| 395 | CRYPTO_add(&object->data.x509.certificate->references,1,CRYPTO_LOCK_X509); | 389 | CRYPTO_add(&object->data.x509.certificate->references, |
| 390 | 1, CRYPTO_LOCK_X509); | ||
| 396 | x = object->data.x509.certificate; | 391 | x = object->data.x509.certificate; |
| 397 | STORE_OBJECT_free(object); | 392 | STORE_OBJECT_free(object); |
| 398 | return x; | 393 | return x; |
| 399 | } | 394 | } |
| 400 | 395 | ||
| 401 | int STORE_list_certificate_end(STORE *s, void *handle) | 396 | int |
| 402 | { | 397 | STORE_list_certificate_end(STORE *s, void *handle) |
| 403 | check_store(s,STORE_F_STORE_LIST_CERTIFICATE_END, | 398 | { |
| 404 | list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION); | 399 | check_store(s, STORE_F_STORE_LIST_CERTIFICATE_END, |
| 400 | list_object_end, STORE_R_NO_LIST_OBJECT_END_FUNCTION); | ||
| 405 | 401 | ||
| 406 | if (!s->meth->list_object_end(s, handle)) | 402 | if (!s->meth->list_object_end(s, handle)) { |
| 407 | { | ||
| 408 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_END, | 403 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_END, |
| 409 | STORE_R_FAILED_LISTING_CERTIFICATES); | 404 | STORE_R_FAILED_LISTING_CERTIFICATES); |
| 410 | return 0; | 405 | return 0; |
| 411 | } | ||
| 412 | return 1; | ||
| 413 | } | 406 | } |
| 407 | return 1; | ||
| 408 | } | ||
| 414 | 409 | ||
| 415 | int STORE_list_certificate_endp(STORE *s, void *handle) | 410 | int |
| 416 | { | 411 | STORE_list_certificate_endp(STORE *s, void *handle) |
| 417 | check_store(s,STORE_F_STORE_LIST_CERTIFICATE_ENDP, | 412 | { |
| 418 | list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | 413 | check_store(s, STORE_F_STORE_LIST_CERTIFICATE_ENDP, |
| 414 | list_object_endp, STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | ||
| 419 | 415 | ||
| 420 | if (!s->meth->list_object_endp(s, handle)) | 416 | if (!s->meth->list_object_endp(s, handle)) { |
| 421 | { | ||
| 422 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_ENDP, | 417 | STOREerr(STORE_F_STORE_LIST_CERTIFICATE_ENDP, |
| 423 | STORE_R_FAILED_LISTING_CERTIFICATES); | 418 | STORE_R_FAILED_LISTING_CERTIFICATES); |
| 424 | return 0; | 419 | return 0; |
| 425 | } | ||
| 426 | return 1; | ||
| 427 | } | 420 | } |
| 421 | return 1; | ||
| 422 | } | ||
| 428 | 423 | ||
| 429 | EVP_PKEY *STORE_generate_key(STORE *s, OPENSSL_ITEM attributes[], | 424 | EVP_PKEY * |
| 430 | OPENSSL_ITEM parameters[]) | 425 | STORE_generate_key(STORE *s, OPENSSL_ITEM attributes[], |
| 431 | { | 426 | OPENSSL_ITEM parameters[]) |
| 427 | { | ||
| 432 | STORE_OBJECT *object; | 428 | STORE_OBJECT *object; |
| 433 | EVP_PKEY *pkey; | 429 | EVP_PKEY *pkey; |
| 434 | 430 | ||
| 435 | check_store(s,STORE_F_STORE_GENERATE_KEY, | 431 | check_store(s, STORE_F_STORE_GENERATE_KEY, |
| 436 | generate_object,STORE_R_NO_GENERATE_OBJECT_FUNCTION); | 432 | generate_object, STORE_R_NO_GENERATE_OBJECT_FUNCTION); |
| 437 | 433 | ||
| 438 | object = s->meth->generate_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, | 434 | object = s->meth->generate_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, |
| 439 | attributes, parameters); | 435 | attributes, parameters); |
| 440 | if (!object || !object->data.key) | 436 | if (!object || !object->data.key) { |
| 441 | { | ||
| 442 | STOREerr(STORE_F_STORE_GENERATE_KEY, | 437 | STOREerr(STORE_F_STORE_GENERATE_KEY, |
| 443 | STORE_R_FAILED_GENERATING_KEY); | 438 | STORE_R_FAILED_GENERATING_KEY); |
| 444 | return 0; | 439 | return 0; |
| 445 | } | 440 | } |
| 446 | CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY); | 441 | CRYPTO_add(&object->data.key->references, 1, CRYPTO_LOCK_EVP_PKEY); |
| 447 | pkey = object->data.key; | 442 | pkey = object->data.key; |
| 448 | STORE_OBJECT_free(object); | 443 | STORE_OBJECT_free(object); |
| 449 | return pkey; | 444 | return pkey; |
| 450 | } | 445 | } |
| 451 | 446 | ||
| 452 | EVP_PKEY *STORE_get_private_key(STORE *s, OPENSSL_ITEM attributes[], | 447 | EVP_PKEY * |
| 453 | OPENSSL_ITEM parameters[]) | 448 | STORE_get_private_key(STORE *s, OPENSSL_ITEM attributes[], |
| 454 | { | 449 | OPENSSL_ITEM parameters[]) |
| 450 | { | ||
| 455 | STORE_OBJECT *object; | 451 | STORE_OBJECT *object; |
| 456 | EVP_PKEY *pkey; | 452 | EVP_PKEY *pkey; |
| 457 | 453 | ||
| 458 | check_store(s,STORE_F_STORE_GET_PRIVATE_KEY, | 454 | check_store(s, STORE_F_STORE_GET_PRIVATE_KEY, |
| 459 | get_object,STORE_R_NO_GET_OBJECT_FUNCTION); | 455 | get_object, STORE_R_NO_GET_OBJECT_FUNCTION); |
| 460 | 456 | ||
| 461 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, | 457 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, |
| 462 | attributes, parameters); | 458 | attributes, parameters); |
| 463 | if (!object || !object->data.key) | 459 | if (!object || !object->data.key) { |
| 464 | { | ||
| 465 | STOREerr(STORE_F_STORE_GET_PRIVATE_KEY, | 460 | STOREerr(STORE_F_STORE_GET_PRIVATE_KEY, |
| 466 | STORE_R_FAILED_GETTING_KEY); | 461 | STORE_R_FAILED_GETTING_KEY); |
| 467 | return 0; | 462 | return 0; |
| 468 | } | 463 | } |
| 469 | CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY); | 464 | CRYPTO_add(&object->data.key->references, 1, CRYPTO_LOCK_EVP_PKEY); |
| 470 | pkey = object->data.key; | 465 | pkey = object->data.key; |
| 471 | STORE_OBJECT_free(object); | 466 | STORE_OBJECT_free(object); |
| 472 | return pkey; | 467 | return pkey; |
| 473 | } | 468 | } |
| 474 | 469 | ||
| 475 | int STORE_store_private_key(STORE *s, EVP_PKEY *data, OPENSSL_ITEM attributes[], | 470 | int |
| 476 | OPENSSL_ITEM parameters[]) | 471 | STORE_store_private_key(STORE *s, EVP_PKEY *data, OPENSSL_ITEM attributes[], |
| 477 | { | 472 | OPENSSL_ITEM parameters[]) |
| 473 | { | ||
| 478 | STORE_OBJECT *object; | 474 | STORE_OBJECT *object; |
| 479 | int i; | 475 | int i; |
| 480 | 476 | ||
| 481 | check_store(s,STORE_F_STORE_STORE_PRIVATE_KEY, | 477 | check_store(s, STORE_F_STORE_STORE_PRIVATE_KEY, |
| 482 | store_object,STORE_R_NO_STORE_OBJECT_FUNCTION); | 478 | store_object, STORE_R_NO_STORE_OBJECT_FUNCTION); |
| 483 | 479 | ||
| 484 | object = STORE_OBJECT_new(); | 480 | object = STORE_OBJECT_new(); |
| 485 | if (!object) | 481 | if (!object) { |
| 486 | { | ||
| 487 | STOREerr(STORE_F_STORE_STORE_PRIVATE_KEY, | 482 | STOREerr(STORE_F_STORE_STORE_PRIVATE_KEY, |
| 488 | ERR_R_MALLOC_FAILURE); | 483 | ERR_R_MALLOC_FAILURE); |
| 489 | return 0; | 484 | return 0; |
| 490 | } | 485 | } |
| 491 | object->data.key = EVP_PKEY_new(); | 486 | object->data.key = EVP_PKEY_new(); |
| 492 | if (!object->data.key) | 487 | if (!object->data.key) { |
| 493 | { | ||
| 494 | STOREerr(STORE_F_STORE_STORE_PRIVATE_KEY, | 488 | STOREerr(STORE_F_STORE_STORE_PRIVATE_KEY, |
| 495 | ERR_R_MALLOC_FAILURE); | 489 | ERR_R_MALLOC_FAILURE); |
| 496 | return 0; | 490 | return 0; |
| 497 | } | 491 | } |
| 498 | 492 | ||
| 499 | CRYPTO_add(&data->references,1,CRYPTO_LOCK_EVP_PKEY); | 493 | CRYPTO_add(&data->references, 1, CRYPTO_LOCK_EVP_PKEY); |
| 500 | object->data.key = data; | 494 | object->data.key = data; |
| 501 | 495 | ||
| 502 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, object, | 496 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, object, |
| 503 | attributes, parameters); | 497 | attributes, parameters); |
| 504 | 498 | ||
| 505 | STORE_OBJECT_free(object); | 499 | STORE_OBJECT_free(object); |
| 506 | 500 | ||
| 507 | if (!i) | 501 | if (!i) { |
| 508 | { | ||
| 509 | STOREerr(STORE_F_STORE_STORE_PRIVATE_KEY, | 502 | STOREerr(STORE_F_STORE_STORE_PRIVATE_KEY, |
| 510 | STORE_R_FAILED_STORING_KEY); | 503 | STORE_R_FAILED_STORING_KEY); |
| 511 | return 0; | 504 | return 0; |
| 512 | } | ||
| 513 | return i; | ||
| 514 | } | 505 | } |
| 506 | return i; | ||
| 507 | } | ||
| 515 | 508 | ||
| 516 | int STORE_modify_private_key(STORE *s, OPENSSL_ITEM search_attributes[], | 509 | int |
| 517 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | 510 | STORE_modify_private_key(STORE *s, OPENSSL_ITEM search_attributes[], |
| 518 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) | 511 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], |
| 519 | { | 512 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) |
| 520 | check_store(s,STORE_F_STORE_MODIFY_PRIVATE_KEY, | 513 | { |
| 521 | modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION); | 514 | check_store(s, STORE_F_STORE_MODIFY_PRIVATE_KEY, |
| 515 | modify_object, STORE_R_NO_MODIFY_OBJECT_FUNCTION); | ||
| 522 | 516 | ||
| 523 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, | 517 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, |
| 524 | search_attributes, add_attributes, modify_attributes, | 518 | search_attributes, add_attributes, modify_attributes, |
| 525 | delete_attributes, parameters)) | 519 | delete_attributes, parameters)) { |
| 526 | { | ||
| 527 | STOREerr(STORE_F_STORE_MODIFY_PRIVATE_KEY, | 520 | STOREerr(STORE_F_STORE_MODIFY_PRIVATE_KEY, |
| 528 | STORE_R_FAILED_MODIFYING_PRIVATE_KEY); | 521 | STORE_R_FAILED_MODIFYING_PRIVATE_KEY); |
| 529 | return 0; | 522 | return 0; |
| 530 | } | ||
| 531 | return 1; | ||
| 532 | } | 523 | } |
| 524 | return 1; | ||
| 525 | } | ||
| 533 | 526 | ||
| 534 | int STORE_revoke_private_key(STORE *s, OPENSSL_ITEM attributes[], | 527 | int |
| 535 | OPENSSL_ITEM parameters[]) | 528 | STORE_revoke_private_key(STORE *s, OPENSSL_ITEM attributes[], |
| 536 | { | 529 | OPENSSL_ITEM parameters[]) |
| 530 | { | ||
| 537 | int i; | 531 | int i; |
| 538 | 532 | ||
| 539 | check_store(s,STORE_F_STORE_REVOKE_PRIVATE_KEY, | 533 | check_store(s, STORE_F_STORE_REVOKE_PRIVATE_KEY, |
| 540 | revoke_object,STORE_R_NO_REVOKE_OBJECT_FUNCTION); | 534 | revoke_object, STORE_R_NO_REVOKE_OBJECT_FUNCTION); |
| 541 | 535 | ||
| 542 | i = s->meth->revoke_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, | 536 | i = s->meth->revoke_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, |
| 543 | attributes, parameters); | 537 | attributes, parameters); |
| 544 | 538 | ||
| 545 | if (!i) | 539 | if (!i) { |
| 546 | { | ||
| 547 | STOREerr(STORE_F_STORE_REVOKE_PRIVATE_KEY, | 540 | STOREerr(STORE_F_STORE_REVOKE_PRIVATE_KEY, |
| 548 | STORE_R_FAILED_REVOKING_KEY); | 541 | STORE_R_FAILED_REVOKING_KEY); |
| 549 | return 0; | 542 | return 0; |
| 550 | } | ||
| 551 | return i; | ||
| 552 | } | 543 | } |
| 544 | return i; | ||
| 545 | } | ||
| 546 | |||
| 547 | int | ||
| 548 | STORE_delete_private_key(STORE *s, OPENSSL_ITEM attributes[], | ||
| 549 | OPENSSL_ITEM parameters[]) | ||
| 550 | { | ||
| 551 | check_store(s, STORE_F_STORE_DELETE_PRIVATE_KEY, | ||
| 552 | delete_object, STORE_R_NO_DELETE_OBJECT_FUNCTION); | ||
| 553 | 553 | ||
| 554 | int STORE_delete_private_key(STORE *s, OPENSSL_ITEM attributes[], | ||
| 555 | OPENSSL_ITEM parameters[]) | ||
| 556 | { | ||
| 557 | check_store(s,STORE_F_STORE_DELETE_PRIVATE_KEY, | ||
| 558 | delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION); | ||
| 559 | |||
| 560 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, | 554 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, |
| 561 | attributes, parameters)) | 555 | attributes, parameters)) { |
| 562 | { | ||
| 563 | STOREerr(STORE_F_STORE_DELETE_PRIVATE_KEY, | 556 | STOREerr(STORE_F_STORE_DELETE_PRIVATE_KEY, |
| 564 | STORE_R_FAILED_DELETING_KEY); | 557 | STORE_R_FAILED_DELETING_KEY); |
| 565 | return 0; | 558 | return 0; |
| 566 | } | ||
| 567 | return 1; | ||
| 568 | } | 559 | } |
| 560 | return 1; | ||
| 561 | } | ||
| 569 | 562 | ||
| 570 | void *STORE_list_private_key_start(STORE *s, OPENSSL_ITEM attributes[], | 563 | void * |
| 571 | OPENSSL_ITEM parameters[]) | 564 | STORE_list_private_key_start(STORE *s, OPENSSL_ITEM attributes[], |
| 572 | { | 565 | OPENSSL_ITEM parameters[]) |
| 566 | { | ||
| 573 | void *handle; | 567 | void *handle; |
| 574 | 568 | ||
| 575 | check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_START, | 569 | check_store(s, STORE_F_STORE_LIST_PRIVATE_KEY_START, |
| 576 | list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION); | 570 | list_object_start, STORE_R_NO_LIST_OBJECT_START_FUNCTION); |
| 577 | 571 | ||
| 578 | handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_PRIVATE_KEY, | 572 | handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_PRIVATE_KEY, |
| 579 | attributes, parameters); | 573 | attributes, parameters); |
| 580 | if (!handle) | 574 | if (!handle) { |
| 581 | { | ||
| 582 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_START, | 575 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_START, |
| 583 | STORE_R_FAILED_LISTING_KEYS); | 576 | STORE_R_FAILED_LISTING_KEYS); |
| 584 | return 0; | 577 | return 0; |
| 585 | } | ||
| 586 | return handle; | ||
| 587 | } | 578 | } |
| 579 | return handle; | ||
| 580 | } | ||
| 588 | 581 | ||
| 589 | EVP_PKEY *STORE_list_private_key_next(STORE *s, void *handle) | 582 | EVP_PKEY * |
| 590 | { | 583 | STORE_list_private_key_next(STORE *s, void *handle) |
| 584 | { | ||
| 591 | STORE_OBJECT *object; | 585 | STORE_OBJECT *object; |
| 592 | EVP_PKEY *pkey; | 586 | EVP_PKEY *pkey; |
| 593 | 587 | ||
| 594 | check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_NEXT, | 588 | check_store(s, STORE_F_STORE_LIST_PRIVATE_KEY_NEXT, |
| 595 | list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); | 589 | list_object_next, STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); |
| 596 | 590 | ||
| 597 | object = s->meth->list_object_next(s, handle); | 591 | object = s->meth->list_object_next(s, handle); |
| 598 | if (!object || !object->data.key) | 592 | if (!object || !object->data.key) { |
| 599 | { | ||
| 600 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_NEXT, | 593 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_NEXT, |
| 601 | STORE_R_FAILED_LISTING_KEYS); | 594 | STORE_R_FAILED_LISTING_KEYS); |
| 602 | return 0; | 595 | return 0; |
| 603 | } | 596 | } |
| 604 | CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY); | 597 | CRYPTO_add(&object->data.key->references, 1, CRYPTO_LOCK_EVP_PKEY); |
| 605 | pkey = object->data.key; | 598 | pkey = object->data.key; |
| 606 | STORE_OBJECT_free(object); | 599 | STORE_OBJECT_free(object); |
| 607 | return pkey; | 600 | return pkey; |
| 608 | } | 601 | } |
| 609 | 602 | ||
| 610 | int STORE_list_private_key_end(STORE *s, void *handle) | 603 | int |
| 611 | { | 604 | STORE_list_private_key_end(STORE *s, void *handle) |
| 612 | check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_END, | 605 | { |
| 613 | list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION); | 606 | check_store(s, STORE_F_STORE_LIST_PRIVATE_KEY_END, |
| 607 | list_object_end, STORE_R_NO_LIST_OBJECT_END_FUNCTION); | ||
| 614 | 608 | ||
| 615 | if (!s->meth->list_object_end(s, handle)) | 609 | if (!s->meth->list_object_end(s, handle)) { |
| 616 | { | ||
| 617 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_END, | 610 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_END, |
| 618 | STORE_R_FAILED_LISTING_KEYS); | 611 | STORE_R_FAILED_LISTING_KEYS); |
| 619 | return 0; | 612 | return 0; |
| 620 | } | ||
| 621 | return 1; | ||
| 622 | } | 613 | } |
| 614 | return 1; | ||
| 615 | } | ||
| 623 | 616 | ||
| 624 | int STORE_list_private_key_endp(STORE *s, void *handle) | 617 | int |
| 625 | { | 618 | STORE_list_private_key_endp(STORE *s, void *handle) |
| 626 | check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_ENDP, | 619 | { |
| 627 | list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | 620 | check_store(s, STORE_F_STORE_LIST_PRIVATE_KEY_ENDP, |
| 621 | list_object_endp, STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | ||
| 628 | 622 | ||
| 629 | if (!s->meth->list_object_endp(s, handle)) | 623 | if (!s->meth->list_object_endp(s, handle)) { |
| 630 | { | ||
| 631 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_ENDP, | 624 | STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_ENDP, |
| 632 | STORE_R_FAILED_LISTING_KEYS); | 625 | STORE_R_FAILED_LISTING_KEYS); |
| 633 | return 0; | 626 | return 0; |
| 634 | } | ||
| 635 | return 1; | ||
| 636 | } | 627 | } |
| 628 | return 1; | ||
| 629 | } | ||
| 637 | 630 | ||
| 638 | EVP_PKEY *STORE_get_public_key(STORE *s, OPENSSL_ITEM attributes[], | 631 | EVP_PKEY * |
| 639 | OPENSSL_ITEM parameters[]) | 632 | STORE_get_public_key(STORE *s, OPENSSL_ITEM attributes[], |
| 640 | { | 633 | OPENSSL_ITEM parameters[]) |
| 634 | { | ||
| 641 | STORE_OBJECT *object; | 635 | STORE_OBJECT *object; |
| 642 | EVP_PKEY *pkey; | 636 | EVP_PKEY *pkey; |
| 643 | 637 | ||
| 644 | check_store(s,STORE_F_STORE_GET_PUBLIC_KEY, | 638 | check_store(s, STORE_F_STORE_GET_PUBLIC_KEY, |
| 645 | get_object,STORE_R_NO_GET_OBJECT_FUNCTION); | 639 | get_object, STORE_R_NO_GET_OBJECT_FUNCTION); |
| 646 | 640 | ||
| 647 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, | 641 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, |
| 648 | attributes, parameters); | 642 | attributes, parameters); |
| 649 | if (!object || !object->data.key) | 643 | if (!object || !object->data.key) { |
| 650 | { | ||
| 651 | STOREerr(STORE_F_STORE_GET_PUBLIC_KEY, | 644 | STOREerr(STORE_F_STORE_GET_PUBLIC_KEY, |
| 652 | STORE_R_FAILED_GETTING_KEY); | 645 | STORE_R_FAILED_GETTING_KEY); |
| 653 | return 0; | 646 | return 0; |
| 654 | } | 647 | } |
| 655 | CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY); | 648 | CRYPTO_add(&object->data.key->references, 1, CRYPTO_LOCK_EVP_PKEY); |
| 656 | pkey = object->data.key; | 649 | pkey = object->data.key; |
| 657 | STORE_OBJECT_free(object); | 650 | STORE_OBJECT_free(object); |
| 658 | return pkey; | 651 | return pkey; |
| 659 | } | 652 | } |
| 660 | 653 | ||
| 661 | int STORE_store_public_key(STORE *s, EVP_PKEY *data, OPENSSL_ITEM attributes[], | 654 | int |
| 662 | OPENSSL_ITEM parameters[]) | 655 | STORE_store_public_key(STORE *s, EVP_PKEY *data, OPENSSL_ITEM attributes[], |
| 663 | { | 656 | OPENSSL_ITEM parameters[]) |
| 657 | { | ||
| 664 | STORE_OBJECT *object; | 658 | STORE_OBJECT *object; |
| 665 | int i; | 659 | int i; |
| 666 | 660 | ||
| 667 | check_store(s,STORE_F_STORE_STORE_PUBLIC_KEY, | 661 | check_store(s, STORE_F_STORE_STORE_PUBLIC_KEY, |
| 668 | store_object,STORE_R_NO_STORE_OBJECT_FUNCTION); | 662 | store_object, STORE_R_NO_STORE_OBJECT_FUNCTION); |
| 669 | 663 | ||
| 670 | object = STORE_OBJECT_new(); | 664 | object = STORE_OBJECT_new(); |
| 671 | if (!object) | 665 | if (!object) { |
| 672 | { | ||
| 673 | STOREerr(STORE_F_STORE_STORE_PUBLIC_KEY, | 666 | STOREerr(STORE_F_STORE_STORE_PUBLIC_KEY, |
| 674 | ERR_R_MALLOC_FAILURE); | 667 | ERR_R_MALLOC_FAILURE); |
| 675 | return 0; | 668 | return 0; |
| 676 | } | 669 | } |
| 677 | object->data.key = EVP_PKEY_new(); | 670 | object->data.key = EVP_PKEY_new(); |
| 678 | if (!object->data.key) | 671 | if (!object->data.key) { |
| 679 | { | ||
| 680 | STOREerr(STORE_F_STORE_STORE_PUBLIC_KEY, | 672 | STOREerr(STORE_F_STORE_STORE_PUBLIC_KEY, |
| 681 | ERR_R_MALLOC_FAILURE); | 673 | ERR_R_MALLOC_FAILURE); |
| 682 | return 0; | 674 | return 0; |
| 683 | } | 675 | } |
| 684 | 676 | ||
| 685 | CRYPTO_add(&data->references,1,CRYPTO_LOCK_EVP_PKEY); | 677 | CRYPTO_add(&data->references, 1, CRYPTO_LOCK_EVP_PKEY); |
| 686 | object->data.key = data; | 678 | object->data.key = data; |
| 687 | 679 | ||
| 688 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, object, | 680 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, object, |
| 689 | attributes, parameters); | 681 | attributes, parameters); |
| 690 | 682 | ||
| 691 | STORE_OBJECT_free(object); | 683 | STORE_OBJECT_free(object); |
| 692 | 684 | ||
| 693 | if (!i) | 685 | if (!i) { |
| 694 | { | ||
| 695 | STOREerr(STORE_F_STORE_STORE_PUBLIC_KEY, | 686 | STOREerr(STORE_F_STORE_STORE_PUBLIC_KEY, |
| 696 | STORE_R_FAILED_STORING_KEY); | 687 | STORE_R_FAILED_STORING_KEY); |
| 697 | return 0; | 688 | return 0; |
| 698 | } | ||
| 699 | return i; | ||
| 700 | } | 689 | } |
| 690 | return i; | ||
| 691 | } | ||
| 701 | 692 | ||
| 702 | int STORE_modify_public_key(STORE *s, OPENSSL_ITEM search_attributes[], | 693 | int |
| 703 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | 694 | STORE_modify_public_key(STORE *s, OPENSSL_ITEM search_attributes[], |
| 704 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) | 695 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], |
| 705 | { | 696 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) |
| 706 | check_store(s,STORE_F_STORE_MODIFY_PUBLIC_KEY, | 697 | { |
| 707 | modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION); | 698 | check_store(s, STORE_F_STORE_MODIFY_PUBLIC_KEY, |
| 699 | modify_object, STORE_R_NO_MODIFY_OBJECT_FUNCTION); | ||
| 708 | 700 | ||
| 709 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, | 701 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, |
| 710 | search_attributes, add_attributes, modify_attributes, | 702 | search_attributes, add_attributes, modify_attributes, |
| 711 | delete_attributes, parameters)) | 703 | delete_attributes, parameters)) { |
| 712 | { | ||
| 713 | STOREerr(STORE_F_STORE_MODIFY_PUBLIC_KEY, | 704 | STOREerr(STORE_F_STORE_MODIFY_PUBLIC_KEY, |
| 714 | STORE_R_FAILED_MODIFYING_PUBLIC_KEY); | 705 | STORE_R_FAILED_MODIFYING_PUBLIC_KEY); |
| 715 | return 0; | 706 | return 0; |
| 716 | } | ||
| 717 | return 1; | ||
| 718 | } | 707 | } |
| 708 | return 1; | ||
| 709 | } | ||
| 719 | 710 | ||
| 720 | int STORE_revoke_public_key(STORE *s, OPENSSL_ITEM attributes[], | 711 | int |
| 721 | OPENSSL_ITEM parameters[]) | 712 | STORE_revoke_public_key(STORE *s, OPENSSL_ITEM attributes[], |
| 722 | { | 713 | OPENSSL_ITEM parameters[]) |
| 714 | { | ||
| 723 | int i; | 715 | int i; |
| 724 | 716 | ||
| 725 | check_store(s,STORE_F_STORE_REVOKE_PUBLIC_KEY, | 717 | check_store(s, STORE_F_STORE_REVOKE_PUBLIC_KEY, |
| 726 | revoke_object,STORE_R_NO_REVOKE_OBJECT_FUNCTION); | 718 | revoke_object, STORE_R_NO_REVOKE_OBJECT_FUNCTION); |
| 727 | 719 | ||
| 728 | i = s->meth->revoke_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, | 720 | i = s->meth->revoke_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, |
| 729 | attributes, parameters); | 721 | attributes, parameters); |
| 730 | 722 | ||
| 731 | if (!i) | 723 | if (!i) { |
| 732 | { | ||
| 733 | STOREerr(STORE_F_STORE_REVOKE_PUBLIC_KEY, | 724 | STOREerr(STORE_F_STORE_REVOKE_PUBLIC_KEY, |
| 734 | STORE_R_FAILED_REVOKING_KEY); | 725 | STORE_R_FAILED_REVOKING_KEY); |
| 735 | return 0; | 726 | return 0; |
| 736 | } | ||
| 737 | return i; | ||
| 738 | } | 727 | } |
| 728 | return i; | ||
| 729 | } | ||
| 730 | |||
| 731 | int | ||
| 732 | STORE_delete_public_key(STORE *s, OPENSSL_ITEM attributes[], | ||
| 733 | OPENSSL_ITEM parameters[]) | ||
| 734 | { | ||
| 735 | check_store(s, STORE_F_STORE_DELETE_PUBLIC_KEY, | ||
| 736 | delete_object, STORE_R_NO_DELETE_OBJECT_FUNCTION); | ||
| 739 | 737 | ||
| 740 | int STORE_delete_public_key(STORE *s, OPENSSL_ITEM attributes[], | ||
| 741 | OPENSSL_ITEM parameters[]) | ||
| 742 | { | ||
| 743 | check_store(s,STORE_F_STORE_DELETE_PUBLIC_KEY, | ||
| 744 | delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION); | ||
| 745 | |||
| 746 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, | 738 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, |
| 747 | attributes, parameters)) | 739 | attributes, parameters)) { |
| 748 | { | ||
| 749 | STOREerr(STORE_F_STORE_DELETE_PUBLIC_KEY, | 740 | STOREerr(STORE_F_STORE_DELETE_PUBLIC_KEY, |
| 750 | STORE_R_FAILED_DELETING_KEY); | 741 | STORE_R_FAILED_DELETING_KEY); |
| 751 | return 0; | 742 | return 0; |
| 752 | } | ||
| 753 | return 1; | ||
| 754 | } | 743 | } |
| 744 | return 1; | ||
| 745 | } | ||
| 755 | 746 | ||
| 756 | void *STORE_list_public_key_start(STORE *s, OPENSSL_ITEM attributes[], | 747 | void * |
| 757 | OPENSSL_ITEM parameters[]) | 748 | STORE_list_public_key_start(STORE *s, OPENSSL_ITEM attributes[], |
| 758 | { | 749 | OPENSSL_ITEM parameters[]) |
| 750 | { | ||
| 759 | void *handle; | 751 | void *handle; |
| 760 | 752 | ||
| 761 | check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_START, | 753 | check_store(s, STORE_F_STORE_LIST_PUBLIC_KEY_START, |
| 762 | list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION); | 754 | list_object_start, STORE_R_NO_LIST_OBJECT_START_FUNCTION); |
| 763 | 755 | ||
| 764 | handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_PUBLIC_KEY, | 756 | handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_PUBLIC_KEY, |
| 765 | attributes, parameters); | 757 | attributes, parameters); |
| 766 | if (!handle) | 758 | if (!handle) { |
| 767 | { | ||
| 768 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_START, | 759 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_START, |
| 769 | STORE_R_FAILED_LISTING_KEYS); | 760 | STORE_R_FAILED_LISTING_KEYS); |
| 770 | return 0; | 761 | return 0; |
| 771 | } | ||
| 772 | return handle; | ||
| 773 | } | 762 | } |
| 763 | return handle; | ||
| 764 | } | ||
| 774 | 765 | ||
| 775 | EVP_PKEY *STORE_list_public_key_next(STORE *s, void *handle) | 766 | EVP_PKEY * |
| 776 | { | 767 | STORE_list_public_key_next(STORE *s, void *handle) |
| 768 | { | ||
| 777 | STORE_OBJECT *object; | 769 | STORE_OBJECT *object; |
| 778 | EVP_PKEY *pkey; | 770 | EVP_PKEY *pkey; |
| 779 | 771 | ||
| 780 | check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_NEXT, | 772 | check_store(s, STORE_F_STORE_LIST_PUBLIC_KEY_NEXT, |
| 781 | list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); | 773 | list_object_next, STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); |
| 782 | 774 | ||
| 783 | object = s->meth->list_object_next(s, handle); | 775 | object = s->meth->list_object_next(s, handle); |
| 784 | if (!object || !object->data.key) | 776 | if (!object || !object->data.key) { |
| 785 | { | ||
| 786 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_NEXT, | 777 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_NEXT, |
| 787 | STORE_R_FAILED_LISTING_KEYS); | 778 | STORE_R_FAILED_LISTING_KEYS); |
| 788 | return 0; | 779 | return 0; |
| 789 | } | 780 | } |
| 790 | CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY); | 781 | CRYPTO_add(&object->data.key->references, 1, CRYPTO_LOCK_EVP_PKEY); |
| 791 | pkey = object->data.key; | 782 | pkey = object->data.key; |
| 792 | STORE_OBJECT_free(object); | 783 | STORE_OBJECT_free(object); |
| 793 | return pkey; | 784 | return pkey; |
| 794 | } | 785 | } |
| 795 | 786 | ||
| 796 | int STORE_list_public_key_end(STORE *s, void *handle) | 787 | int |
| 797 | { | 788 | STORE_list_public_key_end(STORE *s, void *handle) |
| 798 | check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_END, | 789 | { |
| 799 | list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION); | 790 | check_store(s, STORE_F_STORE_LIST_PUBLIC_KEY_END, |
| 791 | list_object_end, STORE_R_NO_LIST_OBJECT_END_FUNCTION); | ||
| 800 | 792 | ||
| 801 | if (!s->meth->list_object_end(s, handle)) | 793 | if (!s->meth->list_object_end(s, handle)) { |
| 802 | { | ||
| 803 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_END, | 794 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_END, |
| 804 | STORE_R_FAILED_LISTING_KEYS); | 795 | STORE_R_FAILED_LISTING_KEYS); |
| 805 | return 0; | 796 | return 0; |
| 806 | } | ||
| 807 | return 1; | ||
| 808 | } | 797 | } |
| 798 | return 1; | ||
| 799 | } | ||
| 809 | 800 | ||
| 810 | int STORE_list_public_key_endp(STORE *s, void *handle) | 801 | int |
| 811 | { | 802 | STORE_list_public_key_endp(STORE *s, void *handle) |
| 812 | check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_ENDP, | 803 | { |
| 813 | list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | 804 | check_store(s, STORE_F_STORE_LIST_PUBLIC_KEY_ENDP, |
| 805 | list_object_endp, STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | ||
| 814 | 806 | ||
| 815 | if (!s->meth->list_object_endp(s, handle)) | 807 | if (!s->meth->list_object_endp(s, handle)) { |
| 816 | { | ||
| 817 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_ENDP, | 808 | STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_ENDP, |
| 818 | STORE_R_FAILED_LISTING_KEYS); | 809 | STORE_R_FAILED_LISTING_KEYS); |
| 819 | return 0; | 810 | return 0; |
| 820 | } | ||
| 821 | return 1; | ||
| 822 | } | 811 | } |
| 812 | return 1; | ||
| 813 | } | ||
| 823 | 814 | ||
| 824 | X509_CRL *STORE_generate_crl(STORE *s, OPENSSL_ITEM attributes[], | 815 | X509_CRL * |
| 825 | OPENSSL_ITEM parameters[]) | 816 | STORE_generate_crl(STORE *s, OPENSSL_ITEM attributes[], |
| 826 | { | 817 | OPENSSL_ITEM parameters[]) |
| 818 | { | ||
| 827 | STORE_OBJECT *object; | 819 | STORE_OBJECT *object; |
| 828 | X509_CRL *crl; | 820 | X509_CRL *crl; |
| 829 | 821 | ||
| 830 | check_store(s,STORE_F_STORE_GENERATE_CRL, | 822 | check_store(s, STORE_F_STORE_GENERATE_CRL, |
| 831 | generate_object,STORE_R_NO_GENERATE_CRL_FUNCTION); | 823 | generate_object, STORE_R_NO_GENERATE_CRL_FUNCTION); |
| 832 | 824 | ||
| 833 | object = s->meth->generate_object(s, STORE_OBJECT_TYPE_X509_CRL, | 825 | object = s->meth->generate_object(s, STORE_OBJECT_TYPE_X509_CRL, |
| 834 | attributes, parameters); | 826 | attributes, parameters); |
| 835 | if (!object || !object->data.crl) | 827 | if (!object || !object->data.crl) { |
| 836 | { | ||
| 837 | STOREerr(STORE_F_STORE_GENERATE_CRL, | 828 | STOREerr(STORE_F_STORE_GENERATE_CRL, |
| 838 | STORE_R_FAILED_GENERATING_CRL); | 829 | STORE_R_FAILED_GENERATING_CRL); |
| 839 | return 0; | 830 | return 0; |
| 840 | } | 831 | } |
| 841 | CRYPTO_add(&object->data.crl->references,1,CRYPTO_LOCK_X509_CRL); | 832 | CRYPTO_add(&object->data.crl->references, 1, CRYPTO_LOCK_X509_CRL); |
| 842 | crl = object->data.crl; | 833 | crl = object->data.crl; |
| 843 | STORE_OBJECT_free(object); | 834 | STORE_OBJECT_free(object); |
| 844 | return crl; | 835 | return crl; |
| 845 | } | 836 | } |
| 846 | 837 | ||
| 847 | X509_CRL *STORE_get_crl(STORE *s, OPENSSL_ITEM attributes[], | 838 | X509_CRL * |
| 848 | OPENSSL_ITEM parameters[]) | 839 | STORE_get_crl(STORE *s, OPENSSL_ITEM attributes[], |
| 849 | { | 840 | OPENSSL_ITEM parameters[]) |
| 841 | { | ||
| 850 | STORE_OBJECT *object; | 842 | STORE_OBJECT *object; |
| 851 | X509_CRL *crl; | 843 | X509_CRL *crl; |
| 852 | 844 | ||
| 853 | check_store(s,STORE_F_STORE_GET_CRL, | 845 | check_store(s, STORE_F_STORE_GET_CRL, |
| 854 | get_object,STORE_R_NO_GET_OBJECT_FUNCTION); | 846 | get_object, STORE_R_NO_GET_OBJECT_FUNCTION); |
| 855 | 847 | ||
| 856 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_X509_CRL, | 848 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_X509_CRL, |
| 857 | attributes, parameters); | 849 | attributes, parameters); |
| 858 | if (!object || !object->data.crl) | 850 | if (!object || !object->data.crl) { |
| 859 | { | ||
| 860 | STOREerr(STORE_F_STORE_GET_CRL, | 851 | STOREerr(STORE_F_STORE_GET_CRL, |
| 861 | STORE_R_FAILED_GETTING_KEY); | 852 | STORE_R_FAILED_GETTING_KEY); |
| 862 | return 0; | 853 | return 0; |
| 863 | } | 854 | } |
| 864 | CRYPTO_add(&object->data.crl->references,1,CRYPTO_LOCK_X509_CRL); | 855 | CRYPTO_add(&object->data.crl->references, 1, CRYPTO_LOCK_X509_CRL); |
| 865 | crl = object->data.crl; | 856 | crl = object->data.crl; |
| 866 | STORE_OBJECT_free(object); | 857 | STORE_OBJECT_free(object); |
| 867 | return crl; | 858 | return crl; |
| 868 | } | 859 | } |
| 869 | 860 | ||
| 870 | int STORE_store_crl(STORE *s, X509_CRL *data, OPENSSL_ITEM attributes[], | 861 | int |
| 871 | OPENSSL_ITEM parameters[]) | 862 | STORE_store_crl(STORE *s, X509_CRL *data, OPENSSL_ITEM attributes[], |
| 872 | { | 863 | OPENSSL_ITEM parameters[]) |
| 864 | { | ||
| 873 | STORE_OBJECT *object; | 865 | STORE_OBJECT *object; |
| 874 | int i; | 866 | int i; |
| 875 | 867 | ||
| 876 | check_store(s,STORE_F_STORE_STORE_CRL, | 868 | check_store(s, STORE_F_STORE_STORE_CRL, |
| 877 | store_object,STORE_R_NO_STORE_OBJECT_FUNCTION); | 869 | store_object, STORE_R_NO_STORE_OBJECT_FUNCTION); |
| 878 | 870 | ||
| 879 | object = STORE_OBJECT_new(); | 871 | object = STORE_OBJECT_new(); |
| 880 | if (!object) | 872 | if (!object) { |
| 881 | { | ||
| 882 | STOREerr(STORE_F_STORE_STORE_CRL, | 873 | STOREerr(STORE_F_STORE_STORE_CRL, |
| 883 | ERR_R_MALLOC_FAILURE); | 874 | ERR_R_MALLOC_FAILURE); |
| 884 | return 0; | 875 | return 0; |
| 885 | } | 876 | } |
| 886 | 877 | ||
| 887 | CRYPTO_add(&data->references,1,CRYPTO_LOCK_X509_CRL); | 878 | CRYPTO_add(&data->references, 1, CRYPTO_LOCK_X509_CRL); |
| 888 | object->data.crl = data; | 879 | object->data.crl = data; |
| 889 | 880 | ||
| 890 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_X509_CRL, object, | 881 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_X509_CRL, object, |
| 891 | attributes, parameters); | 882 | attributes, parameters); |
| 892 | 883 | ||
| 893 | STORE_OBJECT_free(object); | 884 | STORE_OBJECT_free(object); |
| 894 | 885 | ||
| 895 | if (!i) | 886 | if (!i) { |
| 896 | { | ||
| 897 | STOREerr(STORE_F_STORE_STORE_CRL, | 887 | STOREerr(STORE_F_STORE_STORE_CRL, |
| 898 | STORE_R_FAILED_STORING_KEY); | 888 | STORE_R_FAILED_STORING_KEY); |
| 899 | return 0; | 889 | return 0; |
| 900 | } | ||
| 901 | return i; | ||
| 902 | } | 890 | } |
| 891 | return i; | ||
| 892 | } | ||
| 903 | 893 | ||
| 904 | int STORE_modify_crl(STORE *s, OPENSSL_ITEM search_attributes[], | 894 | int |
| 905 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | 895 | STORE_modify_crl(STORE *s, OPENSSL_ITEM search_attributes[], |
| 906 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) | 896 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], |
| 907 | { | 897 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) |
| 908 | check_store(s,STORE_F_STORE_MODIFY_CRL, | 898 | { |
| 909 | modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION); | 899 | check_store(s, STORE_F_STORE_MODIFY_CRL, |
| 900 | modify_object, STORE_R_NO_MODIFY_OBJECT_FUNCTION); | ||
| 910 | 901 | ||
| 911 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_X509_CRL, | 902 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_X509_CRL, |
| 912 | search_attributes, add_attributes, modify_attributes, | 903 | search_attributes, add_attributes, modify_attributes, |
| 913 | delete_attributes, parameters)) | 904 | delete_attributes, parameters)) { |
| 914 | { | ||
| 915 | STOREerr(STORE_F_STORE_MODIFY_CRL, | 905 | STOREerr(STORE_F_STORE_MODIFY_CRL, |
| 916 | STORE_R_FAILED_MODIFYING_CRL); | 906 | STORE_R_FAILED_MODIFYING_CRL); |
| 917 | return 0; | 907 | return 0; |
| 918 | } | ||
| 919 | return 1; | ||
| 920 | } | 908 | } |
| 909 | return 1; | ||
| 910 | } | ||
| 911 | |||
| 912 | int | ||
| 913 | STORE_delete_crl(STORE *s, OPENSSL_ITEM attributes[], | ||
| 914 | OPENSSL_ITEM parameters[]) | ||
| 915 | { | ||
| 916 | check_store(s, STORE_F_STORE_DELETE_CRL, | ||
| 917 | delete_object, STORE_R_NO_DELETE_OBJECT_FUNCTION); | ||
| 921 | 918 | ||
| 922 | int STORE_delete_crl(STORE *s, OPENSSL_ITEM attributes[], | ||
| 923 | OPENSSL_ITEM parameters[]) | ||
| 924 | { | ||
| 925 | check_store(s,STORE_F_STORE_DELETE_CRL, | ||
| 926 | delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION); | ||
| 927 | |||
| 928 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_X509_CRL, | 919 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_X509_CRL, |
| 929 | attributes, parameters)) | 920 | attributes, parameters)) { |
| 930 | { | ||
| 931 | STOREerr(STORE_F_STORE_DELETE_CRL, | 921 | STOREerr(STORE_F_STORE_DELETE_CRL, |
| 932 | STORE_R_FAILED_DELETING_KEY); | 922 | STORE_R_FAILED_DELETING_KEY); |
| 933 | return 0; | 923 | return 0; |
| 934 | } | ||
| 935 | return 1; | ||
| 936 | } | 924 | } |
| 925 | return 1; | ||
| 926 | } | ||
| 937 | 927 | ||
| 938 | void *STORE_list_crl_start(STORE *s, OPENSSL_ITEM attributes[], | 928 | void * |
| 939 | OPENSSL_ITEM parameters[]) | 929 | STORE_list_crl_start(STORE *s, OPENSSL_ITEM attributes[], |
| 940 | { | 930 | OPENSSL_ITEM parameters[]) |
| 931 | { | ||
| 941 | void *handle; | 932 | void *handle; |
| 942 | 933 | ||
| 943 | check_store(s,STORE_F_STORE_LIST_CRL_START, | 934 | check_store(s, STORE_F_STORE_LIST_CRL_START, |
| 944 | list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION); | 935 | list_object_start, STORE_R_NO_LIST_OBJECT_START_FUNCTION); |
| 945 | 936 | ||
| 946 | handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_X509_CRL, | 937 | handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_X509_CRL, |
| 947 | attributes, parameters); | 938 | attributes, parameters); |
| 948 | if (!handle) | 939 | if (!handle) { |
| 949 | { | ||
| 950 | STOREerr(STORE_F_STORE_LIST_CRL_START, | 940 | STOREerr(STORE_F_STORE_LIST_CRL_START, |
| 951 | STORE_R_FAILED_LISTING_KEYS); | 941 | STORE_R_FAILED_LISTING_KEYS); |
| 952 | return 0; | 942 | return 0; |
| 953 | } | ||
| 954 | return handle; | ||
| 955 | } | 943 | } |
| 944 | return handle; | ||
| 945 | } | ||
| 956 | 946 | ||
| 957 | X509_CRL *STORE_list_crl_next(STORE *s, void *handle) | 947 | X509_CRL * |
| 958 | { | 948 | STORE_list_crl_next(STORE *s, void *handle) |
| 949 | { | ||
| 959 | STORE_OBJECT *object; | 950 | STORE_OBJECT *object; |
| 960 | X509_CRL *crl; | 951 | X509_CRL *crl; |
| 961 | 952 | ||
| 962 | check_store(s,STORE_F_STORE_LIST_CRL_NEXT, | 953 | check_store(s, STORE_F_STORE_LIST_CRL_NEXT, |
| 963 | list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); | 954 | list_object_next, STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION); |
| 964 | 955 | ||
| 965 | object = s->meth->list_object_next(s, handle); | 956 | object = s->meth->list_object_next(s, handle); |
| 966 | if (!object || !object->data.crl) | 957 | if (!object || !object->data.crl) { |
| 967 | { | ||
| 968 | STOREerr(STORE_F_STORE_LIST_CRL_NEXT, | 958 | STOREerr(STORE_F_STORE_LIST_CRL_NEXT, |
| 969 | STORE_R_FAILED_LISTING_KEYS); | 959 | STORE_R_FAILED_LISTING_KEYS); |
| 970 | return 0; | 960 | return 0; |
| 971 | } | 961 | } |
| 972 | CRYPTO_add(&object->data.crl->references,1,CRYPTO_LOCK_X509_CRL); | 962 | CRYPTO_add(&object->data.crl->references, 1, CRYPTO_LOCK_X509_CRL); |
| 973 | crl = object->data.crl; | 963 | crl = object->data.crl; |
| 974 | STORE_OBJECT_free(object); | 964 | STORE_OBJECT_free(object); |
| 975 | return crl; | 965 | return crl; |
| 976 | } | 966 | } |
| 977 | 967 | ||
| 978 | int STORE_list_crl_end(STORE *s, void *handle) | 968 | int |
| 979 | { | 969 | STORE_list_crl_end(STORE *s, void *handle) |
| 980 | check_store(s,STORE_F_STORE_LIST_CRL_END, | 970 | { |
| 981 | list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION); | 971 | check_store(s, STORE_F_STORE_LIST_CRL_END, |
| 972 | list_object_end, STORE_R_NO_LIST_OBJECT_END_FUNCTION); | ||
| 982 | 973 | ||
| 983 | if (!s->meth->list_object_end(s, handle)) | 974 | if (!s->meth->list_object_end(s, handle)) { |
| 984 | { | ||
| 985 | STOREerr(STORE_F_STORE_LIST_CRL_END, | 975 | STOREerr(STORE_F_STORE_LIST_CRL_END, |
| 986 | STORE_R_FAILED_LISTING_KEYS); | 976 | STORE_R_FAILED_LISTING_KEYS); |
| 987 | return 0; | 977 | return 0; |
| 988 | } | ||
| 989 | return 1; | ||
| 990 | } | 978 | } |
| 979 | return 1; | ||
| 980 | } | ||
| 991 | 981 | ||
| 992 | int STORE_list_crl_endp(STORE *s, void *handle) | 982 | int |
| 993 | { | 983 | STORE_list_crl_endp(STORE *s, void *handle) |
| 994 | check_store(s,STORE_F_STORE_LIST_CRL_ENDP, | 984 | { |
| 995 | list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | 985 | check_store(s, STORE_F_STORE_LIST_CRL_ENDP, |
| 986 | list_object_endp, STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION); | ||
| 996 | 987 | ||
| 997 | if (!s->meth->list_object_endp(s, handle)) | 988 | if (!s->meth->list_object_endp(s, handle)) { |
| 998 | { | ||
| 999 | STOREerr(STORE_F_STORE_LIST_CRL_ENDP, | 989 | STOREerr(STORE_F_STORE_LIST_CRL_ENDP, |
| 1000 | STORE_R_FAILED_LISTING_KEYS); | 990 | STORE_R_FAILED_LISTING_KEYS); |
| 1001 | return 0; | 991 | return 0; |
| 1002 | } | ||
| 1003 | return 1; | ||
| 1004 | } | 992 | } |
| 993 | return 1; | ||
| 994 | } | ||
| 1005 | 995 | ||
| 1006 | int STORE_store_number(STORE *s, BIGNUM *data, OPENSSL_ITEM attributes[], | 996 | int |
| 1007 | OPENSSL_ITEM parameters[]) | 997 | STORE_store_number(STORE *s, BIGNUM *data, OPENSSL_ITEM attributes[], |
| 1008 | { | 998 | OPENSSL_ITEM parameters[]) |
| 999 | { | ||
| 1009 | STORE_OBJECT *object; | 1000 | STORE_OBJECT *object; |
| 1010 | int i; | 1001 | int i; |
| 1011 | 1002 | ||
| 1012 | check_store(s,STORE_F_STORE_STORE_NUMBER, | 1003 | check_store(s, STORE_F_STORE_STORE_NUMBER, |
| 1013 | store_object,STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION); | 1004 | store_object, STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION); |
| 1014 | 1005 | ||
| 1015 | object = STORE_OBJECT_new(); | 1006 | object = STORE_OBJECT_new(); |
| 1016 | if (!object) | 1007 | if (!object) { |
| 1017 | { | ||
| 1018 | STOREerr(STORE_F_STORE_STORE_NUMBER, | 1008 | STOREerr(STORE_F_STORE_STORE_NUMBER, |
| 1019 | ERR_R_MALLOC_FAILURE); | 1009 | ERR_R_MALLOC_FAILURE); |
| 1020 | return 0; | 1010 | return 0; |
| 1021 | } | 1011 | } |
| 1022 | 1012 | ||
| 1023 | object->data.number = data; | 1013 | object->data.number = data; |
| 1024 | 1014 | ||
| 1025 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_NUMBER, object, | 1015 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_NUMBER, object, |
| 1026 | attributes, parameters); | 1016 | attributes, parameters); |
| 1027 | 1017 | ||
| 1028 | STORE_OBJECT_free(object); | 1018 | STORE_OBJECT_free(object); |
| 1029 | 1019 | ||
| 1030 | if (!i) | 1020 | if (!i) { |
| 1031 | { | ||
| 1032 | STOREerr(STORE_F_STORE_STORE_NUMBER, | 1021 | STOREerr(STORE_F_STORE_STORE_NUMBER, |
| 1033 | STORE_R_FAILED_STORING_NUMBER); | 1022 | STORE_R_FAILED_STORING_NUMBER); |
| 1034 | return 0; | 1023 | return 0; |
| 1035 | } | ||
| 1036 | return 1; | ||
| 1037 | } | 1024 | } |
| 1025 | return 1; | ||
| 1026 | } | ||
| 1038 | 1027 | ||
| 1039 | int STORE_modify_number(STORE *s, OPENSSL_ITEM search_attributes[], | 1028 | int |
| 1040 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | 1029 | STORE_modify_number(STORE *s, OPENSSL_ITEM search_attributes[], |
| 1041 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) | 1030 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], |
| 1042 | { | 1031 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) |
| 1043 | check_store(s,STORE_F_STORE_MODIFY_NUMBER, | 1032 | { |
| 1044 | modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION); | 1033 | check_store(s, STORE_F_STORE_MODIFY_NUMBER, |
| 1034 | modify_object, STORE_R_NO_MODIFY_OBJECT_FUNCTION); | ||
| 1045 | 1035 | ||
| 1046 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_NUMBER, | 1036 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_NUMBER, |
| 1047 | search_attributes, add_attributes, modify_attributes, | 1037 | search_attributes, add_attributes, modify_attributes, |
| 1048 | delete_attributes, parameters)) | 1038 | delete_attributes, parameters)) { |
| 1049 | { | ||
| 1050 | STOREerr(STORE_F_STORE_MODIFY_NUMBER, | 1039 | STOREerr(STORE_F_STORE_MODIFY_NUMBER, |
| 1051 | STORE_R_FAILED_MODIFYING_NUMBER); | 1040 | STORE_R_FAILED_MODIFYING_NUMBER); |
| 1052 | return 0; | 1041 | return 0; |
| 1053 | } | ||
| 1054 | return 1; | ||
| 1055 | } | 1042 | } |
| 1043 | return 1; | ||
| 1044 | } | ||
| 1056 | 1045 | ||
| 1057 | BIGNUM *STORE_get_number(STORE *s, OPENSSL_ITEM attributes[], | 1046 | BIGNUM * |
| 1058 | OPENSSL_ITEM parameters[]) | 1047 | STORE_get_number(STORE *s, OPENSSL_ITEM attributes[], |
| 1059 | { | 1048 | OPENSSL_ITEM parameters[]) |
| 1049 | { | ||
| 1060 | STORE_OBJECT *object; | 1050 | STORE_OBJECT *object; |
| 1061 | BIGNUM *n; | 1051 | BIGNUM *n; |
| 1062 | 1052 | ||
| 1063 | check_store(s,STORE_F_STORE_GET_NUMBER, | 1053 | check_store(s, STORE_F_STORE_GET_NUMBER, |
| 1064 | get_object,STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION); | 1054 | get_object, STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION); |
| 1065 | 1055 | ||
| 1066 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_NUMBER, attributes, | 1056 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_NUMBER, attributes, |
| 1067 | parameters); | 1057 | parameters); |
| 1068 | if (!object || !object->data.number) | 1058 | if (!object || !object->data.number) { |
| 1069 | { | ||
| 1070 | STOREerr(STORE_F_STORE_GET_NUMBER, | 1059 | STOREerr(STORE_F_STORE_GET_NUMBER, |
| 1071 | STORE_R_FAILED_GETTING_NUMBER); | 1060 | STORE_R_FAILED_GETTING_NUMBER); |
| 1072 | return 0; | 1061 | return 0; |
| 1073 | } | 1062 | } |
| 1074 | n = object->data.number; | 1063 | n = object->data.number; |
| 1075 | object->data.number = NULL; | 1064 | object->data.number = NULL; |
| 1076 | STORE_OBJECT_free(object); | 1065 | STORE_OBJECT_free(object); |
| 1077 | return n; | 1066 | return n; |
| 1078 | } | 1067 | } |
| 1079 | 1068 | ||
| 1080 | int STORE_delete_number(STORE *s, OPENSSL_ITEM attributes[], | 1069 | int |
| 1081 | OPENSSL_ITEM parameters[]) | 1070 | STORE_delete_number(STORE *s, OPENSSL_ITEM attributes[], |
| 1082 | { | 1071 | OPENSSL_ITEM parameters[]) |
| 1083 | check_store(s,STORE_F_STORE_DELETE_NUMBER, | 1072 | { |
| 1084 | delete_object,STORE_R_NO_DELETE_NUMBER_FUNCTION); | 1073 | check_store(s, STORE_F_STORE_DELETE_NUMBER, |
| 1074 | delete_object, STORE_R_NO_DELETE_NUMBER_FUNCTION); | ||
| 1085 | 1075 | ||
| 1086 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_NUMBER, attributes, | 1076 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_NUMBER, attributes, |
| 1087 | parameters)) | 1077 | parameters)) { |
| 1088 | { | ||
| 1089 | STOREerr(STORE_F_STORE_DELETE_NUMBER, | 1078 | STOREerr(STORE_F_STORE_DELETE_NUMBER, |
| 1090 | STORE_R_FAILED_DELETING_NUMBER); | 1079 | STORE_R_FAILED_DELETING_NUMBER); |
| 1091 | return 0; | 1080 | return 0; |
| 1092 | } | ||
| 1093 | return 1; | ||
| 1094 | } | 1081 | } |
| 1082 | return 1; | ||
| 1083 | } | ||
| 1095 | 1084 | ||
| 1096 | int STORE_store_arbitrary(STORE *s, BUF_MEM *data, OPENSSL_ITEM attributes[], | 1085 | int |
| 1097 | OPENSSL_ITEM parameters[]) | 1086 | STORE_store_arbitrary(STORE *s, BUF_MEM *data, OPENSSL_ITEM attributes[], |
| 1098 | { | 1087 | OPENSSL_ITEM parameters[]) |
| 1088 | { | ||
| 1099 | STORE_OBJECT *object; | 1089 | STORE_OBJECT *object; |
| 1100 | int i; | 1090 | int i; |
| 1101 | 1091 | ||
| 1102 | check_store(s,STORE_F_STORE_STORE_ARBITRARY, | 1092 | check_store(s, STORE_F_STORE_STORE_ARBITRARY, |
| 1103 | store_object,STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION); | 1093 | store_object, STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION); |
| 1104 | 1094 | ||
| 1105 | object = STORE_OBJECT_new(); | 1095 | object = STORE_OBJECT_new(); |
| 1106 | if (!object) | 1096 | if (!object) { |
| 1107 | { | ||
| 1108 | STOREerr(STORE_F_STORE_STORE_ARBITRARY, | 1097 | STOREerr(STORE_F_STORE_STORE_ARBITRARY, |
| 1109 | ERR_R_MALLOC_FAILURE); | 1098 | ERR_R_MALLOC_FAILURE); |
| 1110 | return 0; | 1099 | return 0; |
| 1111 | } | 1100 | } |
| 1112 | 1101 | ||
| 1113 | object->data.arbitrary = data; | 1102 | object->data.arbitrary = data; |
| 1114 | 1103 | ||
| 1115 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_ARBITRARY, object, | 1104 | i = s->meth->store_object(s, STORE_OBJECT_TYPE_ARBITRARY, object, |
| 1116 | attributes, parameters); | 1105 | attributes, parameters); |
| 1117 | 1106 | ||
| 1118 | STORE_OBJECT_free(object); | 1107 | STORE_OBJECT_free(object); |
| 1119 | 1108 | ||
| 1120 | if (!i) | 1109 | if (!i) { |
| 1121 | { | ||
| 1122 | STOREerr(STORE_F_STORE_STORE_ARBITRARY, | 1110 | STOREerr(STORE_F_STORE_STORE_ARBITRARY, |
| 1123 | STORE_R_FAILED_STORING_ARBITRARY); | 1111 | STORE_R_FAILED_STORING_ARBITRARY); |
| 1124 | return 0; | 1112 | return 0; |
| 1125 | } | ||
| 1126 | return 1; | ||
| 1127 | } | 1113 | } |
| 1114 | return 1; | ||
| 1115 | } | ||
| 1128 | 1116 | ||
| 1129 | int STORE_modify_arbitrary(STORE *s, OPENSSL_ITEM search_attributes[], | 1117 | int |
| 1130 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], | 1118 | STORE_modify_arbitrary(STORE *s, OPENSSL_ITEM search_attributes[], |
| 1131 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) | 1119 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], |
| 1132 | { | 1120 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) |
| 1133 | check_store(s,STORE_F_STORE_MODIFY_ARBITRARY, | 1121 | { |
| 1134 | modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION); | 1122 | check_store(s, STORE_F_STORE_MODIFY_ARBITRARY, |
| 1123 | modify_object, STORE_R_NO_MODIFY_OBJECT_FUNCTION); | ||
| 1135 | 1124 | ||
| 1136 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_ARBITRARY, | 1125 | if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_ARBITRARY, |
| 1137 | search_attributes, add_attributes, modify_attributes, | 1126 | search_attributes, add_attributes, modify_attributes, |
| 1138 | delete_attributes, parameters)) | 1127 | delete_attributes, parameters)) { |
| 1139 | { | ||
| 1140 | STOREerr(STORE_F_STORE_MODIFY_ARBITRARY, | 1128 | STOREerr(STORE_F_STORE_MODIFY_ARBITRARY, |
| 1141 | STORE_R_FAILED_MODIFYING_ARBITRARY); | 1129 | STORE_R_FAILED_MODIFYING_ARBITRARY); |
| 1142 | return 0; | 1130 | return 0; |
| 1143 | } | ||
| 1144 | return 1; | ||
| 1145 | } | 1131 | } |
| 1132 | return 1; | ||
| 1133 | } | ||
| 1146 | 1134 | ||
| 1147 | BUF_MEM *STORE_get_arbitrary(STORE *s, OPENSSL_ITEM attributes[], | 1135 | BUF_MEM * |
| 1148 | OPENSSL_ITEM parameters[]) | 1136 | STORE_get_arbitrary(STORE *s, OPENSSL_ITEM attributes[], |
| 1149 | { | 1137 | OPENSSL_ITEM parameters[]) |
| 1138 | { | ||
| 1150 | STORE_OBJECT *object; | 1139 | STORE_OBJECT *object; |
| 1151 | BUF_MEM *b; | 1140 | BUF_MEM *b; |
| 1152 | 1141 | ||
| 1153 | check_store(s,STORE_F_STORE_GET_ARBITRARY, | 1142 | check_store(s, STORE_F_STORE_GET_ARBITRARY, |
| 1154 | get_object,STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION); | 1143 | get_object, STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION); |
| 1155 | 1144 | ||
| 1156 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_ARBITRARY, | 1145 | object = s->meth->get_object(s, STORE_OBJECT_TYPE_ARBITRARY, |
| 1157 | attributes, parameters); | 1146 | attributes, parameters); |
| 1158 | if (!object || !object->data.arbitrary) | 1147 | if (!object || !object->data.arbitrary) { |
| 1159 | { | ||
| 1160 | STOREerr(STORE_F_STORE_GET_ARBITRARY, | 1148 | STOREerr(STORE_F_STORE_GET_ARBITRARY, |
| 1161 | STORE_R_FAILED_GETTING_ARBITRARY); | 1149 | STORE_R_FAILED_GETTING_ARBITRARY); |
| 1162 | return 0; | 1150 | return 0; |
| 1163 | } | 1151 | } |
| 1164 | b = object->data.arbitrary; | 1152 | b = object->data.arbitrary; |
| 1165 | object->data.arbitrary = NULL; | 1153 | object->data.arbitrary = NULL; |
| 1166 | STORE_OBJECT_free(object); | 1154 | STORE_OBJECT_free(object); |
| 1167 | return b; | 1155 | return b; |
| 1168 | } | 1156 | } |
| 1169 | 1157 | ||
| 1170 | int STORE_delete_arbitrary(STORE *s, OPENSSL_ITEM attributes[], | 1158 | int |
| 1171 | OPENSSL_ITEM parameters[]) | 1159 | STORE_delete_arbitrary(STORE *s, OPENSSL_ITEM attributes[], |
| 1172 | { | 1160 | OPENSSL_ITEM parameters[]) |
| 1173 | check_store(s,STORE_F_STORE_DELETE_ARBITRARY, | 1161 | { |
| 1174 | delete_object,STORE_R_NO_DELETE_ARBITRARY_FUNCTION); | 1162 | check_store(s, STORE_F_STORE_DELETE_ARBITRARY, |
| 1163 | delete_object, STORE_R_NO_DELETE_ARBITRARY_FUNCTION); | ||
| 1175 | 1164 | ||
| 1176 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_ARBITRARY, attributes, | 1165 | if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_ARBITRARY, attributes, |
| 1177 | parameters)) | 1166 | parameters)) { |
| 1178 | { | ||
| 1179 | STOREerr(STORE_F_STORE_DELETE_ARBITRARY, | 1167 | STOREerr(STORE_F_STORE_DELETE_ARBITRARY, |
| 1180 | STORE_R_FAILED_DELETING_ARBITRARY); | 1168 | STORE_R_FAILED_DELETING_ARBITRARY); |
| 1181 | return 0; | 1169 | return 0; |
| 1182 | } | ||
| 1183 | return 1; | ||
| 1184 | } | 1170 | } |
| 1171 | return 1; | ||
| 1172 | } | ||
| 1185 | 1173 | ||
| 1186 | STORE_OBJECT *STORE_OBJECT_new(void) | 1174 | STORE_OBJECT * |
| 1187 | { | 1175 | STORE_OBJECT_new(void) |
| 1176 | { | ||
| 1188 | STORE_OBJECT *object = malloc(sizeof(STORE_OBJECT)); | 1177 | STORE_OBJECT *object = malloc(sizeof(STORE_OBJECT)); |
| 1189 | if (object) memset(object, 0, sizeof(STORE_OBJECT)); | 1178 | |
| 1179 | if (object) | ||
| 1180 | memset(object, 0, sizeof(STORE_OBJECT)); | ||
| 1190 | return object; | 1181 | return object; |
| 1191 | } | 1182 | } |
| 1192 | void STORE_OBJECT_free(STORE_OBJECT *data) | 1183 | |
| 1193 | { | 1184 | void |
| 1194 | if (!data) return; | 1185 | STORE_OBJECT_free(STORE_OBJECT *data) |
| 1195 | switch (data->type) | 1186 | { |
| 1196 | { | 1187 | if (!data) |
| 1188 | return; | ||
| 1189 | switch (data->type) { | ||
| 1197 | case STORE_OBJECT_TYPE_X509_CERTIFICATE: | 1190 | case STORE_OBJECT_TYPE_X509_CERTIFICATE: |
| 1198 | X509_free(data->data.x509.certificate); | 1191 | X509_free(data->data.x509.certificate); |
| 1199 | break; | 1192 | break; |
| @@ -1210,43 +1203,42 @@ void STORE_OBJECT_free(STORE_OBJECT *data) | |||
| 1210 | case STORE_OBJECT_TYPE_ARBITRARY: | 1203 | case STORE_OBJECT_TYPE_ARBITRARY: |
| 1211 | BUF_MEM_free(data->data.arbitrary); | 1204 | BUF_MEM_free(data->data.arbitrary); |
| 1212 | break; | 1205 | break; |
| 1213 | } | ||
| 1214 | free(data); | ||
| 1215 | } | 1206 | } |
| 1207 | free(data); | ||
| 1208 | } | ||
| 1216 | 1209 | ||
| 1217 | IMPLEMENT_STACK_OF(STORE_OBJECT*) | 1210 | IMPLEMENT_STACK_OF(STORE_OBJECT*) |
| 1218 | 1211 | ||
| 1219 | 1212 | ||
| 1220 | struct STORE_attr_info_st | 1213 | struct STORE_attr_info_st { |
| 1221 | { | ||
| 1222 | unsigned char set[(STORE_ATTR_TYPE_NUM + 8) / 8]; | 1214 | unsigned char set[(STORE_ATTR_TYPE_NUM + 8) / 8]; |
| 1223 | union | 1215 | union { |
| 1224 | { | ||
| 1225 | char *cstring; | 1216 | char *cstring; |
| 1226 | unsigned char *sha1string; | 1217 | unsigned char *sha1string; |
| 1227 | X509_NAME *dn; | 1218 | X509_NAME *dn; |
| 1228 | BIGNUM *number; | 1219 | BIGNUM *number; |
| 1229 | void *any; | 1220 | void *any; |
| 1230 | } values[STORE_ATTR_TYPE_NUM+1]; | 1221 | } values[STORE_ATTR_TYPE_NUM + 1]; |
| 1231 | size_t value_sizes[STORE_ATTR_TYPE_NUM+1]; | 1222 | size_t value_sizes[STORE_ATTR_TYPE_NUM + 1]; |
| 1232 | }; | 1223 | }; |
| 1233 | 1224 | ||
| 1234 | #define ATTR_IS_SET(a,i) ((i) > 0 && (i) < STORE_ATTR_TYPE_NUM \ | 1225 | #define ATTR_IS_SET(a,i) ((i) > 0 && (i) < STORE_ATTR_TYPE_NUM \ |
| 1235 | && ((a)->set[(i) / 8] & (1 << ((i) % 8)))) | 1226 | && ((a)->set[(i) / 8] & (1 << ((i) % 8)))) |
| 1236 | #define SET_ATTRBIT(a,i) ((a)->set[(i) / 8] |= (1 << ((i) % 8))) | 1227 | #define SET_ATTRBIT(a,i) ((a)->set[(i) / 8] |= (1 << ((i) % 8))) |
| 1237 | #define CLEAR_ATTRBIT(a,i) ((a)->set[(i) / 8] &= ~(1 << ((i) % 8))) | 1228 | #define CLEAR_ATTRBIT(a,i) ((a)->set[(i) / 8] &= ~(1 << ((i) % 8))) |
| 1238 | 1229 | ||
| 1239 | STORE_ATTR_INFO *STORE_ATTR_INFO_new(void) | 1230 | STORE_ATTR_INFO * |
| 1240 | { | 1231 | STORE_ATTR_INFO_new(void) |
| 1232 | { | ||
| 1241 | return (STORE_ATTR_INFO *)malloc(sizeof(STORE_ATTR_INFO)); | 1233 | return (STORE_ATTR_INFO *)malloc(sizeof(STORE_ATTR_INFO)); |
| 1242 | } | 1234 | } |
| 1243 | static void STORE_ATTR_INFO_attr_free(STORE_ATTR_INFO *attrs, | 1235 | |
| 1244 | STORE_ATTR_TYPES code) | 1236 | static void |
| 1245 | { | 1237 | STORE_ATTR_INFO_attr_free(STORE_ATTR_INFO *attrs, |
| 1246 | if (ATTR_IS_SET(attrs,code)) | 1238 | STORE_ATTR_TYPES code) |
| 1247 | { | 1239 | { |
| 1248 | switch(code) | 1240 | if (ATTR_IS_SET(attrs, code)) { |
| 1249 | { | 1241 | switch (code) { |
| 1250 | case STORE_ATTR_FRIENDLYNAME: | 1242 | case STORE_ATTR_FRIENDLYNAME: |
| 1251 | case STORE_ATTR_EMAIL: | 1243 | case STORE_ATTR_EMAIL: |
| 1252 | case STORE_ATTR_FILENAME: | 1244 | case STORE_ATTR_FILENAME: |
| @@ -1268,492 +1260,538 @@ static void STORE_ATTR_INFO_attr_free(STORE_ATTR_INFO *attrs, | |||
| 1268 | break; | 1260 | break; |
| 1269 | default: | 1261 | default: |
| 1270 | break; | 1262 | break; |
| 1271 | } | ||
| 1272 | } | 1263 | } |
| 1273 | } | 1264 | } |
| 1274 | int STORE_ATTR_INFO_free(STORE_ATTR_INFO *attrs) | 1265 | } |
| 1275 | { | 1266 | |
| 1276 | if (attrs) | 1267 | int |
| 1277 | { | 1268 | STORE_ATTR_INFO_free(STORE_ATTR_INFO *attrs) |
| 1269 | { | ||
| 1270 | if (attrs) { | ||
| 1278 | STORE_ATTR_TYPES i; | 1271 | STORE_ATTR_TYPES i; |
| 1279 | for(i = 0; i++ < STORE_ATTR_TYPE_NUM;) | 1272 | for (i = 0; i++ < STORE_ATTR_TYPE_NUM; ) |
| 1280 | STORE_ATTR_INFO_attr_free(attrs, i); | 1273 | STORE_ATTR_INFO_attr_free(attrs, i); |
| 1281 | free(attrs); | 1274 | free(attrs); |
| 1282 | } | ||
| 1283 | return 1; | ||
| 1284 | } | 1275 | } |
| 1285 | char *STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code) | 1276 | return 1; |
| 1286 | { | 1277 | } |
| 1287 | if (!attrs) | 1278 | |
| 1288 | { | 1279 | char * |
| 1280 | STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code) | ||
| 1281 | { | ||
| 1282 | if (!attrs) { | ||
| 1289 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_CSTR, | 1283 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_CSTR, |
| 1290 | ERR_R_PASSED_NULL_PARAMETER); | 1284 | ERR_R_PASSED_NULL_PARAMETER); |
| 1291 | return NULL; | 1285 | return NULL; |
| 1292 | } | 1286 | } |
| 1293 | if (ATTR_IS_SET(attrs,code)) | 1287 | if (ATTR_IS_SET(attrs, code)) |
| 1294 | return attrs->values[code].cstring; | 1288 | return attrs->values[code].cstring; |
| 1295 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_CSTR, | 1289 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_CSTR, STORE_R_NO_VALUE); |
| 1296 | STORE_R_NO_VALUE); | ||
| 1297 | return NULL; | 1290 | return NULL; |
| 1298 | } | 1291 | } |
| 1299 | unsigned char *STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs, | 1292 | |
| 1300 | STORE_ATTR_TYPES code) | 1293 | unsigned char * |
| 1301 | { | 1294 | STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code) |
| 1302 | if (!attrs) | 1295 | { |
| 1303 | { | 1296 | if (!attrs) { |
| 1304 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_SHA1STR, | 1297 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_SHA1STR, |
| 1305 | ERR_R_PASSED_NULL_PARAMETER); | 1298 | ERR_R_PASSED_NULL_PARAMETER); |
| 1306 | return NULL; | 1299 | return NULL; |
| 1307 | } | 1300 | } |
| 1308 | if (ATTR_IS_SET(attrs,code)) | 1301 | if (ATTR_IS_SET(attrs, code)) |
| 1309 | return attrs->values[code].sha1string; | 1302 | return attrs->values[code].sha1string; |
| 1310 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_SHA1STR, | 1303 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_SHA1STR, STORE_R_NO_VALUE); |
| 1311 | STORE_R_NO_VALUE); | ||
| 1312 | return NULL; | 1304 | return NULL; |
| 1313 | } | 1305 | } |
| 1314 | X509_NAME *STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code) | 1306 | |
| 1315 | { | 1307 | X509_NAME * |
| 1316 | if (!attrs) | 1308 | STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code) |
| 1317 | { | 1309 | { |
| 1310 | if (!attrs) { | ||
| 1318 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_DN, | 1311 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_DN, |
| 1319 | ERR_R_PASSED_NULL_PARAMETER); | 1312 | ERR_R_PASSED_NULL_PARAMETER); |
| 1320 | return NULL; | 1313 | return NULL; |
| 1321 | } | 1314 | } |
| 1322 | if (ATTR_IS_SET(attrs,code)) | 1315 | if (ATTR_IS_SET(attrs, code)) |
| 1323 | return attrs->values[code].dn; | 1316 | return attrs->values[code].dn; |
| 1324 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_DN, | 1317 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_DN, STORE_R_NO_VALUE); |
| 1325 | STORE_R_NO_VALUE); | ||
| 1326 | return NULL; | 1318 | return NULL; |
| 1327 | } | 1319 | } |
| 1328 | BIGNUM *STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code) | 1320 | |
| 1329 | { | 1321 | BIGNUM * |
| 1330 | if (!attrs) | 1322 | STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code) |
| 1331 | { | 1323 | { |
| 1324 | if (!attrs) { | ||
| 1332 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_NUMBER, | 1325 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_NUMBER, |
| 1333 | ERR_R_PASSED_NULL_PARAMETER); | 1326 | ERR_R_PASSED_NULL_PARAMETER); |
| 1334 | return NULL; | 1327 | return NULL; |
| 1335 | } | 1328 | } |
| 1336 | if (ATTR_IS_SET(attrs,code)) | 1329 | if (ATTR_IS_SET(attrs, code)) |
| 1337 | return attrs->values[code].number; | 1330 | return attrs->values[code].number; |
| 1338 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_NUMBER, | 1331 | STOREerr(STORE_F_STORE_ATTR_INFO_GET0_NUMBER, STORE_R_NO_VALUE); |
| 1339 | STORE_R_NO_VALUE); | ||
| 1340 | return NULL; | 1332 | return NULL; |
| 1341 | } | 1333 | } |
| 1342 | int STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 1334 | |
| 1343 | char *cstr, size_t cstr_size) | 1335 | int |
| 1344 | { | 1336 | STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
| 1345 | if (!attrs) | 1337 | char *cstr, size_t cstr_size) |
| 1346 | { | 1338 | { |
| 1339 | if (!attrs) { | ||
| 1347 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR, | 1340 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR, |
| 1348 | ERR_R_PASSED_NULL_PARAMETER); | 1341 | ERR_R_PASSED_NULL_PARAMETER); |
| 1349 | return 0; | 1342 | return 0; |
| 1350 | } | 1343 | } |
| 1351 | if (!ATTR_IS_SET(attrs,code)) | 1344 | if (!ATTR_IS_SET(attrs, code)) { |
| 1352 | { | ||
| 1353 | if ((attrs->values[code].cstring = BUF_strndup(cstr, cstr_size))) | 1345 | if ((attrs->values[code].cstring = BUF_strndup(cstr, cstr_size))) |
| 1354 | return 1; | 1346 | return 1; |
| 1355 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR, | 1347 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR, |
| 1356 | ERR_R_MALLOC_FAILURE); | 1348 | ERR_R_MALLOC_FAILURE); |
| 1357 | return 0; | 1349 | return 0; |
| 1358 | } | 1350 | } |
| 1359 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR, STORE_R_ALREADY_HAS_A_VALUE); | 1351 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR, STORE_R_ALREADY_HAS_A_VALUE); |
| 1360 | return 0; | 1352 | return 0; |
| 1361 | } | 1353 | } |
| 1362 | int STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 1354 | |
| 1363 | unsigned char *sha1str, size_t sha1str_size) | 1355 | int |
| 1364 | { | 1356 | STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
| 1365 | if (!attrs) | 1357 | unsigned char *sha1str, size_t sha1str_size) |
| 1366 | { | 1358 | { |
| 1359 | if (!attrs) { | ||
| 1367 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR, | 1360 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR, |
| 1368 | ERR_R_PASSED_NULL_PARAMETER); | 1361 | ERR_R_PASSED_NULL_PARAMETER); |
| 1369 | return 0; | 1362 | return 0; |
| 1370 | } | 1363 | } |
| 1371 | if (!ATTR_IS_SET(attrs,code)) | 1364 | if (!ATTR_IS_SET(attrs, code)) { |
| 1372 | { | ||
| 1373 | if ((attrs->values[code].sha1string = | 1365 | if ((attrs->values[code].sha1string = |
| 1374 | (unsigned char *)BUF_memdup(sha1str, | 1366 | (unsigned char *)BUF_memdup(sha1str, |
| 1375 | sha1str_size))) | 1367 | sha1str_size))) |
| 1376 | return 1; | 1368 | return 1; |
| 1377 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR, | 1369 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR, |
| 1378 | ERR_R_MALLOC_FAILURE); | 1370 | ERR_R_MALLOC_FAILURE); |
| 1379 | return 0; | 1371 | return 0; |
| 1380 | } | ||
| 1381 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR, STORE_R_ALREADY_HAS_A_VALUE); | ||
| 1382 | return 0; | ||
| 1383 | } | 1372 | } |
| 1384 | int STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 1373 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR, |
| 1385 | X509_NAME *dn) | 1374 | STORE_R_ALREADY_HAS_A_VALUE); |
| 1386 | { | 1375 | return 0; |
| 1387 | if (!attrs) | 1376 | } |
| 1388 | { | 1377 | |
| 1378 | int | ||
| 1379 | STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | ||
| 1380 | X509_NAME *dn) | ||
| 1381 | { | ||
| 1382 | if (!attrs) { | ||
| 1389 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN, | 1383 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN, |
| 1390 | ERR_R_PASSED_NULL_PARAMETER); | 1384 | ERR_R_PASSED_NULL_PARAMETER); |
| 1391 | return 0; | 1385 | return 0; |
| 1392 | } | 1386 | } |
| 1393 | if (!ATTR_IS_SET(attrs,code)) | 1387 | if (!ATTR_IS_SET(attrs, code)) { |
| 1394 | { | ||
| 1395 | if ((attrs->values[code].dn = X509_NAME_dup(dn))) | 1388 | if ((attrs->values[code].dn = X509_NAME_dup(dn))) |
| 1396 | return 1; | 1389 | return 1; |
| 1397 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN, | 1390 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN, |
| 1398 | ERR_R_MALLOC_FAILURE); | 1391 | ERR_R_MALLOC_FAILURE); |
| 1399 | return 0; | 1392 | return 0; |
| 1400 | } | 1393 | } |
| 1401 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN, STORE_R_ALREADY_HAS_A_VALUE); | 1394 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN, STORE_R_ALREADY_HAS_A_VALUE); |
| 1402 | return 0; | 1395 | return 0; |
| 1403 | } | 1396 | } |
| 1404 | int STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 1397 | |
| 1405 | BIGNUM *number) | 1398 | int |
| 1406 | { | 1399 | STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
| 1407 | if (!attrs) | 1400 | BIGNUM *number) |
| 1408 | { | 1401 | { |
| 1402 | if (!attrs) { | ||
| 1409 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER, | 1403 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER, |
| 1410 | ERR_R_PASSED_NULL_PARAMETER); | 1404 | ERR_R_PASSED_NULL_PARAMETER); |
| 1411 | return 0; | 1405 | return 0; |
| 1412 | } | 1406 | } |
| 1413 | if (!ATTR_IS_SET(attrs,code)) | 1407 | if (!ATTR_IS_SET(attrs, code)) { |
| 1414 | { | ||
| 1415 | if ((attrs->values[code].number = BN_dup(number))) | 1408 | if ((attrs->values[code].number = BN_dup(number))) |
| 1416 | return 1; | 1409 | return 1; |
| 1417 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER, | 1410 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER, |
| 1418 | ERR_R_MALLOC_FAILURE); | 1411 | ERR_R_MALLOC_FAILURE); |
| 1419 | return 0; | 1412 | return 0; |
| 1420 | } | ||
| 1421 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER, STORE_R_ALREADY_HAS_A_VALUE); | ||
| 1422 | return 0; | ||
| 1423 | } | 1413 | } |
| 1424 | int STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 1414 | STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER, |
| 1425 | char *cstr, size_t cstr_size) | 1415 | STORE_R_ALREADY_HAS_A_VALUE); |
| 1426 | { | 1416 | return 0; |
| 1427 | if (!attrs) | 1417 | } |
| 1428 | { | 1418 | |
| 1419 | int | ||
| 1420 | STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | ||
| 1421 | char *cstr, size_t cstr_size) | ||
| 1422 | { | ||
| 1423 | if (!attrs) { | ||
| 1429 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_CSTR, | 1424 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_CSTR, |
| 1430 | ERR_R_PASSED_NULL_PARAMETER); | 1425 | ERR_R_PASSED_NULL_PARAMETER); |
| 1431 | return 0; | 1426 | return 0; |
| 1432 | } | 1427 | } |
| 1433 | if (ATTR_IS_SET(attrs,code)) | 1428 | if (ATTR_IS_SET(attrs, code)) { |
| 1434 | { | ||
| 1435 | free(attrs->values[code].cstring); | 1429 | free(attrs->values[code].cstring); |
| 1436 | attrs->values[code].cstring = NULL; | 1430 | attrs->values[code].cstring = NULL; |
| 1437 | CLEAR_ATTRBIT(attrs, code); | 1431 | CLEAR_ATTRBIT(attrs, code); |
| 1438 | } | ||
| 1439 | return STORE_ATTR_INFO_set_cstr(attrs, code, cstr, cstr_size); | ||
| 1440 | } | 1432 | } |
| 1441 | int STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 1433 | return STORE_ATTR_INFO_set_cstr(attrs, code, cstr, cstr_size); |
| 1442 | unsigned char *sha1str, size_t sha1str_size) | 1434 | } |
| 1443 | { | 1435 | |
| 1444 | if (!attrs) | 1436 | int |
| 1445 | { | 1437 | STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
| 1438 | unsigned char *sha1str, size_t sha1str_size) | ||
| 1439 | { | ||
| 1440 | if (!attrs) { | ||
| 1446 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR, | 1441 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR, |
| 1447 | ERR_R_PASSED_NULL_PARAMETER); | 1442 | ERR_R_PASSED_NULL_PARAMETER); |
| 1448 | return 0; | 1443 | return 0; |
| 1449 | } | 1444 | } |
| 1450 | if (ATTR_IS_SET(attrs,code)) | 1445 | if (ATTR_IS_SET(attrs, code)) { |
| 1451 | { | ||
| 1452 | free(attrs->values[code].sha1string); | 1446 | free(attrs->values[code].sha1string); |
| 1453 | attrs->values[code].sha1string = NULL; | 1447 | attrs->values[code].sha1string = NULL; |
| 1454 | CLEAR_ATTRBIT(attrs, code); | 1448 | CLEAR_ATTRBIT(attrs, code); |
| 1455 | } | ||
| 1456 | return STORE_ATTR_INFO_set_sha1str(attrs, code, sha1str, sha1str_size); | ||
| 1457 | } | 1449 | } |
| 1458 | int STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 1450 | return STORE_ATTR_INFO_set_sha1str(attrs, code, sha1str, sha1str_size); |
| 1459 | X509_NAME *dn) | 1451 | } |
| 1460 | { | 1452 | |
| 1461 | if (!attrs) | 1453 | int |
| 1462 | { | 1454 | STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
| 1455 | X509_NAME *dn) | ||
| 1456 | { | ||
| 1457 | if (!attrs) { | ||
| 1463 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_DN, | 1458 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_DN, |
| 1464 | ERR_R_PASSED_NULL_PARAMETER); | 1459 | ERR_R_PASSED_NULL_PARAMETER); |
| 1465 | return 0; | 1460 | return 0; |
| 1466 | } | 1461 | } |
| 1467 | if (ATTR_IS_SET(attrs,code)) | 1462 | if (ATTR_IS_SET(attrs, code)) { |
| 1468 | { | ||
| 1469 | free(attrs->values[code].dn); | 1463 | free(attrs->values[code].dn); |
| 1470 | attrs->values[code].dn = NULL; | 1464 | attrs->values[code].dn = NULL; |
| 1471 | CLEAR_ATTRBIT(attrs, code); | 1465 | CLEAR_ATTRBIT(attrs, code); |
| 1472 | } | ||
| 1473 | return STORE_ATTR_INFO_set_dn(attrs, code, dn); | ||
| 1474 | } | 1466 | } |
| 1475 | int STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, | 1467 | return STORE_ATTR_INFO_set_dn(attrs, code, dn); |
| 1476 | BIGNUM *number) | 1468 | } |
| 1477 | { | 1469 | |
| 1478 | if (!attrs) | 1470 | int |
| 1479 | { | 1471 | STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, |
| 1472 | BIGNUM *number) | ||
| 1473 | { | ||
| 1474 | if (!attrs) { | ||
| 1480 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER, | 1475 | STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER, |
| 1481 | ERR_R_PASSED_NULL_PARAMETER); | 1476 | ERR_R_PASSED_NULL_PARAMETER); |
| 1482 | return 0; | 1477 | return 0; |
| 1483 | } | 1478 | } |
| 1484 | if (ATTR_IS_SET(attrs,code)) | 1479 | if (ATTR_IS_SET(attrs, code)) { |
| 1485 | { | ||
| 1486 | free(attrs->values[code].number); | 1480 | free(attrs->values[code].number); |
| 1487 | attrs->values[code].number = NULL; | 1481 | attrs->values[code].number = NULL; |
| 1488 | CLEAR_ATTRBIT(attrs, code); | 1482 | CLEAR_ATTRBIT(attrs, code); |
| 1489 | } | ||
| 1490 | return STORE_ATTR_INFO_set_number(attrs, code, number); | ||
| 1491 | } | 1483 | } |
| 1484 | return STORE_ATTR_INFO_set_number(attrs, code, number); | ||
| 1485 | } | ||
| 1492 | 1486 | ||
| 1493 | struct attr_list_ctx_st | 1487 | struct attr_list_ctx_st { |
| 1494 | { | ||
| 1495 | OPENSSL_ITEM *attributes; | 1488 | OPENSSL_ITEM *attributes; |
| 1496 | }; | 1489 | }; |
| 1497 | void *STORE_parse_attrs_start(OPENSSL_ITEM *attributes) | 1490 | |
| 1498 | { | 1491 | void * |
| 1499 | if (attributes) | 1492 | STORE_parse_attrs_start(OPENSSL_ITEM *attributes) |
| 1500 | { | 1493 | { |
| 1494 | if (attributes) { | ||
| 1501 | struct attr_list_ctx_st *context = | 1495 | struct attr_list_ctx_st *context = |
| 1502 | (struct attr_list_ctx_st *)malloc(sizeof(struct attr_list_ctx_st)); | 1496 | (struct attr_list_ctx_st *)malloc(sizeof(struct attr_list_ctx_st)); |
| 1503 | if (context) | 1497 | if (context) |
| 1504 | context->attributes = attributes; | 1498 | context->attributes = attributes; |
| 1505 | else | 1499 | else |
| 1506 | STOREerr(STORE_F_STORE_PARSE_ATTRS_START, | 1500 | STOREerr(STORE_F_STORE_PARSE_ATTRS_START, |
| 1507 | ERR_R_MALLOC_FAILURE); | 1501 | ERR_R_MALLOC_FAILURE); |
| 1508 | return context; | 1502 | return context; |
| 1509 | } | 1503 | } |
| 1510 | STOREerr(STORE_F_STORE_PARSE_ATTRS_START, ERR_R_PASSED_NULL_PARAMETER); | 1504 | STOREerr(STORE_F_STORE_PARSE_ATTRS_START, ERR_R_PASSED_NULL_PARAMETER); |
| 1511 | return 0; | 1505 | return 0; |
| 1512 | } | 1506 | } |
| 1513 | STORE_ATTR_INFO *STORE_parse_attrs_next(void *handle) | 1507 | |
| 1514 | { | 1508 | STORE_ATTR_INFO * |
| 1509 | STORE_parse_attrs_next(void *handle) | ||
| 1510 | { | ||
| 1515 | struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle; | 1511 | struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle; |
| 1516 | 1512 | ||
| 1517 | if (context && context->attributes) | 1513 | if (context && context->attributes) { |
| 1518 | { | ||
| 1519 | STORE_ATTR_INFO *attrs = NULL; | 1514 | STORE_ATTR_INFO *attrs = NULL; |
| 1520 | 1515 | ||
| 1521 | while(context->attributes | 1516 | while (context->attributes && |
| 1522 | && context->attributes->code != STORE_ATTR_OR | 1517 | context->attributes->code != STORE_ATTR_OR && |
| 1523 | && context->attributes->code != STORE_ATTR_END) | 1518 | context->attributes->code != STORE_ATTR_END) { |
| 1524 | { | 1519 | switch (context->attributes->code) { |
| 1525 | switch(context->attributes->code) | ||
| 1526 | { | ||
| 1527 | case STORE_ATTR_FRIENDLYNAME: | 1520 | case STORE_ATTR_FRIENDLYNAME: |
| 1528 | case STORE_ATTR_EMAIL: | 1521 | case STORE_ATTR_EMAIL: |
| 1529 | case STORE_ATTR_FILENAME: | 1522 | case STORE_ATTR_FILENAME: |
| 1530 | if (!attrs) attrs = STORE_ATTR_INFO_new(); | 1523 | if (!attrs) |
| 1531 | if (attrs == NULL) | 1524 | attrs = STORE_ATTR_INFO_new(); |
| 1532 | { | 1525 | if (attrs == NULL) { |
| 1533 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, | 1526 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, |
| 1534 | ERR_R_MALLOC_FAILURE); | 1527 | ERR_R_MALLOC_FAILURE); |
| 1535 | goto err; | 1528 | goto err; |
| 1536 | } | 1529 | } |
| 1537 | STORE_ATTR_INFO_set_cstr(attrs, | 1530 | STORE_ATTR_INFO_set_cstr(attrs, |
| 1538 | context->attributes->code, | 1531 | context->attributes->code, |
| 1539 | context->attributes->value, | 1532 | context->attributes->value, |
| 1540 | context->attributes->value_size); | 1533 | context->attributes->value_size); |
| 1541 | break; | 1534 | break; |
| 1542 | case STORE_ATTR_KEYID: | 1535 | case STORE_ATTR_KEYID: |
| 1543 | case STORE_ATTR_ISSUERKEYID: | 1536 | case STORE_ATTR_ISSUERKEYID: |
| 1544 | case STORE_ATTR_SUBJECTKEYID: | 1537 | case STORE_ATTR_SUBJECTKEYID: |
| 1545 | case STORE_ATTR_ISSUERSERIALHASH: | 1538 | case STORE_ATTR_ISSUERSERIALHASH: |
| 1546 | case STORE_ATTR_CERTHASH: | 1539 | case STORE_ATTR_CERTHASH: |
| 1547 | if (!attrs) attrs = STORE_ATTR_INFO_new(); | 1540 | if (!attrs) |
| 1548 | if (attrs == NULL) | 1541 | attrs = STORE_ATTR_INFO_new(); |
| 1549 | { | 1542 | if (attrs == NULL) { |
| 1550 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, | 1543 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, |
| 1551 | ERR_R_MALLOC_FAILURE); | 1544 | ERR_R_MALLOC_FAILURE); |
| 1552 | goto err; | 1545 | goto err; |
| 1553 | } | 1546 | } |
| 1554 | STORE_ATTR_INFO_set_sha1str(attrs, | 1547 | STORE_ATTR_INFO_set_sha1str(attrs, |
| 1555 | context->attributes->code, | 1548 | context->attributes->code, |
| 1556 | context->attributes->value, | 1549 | context->attributes->value, |
| 1557 | context->attributes->value_size); | 1550 | context->attributes->value_size); |
| 1558 | break; | 1551 | break; |
| 1559 | case STORE_ATTR_ISSUER: | 1552 | case STORE_ATTR_ISSUER: |
| 1560 | case STORE_ATTR_SUBJECT: | 1553 | case STORE_ATTR_SUBJECT: |
| 1561 | if (!attrs) attrs = STORE_ATTR_INFO_new(); | 1554 | if (!attrs) |
| 1562 | if (attrs == NULL) | 1555 | attrs = STORE_ATTR_INFO_new(); |
| 1563 | { | 1556 | if (attrs == NULL) { |
| 1564 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, | 1557 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, |
| 1565 | ERR_R_MALLOC_FAILURE); | 1558 | ERR_R_MALLOC_FAILURE); |
| 1566 | goto err; | 1559 | goto err; |
| 1567 | } | 1560 | } |
| 1568 | STORE_ATTR_INFO_modify_dn(attrs, | 1561 | STORE_ATTR_INFO_modify_dn(attrs, |
| 1569 | context->attributes->code, | 1562 | context->attributes->code, |
| 1570 | context->attributes->value); | 1563 | context->attributes->value); |
| 1571 | break; | 1564 | break; |
| 1572 | case STORE_ATTR_SERIAL: | 1565 | case STORE_ATTR_SERIAL: |
| 1573 | if (!attrs) attrs = STORE_ATTR_INFO_new(); | 1566 | if (!attrs) |
| 1574 | if (attrs == NULL) | 1567 | attrs = STORE_ATTR_INFO_new(); |
| 1575 | { | 1568 | if (attrs == NULL) { |
| 1576 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, | 1569 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, |
| 1577 | ERR_R_MALLOC_FAILURE); | 1570 | ERR_R_MALLOC_FAILURE); |
| 1578 | goto err; | 1571 | goto err; |
| 1579 | } | 1572 | } |
| 1580 | STORE_ATTR_INFO_modify_number(attrs, | 1573 | STORE_ATTR_INFO_modify_number(attrs, |
| 1581 | context->attributes->code, | 1574 | context->attributes->code, |
| 1582 | context->attributes->value); | 1575 | context->attributes->value); |
| 1583 | break; | 1576 | break; |
| 1584 | } | ||
| 1585 | context->attributes++; | ||
| 1586 | } | 1577 | } |
| 1578 | context->attributes++; | ||
| 1579 | } | ||
| 1587 | if (context->attributes->code == STORE_ATTR_OR) | 1580 | if (context->attributes->code == STORE_ATTR_OR) |
| 1588 | context->attributes++; | 1581 | context->attributes++; |
| 1589 | return attrs; | 1582 | return attrs; |
| 1590 | err: | 1583 | |
| 1591 | while(context->attributes | 1584 | err: |
| 1592 | && context->attributes->code != STORE_ATTR_OR | 1585 | while (context->attributes && |
| 1593 | && context->attributes->code != STORE_ATTR_END) | 1586 | context->attributes->code != STORE_ATTR_OR && |
| 1587 | context->attributes->code != STORE_ATTR_END) | ||
| 1594 | context->attributes++; | 1588 | context->attributes++; |
| 1595 | if (context->attributes->code == STORE_ATTR_OR) | 1589 | if (context->attributes->code == STORE_ATTR_OR) |
| 1596 | context->attributes++; | 1590 | context->attributes++; |
| 1597 | return NULL; | 1591 | return NULL; |
| 1598 | } | 1592 | } |
| 1599 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, ERR_R_PASSED_NULL_PARAMETER); | 1593 | STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, ERR_R_PASSED_NULL_PARAMETER); |
| 1600 | return NULL; | 1594 | return NULL; |
| 1601 | } | 1595 | } |
| 1602 | int STORE_parse_attrs_end(void *handle) | 1596 | |
| 1603 | { | 1597 | int |
| 1598 | STORE_parse_attrs_end(void *handle) | ||
| 1599 | { | ||
| 1604 | struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle; | 1600 | struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle; |
| 1605 | 1601 | ||
| 1606 | if (context && context->attributes) | 1602 | if (context && context->attributes) { |
| 1607 | { | ||
| 1608 | #if 0 | 1603 | #if 0 |
| 1609 | OPENSSL_ITEM *attributes = context->attributes; | 1604 | OPENSSL_ITEM *attributes = context->attributes; |
| 1610 | #endif | 1605 | #endif |
| 1611 | free(context); | 1606 | free(context); |
| 1612 | return 1; | 1607 | return 1; |
| 1613 | } | 1608 | } |
| 1614 | STOREerr(STORE_F_STORE_PARSE_ATTRS_END, ERR_R_PASSED_NULL_PARAMETER); | 1609 | STOREerr(STORE_F_STORE_PARSE_ATTRS_END, ERR_R_PASSED_NULL_PARAMETER); |
| 1615 | return 0; | 1610 | return 0; |
| 1616 | } | 1611 | } |
| 1617 | 1612 | ||
| 1618 | int STORE_parse_attrs_endp(void *handle) | 1613 | int |
| 1619 | { | 1614 | STORE_parse_attrs_endp(void *handle) |
| 1615 | { | ||
| 1620 | struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle; | 1616 | struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle; |
| 1621 | 1617 | ||
| 1622 | if (context && context->attributes) | 1618 | if (context && context->attributes) { |
| 1623 | { | ||
| 1624 | return context->attributes->code == STORE_ATTR_END; | 1619 | return context->attributes->code == STORE_ATTR_END; |
| 1625 | } | 1620 | } |
| 1626 | STOREerr(STORE_F_STORE_PARSE_ATTRS_ENDP, ERR_R_PASSED_NULL_PARAMETER); | 1621 | STOREerr(STORE_F_STORE_PARSE_ATTRS_ENDP, ERR_R_PASSED_NULL_PARAMETER); |
| 1627 | return 0; | 1622 | return 0; |
| 1628 | } | 1623 | } |
| 1629 | 1624 | ||
| 1630 | static int attr_info_compare_compute_range( | 1625 | static int |
| 1631 | const unsigned char *abits, const unsigned char *bbits, | 1626 | attr_info_compare_compute_range(const unsigned char *abits, |
| 1632 | unsigned int *alowp, unsigned int *ahighp, | 1627 | const unsigned char *bbits, unsigned int *alowp, unsigned int *ahighp, |
| 1633 | unsigned int *blowp, unsigned int *bhighp) | 1628 | unsigned int *blowp, unsigned int *bhighp) |
| 1634 | { | 1629 | { |
| 1635 | unsigned int alow = (unsigned int)-1, ahigh = 0; | 1630 | unsigned int alow = (unsigned int) - 1, ahigh = 0; |
| 1636 | unsigned int blow = (unsigned int)-1, bhigh = 0; | 1631 | unsigned int blow = (unsigned int) - 1, bhigh = 0; |
| 1637 | int i, res = 0; | 1632 | int i, res = 0; |
| 1638 | 1633 | ||
| 1639 | for (i = 0; i < (STORE_ATTR_TYPE_NUM + 8) / 8; i++, abits++, bbits++) | 1634 | for (i = 0; i < (STORE_ATTR_TYPE_NUM + 8) / 8; i++, abits++, bbits++) { |
| 1640 | { | 1635 | if (res == 0) { |
| 1641 | if (res == 0) | 1636 | if (*abits < *bbits) |
| 1642 | { | 1637 | res = -1; |
| 1643 | if (*abits < *bbits) res = -1; | 1638 | if (*abits > *bbits) |
| 1644 | if (*abits > *bbits) res = 1; | 1639 | res = 1; |
| 1645 | } | 1640 | } |
| 1646 | if (*abits) | 1641 | if (*abits) { |
| 1647 | { | 1642 | if (alow == (unsigned int) - 1) { |
| 1648 | if (alow == (unsigned int)-1) | ||
| 1649 | { | ||
| 1650 | alow = i * 8; | 1643 | alow = i * 8; |
| 1651 | if (!(*abits & 0x01)) alow++; | 1644 | if (!(*abits & 0x01)) |
| 1652 | if (!(*abits & 0x02)) alow++; | 1645 | alow++; |
| 1653 | if (!(*abits & 0x04)) alow++; | 1646 | if (!(*abits & 0x02)) |
| 1654 | if (!(*abits & 0x08)) alow++; | 1647 | alow++; |
| 1655 | if (!(*abits & 0x10)) alow++; | 1648 | if (!(*abits & 0x04)) |
| 1656 | if (!(*abits & 0x20)) alow++; | 1649 | alow++; |
| 1657 | if (!(*abits & 0x40)) alow++; | 1650 | if (!(*abits & 0x08)) |
| 1658 | } | 1651 | alow++; |
| 1659 | ahigh = i * 8 + 7; | 1652 | if (!(*abits & 0x10)) |
| 1660 | if (!(*abits & 0x80)) ahigh++; | 1653 | alow++; |
| 1661 | if (!(*abits & 0x40)) ahigh++; | 1654 | if (!(*abits & 0x20)) |
| 1662 | if (!(*abits & 0x20)) ahigh++; | 1655 | alow++; |
| 1663 | if (!(*abits & 0x10)) ahigh++; | 1656 | if (!(*abits & 0x40)) |
| 1664 | if (!(*abits & 0x08)) ahigh++; | 1657 | alow++; |
| 1665 | if (!(*abits & 0x04)) ahigh++; | ||
| 1666 | if (!(*abits & 0x02)) ahigh++; | ||
| 1667 | } | 1658 | } |
| 1668 | if (*bbits) | 1659 | ahigh = i * 8 + 7; |
| 1669 | { | 1660 | if (!(*abits & 0x80)) |
| 1670 | if (blow == (unsigned int)-1) | 1661 | ahigh++; |
| 1671 | { | 1662 | if (!(*abits & 0x40)) |
| 1663 | ahigh++; | ||
| 1664 | if (!(*abits & 0x20)) | ||
| 1665 | ahigh++; | ||
| 1666 | if (!(*abits & 0x10)) | ||
| 1667 | ahigh++; | ||
| 1668 | if (!(*abits & 0x08)) | ||
| 1669 | ahigh++; | ||
| 1670 | if (!(*abits & 0x04)) | ||
| 1671 | ahigh++; | ||
| 1672 | if (!(*abits & 0x02)) | ||
| 1673 | ahigh++; | ||
| 1674 | } | ||
| 1675 | if (*bbits) { | ||
| 1676 | if (blow == (unsigned int) - 1) { | ||
| 1672 | blow = i * 8; | 1677 | blow = i * 8; |
| 1673 | if (!(*bbits & 0x01)) blow++; | 1678 | if (!(*bbits & 0x01)) |
| 1674 | if (!(*bbits & 0x02)) blow++; | 1679 | blow++; |
| 1675 | if (!(*bbits & 0x04)) blow++; | 1680 | if (!(*bbits & 0x02)) |
| 1676 | if (!(*bbits & 0x08)) blow++; | 1681 | blow++; |
| 1677 | if (!(*bbits & 0x10)) blow++; | 1682 | if (!(*bbits & 0x04)) |
| 1678 | if (!(*bbits & 0x20)) blow++; | 1683 | blow++; |
| 1679 | if (!(*bbits & 0x40)) blow++; | 1684 | if (!(*bbits & 0x08)) |
| 1680 | } | 1685 | blow++; |
| 1681 | bhigh = i * 8 + 7; | 1686 | if (!(*bbits & 0x10)) |
| 1682 | if (!(*bbits & 0x80)) bhigh++; | 1687 | blow++; |
| 1683 | if (!(*bbits & 0x40)) bhigh++; | 1688 | if (!(*bbits & 0x20)) |
| 1684 | if (!(*bbits & 0x20)) bhigh++; | 1689 | blow++; |
| 1685 | if (!(*bbits & 0x10)) bhigh++; | 1690 | if (!(*bbits & 0x40)) |
| 1686 | if (!(*bbits & 0x08)) bhigh++; | 1691 | blow++; |
| 1687 | if (!(*bbits & 0x04)) bhigh++; | ||
| 1688 | if (!(*bbits & 0x02)) bhigh++; | ||
| 1689 | } | 1692 | } |
| 1690 | } | 1693 | bhigh = i * 8 + 7; |
| 1691 | if (ahigh + alow < bhigh + blow) res = -1; | 1694 | if (!(*bbits & 0x80)) |
| 1692 | if (ahigh + alow > bhigh + blow) res = 1; | 1695 | bhigh++; |
| 1693 | if (alowp) *alowp = alow; | 1696 | if (!(*bbits & 0x40)) |
| 1694 | if (ahighp) *ahighp = ahigh; | 1697 | bhigh++; |
| 1695 | if (blowp) *blowp = blow; | 1698 | if (!(*bbits & 0x20)) |
| 1696 | if (bhighp) *bhighp = bhigh; | 1699 | bhigh++; |
| 1700 | if (!(*bbits & 0x10)) | ||
| 1701 | bhigh++; | ||
| 1702 | if (!(*bbits & 0x08)) | ||
| 1703 | bhigh++; | ||
| 1704 | if (!(*bbits & 0x04)) | ||
| 1705 | bhigh++; | ||
| 1706 | if (!(*bbits & 0x02)) | ||
| 1707 | bhigh++; | ||
| 1708 | } | ||
| 1709 | } | ||
| 1710 | if (ahigh + alow < bhigh + blow) | ||
| 1711 | res = -1; | ||
| 1712 | if (ahigh + alow > bhigh + blow) | ||
| 1713 | res = 1; | ||
| 1714 | if (alowp) | ||
| 1715 | *alowp = alow; | ||
| 1716 | if (ahighp) | ||
| 1717 | *ahighp = ahigh; | ||
| 1718 | if (blowp) | ||
| 1719 | *blowp = blow; | ||
| 1720 | if (bhighp) | ||
| 1721 | *bhighp = bhigh; | ||
| 1697 | return res; | 1722 | return res; |
| 1698 | } | 1723 | } |
| 1699 | 1724 | ||
| 1700 | int STORE_ATTR_INFO_compare(const STORE_ATTR_INFO * const *a, | 1725 | int |
| 1701 | const STORE_ATTR_INFO * const *b) | 1726 | STORE_ATTR_INFO_compare(const STORE_ATTR_INFO * const *a, |
| 1702 | { | 1727 | const STORE_ATTR_INFO * const *b) |
| 1703 | if (a == b) return 0; | 1728 | { |
| 1704 | if (!a) return -1; | 1729 | if (a == b) |
| 1705 | if (!b) return 1; | 1730 | return 0; |
| 1706 | return attr_info_compare_compute_range((*a)->set, (*b)->set, 0, 0, 0, 0); | 1731 | if (!a) |
| 1707 | } | 1732 | return -1; |
| 1733 | if (!b) | ||
| 1734 | return 1; | ||
| 1735 | return attr_info_compare_compute_range((*a)->set, (*b)->set, | ||
| 1736 | 0, 0, 0, 0); | ||
| 1737 | } | ||
| 1708 | 1738 | ||
| 1709 | int STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) | 1739 | int |
| 1710 | { | 1740 | STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) |
| 1741 | { | ||
| 1711 | unsigned int alow, ahigh, blow, bhigh; | 1742 | unsigned int alow, ahigh, blow, bhigh; |
| 1712 | 1743 | ||
| 1713 | if (a == b) return 1; | 1744 | if (a == b) |
| 1714 | if (!a) return 0; | 1745 | return 1; |
| 1715 | if (!b) return 0; | 1746 | if (!a) |
| 1747 | return 0; | ||
| 1748 | if (!b) | ||
| 1749 | return 0; | ||
| 1716 | attr_info_compare_compute_range(a->set, b->set, | 1750 | attr_info_compare_compute_range(a->set, b->set, |
| 1717 | &alow, &ahigh, &blow, &bhigh); | 1751 | &alow, &ahigh, &blow, &bhigh); |
| 1718 | if (alow >= blow && ahigh <= bhigh) | 1752 | if (alow >= blow && ahigh <= bhigh) |
| 1719 | return 1; | 1753 | return 1; |
| 1720 | return 0; | 1754 | return 0; |
| 1721 | } | 1755 | } |
| 1722 | 1756 | ||
| 1723 | int STORE_ATTR_INFO_in(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) | 1757 | int |
| 1724 | { | 1758 | STORE_ATTR_INFO_in(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) |
| 1759 | { | ||
| 1725 | unsigned char *abits, *bbits; | 1760 | unsigned char *abits, *bbits; |
| 1726 | int i; | 1761 | int i; |
| 1727 | 1762 | ||
| 1728 | if (a == b) return 1; | 1763 | if (a == b) |
| 1729 | if (!a) return 0; | 1764 | return 1; |
| 1730 | if (!b) return 0; | 1765 | if (!a) |
| 1766 | return 0; | ||
| 1767 | if (!b) | ||
| 1768 | return 0; | ||
| 1731 | abits = a->set; | 1769 | abits = a->set; |
| 1732 | bbits = b->set; | 1770 | bbits = b->set; |
| 1733 | for (i = 0; i < (STORE_ATTR_TYPE_NUM + 8) / 8; i++, abits++, bbits++) | 1771 | for (i = 0; i < (STORE_ATTR_TYPE_NUM + 8) / 8; i++, abits++, bbits++) { |
| 1734 | { | ||
| 1735 | if (*abits && (*bbits & *abits) != *abits) | 1772 | if (*abits && (*bbits & *abits) != *abits) |
| 1736 | return 0; | 1773 | return 0; |
| 1737 | } | ||
| 1738 | return 1; | ||
| 1739 | } | 1774 | } |
| 1775 | return 1; | ||
| 1776 | } | ||
| 1740 | 1777 | ||
| 1741 | int STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) | 1778 | int |
| 1742 | { | 1779 | STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) |
| 1780 | { | ||
| 1743 | STORE_ATTR_TYPES i; | 1781 | STORE_ATTR_TYPES i; |
| 1744 | 1782 | ||
| 1745 | if (a == b) return 1; | 1783 | if (a == b) |
| 1746 | if (!STORE_ATTR_INFO_in(a, b)) return 0; | 1784 | return 1; |
| 1785 | if (!STORE_ATTR_INFO_in(a, b)) | ||
| 1786 | return 0; | ||
| 1747 | for (i = 1; i < STORE_ATTR_TYPE_NUM; i++) | 1787 | for (i = 1; i < STORE_ATTR_TYPE_NUM; i++) |
| 1748 | if (ATTR_IS_SET(a, i)) | 1788 | if (ATTR_IS_SET(a, i)) { |
| 1749 | { | 1789 | switch (i) { |
| 1750 | switch(i) | ||
| 1751 | { | ||
| 1752 | case STORE_ATTR_FRIENDLYNAME: | 1790 | case STORE_ATTR_FRIENDLYNAME: |
| 1753 | case STORE_ATTR_EMAIL: | 1791 | case STORE_ATTR_EMAIL: |
| 1754 | case STORE_ATTR_FILENAME: | 1792 | case STORE_ATTR_FILENAME: |
| 1755 | if (strcmp(a->values[i].cstring, | 1793 | if (strcmp(a->values[i].cstring, |
| 1756 | b->values[i].cstring)) | 1794 | b->values[i].cstring)) |
| 1757 | return 0; | 1795 | return 0; |
| 1758 | break; | 1796 | break; |
| 1759 | case STORE_ATTR_KEYID: | 1797 | case STORE_ATTR_KEYID: |
| @@ -1762,25 +1800,25 @@ int STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) | |||
| 1762 | case STORE_ATTR_ISSUERSERIALHASH: | 1800 | case STORE_ATTR_ISSUERSERIALHASH: |
| 1763 | case STORE_ATTR_CERTHASH: | 1801 | case STORE_ATTR_CERTHASH: |
| 1764 | if (memcmp(a->values[i].sha1string, | 1802 | if (memcmp(a->values[i].sha1string, |
| 1765 | b->values[i].sha1string, | 1803 | b->values[i].sha1string, |
| 1766 | a->value_sizes[i])) | 1804 | a->value_sizes[i])) |
| 1767 | return 0; | 1805 | return 0; |
| 1768 | break; | 1806 | break; |
| 1769 | case STORE_ATTR_ISSUER: | 1807 | case STORE_ATTR_ISSUER: |
| 1770 | case STORE_ATTR_SUBJECT: | 1808 | case STORE_ATTR_SUBJECT: |
| 1771 | if (X509_NAME_cmp(a->values[i].dn, | 1809 | if (X509_NAME_cmp(a->values[i].dn, |
| 1772 | b->values[i].dn)) | 1810 | b->values[i].dn)) |
| 1773 | return 0; | 1811 | return 0; |
| 1774 | break; | 1812 | break; |
| 1775 | case STORE_ATTR_SERIAL: | 1813 | case STORE_ATTR_SERIAL: |
| 1776 | if (BN_cmp(a->values[i].number, | 1814 | if (BN_cmp(a->values[i].number, |
| 1777 | b->values[i].number)) | 1815 | b->values[i].number)) |
| 1778 | return 0; | 1816 | return 0; |
| 1779 | break; | 1817 | break; |
| 1780 | default: | 1818 | default: |
| 1781 | break; | 1819 | break; |
| 1782 | } | ||
| 1783 | } | 1820 | } |
| 1821 | } | ||
| 1784 | 1822 | ||
| 1785 | return 1; | 1823 | return 1; |
| 1786 | } | 1824 | } |
diff --git a/src/lib/libssl/src/crypto/store/str_locl.h b/src/lib/libssl/src/crypto/store/str_locl.h index 3f8cb75619..c58172c460 100644 --- a/src/lib/libssl/src/crypto/store/str_locl.h +++ b/src/lib/libssl/src/crypto/store/str_locl.h | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | * are met: | 10 | * are met: |
| 11 | * | 11 | * |
| 12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * | 14 | * |
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
| @@ -66,8 +66,7 @@ | |||
| 66 | extern "C" { | 66 | extern "C" { |
| 67 | #endif | 67 | #endif |
| 68 | 68 | ||
| 69 | struct store_method_st | 69 | struct store_method_st { |
| 70 | { | ||
| 71 | char *name; | 70 | char *name; |
| 72 | 71 | ||
| 73 | /* All the functions return a positive integer or non-NULL for success | 72 | /* All the functions return a positive integer or non-NULL for success |
| @@ -106,17 +105,16 @@ struct store_method_st | |||
| 106 | 105 | ||
| 107 | /* Generic control function */ | 106 | /* Generic control function */ |
| 108 | STORE_CTRL_FUNC_PTR ctrl; | 107 | STORE_CTRL_FUNC_PTR ctrl; |
| 109 | }; | 108 | }; |
| 110 | 109 | ||
| 111 | struct store_st | 110 | struct store_st { |
| 112 | { | ||
| 113 | const STORE_METHOD *meth; | 111 | const STORE_METHOD *meth; |
| 114 | /* functional reference if 'meth' is ENGINE-provided */ | 112 | /* functional reference if 'meth' is ENGINE-provided */ |
| 115 | ENGINE *engine; | 113 | ENGINE *engine; |
| 116 | 114 | ||
| 117 | CRYPTO_EX_DATA ex_data; | 115 | CRYPTO_EX_DATA ex_data; |
| 118 | int references; | 116 | int references; |
| 119 | }; | 117 | }; |
| 120 | #ifdef __cplusplus | 118 | #ifdef __cplusplus |
| 121 | } | 119 | } |
| 122 | #endif | 120 | #endif |
diff --git a/src/lib/libssl/src/crypto/store/str_mem.c b/src/lib/libssl/src/crypto/store/str_mem.c index 7e2346d93d..0409fd198d 100644 --- a/src/lib/libssl/src/crypto/store/str_mem.c +++ b/src/lib/libssl/src/crypto/store/str_mem.c | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | * are met: | 10 | * are met: |
| 11 | * | 11 | * |
| 12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * | 14 | * |
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
| @@ -76,26 +76,23 @@ | |||
| 76 | attribute type code). | 76 | attribute type code). |
| 77 | */ | 77 | */ |
| 78 | 78 | ||
| 79 | typedef struct mem_object_data_st | 79 | typedef struct mem_object_data_st { |
| 80 | { | ||
| 81 | STORE_OBJECT *object; | 80 | STORE_OBJECT *object; |
| 82 | STORE_ATTR_INFO *attr_info; | 81 | STORE_ATTR_INFO *attr_info; |
| 83 | int references; | 82 | int references; |
| 84 | } MEM_OBJECT_DATA; | 83 | } MEM_OBJECT_DATA; |
| 85 | 84 | ||
| 86 | DECLARE_STACK_OF(MEM_OBJECT_DATA) | 85 | DECLARE_STACK_OF(MEM_OBJECT_DATA) |
| 87 | struct mem_data_st | 86 | struct mem_data_st { |
| 88 | { | ||
| 89 | STACK_OF(MEM_OBJECT_DATA) *data; /* sorted with | 87 | STACK_OF(MEM_OBJECT_DATA) *data; /* sorted with |
| 90 | * STORE_ATTR_INFO_compare(). */ | 88 | * STORE_ATTR_INFO_compare(). */ |
| 91 | unsigned int compute_components : 1; /* Currently unused, but can | 89 | unsigned int compute_components : 1; /* Currently unused, but can |
| 92 | be used to add attributes | 90 | be used to add attributes |
| 93 | from parts of the data. */ | 91 | from parts of the data. */ |
| 94 | }; | 92 | }; |
| 95 | 93 | ||
| 96 | DECLARE_STACK_OF(STORE_ATTR_INFO) | 94 | DECLARE_STACK_OF(STORE_ATTR_INFO) |
| 97 | struct mem_ctx_st | 95 | struct mem_ctx_st { |
| 98 | { | ||
| 99 | int type; /* The type we're searching for */ | 96 | int type; /* The type we're searching for */ |
| 100 | STACK_OF(STORE_ATTR_INFO) *search_attributes; /* Sets of | 97 | STACK_OF(STORE_ATTR_INFO) *search_attributes; /* Sets of |
| 101 | attributes to search for. Each | 98 | attributes to search for. Each |
| @@ -105,32 +102,31 @@ struct mem_ctx_st | |||
| 105 | haven't found any */ | 102 | haven't found any */ |
| 106 | int index; /* -1 as long as we're searching for | 103 | int index; /* -1 as long as we're searching for |
| 107 | the first */ | 104 | the first */ |
| 108 | }; | 105 | }; |
| 109 | 106 | ||
| 110 | static int mem_init(STORE *s); | 107 | static int mem_init(STORE *s); |
| 111 | static void mem_clean(STORE *s); | 108 | static void mem_clean(STORE *s); |
| 112 | static STORE_OBJECT *mem_generate(STORE *s, STORE_OBJECT_TYPES type, | 109 | static STORE_OBJECT *mem_generate(STORE *s, STORE_OBJECT_TYPES type, |
| 113 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | 110 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); |
| 114 | static STORE_OBJECT *mem_get(STORE *s, STORE_OBJECT_TYPES type, | 111 | static STORE_OBJECT *mem_get(STORE *s, STORE_OBJECT_TYPES type, |
| 115 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | 112 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); |
| 116 | static int mem_store(STORE *s, STORE_OBJECT_TYPES type, | 113 | static int mem_store(STORE *s, STORE_OBJECT_TYPES type, STORE_OBJECT *data, |
| 117 | STORE_OBJECT *data, OPENSSL_ITEM attributes[], | 114 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); |
| 118 | OPENSSL_ITEM parameters[]); | ||
| 119 | static int mem_modify(STORE *s, STORE_OBJECT_TYPES type, | 115 | static int mem_modify(STORE *s, STORE_OBJECT_TYPES type, |
| 120 | OPENSSL_ITEM search_attributes[], OPENSSL_ITEM add_attributes[], | 116 | OPENSSL_ITEM search_attributes[], OPENSSL_ITEM add_attributes[], |
| 121 | OPENSSL_ITEM modify_attributes[], OPENSSL_ITEM delete_attributes[], | 117 | OPENSSL_ITEM modify_attributes[], OPENSSL_ITEM delete_attributes[], |
| 122 | OPENSSL_ITEM parameters[]); | 118 | OPENSSL_ITEM parameters[]); |
| 123 | static int mem_delete(STORE *s, STORE_OBJECT_TYPES type, | 119 | static int mem_delete(STORE *s, STORE_OBJECT_TYPES type, |
| 124 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | 120 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); |
| 125 | static void *mem_list_start(STORE *s, STORE_OBJECT_TYPES type, | 121 | static void *mem_list_start(STORE *s, STORE_OBJECT_TYPES type, |
| 126 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); | 122 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); |
| 127 | static STORE_OBJECT *mem_list_next(STORE *s, void *handle); | 123 | static STORE_OBJECT *mem_list_next(STORE *s, void *handle); |
| 128 | static int mem_list_end(STORE *s, void *handle); | 124 | static int mem_list_end(STORE *s, void *handle); |
| 129 | static int mem_list_endp(STORE *s, void *handle); | 125 | static int mem_list_endp(STORE *s, void *handle); |
| 130 | static int mem_lock(STORE *s, OPENSSL_ITEM attributes[], | 126 | static int mem_lock(STORE *s, OPENSSL_ITEM attributes[], |
| 131 | OPENSSL_ITEM parameters[]); | 127 | OPENSSL_ITEM parameters[]); |
| 132 | static int mem_unlock(STORE *s, OPENSSL_ITEM attributes[], | 128 | static int mem_unlock(STORE *s, OPENSSL_ITEM attributes[], |
| 133 | OPENSSL_ITEM parameters[]); | 129 | OPENSSL_ITEM parameters[]); |
| 134 | static int mem_ctrl(STORE *s, int cmd, long l, void *p, void (*f)(void)); | 130 | static int mem_ctrl(STORE *s, int cmd, long l, void *p, void (*f)(void)); |
| 135 | 131 | ||
| 136 | static STORE_METHOD store_memory = { | 132 | static STORE_METHOD store_memory = { |
| @@ -149,64 +145,73 @@ static STORE_METHOD store_memory = { | |||
| 149 | .lock_store = mem_lock, | 145 | .lock_store = mem_lock, |
| 150 | .unlock_store = mem_unlock, | 146 | .unlock_store = mem_unlock, |
| 151 | .ctrl = mem_ctrl | 147 | .ctrl = mem_ctrl |
| 152 | }; | 148 | }; |
| 153 | 149 | ||
| 154 | const STORE_METHOD *STORE_Memory(void) | 150 | const STORE_METHOD * |
| 155 | { | 151 | STORE_Memory(void) |
| 152 | { | ||
| 156 | return &store_memory; | 153 | return &store_memory; |
| 157 | } | 154 | } |
| 158 | 155 | ||
| 159 | static int mem_init(STORE *s) | 156 | static int |
| 160 | { | 157 | mem_init(STORE *s) |
| 158 | { | ||
| 161 | return 1; | 159 | return 1; |
| 162 | } | 160 | } |
| 163 | 161 | ||
| 164 | static void mem_clean(STORE *s) | 162 | static void |
| 165 | { | 163 | mem_clean(STORE *s) |
| 164 | { | ||
| 166 | return; | 165 | return; |
| 167 | } | 166 | } |
| 168 | 167 | ||
| 169 | static STORE_OBJECT *mem_generate(STORE *s, STORE_OBJECT_TYPES type, | 168 | static STORE_OBJECT * |
| 170 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]) | 169 | mem_generate(STORE *s, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], |
| 171 | { | 170 | OPENSSL_ITEM parameters[]) |
| 171 | { | ||
| 172 | STOREerr(STORE_F_MEM_GENERATE, STORE_R_NOT_IMPLEMENTED); | 172 | STOREerr(STORE_F_MEM_GENERATE, STORE_R_NOT_IMPLEMENTED); |
| 173 | return 0; | 173 | return 0; |
| 174 | } | 174 | } |
| 175 | static STORE_OBJECT *mem_get(STORE *s, STORE_OBJECT_TYPES type, | 175 | |
| 176 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]) | 176 | static STORE_OBJECT * |
| 177 | { | 177 | mem_get(STORE *s, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], |
| 178 | OPENSSL_ITEM parameters[]) | ||
| 179 | { | ||
| 178 | void *context = mem_list_start(s, type, attributes, parameters); | 180 | void *context = mem_list_start(s, type, attributes, parameters); |
| 179 | 181 | ||
| 180 | if (context) | 182 | if (context) { |
| 181 | { | ||
| 182 | STORE_OBJECT *object = mem_list_next(s, context); | 183 | STORE_OBJECT *object = mem_list_next(s, context); |
| 183 | 184 | ||
| 184 | if (mem_list_end(s, context)) | 185 | if (mem_list_end(s, context)) |
| 185 | return object; | 186 | return object; |
| 186 | } | ||
| 187 | return NULL; | ||
| 188 | } | 187 | } |
| 189 | static int mem_store(STORE *s, STORE_OBJECT_TYPES type, | 188 | return NULL; |
| 190 | STORE_OBJECT *data, OPENSSL_ITEM attributes[], | 189 | } |
| 191 | OPENSSL_ITEM parameters[]) | 190 | |
| 192 | { | 191 | static int |
| 192 | mem_store(STORE *s, STORE_OBJECT_TYPES type, STORE_OBJECT *data, | ||
| 193 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]) | ||
| 194 | { | ||
| 193 | STOREerr(STORE_F_MEM_STORE, STORE_R_NOT_IMPLEMENTED); | 195 | STOREerr(STORE_F_MEM_STORE, STORE_R_NOT_IMPLEMENTED); |
| 194 | return 0; | 196 | return 0; |
| 195 | } | 197 | } |
| 196 | static int mem_modify(STORE *s, STORE_OBJECT_TYPES type, | 198 | |
| 197 | OPENSSL_ITEM search_attributes[], OPENSSL_ITEM add_attributes[], | 199 | static int |
| 198 | OPENSSL_ITEM modify_attributes[], OPENSSL_ITEM delete_attributes[], | 200 | mem_modify(STORE *s, STORE_OBJECT_TYPES type, OPENSSL_ITEM search_attributes[], |
| 199 | OPENSSL_ITEM parameters[]) | 201 | OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], |
| 200 | { | 202 | OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]) |
| 203 | { | ||
| 201 | STOREerr(STORE_F_MEM_MODIFY, STORE_R_NOT_IMPLEMENTED); | 204 | STOREerr(STORE_F_MEM_MODIFY, STORE_R_NOT_IMPLEMENTED); |
| 202 | return 0; | 205 | return 0; |
| 203 | } | 206 | } |
| 204 | static int mem_delete(STORE *s, STORE_OBJECT_TYPES type, | 207 | |
| 205 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]) | 208 | static int |
| 206 | { | 209 | mem_delete(STORE *s, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], |
| 210 | OPENSSL_ITEM parameters[]) | ||
| 211 | { | ||
| 207 | STOREerr(STORE_F_MEM_DELETE, STORE_R_NOT_IMPLEMENTED); | 212 | STOREerr(STORE_F_MEM_DELETE, STORE_R_NOT_IMPLEMENTED); |
| 208 | return 0; | 213 | return 0; |
| 209 | } | 214 | } |
| 210 | 215 | ||
| 211 | /* The list functions may be the hardest to understand. Basically, | 216 | /* The list functions may be the hardest to understand. Basically, |
| 212 | mem_list_start compiles a stack of attribute info elements, and | 217 | mem_list_start compiles a stack of attribute info elements, and |
| @@ -215,105 +220,99 @@ static int mem_delete(STORE *s, STORE_OBJECT_TYPES type, | |||
| 215 | walk all the way to the end of the store (since any combination | 220 | walk all the way to the end of the store (since any combination |
| 216 | of attribute bits above the starting point may match the searched | 221 | of attribute bits above the starting point may match the searched |
| 217 | for bit pattern...). */ | 222 | for bit pattern...). */ |
| 218 | static void *mem_list_start(STORE *s, STORE_OBJECT_TYPES type, | 223 | static void * |
| 219 | OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]) | 224 | mem_list_start(STORE *s, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], |
| 220 | { | 225 | OPENSSL_ITEM parameters[]) |
| 226 | { | ||
| 221 | struct mem_ctx_st *context = | 227 | struct mem_ctx_st *context = |
| 222 | (struct mem_ctx_st *)malloc(sizeof(struct mem_ctx_st)); | 228 | (struct mem_ctx_st *)malloc(sizeof(struct mem_ctx_st)); |
| 223 | void *attribute_context = NULL; | 229 | void *attribute_context = NULL; |
| 224 | STORE_ATTR_INFO *attrs = NULL; | 230 | STORE_ATTR_INFO *attrs = NULL; |
| 225 | 231 | ||
| 226 | if (!context) | 232 | if (!context) { |
| 227 | { | ||
| 228 | STOREerr(STORE_F_MEM_LIST_START, ERR_R_MALLOC_FAILURE); | 233 | STOREerr(STORE_F_MEM_LIST_START, ERR_R_MALLOC_FAILURE); |
| 229 | return 0; | 234 | return 0; |
| 230 | } | 235 | } |
| 231 | memset(context, 0, sizeof(struct mem_ctx_st)); | 236 | memset(context, 0, sizeof(struct mem_ctx_st)); |
| 232 | 237 | ||
| 233 | attribute_context = STORE_parse_attrs_start(attributes); | 238 | attribute_context = STORE_parse_attrs_start(attributes); |
| 234 | if (!attribute_context) | 239 | if (!attribute_context) { |
| 235 | { | ||
| 236 | STOREerr(STORE_F_MEM_LIST_START, ERR_R_STORE_LIB); | 240 | STOREerr(STORE_F_MEM_LIST_START, ERR_R_STORE_LIB); |
| 237 | goto err; | 241 | goto err; |
| 238 | } | 242 | } |
| 239 | 243 | ||
| 240 | while((attrs = STORE_parse_attrs_next(attribute_context))) | 244 | while ((attrs = STORE_parse_attrs_next(attribute_context))) { |
| 241 | { | 245 | if (context->search_attributes == NULL) { |
| 242 | if (context->search_attributes == NULL) | ||
| 243 | { | ||
| 244 | context->search_attributes = | 246 | context->search_attributes = |
| 245 | sk_STORE_ATTR_INFO_new(STORE_ATTR_INFO_compare); | 247 | sk_STORE_ATTR_INFO_new(STORE_ATTR_INFO_compare); |
| 246 | if (!context->search_attributes) | 248 | if (!context->search_attributes) { |
| 247 | { | ||
| 248 | STOREerr(STORE_F_MEM_LIST_START, | 249 | STOREerr(STORE_F_MEM_LIST_START, |
| 249 | ERR_R_MALLOC_FAILURE); | 250 | ERR_R_MALLOC_FAILURE); |
| 250 | goto err; | 251 | goto err; |
| 251 | } | ||
| 252 | } | 252 | } |
| 253 | sk_STORE_ATTR_INFO_push(context->search_attributes,attrs); | ||
| 254 | } | 253 | } |
| 254 | sk_STORE_ATTR_INFO_push(context->search_attributes, attrs); | ||
| 255 | } | ||
| 255 | if (!STORE_parse_attrs_endp(attribute_context)) | 256 | if (!STORE_parse_attrs_endp(attribute_context)) |
| 256 | goto err; | 257 | goto err; |
| 257 | STORE_parse_attrs_end(attribute_context); | 258 | STORE_parse_attrs_end(attribute_context); |
| 258 | context->search_index = -1; | 259 | context->search_index = -1; |
| 259 | context->index = -1; | 260 | context->index = -1; |
| 260 | return context; | 261 | return context; |
| 261 | err: | 262 | |
| 262 | if (attribute_context) STORE_parse_attrs_end(attribute_context); | 263 | err: |
| 264 | if (attribute_context) | ||
| 265 | STORE_parse_attrs_end(attribute_context); | ||
| 263 | mem_list_end(s, context); | 266 | mem_list_end(s, context); |
| 264 | return NULL; | 267 | return NULL; |
| 265 | } | 268 | } |
| 266 | static STORE_OBJECT *mem_list_next(STORE *s, void *handle) | 269 | |
| 267 | { | 270 | static STORE_OBJECT * |
| 271 | mem_list_next(STORE *s, void *handle) | ||
| 272 | { | ||
| 268 | int i; | 273 | int i; |
| 269 | struct mem_ctx_st *context = (struct mem_ctx_st *)handle; | 274 | struct mem_ctx_st *context = (struct mem_ctx_st *)handle; |
| 270 | struct mem_object_data_st key = { 0, 0, 1 }; | 275 | struct mem_object_data_st key = { 0, 0, 1 }; |
| 271 | struct mem_data_st *store = | 276 | struct mem_data_st *store = |
| 272 | (struct mem_data_st *)STORE_get_ex_data(s, 1); | 277 | (struct mem_data_st *)STORE_get_ex_data(s, 1); |
| 273 | int srch; | 278 | int srch; |
| 274 | int cres = 0; | 279 | int cres = 0; |
| 275 | 280 | ||
| 276 | if (!context) | 281 | if (!context) { |
| 277 | { | ||
| 278 | STOREerr(STORE_F_MEM_LIST_NEXT, ERR_R_PASSED_NULL_PARAMETER); | 282 | STOREerr(STORE_F_MEM_LIST_NEXT, ERR_R_PASSED_NULL_PARAMETER); |
| 279 | return NULL; | 283 | return NULL; |
| 280 | } | 284 | } |
| 281 | if (!store) | 285 | if (!store) { |
| 282 | { | ||
| 283 | STOREerr(STORE_F_MEM_LIST_NEXT, STORE_R_NO_STORE); | 286 | STOREerr(STORE_F_MEM_LIST_NEXT, STORE_R_NO_STORE); |
| 284 | return NULL; | 287 | return NULL; |
| 285 | } | 288 | } |
| 286 | 289 | ||
| 287 | if (context->search_index == -1) | 290 | if (context->search_index == -1) { |
| 288 | { | ||
| 289 | for (i = 0; | 291 | for (i = 0; |
| 290 | i < sk_STORE_ATTR_INFO_num(context->search_attributes); | 292 | i < sk_STORE_ATTR_INFO_num(context->search_attributes); |
| 291 | i++) | 293 | i++) { |
| 292 | { | ||
| 293 | key.attr_info | 294 | key.attr_info |
| 294 | = sk_STORE_ATTR_INFO_value(context->search_attributes, | 295 | = sk_STORE_ATTR_INFO_value(context->search_attributes, |
| 295 | i); | 296 | i); |
| 296 | srch = sk_MEM_OBJECT_DATA_find_ex(store->data, &key); | 297 | srch = sk_MEM_OBJECT_DATA_find_ex(store->data, &key); |
| 297 | 298 | ||
| 298 | if (srch >= 0) | 299 | if (srch >= 0) { |
| 299 | { | ||
| 300 | context->search_index = srch; | 300 | context->search_index = srch; |
| 301 | break; | 301 | break; |
| 302 | } | ||
| 303 | } | 302 | } |
| 304 | } | 303 | } |
| 304 | } | ||
| 305 | if (context->search_index < 0) | 305 | if (context->search_index < 0) |
| 306 | return NULL; | 306 | return NULL; |
| 307 | 307 | ||
| 308 | key.attr_info = | 308 | key.attr_info = sk_STORE_ATTR_INFO_value(context->search_attributes, |
| 309 | sk_STORE_ATTR_INFO_value(context->search_attributes, | 309 | context->search_index); |
| 310 | context->search_index); | ||
| 311 | for(srch = context->search_index; | 310 | for(srch = context->search_index; |
| 312 | srch < sk_MEM_OBJECT_DATA_num(store->data) | 311 | srch < sk_MEM_OBJECT_DATA_num(store->data) && |
| 313 | && STORE_ATTR_INFO_in_range(key.attr_info, | 312 | STORE_ATTR_INFO_in_range(key.attr_info, |
| 314 | sk_MEM_OBJECT_DATA_value(store->data, srch)->attr_info) | 313 | sk_MEM_OBJECT_DATA_value(store->data, srch)->attr_info) && |
| 315 | && !(cres = STORE_ATTR_INFO_in_ex(key.attr_info, | 314 | !(cres = STORE_ATTR_INFO_in_ex(key.attr_info, |
| 316 | sk_MEM_OBJECT_DATA_value(store->data, srch)->attr_info)); | 315 | sk_MEM_OBJECT_DATA_value(store->data, srch)->attr_info)); |
| 317 | srch++) | 316 | srch++) |
| 318 | ; | 317 | ; |
| 319 | 318 | ||
| @@ -321,42 +320,48 @@ static STORE_OBJECT *mem_list_next(STORE *s, void *handle) | |||
| 321 | if (cres) | 320 | if (cres) |
| 322 | return (sk_MEM_OBJECT_DATA_value(store->data, srch))->object; | 321 | return (sk_MEM_OBJECT_DATA_value(store->data, srch))->object; |
| 323 | return NULL; | 322 | return NULL; |
| 324 | } | 323 | } |
| 325 | static int mem_list_end(STORE *s, void *handle) | 324 | |
| 326 | { | 325 | static int |
| 326 | mem_list_end(STORE *s, void *handle) | ||
| 327 | { | ||
| 327 | struct mem_ctx_st *context = (struct mem_ctx_st *)handle; | 328 | struct mem_ctx_st *context = (struct mem_ctx_st *)handle; |
| 328 | 329 | ||
| 329 | if (!context) | 330 | if (!context) { |
| 330 | { | ||
| 331 | STOREerr(STORE_F_MEM_LIST_END, ERR_R_PASSED_NULL_PARAMETER); | 331 | STOREerr(STORE_F_MEM_LIST_END, ERR_R_PASSED_NULL_PARAMETER); |
| 332 | return 0; | 332 | return 0; |
| 333 | } | 333 | } |
| 334 | if (context && context->search_attributes) | 334 | if (context && context->search_attributes) |
| 335 | sk_STORE_ATTR_INFO_free(context->search_attributes); | 335 | sk_STORE_ATTR_INFO_free(context->search_attributes); |
| 336 | free(context); | 336 | free(context); |
| 337 | return 1; | 337 | return 1; |
| 338 | } | 338 | } |
| 339 | static int mem_list_endp(STORE *s, void *handle) | 339 | |
| 340 | { | 340 | static int |
| 341 | mem_list_endp(STORE *s, void *handle) | ||
| 342 | { | ||
| 341 | struct mem_ctx_st *context = (struct mem_ctx_st *)handle; | 343 | struct mem_ctx_st *context = (struct mem_ctx_st *)handle; |
| 342 | 344 | ||
| 343 | if (!context | 345 | if (!context || context->search_index == |
| 344 | || context->search_index | 346 | sk_STORE_ATTR_INFO_num(context->search_attributes)) |
| 345 | == sk_STORE_ATTR_INFO_num(context->search_attributes)) | ||
| 346 | return 1; | 347 | return 1; |
| 347 | return 0; | 348 | return 0; |
| 348 | } | 349 | } |
| 349 | static int mem_lock(STORE *s, OPENSSL_ITEM attributes[], | 350 | |
| 350 | OPENSSL_ITEM parameters[]) | 351 | static int |
| 351 | { | 352 | mem_lock(STORE *s, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]) |
| 353 | { | ||
| 352 | return 1; | 354 | return 1; |
| 353 | } | 355 | } |
| 354 | static int mem_unlock(STORE *s, OPENSSL_ITEM attributes[], | 356 | |
| 355 | OPENSSL_ITEM parameters[]) | 357 | static int |
| 356 | { | 358 | mem_unlock(STORE *s, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]) |
| 359 | { | ||
| 357 | return 1; | 360 | return 1; |
| 358 | } | 361 | } |
| 359 | static int mem_ctrl(STORE *s, int cmd, long l, void *p, void (*f)(void)) | 362 | |
| 360 | { | 363 | static int |
| 364 | mem_ctrl(STORE *s, int cmd, long l, void *p, void (*f)(void)) | ||
| 365 | { | ||
| 361 | return 1; | 366 | return 1; |
| 362 | } | 367 | } |
diff --git a/src/lib/libssl/src/crypto/store/str_meth.c b/src/lib/libssl/src/crypto/store/str_meth.c index 0401aaa129..9457087757 100644 --- a/src/lib/libssl/src/crypto/store/str_meth.c +++ b/src/lib/libssl/src/crypto/store/str_meth.c | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | * are met: | 10 | * are met: |
| 11 | * | 11 | * |
| 12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * | 14 | * |
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
| @@ -60,189 +60,236 @@ | |||
| 60 | #include <openssl/buffer.h> | 60 | #include <openssl/buffer.h> |
| 61 | #include "str_locl.h" | 61 | #include "str_locl.h" |
| 62 | 62 | ||
| 63 | STORE_METHOD *STORE_create_method(char *name) | 63 | STORE_METHOD * |
| 64 | { | 64 | STORE_create_method(char *name) |
| 65 | { | ||
| 65 | STORE_METHOD *store_method = calloc(1, sizeof(STORE_METHOD)); | 66 | STORE_METHOD *store_method = calloc(1, sizeof(STORE_METHOD)); |
| 66 | 67 | ||
| 67 | if (store_method) | 68 | if (store_method) |
| 68 | store_method->name = BUF_strdup(name); | 69 | store_method->name = BUF_strdup(name); |
| 69 | 70 | ||
| 70 | return store_method; | 71 | return store_method; |
| 71 | } | 72 | } |
| 72 | 73 | ||
| 73 | /* BIG FSCKING WARNING!!!! If you use this on a statically allocated method | 74 | /* BIG FSCKING WARNING!!!! If you use this on a statically allocated method |
| 74 | (that is, it hasn't been allocated using STORE_create_method(), you deserve | 75 | (that is, it hasn't been allocated using STORE_create_method(), you deserve |
| 75 | anything Murphy can throw at you and more! You have been warned. */ | 76 | anything Murphy can throw at you and more! You have been warned. */ |
| 76 | void STORE_destroy_method(STORE_METHOD *store_method) | 77 | void |
| 77 | { | 78 | STORE_destroy_method(STORE_METHOD *store_method) |
| 78 | if (!store_method) return; | 79 | { |
| 80 | if (!store_method) | ||
| 81 | return; | ||
| 79 | free(store_method->name); | 82 | free(store_method->name); |
| 80 | store_method->name = NULL; | 83 | store_method->name = NULL; |
| 81 | free(store_method); | 84 | free(store_method); |
| 82 | } | 85 | } |
| 83 | 86 | ||
| 84 | int STORE_method_set_initialise_function(STORE_METHOD *sm, STORE_INITIALISE_FUNC_PTR init_f) | 87 | int |
| 85 | { | 88 | STORE_method_set_initialise_function(STORE_METHOD *sm, |
| 89 | STORE_INITIALISE_FUNC_PTR init_f) | ||
| 90 | { | ||
| 86 | sm->init = init_f; | 91 | sm->init = init_f; |
| 87 | return 1; | 92 | return 1; |
| 88 | } | 93 | } |
| 89 | 94 | ||
| 90 | int STORE_method_set_cleanup_function(STORE_METHOD *sm, STORE_CLEANUP_FUNC_PTR clean_f) | 95 | int |
| 91 | { | 96 | STORE_method_set_cleanup_function(STORE_METHOD *sm, |
| 97 | STORE_CLEANUP_FUNC_PTR clean_f) | ||
| 98 | { | ||
| 92 | sm->clean = clean_f; | 99 | sm->clean = clean_f; |
| 93 | return 1; | 100 | return 1; |
| 94 | } | 101 | } |
| 95 | 102 | ||
| 96 | int STORE_method_set_generate_function(STORE_METHOD *sm, STORE_GENERATE_OBJECT_FUNC_PTR generate_f) | 103 | int |
| 97 | { | 104 | STORE_method_set_generate_function(STORE_METHOD *sm, |
| 105 | STORE_GENERATE_OBJECT_FUNC_PTR generate_f) | ||
| 106 | { | ||
| 98 | sm->generate_object = generate_f; | 107 | sm->generate_object = generate_f; |
| 99 | return 1; | 108 | return 1; |
| 100 | } | 109 | } |
| 101 | 110 | ||
| 102 | int STORE_method_set_get_function(STORE_METHOD *sm, STORE_GET_OBJECT_FUNC_PTR get_f) | 111 | int |
| 103 | { | 112 | STORE_method_set_get_function(STORE_METHOD *sm, |
| 113 | STORE_GET_OBJECT_FUNC_PTR get_f) | ||
| 114 | { | ||
| 104 | sm->get_object = get_f; | 115 | sm->get_object = get_f; |
| 105 | return 1; | 116 | return 1; |
| 106 | } | 117 | } |
| 107 | 118 | ||
| 108 | int STORE_method_set_store_function(STORE_METHOD *sm, STORE_STORE_OBJECT_FUNC_PTR store_f) | 119 | int |
| 109 | { | 120 | STORE_method_set_store_function(STORE_METHOD *sm, |
| 121 | STORE_STORE_OBJECT_FUNC_PTR store_f) | ||
| 122 | { | ||
| 110 | sm->store_object = store_f; | 123 | sm->store_object = store_f; |
| 111 | return 1; | 124 | return 1; |
| 112 | } | 125 | } |
| 113 | 126 | ||
| 114 | int STORE_method_set_modify_function(STORE_METHOD *sm, STORE_MODIFY_OBJECT_FUNC_PTR modify_f) | 127 | int |
| 115 | { | 128 | STORE_method_set_modify_function(STORE_METHOD *sm, |
| 129 | STORE_MODIFY_OBJECT_FUNC_PTR modify_f) | ||
| 130 | { | ||
| 116 | sm->modify_object = modify_f; | 131 | sm->modify_object = modify_f; |
| 117 | return 1; | 132 | return 1; |
| 118 | } | 133 | } |
| 119 | 134 | ||
| 120 | int STORE_method_set_revoke_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR revoke_f) | 135 | int |
| 121 | { | 136 | STORE_method_set_revoke_function(STORE_METHOD *sm, |
| 137 | STORE_HANDLE_OBJECT_FUNC_PTR revoke_f) | ||
| 138 | { | ||
| 122 | sm->revoke_object = revoke_f; | 139 | sm->revoke_object = revoke_f; |
| 123 | return 1; | 140 | return 1; |
| 124 | } | 141 | } |
| 125 | 142 | ||
| 126 | int STORE_method_set_delete_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR delete_f) | 143 | int |
| 127 | { | 144 | STORE_method_set_delete_function(STORE_METHOD *sm, |
| 145 | STORE_HANDLE_OBJECT_FUNC_PTR delete_f) | ||
| 146 | { | ||
| 128 | sm->delete_object = delete_f; | 147 | sm->delete_object = delete_f; |
| 129 | return 1; | 148 | return 1; |
| 130 | } | 149 | } |
| 131 | 150 | ||
| 132 | int STORE_method_set_list_start_function(STORE_METHOD *sm, STORE_START_OBJECT_FUNC_PTR list_start_f) | 151 | int |
| 133 | { | 152 | STORE_method_set_list_start_function(STORE_METHOD *sm, |
| 153 | STORE_START_OBJECT_FUNC_PTR list_start_f) | ||
| 154 | { | ||
| 134 | sm->list_object_start = list_start_f; | 155 | sm->list_object_start = list_start_f; |
| 135 | return 1; | 156 | return 1; |
| 136 | } | 157 | } |
| 137 | 158 | ||
| 138 | int STORE_method_set_list_next_function(STORE_METHOD *sm, STORE_NEXT_OBJECT_FUNC_PTR list_next_f) | 159 | int |
| 139 | { | 160 | STORE_method_set_list_next_function(STORE_METHOD *sm, |
| 161 | STORE_NEXT_OBJECT_FUNC_PTR list_next_f) | ||
| 162 | { | ||
| 140 | sm->list_object_next = list_next_f; | 163 | sm->list_object_next = list_next_f; |
| 141 | return 1; | 164 | return 1; |
| 142 | } | 165 | } |
| 143 | 166 | ||
| 144 | int STORE_method_set_list_end_function(STORE_METHOD *sm, STORE_END_OBJECT_FUNC_PTR list_end_f) | 167 | int |
| 145 | { | 168 | STORE_method_set_list_end_function(STORE_METHOD *sm, |
| 169 | STORE_END_OBJECT_FUNC_PTR list_end_f) | ||
| 170 | { | ||
| 146 | sm->list_object_end = list_end_f; | 171 | sm->list_object_end = list_end_f; |
| 147 | return 1; | 172 | return 1; |
| 148 | } | 173 | } |
| 149 | 174 | ||
| 150 | int STORE_method_set_update_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR update_f) | 175 | int |
| 151 | { | 176 | STORE_method_set_update_store_function(STORE_METHOD *sm, |
| 177 | STORE_GENERIC_FUNC_PTR update_f) | ||
| 178 | { | ||
| 152 | sm->update_store = update_f; | 179 | sm->update_store = update_f; |
| 153 | return 1; | 180 | return 1; |
| 154 | } | 181 | } |
| 155 | 182 | ||
| 156 | int STORE_method_set_lock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR lock_f) | 183 | int |
| 157 | { | 184 | STORE_method_set_lock_store_function(STORE_METHOD *sm, |
| 185 | STORE_GENERIC_FUNC_PTR lock_f) | ||
| 186 | { | ||
| 158 | sm->lock_store = lock_f; | 187 | sm->lock_store = lock_f; |
| 159 | return 1; | 188 | return 1; |
| 160 | } | 189 | } |
| 161 | 190 | ||
| 162 | int STORE_method_set_unlock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR unlock_f) | 191 | int |
| 163 | { | 192 | STORE_method_set_unlock_store_function(STORE_METHOD *sm, |
| 193 | STORE_GENERIC_FUNC_PTR unlock_f) | ||
| 194 | { | ||
| 164 | sm->unlock_store = unlock_f; | 195 | sm->unlock_store = unlock_f; |
| 165 | return 1; | 196 | return 1; |
| 166 | } | 197 | } |
| 167 | 198 | ||
| 168 | int STORE_method_set_ctrl_function(STORE_METHOD *sm, STORE_CTRL_FUNC_PTR ctrl_f) | 199 | int |
| 169 | { | 200 | STORE_method_set_ctrl_function(STORE_METHOD *sm, STORE_CTRL_FUNC_PTR ctrl_f) |
| 201 | { | ||
| 170 | sm->ctrl = ctrl_f; | 202 | sm->ctrl = ctrl_f; |
| 171 | return 1; | 203 | return 1; |
| 172 | } | 204 | } |
| 173 | 205 | ||
| 174 | STORE_INITIALISE_FUNC_PTR STORE_method_get_initialise_function(STORE_METHOD *sm) | 206 | STORE_INITIALISE_FUNC_PTR |
| 175 | { | 207 | STORE_method_get_initialise_function(STORE_METHOD *sm) |
| 208 | { | ||
| 176 | return sm->init; | 209 | return sm->init; |
| 177 | } | 210 | } |
| 178 | 211 | ||
| 179 | STORE_CLEANUP_FUNC_PTR STORE_method_get_cleanup_function(STORE_METHOD *sm) | 212 | STORE_CLEANUP_FUNC_PTR |
| 180 | { | 213 | STORE_method_get_cleanup_function(STORE_METHOD *sm) |
| 214 | { | ||
| 181 | return sm->clean; | 215 | return sm->clean; |
| 182 | } | 216 | } |
| 183 | 217 | ||
| 184 | STORE_GENERATE_OBJECT_FUNC_PTR STORE_method_get_generate_function(STORE_METHOD *sm) | 218 | STORE_GENERATE_OBJECT_FUNC_PTR |
| 185 | { | 219 | STORE_method_get_generate_function(STORE_METHOD *sm) |
| 220 | { | ||
| 186 | return sm->generate_object; | 221 | return sm->generate_object; |
| 187 | } | 222 | } |
| 188 | 223 | ||
| 189 | STORE_GET_OBJECT_FUNC_PTR STORE_method_get_get_function(STORE_METHOD *sm) | 224 | STORE_GET_OBJECT_FUNC_PTR |
| 190 | { | 225 | STORE_method_get_get_function(STORE_METHOD *sm) |
| 226 | { | ||
| 191 | return sm->get_object; | 227 | return sm->get_object; |
| 192 | } | 228 | } |
| 193 | 229 | ||
| 194 | STORE_STORE_OBJECT_FUNC_PTR STORE_method_get_store_function(STORE_METHOD *sm) | 230 | STORE_STORE_OBJECT_FUNC_PTR |
| 195 | { | 231 | STORE_method_get_store_function(STORE_METHOD *sm) |
| 232 | { | ||
| 196 | return sm->store_object; | 233 | return sm->store_object; |
| 197 | } | 234 | } |
| 198 | 235 | ||
| 199 | STORE_MODIFY_OBJECT_FUNC_PTR STORE_method_get_modify_function(STORE_METHOD *sm) | 236 | STORE_MODIFY_OBJECT_FUNC_PTR |
| 200 | { | 237 | STORE_method_get_modify_function(STORE_METHOD *sm) |
| 238 | { | ||
| 201 | return sm->modify_object; | 239 | return sm->modify_object; |
| 202 | } | 240 | } |
| 203 | 241 | ||
| 204 | STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_revoke_function(STORE_METHOD *sm) | 242 | STORE_HANDLE_OBJECT_FUNC_PTR |
| 205 | { | 243 | STORE_method_get_revoke_function(STORE_METHOD *sm) |
| 244 | { | ||
| 206 | return sm->revoke_object; | 245 | return sm->revoke_object; |
| 207 | } | 246 | } |
| 208 | 247 | ||
| 209 | STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_delete_function(STORE_METHOD *sm) | 248 | STORE_HANDLE_OBJECT_FUNC_PTR |
| 210 | { | 249 | STORE_method_get_delete_function(STORE_METHOD *sm) |
| 250 | { | ||
| 211 | return sm->delete_object; | 251 | return sm->delete_object; |
| 212 | } | 252 | } |
| 213 | 253 | ||
| 214 | STORE_START_OBJECT_FUNC_PTR STORE_method_get_list_start_function(STORE_METHOD *sm) | 254 | STORE_START_OBJECT_FUNC_PTR |
| 215 | { | 255 | STORE_method_get_list_start_function(STORE_METHOD *sm) |
| 256 | { | ||
| 216 | return sm->list_object_start; | 257 | return sm->list_object_start; |
| 217 | } | 258 | } |
| 218 | 259 | ||
| 219 | STORE_NEXT_OBJECT_FUNC_PTR STORE_method_get_list_next_function(STORE_METHOD *sm) | 260 | STORE_NEXT_OBJECT_FUNC_PTR |
| 220 | { | 261 | STORE_method_get_list_next_function(STORE_METHOD *sm) |
| 262 | { | ||
| 221 | return sm->list_object_next; | 263 | return sm->list_object_next; |
| 222 | } | 264 | } |
| 223 | 265 | ||
| 224 | STORE_END_OBJECT_FUNC_PTR STORE_method_get_list_end_function(STORE_METHOD *sm) | 266 | STORE_END_OBJECT_FUNC_PTR |
| 225 | { | 267 | STORE_method_get_list_end_function(STORE_METHOD *sm) |
| 268 | { | ||
| 226 | return sm->list_object_end; | 269 | return sm->list_object_end; |
| 227 | } | 270 | } |
| 228 | 271 | ||
| 229 | STORE_GENERIC_FUNC_PTR STORE_method_get_update_store_function(STORE_METHOD *sm) | 272 | STORE_GENERIC_FUNC_PTR |
| 230 | { | 273 | STORE_method_get_update_store_function(STORE_METHOD *sm) |
| 274 | { | ||
| 231 | return sm->update_store; | 275 | return sm->update_store; |
| 232 | } | 276 | } |
| 233 | 277 | ||
| 234 | STORE_GENERIC_FUNC_PTR STORE_method_get_lock_store_function(STORE_METHOD *sm) | 278 | STORE_GENERIC_FUNC_PTR |
| 235 | { | 279 | STORE_method_get_lock_store_function(STORE_METHOD *sm) |
| 280 | { | ||
| 236 | return sm->lock_store; | 281 | return sm->lock_store; |
| 237 | } | 282 | } |
| 238 | 283 | ||
| 239 | STORE_GENERIC_FUNC_PTR STORE_method_get_unlock_store_function(STORE_METHOD *sm) | 284 | STORE_GENERIC_FUNC_PTR |
| 240 | { | 285 | STORE_method_get_unlock_store_function(STORE_METHOD *sm) |
| 286 | { | ||
| 241 | return sm->unlock_store; | 287 | return sm->unlock_store; |
| 242 | } | 288 | } |
| 243 | 289 | ||
| 244 | STORE_CTRL_FUNC_PTR STORE_method_get_ctrl_function(STORE_METHOD *sm) | 290 | STORE_CTRL_FUNC_PTR |
| 245 | { | 291 | STORE_method_get_ctrl_function(STORE_METHOD *sm) |
| 292 | { | ||
| 246 | return sm->ctrl; | 293 | return sm->ctrl; |
| 247 | } | 294 | } |
| 248 | 295 | ||
