1160814Ssimon/* crypto/store/store.h -*- mode:C; c-file-style: "eay" -*- */ 2296465Sdelphij/* 3296465Sdelphij * Written by Richard Levitte (richard@levitte.org) for the OpenSSL project 4296465Sdelphij * 2003. 5160814Ssimon */ 6160814Ssimon/* ==================================================================== 7160814Ssimon * Copyright (c) 2003 The OpenSSL Project. All rights reserved. 8160814Ssimon * 9160814Ssimon * Redistribution and use in source and binary forms, with or without 10160814Ssimon * modification, are permitted provided that the following conditions 11160814Ssimon * are met: 12160814Ssimon * 13160814Ssimon * 1. Redistributions of source code must retain the above copyright 14296465Sdelphij * notice, this list of conditions and the following disclaimer. 15160814Ssimon * 16160814Ssimon * 2. Redistributions in binary form must reproduce the above copyright 17160814Ssimon * notice, this list of conditions and the following disclaimer in 18160814Ssimon * the documentation and/or other materials provided with the 19160814Ssimon * distribution. 20160814Ssimon * 21160814Ssimon * 3. All advertising materials mentioning features or use of this 22160814Ssimon * software must display the following acknowledgment: 23160814Ssimon * "This product includes software developed by the OpenSSL Project 24160814Ssimon * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 25160814Ssimon * 26160814Ssimon * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 27160814Ssimon * endorse or promote products derived from this software without 28160814Ssimon * prior written permission. For written permission, please contact 29160814Ssimon * openssl-core@openssl.org. 30160814Ssimon * 31160814Ssimon * 5. Products derived from this software may not be called "OpenSSL" 32160814Ssimon * nor may "OpenSSL" appear in their names without prior written 33160814Ssimon * permission of the OpenSSL Project. 34160814Ssimon * 35160814Ssimon * 6. Redistributions of any form whatsoever must retain the following 36160814Ssimon * acknowledgment: 37160814Ssimon * "This product includes software developed by the OpenSSL Project 38160814Ssimon * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 39160814Ssimon * 40160814Ssimon * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 41160814Ssimon * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 42160814Ssimon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 43160814Ssimon * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 44160814Ssimon * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 45160814Ssimon * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 46160814Ssimon * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 47160814Ssimon * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48160814Ssimon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 49160814Ssimon * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 50160814Ssimon * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 51160814Ssimon * OF THE POSSIBILITY OF SUCH DAMAGE. 52160814Ssimon * ==================================================================== 53160814Ssimon * 54160814Ssimon * This product includes cryptographic software written by Eric Young 55160814Ssimon * (eay@cryptsoft.com). This product includes software written by Tim 56160814Ssimon * Hudson (tjh@cryptsoft.com). 57160814Ssimon * 58160814Ssimon */ 59160814Ssimon 60160814Ssimon#ifndef HEADER_STORE_H 61296465Sdelphij# define HEADER_STORE_H 62160814Ssimon 63296465Sdelphij# include <openssl/ossl_typ.h> 64296465Sdelphij# ifndef OPENSSL_NO_DEPRECATED 65296465Sdelphij# include <openssl/evp.h> 66296465Sdelphij# include <openssl/bn.h> 67296465Sdelphij# include <openssl/x509.h> 68296465Sdelphij# endif 69160814Ssimon 70160814Ssimon#ifdef __cplusplus 71160814Ssimonextern "C" { 72160814Ssimon#endif 73160814Ssimon 74160814Ssimon/* Already defined in ossl_typ.h */ 75160814Ssimon/* typedef struct store_st STORE; */ 76160814Ssimon/* typedef struct store_method_st STORE_METHOD; */ 77160814Ssimon 78296465Sdelphij/* 79296465Sdelphij * All the following functions return 0, a negative number or NULL on error. 80296465Sdelphij * When everything is fine, they return a positive value or a non-NULL 81296465Sdelphij * pointer, all depending on their purpose. 82296465Sdelphij */ 83160814Ssimon 84160814Ssimon/* Creators and destructor. */ 85160814SsimonSTORE *STORE_new_method(const STORE_METHOD *method); 86160814SsimonSTORE *STORE_new_engine(ENGINE *engine); 87160814Ssimonvoid STORE_free(STORE *ui); 88160814Ssimon 89296465Sdelphij/* 90296465Sdelphij * Give a user interface parametrised control commands. This can be used to 91296465Sdelphij * send down an integer, a data pointer or a function pointer, as well as be 92296465Sdelphij * used to get information from a STORE. 93296465Sdelphij */ 94296465Sdelphijint STORE_ctrl(STORE *store, int cmd, long i, void *p, void (*f) (void)); 95160814Ssimon 96296465Sdelphij/* 97296465Sdelphij * A control to set the directory with keys and certificates. Used by the 98296465Sdelphij * built-in directory level method. 99296465Sdelphij */ 100296465Sdelphij# define STORE_CTRL_SET_DIRECTORY 0x0001 101296465Sdelphij/* 102296465Sdelphij * A control to set a file to load. Used by the built-in file level method. 103296465Sdelphij */ 104296465Sdelphij# define STORE_CTRL_SET_FILE 0x0002 105296465Sdelphij/* 106296465Sdelphij * A control to set a configuration file to load. Can be used by any method 107296465Sdelphij * that wishes to load a configuration file. 108296465Sdelphij */ 109296465Sdelphij# define STORE_CTRL_SET_CONF_FILE 0x0003 110296465Sdelphij/* 111296465Sdelphij * A control to set a the section of the loaded configuration file. Can be 112296465Sdelphij * used by any method that wishes to load a configuration file. 113296465Sdelphij */ 114296465Sdelphij# define STORE_CTRL_SET_CONF_SECTION 0x0004 115160814Ssimon 116160814Ssimon/* Some methods may use extra data */ 117296465Sdelphij# define STORE_set_app_data(s,arg) STORE_set_ex_data(s,0,arg) 118296465Sdelphij# define STORE_get_app_data(s) STORE_get_ex_data(s,0) 119160814Ssimonint STORE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, 120296465Sdelphij CRYPTO_EX_dup *dup_func, 121296465Sdelphij CRYPTO_EX_free *free_func); 122296465Sdelphijint STORE_set_ex_data(STORE *r, int idx, void *arg); 123160814Ssimonvoid *STORE_get_ex_data(STORE *r, int idx); 124160814Ssimon 125160814Ssimon/* Use specific methods instead of the built-in one */ 126160814Ssimonconst STORE_METHOD *STORE_get_method(STORE *store); 127160814Ssimonconst STORE_METHOD *STORE_set_method(STORE *store, const STORE_METHOD *meth); 128160814Ssimon 129160814Ssimon/* The standard OpenSSL methods. */ 130296465Sdelphij/* 131296465Sdelphij * This is the in-memory method. It does everything except revoking and 132296465Sdelphij * updating, and is of course volatile. It's used by other methods that have 133296465Sdelphij * an in-memory cache. 134296465Sdelphij */ 135160814Ssimonconst STORE_METHOD *STORE_Memory(void); 136296465Sdelphij# if 0 /* Not yet implemented */ 137296465Sdelphij/* 138296465Sdelphij * This is the directory store. It does everything except revoking and 139296465Sdelphij * updating, and uses STORE_Memory() to cache things in memory. 140296465Sdelphij */ 141160814Ssimonconst STORE_METHOD *STORE_Directory(void); 142296465Sdelphij/* 143296465Sdelphij * This is the file store. It does everything except revoking and updating, 144296465Sdelphij * and uses STORE_Memory() to cache things in memory. Certificates are added 145296465Sdelphij * to it with the store operation, and it will only get cached certificates. 146296465Sdelphij */ 147160814Ssimonconst STORE_METHOD *STORE_File(void); 148296465Sdelphij# endif 149160814Ssimon 150296465Sdelphij/* 151296465Sdelphij * Store functions take a type code for the type of data they should store or 152296465Sdelphij * fetch 153296465Sdelphij */ 154296465Sdelphijtypedef enum STORE_object_types { 155296465Sdelphij STORE_OBJECT_TYPE_X509_CERTIFICATE = 0x01, /* X509 * */ 156296465Sdelphij STORE_OBJECT_TYPE_X509_CRL = 0x02, /* X509_CRL * */ 157296465Sdelphij STORE_OBJECT_TYPE_PRIVATE_KEY = 0x03, /* EVP_PKEY * */ 158296465Sdelphij STORE_OBJECT_TYPE_PUBLIC_KEY = 0x04, /* EVP_PKEY * */ 159296465Sdelphij STORE_OBJECT_TYPE_NUMBER = 0x05, /* BIGNUM * */ 160296465Sdelphij STORE_OBJECT_TYPE_ARBITRARY = 0x06, /* BUF_MEM * */ 161296465Sdelphij STORE_OBJECT_TYPE_NUM = 0x06 /* The amount of known object types */ 162296465Sdelphij} STORE_OBJECT_TYPES; 163160814Ssimon/* List of text strings corresponding to the object types. */ 164296465Sdelphijextern const char *const STORE_object_type_string[STORE_OBJECT_TYPE_NUM + 1]; 165160814Ssimon 166296465Sdelphij/* 167296465Sdelphij * Some store functions take a parameter list. Those parameters come with 168296465Sdelphij * one of the following codes. The comments following the codes below 169296465Sdelphij * indicate what type the value should be a pointer to. 170296465Sdelphij */ 171296465Sdelphijtypedef enum STORE_params { 172296465Sdelphij STORE_PARAM_EVP_TYPE = 0x01, /* int */ 173296465Sdelphij STORE_PARAM_BITS = 0x02, /* size_t */ 174296465Sdelphij STORE_PARAM_KEY_PARAMETERS = 0x03, /* ??? */ 175296465Sdelphij STORE_PARAM_KEY_NO_PARAMETERS = 0x04, /* N/A */ 176296465Sdelphij STORE_PARAM_AUTH_PASSPHRASE = 0x05, /* char * */ 177296465Sdelphij STORE_PARAM_AUTH_KRB5_TICKET = 0x06, /* void * */ 178296465Sdelphij STORE_PARAM_TYPE_NUM = 0x06 /* The amount of known parameter types */ 179296465Sdelphij} STORE_PARAM_TYPES; 180296465Sdelphij/* 181296465Sdelphij * Parameter value sizes. -1 means unknown, anything else is the required 182296465Sdelphij * size. 183296465Sdelphij */ 184296465Sdelphijextern const int STORE_param_sizes[STORE_PARAM_TYPE_NUM + 1]; 185160814Ssimon 186296465Sdelphij/* 187296465Sdelphij * Store functions take attribute lists. Those attributes come with codes. 188296465Sdelphij * The comments following the codes below indicate what type the value should 189296465Sdelphij * be a pointer to. 190296465Sdelphij */ 191296465Sdelphijtypedef enum STORE_attribs { 192296465Sdelphij STORE_ATTR_END = 0x00, 193296465Sdelphij STORE_ATTR_FRIENDLYNAME = 0x01, /* C string */ 194296465Sdelphij STORE_ATTR_KEYID = 0x02, /* 160 bit string (SHA1) */ 195296465Sdelphij STORE_ATTR_ISSUERKEYID = 0x03, /* 160 bit string (SHA1) */ 196296465Sdelphij STORE_ATTR_SUBJECTKEYID = 0x04, /* 160 bit string (SHA1) */ 197296465Sdelphij STORE_ATTR_ISSUERSERIALHASH = 0x05, /* 160 bit string (SHA1) */ 198296465Sdelphij STORE_ATTR_ISSUER = 0x06, /* X509_NAME * */ 199296465Sdelphij STORE_ATTR_SERIAL = 0x07, /* BIGNUM * */ 200296465Sdelphij STORE_ATTR_SUBJECT = 0x08, /* X509_NAME * */ 201296465Sdelphij STORE_ATTR_CERTHASH = 0x09, /* 160 bit string (SHA1) */ 202296465Sdelphij STORE_ATTR_EMAIL = 0x0a, /* C string */ 203296465Sdelphij STORE_ATTR_FILENAME = 0x0b, /* C string */ 204296465Sdelphij STORE_ATTR_TYPE_NUM = 0x0b, /* The amount of known attribute types */ 205296465Sdelphij STORE_ATTR_OR = 0xff /* This is a special separator, which 206296465Sdelphij * expresses the OR operation. */ 207296465Sdelphij} STORE_ATTR_TYPES; 208296465Sdelphij/* 209296465Sdelphij * Attribute value sizes. -1 means unknown, anything else is the required 210296465Sdelphij * size. 211296465Sdelphij */ 212296465Sdelphijextern const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM + 1]; 213160814Ssimon 214296465Sdelphijtypedef enum STORE_certificate_status { 215296465Sdelphij STORE_X509_VALID = 0x00, 216296465Sdelphij STORE_X509_EXPIRED = 0x01, 217296465Sdelphij STORE_X509_SUSPENDED = 0x02, 218296465Sdelphij STORE_X509_REVOKED = 0x03 219296465Sdelphij} STORE_CERTIFICATE_STATUS; 220160814Ssimon 221296465Sdelphij/* 222296465Sdelphij * Engine store functions will return a structure that contains all the 223296465Sdelphij * necessary information, including revokation status for certificates. This 224296465Sdelphij * is really not needed for application authors, as the ENGINE framework 225296465Sdelphij * functions will extract the OpenSSL-specific information when at all 226296465Sdelphij * possible. However, for engine authors, it's crucial to know this 227296465Sdelphij * structure. 228296465Sdelphij */ 229296465Sdelphijtypedef struct STORE_OBJECT_st { 230296465Sdelphij STORE_OBJECT_TYPES type; 231296465Sdelphij union { 232296465Sdelphij struct { 233296465Sdelphij STORE_CERTIFICATE_STATUS status; 234296465Sdelphij X509 *certificate; 235296465Sdelphij } x509; 236296465Sdelphij X509_CRL *crl; 237296465Sdelphij EVP_PKEY *key; 238296465Sdelphij BIGNUM *number; 239296465Sdelphij BUF_MEM *arbitrary; 240296465Sdelphij } data; 241296465Sdelphij} STORE_OBJECT; 242160814SsimonDECLARE_STACK_OF(STORE_OBJECT) 243160814SsimonSTORE_OBJECT *STORE_OBJECT_new(void); 244160814Ssimonvoid STORE_OBJECT_free(STORE_OBJECT *data); 245160814Ssimon 246296465Sdelphij/* 247296465Sdelphij * The following functions handle the storage. They return 0, a negative 248296465Sdelphij * number or NULL on error, anything else on success. 249296465Sdelphij */ 250160814SsimonX509 *STORE_get_certificate(STORE *e, OPENSSL_ITEM attributes[], 251296465Sdelphij OPENSSL_ITEM parameters[]); 252160814Ssimonint STORE_store_certificate(STORE *e, X509 *data, OPENSSL_ITEM attributes[], 253296465Sdelphij OPENSSL_ITEM parameters[]); 254160814Ssimonint STORE_modify_certificate(STORE *e, OPENSSL_ITEM search_attributes[], 255296465Sdelphij OPENSSL_ITEM add_attributes[], 256296465Sdelphij OPENSSL_ITEM modify_attributes[], 257296465Sdelphij OPENSSL_ITEM delete_attributes[], 258296465Sdelphij OPENSSL_ITEM parameters[]); 259160814Ssimonint STORE_revoke_certificate(STORE *e, OPENSSL_ITEM attributes[], 260296465Sdelphij OPENSSL_ITEM parameters[]); 261160814Ssimonint STORE_delete_certificate(STORE *e, OPENSSL_ITEM attributes[], 262296465Sdelphij OPENSSL_ITEM parameters[]); 263160814Ssimonvoid *STORE_list_certificate_start(STORE *e, OPENSSL_ITEM attributes[], 264296465Sdelphij OPENSSL_ITEM parameters[]); 265160814SsimonX509 *STORE_list_certificate_next(STORE *e, void *handle); 266160814Ssimonint STORE_list_certificate_end(STORE *e, void *handle); 267160814Ssimonint STORE_list_certificate_endp(STORE *e, void *handle); 268160814SsimonEVP_PKEY *STORE_generate_key(STORE *e, OPENSSL_ITEM attributes[], 269296465Sdelphij OPENSSL_ITEM parameters[]); 270160814SsimonEVP_PKEY *STORE_get_private_key(STORE *e, OPENSSL_ITEM attributes[], 271296465Sdelphij OPENSSL_ITEM parameters[]); 272160814Ssimonint STORE_store_private_key(STORE *e, EVP_PKEY *data, 273296465Sdelphij OPENSSL_ITEM attributes[], 274296465Sdelphij OPENSSL_ITEM parameters[]); 275160814Ssimonint STORE_modify_private_key(STORE *e, OPENSSL_ITEM search_attributes[], 276296465Sdelphij OPENSSL_ITEM add_sttributes[], 277296465Sdelphij OPENSSL_ITEM modify_attributes[], 278296465Sdelphij OPENSSL_ITEM delete_attributes[], 279296465Sdelphij OPENSSL_ITEM parameters[]); 280160814Ssimonint STORE_revoke_private_key(STORE *e, OPENSSL_ITEM attributes[], 281296465Sdelphij OPENSSL_ITEM parameters[]); 282160814Ssimonint STORE_delete_private_key(STORE *e, OPENSSL_ITEM attributes[], 283296465Sdelphij OPENSSL_ITEM parameters[]); 284160814Ssimonvoid *STORE_list_private_key_start(STORE *e, OPENSSL_ITEM attributes[], 285296465Sdelphij OPENSSL_ITEM parameters[]); 286160814SsimonEVP_PKEY *STORE_list_private_key_next(STORE *e, void *handle); 287160814Ssimonint STORE_list_private_key_end(STORE *e, void *handle); 288160814Ssimonint STORE_list_private_key_endp(STORE *e, void *handle); 289160814SsimonEVP_PKEY *STORE_get_public_key(STORE *e, OPENSSL_ITEM attributes[], 290296465Sdelphij OPENSSL_ITEM parameters[]); 291296465Sdelphijint STORE_store_public_key(STORE *e, EVP_PKEY *data, 292296465Sdelphij OPENSSL_ITEM attributes[], 293296465Sdelphij OPENSSL_ITEM parameters[]); 294160814Ssimonint STORE_modify_public_key(STORE *e, OPENSSL_ITEM search_attributes[], 295296465Sdelphij OPENSSL_ITEM add_sttributes[], 296296465Sdelphij OPENSSL_ITEM modify_attributes[], 297296465Sdelphij OPENSSL_ITEM delete_attributes[], 298296465Sdelphij OPENSSL_ITEM parameters[]); 299160814Ssimonint STORE_revoke_public_key(STORE *e, OPENSSL_ITEM attributes[], 300296465Sdelphij OPENSSL_ITEM parameters[]); 301160814Ssimonint STORE_delete_public_key(STORE *e, OPENSSL_ITEM attributes[], 302296465Sdelphij OPENSSL_ITEM parameters[]); 303160814Ssimonvoid *STORE_list_public_key_start(STORE *e, OPENSSL_ITEM attributes[], 304296465Sdelphij OPENSSL_ITEM parameters[]); 305160814SsimonEVP_PKEY *STORE_list_public_key_next(STORE *e, void *handle); 306160814Ssimonint STORE_list_public_key_end(STORE *e, void *handle); 307160814Ssimonint STORE_list_public_key_endp(STORE *e, void *handle); 308160814SsimonX509_CRL *STORE_generate_crl(STORE *e, OPENSSL_ITEM attributes[], 309296465Sdelphij OPENSSL_ITEM parameters[]); 310160814SsimonX509_CRL *STORE_get_crl(STORE *e, OPENSSL_ITEM attributes[], 311296465Sdelphij OPENSSL_ITEM parameters[]); 312160814Ssimonint STORE_store_crl(STORE *e, X509_CRL *data, OPENSSL_ITEM attributes[], 313296465Sdelphij OPENSSL_ITEM parameters[]); 314160814Ssimonint STORE_modify_crl(STORE *e, OPENSSL_ITEM search_attributes[], 315296465Sdelphij OPENSSL_ITEM add_sttributes[], 316296465Sdelphij OPENSSL_ITEM modify_attributes[], 317296465Sdelphij OPENSSL_ITEM delete_attributes[], 318296465Sdelphij OPENSSL_ITEM parameters[]); 319160814Ssimonint STORE_delete_crl(STORE *e, OPENSSL_ITEM attributes[], 320296465Sdelphij OPENSSL_ITEM parameters[]); 321160814Ssimonvoid *STORE_list_crl_start(STORE *e, OPENSSL_ITEM attributes[], 322296465Sdelphij OPENSSL_ITEM parameters[]); 323160814SsimonX509_CRL *STORE_list_crl_next(STORE *e, void *handle); 324160814Ssimonint STORE_list_crl_end(STORE *e, void *handle); 325160814Ssimonint STORE_list_crl_endp(STORE *e, void *handle); 326160814Ssimonint STORE_store_number(STORE *e, BIGNUM *data, OPENSSL_ITEM attributes[], 327296465Sdelphij OPENSSL_ITEM parameters[]); 328160814Ssimonint STORE_modify_number(STORE *e, OPENSSL_ITEM search_attributes[], 329296465Sdelphij OPENSSL_ITEM add_sttributes[], 330296465Sdelphij OPENSSL_ITEM modify_attributes[], 331296465Sdelphij OPENSSL_ITEM delete_attributes[], 332296465Sdelphij OPENSSL_ITEM parameters[]); 333160814SsimonBIGNUM *STORE_get_number(STORE *e, OPENSSL_ITEM attributes[], 334296465Sdelphij OPENSSL_ITEM parameters[]); 335160814Ssimonint STORE_delete_number(STORE *e, OPENSSL_ITEM attributes[], 336296465Sdelphij OPENSSL_ITEM parameters[]); 337160814Ssimonint STORE_store_arbitrary(STORE *e, BUF_MEM *data, OPENSSL_ITEM attributes[], 338296465Sdelphij OPENSSL_ITEM parameters[]); 339160814Ssimonint STORE_modify_arbitrary(STORE *e, OPENSSL_ITEM search_attributes[], 340296465Sdelphij OPENSSL_ITEM add_sttributes[], 341296465Sdelphij OPENSSL_ITEM modify_attributes[], 342296465Sdelphij OPENSSL_ITEM delete_attributes[], 343296465Sdelphij OPENSSL_ITEM parameters[]); 344160814SsimonBUF_MEM *STORE_get_arbitrary(STORE *e, OPENSSL_ITEM attributes[], 345296465Sdelphij OPENSSL_ITEM parameters[]); 346160814Ssimonint STORE_delete_arbitrary(STORE *e, OPENSSL_ITEM attributes[], 347296465Sdelphij OPENSSL_ITEM parameters[]); 348160814Ssimon 349160814Ssimon/* Create and manipulate methods */ 350160814SsimonSTORE_METHOD *STORE_create_method(char *name); 351160814Ssimonvoid STORE_destroy_method(STORE_METHOD *store_method); 352160814Ssimon 353160814Ssimon/* These callback types are use for store handlers */ 354296465Sdelphijtypedef int (*STORE_INITIALISE_FUNC_PTR) (STORE *); 355296465Sdelphijtypedef void (*STORE_CLEANUP_FUNC_PTR) (STORE *); 356296465Sdelphijtypedef STORE_OBJECT *(*STORE_GENERATE_OBJECT_FUNC_PTR)(STORE *, 357296465Sdelphij STORE_OBJECT_TYPES 358296465Sdelphij type, 359296465Sdelphij OPENSSL_ITEM 360296465Sdelphij attributes[], 361296465Sdelphij OPENSSL_ITEM 362296465Sdelphij parameters[]); 363296465Sdelphijtypedef STORE_OBJECT *(*STORE_GET_OBJECT_FUNC_PTR)(STORE *, 364296465Sdelphij STORE_OBJECT_TYPES type, 365296465Sdelphij OPENSSL_ITEM attributes[], 366296465Sdelphij OPENSSL_ITEM parameters[]); 367296465Sdelphijtypedef void *(*STORE_START_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, 368296465Sdelphij OPENSSL_ITEM attributes[], 369296465Sdelphij OPENSSL_ITEM parameters[]); 370160814Ssimontypedef STORE_OBJECT *(*STORE_NEXT_OBJECT_FUNC_PTR)(STORE *, void *handle); 371296465Sdelphijtypedef int (*STORE_END_OBJECT_FUNC_PTR) (STORE *, void *handle); 372296465Sdelphijtypedef int (*STORE_HANDLE_OBJECT_FUNC_PTR) (STORE *, STORE_OBJECT_TYPES type, 373296465Sdelphij OPENSSL_ITEM attributes[], 374296465Sdelphij OPENSSL_ITEM parameters[]); 375296465Sdelphijtypedef int (*STORE_STORE_OBJECT_FUNC_PTR) (STORE *, STORE_OBJECT_TYPES type, 376296465Sdelphij STORE_OBJECT *data, 377296465Sdelphij OPENSSL_ITEM attributes[], 378296465Sdelphij OPENSSL_ITEM parameters[]); 379296465Sdelphijtypedef int (*STORE_MODIFY_OBJECT_FUNC_PTR) (STORE *, STORE_OBJECT_TYPES type, 380296465Sdelphij OPENSSL_ITEM search_attributes[], 381296465Sdelphij OPENSSL_ITEM add_attributes[], 382296465Sdelphij OPENSSL_ITEM modify_attributes[], 383296465Sdelphij OPENSSL_ITEM delete_attributes[], 384296465Sdelphij OPENSSL_ITEM parameters[]); 385296465Sdelphijtypedef int (*STORE_GENERIC_FUNC_PTR) (STORE *, OPENSSL_ITEM attributes[], 386296465Sdelphij OPENSSL_ITEM parameters[]); 387296465Sdelphijtypedef int (*STORE_CTRL_FUNC_PTR) (STORE *, int cmd, long l, void *p, 388296465Sdelphij void (*f) (void)); 389160814Ssimon 390296465Sdelphijint STORE_method_set_initialise_function(STORE_METHOD *sm, 391296465Sdelphij STORE_INITIALISE_FUNC_PTR init_f); 392296465Sdelphijint STORE_method_set_cleanup_function(STORE_METHOD *sm, 393296465Sdelphij STORE_CLEANUP_FUNC_PTR clean_f); 394296465Sdelphijint STORE_method_set_generate_function(STORE_METHOD *sm, 395296465Sdelphij STORE_GENERATE_OBJECT_FUNC_PTR 396296465Sdelphij generate_f); 397296465Sdelphijint STORE_method_set_get_function(STORE_METHOD *sm, 398296465Sdelphij STORE_GET_OBJECT_FUNC_PTR get_f); 399296465Sdelphijint STORE_method_set_store_function(STORE_METHOD *sm, 400296465Sdelphij STORE_STORE_OBJECT_FUNC_PTR store_f); 401296465Sdelphijint STORE_method_set_modify_function(STORE_METHOD *sm, 402296465Sdelphij STORE_MODIFY_OBJECT_FUNC_PTR store_f); 403296465Sdelphijint STORE_method_set_revoke_function(STORE_METHOD *sm, 404296465Sdelphij STORE_HANDLE_OBJECT_FUNC_PTR revoke_f); 405296465Sdelphijint STORE_method_set_delete_function(STORE_METHOD *sm, 406296465Sdelphij STORE_HANDLE_OBJECT_FUNC_PTR delete_f); 407296465Sdelphijint STORE_method_set_list_start_function(STORE_METHOD *sm, 408296465Sdelphij STORE_START_OBJECT_FUNC_PTR 409296465Sdelphij list_start_f); 410296465Sdelphijint STORE_method_set_list_next_function(STORE_METHOD *sm, 411296465Sdelphij STORE_NEXT_OBJECT_FUNC_PTR 412296465Sdelphij list_next_f); 413296465Sdelphijint STORE_method_set_list_end_function(STORE_METHOD *sm, 414296465Sdelphij STORE_END_OBJECT_FUNC_PTR list_end_f); 415296465Sdelphijint STORE_method_set_update_store_function(STORE_METHOD *sm, 416296465Sdelphij STORE_GENERIC_FUNC_PTR); 417296465Sdelphijint STORE_method_set_lock_store_function(STORE_METHOD *sm, 418296465Sdelphij STORE_GENERIC_FUNC_PTR); 419296465Sdelphijint STORE_method_set_unlock_store_function(STORE_METHOD *sm, 420296465Sdelphij STORE_GENERIC_FUNC_PTR); 421296465Sdelphijint STORE_method_set_ctrl_function(STORE_METHOD *sm, 422296465Sdelphij STORE_CTRL_FUNC_PTR ctrl_f); 423160814Ssimon 424296465SdelphijSTORE_INITIALISE_FUNC_PTR STORE_method_get_initialise_function(STORE_METHOD 425296465Sdelphij *sm); 426160814SsimonSTORE_CLEANUP_FUNC_PTR STORE_method_get_cleanup_function(STORE_METHOD *sm); 427296465SdelphijSTORE_GENERATE_OBJECT_FUNC_PTR STORE_method_get_generate_function(STORE_METHOD 428296465Sdelphij *sm); 429160814SsimonSTORE_GET_OBJECT_FUNC_PTR STORE_method_get_get_function(STORE_METHOD *sm); 430160814SsimonSTORE_STORE_OBJECT_FUNC_PTR STORE_method_get_store_function(STORE_METHOD *sm); 431296465SdelphijSTORE_MODIFY_OBJECT_FUNC_PTR STORE_method_get_modify_function(STORE_METHOD 432296465Sdelphij *sm); 433296465SdelphijSTORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_revoke_function(STORE_METHOD 434296465Sdelphij *sm); 435296465SdelphijSTORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_delete_function(STORE_METHOD 436296465Sdelphij *sm); 437296465SdelphijSTORE_START_OBJECT_FUNC_PTR STORE_method_get_list_start_function(STORE_METHOD 438296465Sdelphij *sm); 439296465SdelphijSTORE_NEXT_OBJECT_FUNC_PTR STORE_method_get_list_next_function(STORE_METHOD 440296465Sdelphij *sm); 441296465SdelphijSTORE_END_OBJECT_FUNC_PTR STORE_method_get_list_end_function(STORE_METHOD 442296465Sdelphij *sm); 443296465SdelphijSTORE_GENERIC_FUNC_PTR STORE_method_get_update_store_function(STORE_METHOD 444296465Sdelphij *sm); 445160814SsimonSTORE_GENERIC_FUNC_PTR STORE_method_get_lock_store_function(STORE_METHOD *sm); 446296465SdelphijSTORE_GENERIC_FUNC_PTR STORE_method_get_unlock_store_function(STORE_METHOD 447296465Sdelphij *sm); 448160814SsimonSTORE_CTRL_FUNC_PTR STORE_method_get_ctrl_function(STORE_METHOD *sm); 449160814Ssimon 450160814Ssimon/* Method helper structures and functions. */ 451160814Ssimon 452296465Sdelphij/* 453296465Sdelphij * This structure is the result of parsing through the information in a list 454296465Sdelphij * of OPENSSL_ITEMs. It stores all the necessary information in a structured 455296465Sdelphij * way. 456296465Sdelphij */ 457160814Ssimontypedef struct STORE_attr_info_st STORE_ATTR_INFO; 458160814Ssimon 459296465Sdelphij/* 460296465Sdelphij * Parse a list of OPENSSL_ITEMs and return a pointer to a STORE_ATTR_INFO. 461296465Sdelphij * Note that we do this in the list form, since the list of OPENSSL_ITEMs can 462296465Sdelphij * come in blocks separated with STORE_ATTR_OR. Note that the value returned 463296465Sdelphij * by STORE_parse_attrs_next() must be freed with STORE_ATTR_INFO_free(). 464296465Sdelphij */ 465160814Ssimonvoid *STORE_parse_attrs_start(OPENSSL_ITEM *attributes); 466160814SsimonSTORE_ATTR_INFO *STORE_parse_attrs_next(void *handle); 467160814Ssimonint STORE_parse_attrs_end(void *handle); 468160814Ssimonint STORE_parse_attrs_endp(void *handle); 469160814Ssimon 470160814Ssimon/* Creator and destructor */ 471160814SsimonSTORE_ATTR_INFO *STORE_ATTR_INFO_new(void); 472160814Ssimonint STORE_ATTR_INFO_free(STORE_ATTR_INFO *attrs); 473160814Ssimon 474160814Ssimon/* Manipulators */ 475296465Sdelphijchar *STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs, 476296465Sdelphij STORE_ATTR_TYPES code); 477160814Ssimonunsigned char *STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs, 478296465Sdelphij STORE_ATTR_TYPES code); 479296465SdelphijX509_NAME *STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs, 480296465Sdelphij STORE_ATTR_TYPES code); 481296465SdelphijBIGNUM *STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs, 482296465Sdelphij STORE_ATTR_TYPES code); 483160814Ssimonint STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, 484296465Sdelphij char *cstr, size_t cstr_size); 485160814Ssimonint STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, 486296465Sdelphij unsigned char *sha1str, size_t sha1str_size); 487160814Ssimonint STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, 488296465Sdelphij X509_NAME *dn); 489160814Ssimonint STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, 490296465Sdelphij BIGNUM *number); 491160814Ssimonint STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, 492296465Sdelphij char *cstr, size_t cstr_size); 493296465Sdelphijint STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs, 494296465Sdelphij STORE_ATTR_TYPES code, 495296465Sdelphij unsigned char *sha1str, 496296465Sdelphij size_t sha1str_size); 497160814Ssimonint STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, 498296465Sdelphij X509_NAME *dn); 499296465Sdelphijint STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs, 500296465Sdelphij STORE_ATTR_TYPES code, BIGNUM *number); 501160814Ssimon 502296465Sdelphij/* 503296465Sdelphij * Compare on basis of a bit pattern formed by the STORE_ATTR_TYPES values in 504296465Sdelphij * each contained attribute. 505296465Sdelphij */ 506160814Ssimonint STORE_ATTR_INFO_compare(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); 507296465Sdelphij/* 508296465Sdelphij * Check if the set of attributes in a is within the range of attributes set 509296465Sdelphij * in b. 510296465Sdelphij */ 511160814Ssimonint STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); 512160814Ssimon/* Check if the set of attributes in a are also set in b. */ 513160814Ssimonint STORE_ATTR_INFO_in(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); 514160814Ssimon/* Same as STORE_ATTR_INFO_in(), but also checks the attribute values. */ 515160814Ssimonint STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); 516160814Ssimon 517160814Ssimon/* BEGIN ERROR CODES */ 518296465Sdelphij/* 519296465Sdelphij * The following lines are auto generated by the script mkerr.pl. Any changes 520160814Ssimon * made after this point may be overwritten when the script is next run. 521160814Ssimon */ 522160814Ssimonvoid ERR_load_STORE_strings(void); 523160814Ssimon 524160814Ssimon/* Error codes for the STORE functions. */ 525160814Ssimon 526160814Ssimon/* Function codes. */ 527296465Sdelphij# define STORE_F_MEM_DELETE 134 528296465Sdelphij# define STORE_F_MEM_GENERATE 135 529296465Sdelphij# define STORE_F_MEM_LIST_END 168 530296465Sdelphij# define STORE_F_MEM_LIST_NEXT 136 531296465Sdelphij# define STORE_F_MEM_LIST_START 137 532296465Sdelphij# define STORE_F_MEM_MODIFY 169 533296465Sdelphij# define STORE_F_MEM_STORE 138 534296465Sdelphij# define STORE_F_STORE_ATTR_INFO_GET0_CSTR 139 535296465Sdelphij# define STORE_F_STORE_ATTR_INFO_GET0_DN 140 536296465Sdelphij# define STORE_F_STORE_ATTR_INFO_GET0_NUMBER 141 537296465Sdelphij# define STORE_F_STORE_ATTR_INFO_GET0_SHA1STR 142 538296465Sdelphij# define STORE_F_STORE_ATTR_INFO_MODIFY_CSTR 143 539296465Sdelphij# define STORE_F_STORE_ATTR_INFO_MODIFY_DN 144 540296465Sdelphij# define STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER 145 541296465Sdelphij# define STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR 146 542296465Sdelphij# define STORE_F_STORE_ATTR_INFO_SET_CSTR 147 543296465Sdelphij# define STORE_F_STORE_ATTR_INFO_SET_DN 148 544296465Sdelphij# define STORE_F_STORE_ATTR_INFO_SET_NUMBER 149 545296465Sdelphij# define STORE_F_STORE_ATTR_INFO_SET_SHA1STR 150 546296465Sdelphij# define STORE_F_STORE_CERTIFICATE 170 547296465Sdelphij# define STORE_F_STORE_CTRL 161 548296465Sdelphij# define STORE_F_STORE_DELETE_ARBITRARY 158 549296465Sdelphij# define STORE_F_STORE_DELETE_CERTIFICATE 102 550296465Sdelphij# define STORE_F_STORE_DELETE_CRL 103 551296465Sdelphij# define STORE_F_STORE_DELETE_NUMBER 104 552296465Sdelphij# define STORE_F_STORE_DELETE_PRIVATE_KEY 105 553296465Sdelphij# define STORE_F_STORE_DELETE_PUBLIC_KEY 106 554296465Sdelphij# define STORE_F_STORE_GENERATE_CRL 107 555296465Sdelphij# define STORE_F_STORE_GENERATE_KEY 108 556296465Sdelphij# define STORE_F_STORE_GET_ARBITRARY 159 557296465Sdelphij# define STORE_F_STORE_GET_CERTIFICATE 109 558296465Sdelphij# define STORE_F_STORE_GET_CRL 110 559296465Sdelphij# define STORE_F_STORE_GET_NUMBER 111 560296465Sdelphij# define STORE_F_STORE_GET_PRIVATE_KEY 112 561296465Sdelphij# define STORE_F_STORE_GET_PUBLIC_KEY 113 562296465Sdelphij# define STORE_F_STORE_LIST_CERTIFICATE_END 114 563296465Sdelphij# define STORE_F_STORE_LIST_CERTIFICATE_ENDP 153 564296465Sdelphij# define STORE_F_STORE_LIST_CERTIFICATE_NEXT 115 565296465Sdelphij# define STORE_F_STORE_LIST_CERTIFICATE_START 116 566296465Sdelphij# define STORE_F_STORE_LIST_CRL_END 117 567296465Sdelphij# define STORE_F_STORE_LIST_CRL_ENDP 154 568296465Sdelphij# define STORE_F_STORE_LIST_CRL_NEXT 118 569296465Sdelphij# define STORE_F_STORE_LIST_CRL_START 119 570296465Sdelphij# define STORE_F_STORE_LIST_PRIVATE_KEY_END 120 571296465Sdelphij# define STORE_F_STORE_LIST_PRIVATE_KEY_ENDP 155 572296465Sdelphij# define STORE_F_STORE_LIST_PRIVATE_KEY_NEXT 121 573296465Sdelphij# define STORE_F_STORE_LIST_PRIVATE_KEY_START 122 574296465Sdelphij# define STORE_F_STORE_LIST_PUBLIC_KEY_END 123 575296465Sdelphij# define STORE_F_STORE_LIST_PUBLIC_KEY_ENDP 156 576296465Sdelphij# define STORE_F_STORE_LIST_PUBLIC_KEY_NEXT 124 577296465Sdelphij# define STORE_F_STORE_LIST_PUBLIC_KEY_START 125 578296465Sdelphij# define STORE_F_STORE_MODIFY_ARBITRARY 162 579296465Sdelphij# define STORE_F_STORE_MODIFY_CERTIFICATE 163 580296465Sdelphij# define STORE_F_STORE_MODIFY_CRL 164 581296465Sdelphij# define STORE_F_STORE_MODIFY_NUMBER 165 582296465Sdelphij# define STORE_F_STORE_MODIFY_PRIVATE_KEY 166 583296465Sdelphij# define STORE_F_STORE_MODIFY_PUBLIC_KEY 167 584296465Sdelphij# define STORE_F_STORE_NEW_ENGINE 133 585296465Sdelphij# define STORE_F_STORE_NEW_METHOD 132 586296465Sdelphij# define STORE_F_STORE_PARSE_ATTRS_END 151 587296465Sdelphij# define STORE_F_STORE_PARSE_ATTRS_ENDP 172 588296465Sdelphij# define STORE_F_STORE_PARSE_ATTRS_NEXT 152 589296465Sdelphij# define STORE_F_STORE_PARSE_ATTRS_START 171 590296465Sdelphij# define STORE_F_STORE_REVOKE_CERTIFICATE 129 591296465Sdelphij# define STORE_F_STORE_REVOKE_PRIVATE_KEY 130 592296465Sdelphij# define STORE_F_STORE_REVOKE_PUBLIC_KEY 131 593296465Sdelphij# define STORE_F_STORE_STORE_ARBITRARY 157 594296465Sdelphij# define STORE_F_STORE_STORE_CERTIFICATE 100 595296465Sdelphij# define STORE_F_STORE_STORE_CRL 101 596296465Sdelphij# define STORE_F_STORE_STORE_NUMBER 126 597296465Sdelphij# define STORE_F_STORE_STORE_PRIVATE_KEY 127 598296465Sdelphij# define STORE_F_STORE_STORE_PUBLIC_KEY 128 599160814Ssimon 600160814Ssimon/* Reason codes. */ 601296465Sdelphij# define STORE_R_ALREADY_HAS_A_VALUE 127 602296465Sdelphij# define STORE_R_FAILED_DELETING_ARBITRARY 132 603296465Sdelphij# define STORE_R_FAILED_DELETING_CERTIFICATE 100 604296465Sdelphij# define STORE_R_FAILED_DELETING_KEY 101 605296465Sdelphij# define STORE_R_FAILED_DELETING_NUMBER 102 606296465Sdelphij# define STORE_R_FAILED_GENERATING_CRL 103 607296465Sdelphij# define STORE_R_FAILED_GENERATING_KEY 104 608296465Sdelphij# define STORE_R_FAILED_GETTING_ARBITRARY 133 609296465Sdelphij# define STORE_R_FAILED_GETTING_CERTIFICATE 105 610296465Sdelphij# define STORE_R_FAILED_GETTING_KEY 106 611296465Sdelphij# define STORE_R_FAILED_GETTING_NUMBER 107 612296465Sdelphij# define STORE_R_FAILED_LISTING_CERTIFICATES 108 613296465Sdelphij# define STORE_R_FAILED_LISTING_KEYS 109 614296465Sdelphij# define STORE_R_FAILED_MODIFYING_ARBITRARY 138 615296465Sdelphij# define STORE_R_FAILED_MODIFYING_CERTIFICATE 139 616296465Sdelphij# define STORE_R_FAILED_MODIFYING_CRL 140 617296465Sdelphij# define STORE_R_FAILED_MODIFYING_NUMBER 141 618296465Sdelphij# define STORE_R_FAILED_MODIFYING_PRIVATE_KEY 142 619296465Sdelphij# define STORE_R_FAILED_MODIFYING_PUBLIC_KEY 143 620296465Sdelphij# define STORE_R_FAILED_REVOKING_CERTIFICATE 110 621296465Sdelphij# define STORE_R_FAILED_REVOKING_KEY 111 622296465Sdelphij# define STORE_R_FAILED_STORING_ARBITRARY 134 623296465Sdelphij# define STORE_R_FAILED_STORING_CERTIFICATE 112 624296465Sdelphij# define STORE_R_FAILED_STORING_KEY 113 625296465Sdelphij# define STORE_R_FAILED_STORING_NUMBER 114 626296465Sdelphij# define STORE_R_NOT_IMPLEMENTED 128 627296465Sdelphij# define STORE_R_NO_CONTROL_FUNCTION 144 628296465Sdelphij# define STORE_R_NO_DELETE_ARBITRARY_FUNCTION 135 629296465Sdelphij# define STORE_R_NO_DELETE_NUMBER_FUNCTION 115 630296465Sdelphij# define STORE_R_NO_DELETE_OBJECT_FUNCTION 116 631296465Sdelphij# define STORE_R_NO_GENERATE_CRL_FUNCTION 117 632296465Sdelphij# define STORE_R_NO_GENERATE_OBJECT_FUNCTION 118 633296465Sdelphij# define STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION 136 634296465Sdelphij# define STORE_R_NO_GET_OBJECT_FUNCTION 119 635296465Sdelphij# define STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION 120 636296465Sdelphij# define STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION 131 637296465Sdelphij# define STORE_R_NO_LIST_OBJECT_END_FUNCTION 121 638296465Sdelphij# define STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION 122 639296465Sdelphij# define STORE_R_NO_LIST_OBJECT_START_FUNCTION 123 640296465Sdelphij# define STORE_R_NO_MODIFY_OBJECT_FUNCTION 145 641296465Sdelphij# define STORE_R_NO_REVOKE_OBJECT_FUNCTION 124 642296465Sdelphij# define STORE_R_NO_STORE 129 643296465Sdelphij# define STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION 137 644296465Sdelphij# define STORE_R_NO_STORE_OBJECT_FUNCTION 125 645296465Sdelphij# define STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION 126 646296465Sdelphij# define STORE_R_NO_VALUE 130 647160814Ssimon 648160814Ssimon#ifdef __cplusplus 649160814Ssimon} 650160814Ssimon#endif 651160814Ssimon#endif 652