1295009Sjkim/* crypto/store/store.h */ 2280297Sjkim/* 3280297Sjkim * Written by Richard Levitte (richard@levitte.org) for the OpenSSL project 4280297Sjkim * 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 14280297Sjkim * 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 61280297Sjkim# define HEADER_STORE_H 62160814Ssimon 63280297Sjkim# include <openssl/opensslconf.h> 64238405Sjkim 65280297Sjkim# ifdef OPENSSL_NO_STORE 66280297Sjkim# error STORE is disabled. 67280297Sjkim# endif 68238405Sjkim 69280297Sjkim# include <openssl/ossl_typ.h> 70280297Sjkim# ifndef OPENSSL_NO_DEPRECATED 71280297Sjkim# include <openssl/evp.h> 72280297Sjkim# include <openssl/bn.h> 73280297Sjkim# include <openssl/x509.h> 74280297Sjkim# endif 75160814Ssimon 76160814Ssimon#ifdef __cplusplus 77160814Ssimonextern "C" { 78160814Ssimon#endif 79160814Ssimon 80160814Ssimon/* Already defined in ossl_typ.h */ 81160814Ssimon/* typedef struct store_st STORE; */ 82160814Ssimon/* typedef struct store_method_st STORE_METHOD; */ 83160814Ssimon 84280297Sjkim/* 85280297Sjkim * All the following functions return 0, a negative number or NULL on error. 86280297Sjkim * When everything is fine, they return a positive value or a non-NULL 87280297Sjkim * pointer, all depending on their purpose. 88280297Sjkim */ 89160814Ssimon 90160814Ssimon/* Creators and destructor. */ 91160814SsimonSTORE *STORE_new_method(const STORE_METHOD *method); 92160814SsimonSTORE *STORE_new_engine(ENGINE *engine); 93160814Ssimonvoid STORE_free(STORE *ui); 94160814Ssimon 95280297Sjkim/* 96280297Sjkim * Give a user interface parametrised control commands. This can be used to 97280297Sjkim * send down an integer, a data pointer or a function pointer, as well as be 98280297Sjkim * used to get information from a STORE. 99280297Sjkim */ 100280297Sjkimint STORE_ctrl(STORE *store, int cmd, long i, void *p, void (*f) (void)); 101160814Ssimon 102280297Sjkim/* 103280297Sjkim * A control to set the directory with keys and certificates. Used by the 104280297Sjkim * built-in directory level method. 105280297Sjkim */ 106280297Sjkim# define STORE_CTRL_SET_DIRECTORY 0x0001 107280297Sjkim/* 108280297Sjkim * A control to set a file to load. Used by the built-in file level method. 109280297Sjkim */ 110280297Sjkim# define STORE_CTRL_SET_FILE 0x0002 111280297Sjkim/* 112280297Sjkim * A control to set a configuration file to load. Can be used by any method 113280297Sjkim * that wishes to load a configuration file. 114280297Sjkim */ 115280297Sjkim# define STORE_CTRL_SET_CONF_FILE 0x0003 116280297Sjkim/* 117280297Sjkim * A control to set a the section of the loaded configuration file. Can be 118280297Sjkim * used by any method that wishes to load a configuration file. 119280297Sjkim */ 120280297Sjkim# define STORE_CTRL_SET_CONF_SECTION 0x0004 121160814Ssimon 122160814Ssimon/* Some methods may use extra data */ 123280297Sjkim# define STORE_set_app_data(s,arg) STORE_set_ex_data(s,0,arg) 124280297Sjkim# define STORE_get_app_data(s) STORE_get_ex_data(s,0) 125160814Ssimonint STORE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, 126280297Sjkim CRYPTO_EX_dup *dup_func, 127280297Sjkim CRYPTO_EX_free *free_func); 128280297Sjkimint STORE_set_ex_data(STORE *r, int idx, void *arg); 129160814Ssimonvoid *STORE_get_ex_data(STORE *r, int idx); 130160814Ssimon 131160814Ssimon/* Use specific methods instead of the built-in one */ 132160814Ssimonconst STORE_METHOD *STORE_get_method(STORE *store); 133160814Ssimonconst STORE_METHOD *STORE_set_method(STORE *store, const STORE_METHOD *meth); 134160814Ssimon 135160814Ssimon/* The standard OpenSSL methods. */ 136280297Sjkim/* 137280297Sjkim * This is the in-memory method. It does everything except revoking and 138280297Sjkim * updating, and is of course volatile. It's used by other methods that have 139280297Sjkim * an in-memory cache. 140280297Sjkim */ 141160814Ssimonconst STORE_METHOD *STORE_Memory(void); 142280297Sjkim# if 0 /* Not yet implemented */ 143280297Sjkim/* 144280297Sjkim * This is the directory store. It does everything except revoking and 145280297Sjkim * updating, and uses STORE_Memory() to cache things in memory. 146280297Sjkim */ 147160814Ssimonconst STORE_METHOD *STORE_Directory(void); 148280297Sjkim/* 149280297Sjkim * This is the file store. It does everything except revoking and updating, 150280297Sjkim * and uses STORE_Memory() to cache things in memory. Certificates are added 151280297Sjkim * to it with the store operation, and it will only get cached certificates. 152280297Sjkim */ 153160814Ssimonconst STORE_METHOD *STORE_File(void); 154280297Sjkim# endif 155160814Ssimon 156280297Sjkim/* 157280297Sjkim * Store functions take a type code for the type of data they should store or 158280297Sjkim * fetch 159280297Sjkim */ 160280297Sjkimtypedef enum STORE_object_types { 161280297Sjkim STORE_OBJECT_TYPE_X509_CERTIFICATE = 0x01, /* X509 * */ 162280297Sjkim STORE_OBJECT_TYPE_X509_CRL = 0x02, /* X509_CRL * */ 163280297Sjkim STORE_OBJECT_TYPE_PRIVATE_KEY = 0x03, /* EVP_PKEY * */ 164280297Sjkim STORE_OBJECT_TYPE_PUBLIC_KEY = 0x04, /* EVP_PKEY * */ 165280297Sjkim STORE_OBJECT_TYPE_NUMBER = 0x05, /* BIGNUM * */ 166280297Sjkim STORE_OBJECT_TYPE_ARBITRARY = 0x06, /* BUF_MEM * */ 167280297Sjkim STORE_OBJECT_TYPE_NUM = 0x06 /* The amount of known object types */ 168280297Sjkim} STORE_OBJECT_TYPES; 169160814Ssimon/* List of text strings corresponding to the object types. */ 170280297Sjkimextern const char *const STORE_object_type_string[STORE_OBJECT_TYPE_NUM + 1]; 171160814Ssimon 172280297Sjkim/* 173280297Sjkim * Some store functions take a parameter list. Those parameters come with 174280297Sjkim * one of the following codes. The comments following the codes below 175280297Sjkim * indicate what type the value should be a pointer to. 176280297Sjkim */ 177280297Sjkimtypedef enum STORE_params { 178280297Sjkim STORE_PARAM_EVP_TYPE = 0x01, /* int */ 179280297Sjkim STORE_PARAM_BITS = 0x02, /* size_t */ 180280297Sjkim STORE_PARAM_KEY_PARAMETERS = 0x03, /* ??? */ 181280297Sjkim STORE_PARAM_KEY_NO_PARAMETERS = 0x04, /* N/A */ 182280297Sjkim STORE_PARAM_AUTH_PASSPHRASE = 0x05, /* char * */ 183280297Sjkim STORE_PARAM_AUTH_KRB5_TICKET = 0x06, /* void * */ 184280297Sjkim STORE_PARAM_TYPE_NUM = 0x06 /* The amount of known parameter types */ 185280297Sjkim} STORE_PARAM_TYPES; 186280297Sjkim/* 187280297Sjkim * Parameter value sizes. -1 means unknown, anything else is the required 188280297Sjkim * size. 189280297Sjkim */ 190280297Sjkimextern const int STORE_param_sizes[STORE_PARAM_TYPE_NUM + 1]; 191160814Ssimon 192280297Sjkim/* 193280297Sjkim * Store functions take attribute lists. Those attributes come with codes. 194280297Sjkim * The comments following the codes below indicate what type the value should 195280297Sjkim * be a pointer to. 196280297Sjkim */ 197280297Sjkimtypedef enum STORE_attribs { 198280297Sjkim STORE_ATTR_END = 0x00, 199280297Sjkim STORE_ATTR_FRIENDLYNAME = 0x01, /* C string */ 200280297Sjkim STORE_ATTR_KEYID = 0x02, /* 160 bit string (SHA1) */ 201280297Sjkim STORE_ATTR_ISSUERKEYID = 0x03, /* 160 bit string (SHA1) */ 202280297Sjkim STORE_ATTR_SUBJECTKEYID = 0x04, /* 160 bit string (SHA1) */ 203280297Sjkim STORE_ATTR_ISSUERSERIALHASH = 0x05, /* 160 bit string (SHA1) */ 204280297Sjkim STORE_ATTR_ISSUER = 0x06, /* X509_NAME * */ 205280297Sjkim STORE_ATTR_SERIAL = 0x07, /* BIGNUM * */ 206280297Sjkim STORE_ATTR_SUBJECT = 0x08, /* X509_NAME * */ 207280297Sjkim STORE_ATTR_CERTHASH = 0x09, /* 160 bit string (SHA1) */ 208280297Sjkim STORE_ATTR_EMAIL = 0x0a, /* C string */ 209280297Sjkim STORE_ATTR_FILENAME = 0x0b, /* C string */ 210280297Sjkim STORE_ATTR_TYPE_NUM = 0x0b, /* The amount of known attribute types */ 211280297Sjkim STORE_ATTR_OR = 0xff /* This is a special separator, which 212280297Sjkim * expresses the OR operation. */ 213280297Sjkim} STORE_ATTR_TYPES; 214280297Sjkim/* 215280297Sjkim * Attribute value sizes. -1 means unknown, anything else is the required 216280297Sjkim * size. 217280297Sjkim */ 218280297Sjkimextern const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM + 1]; 219160814Ssimon 220280297Sjkimtypedef enum STORE_certificate_status { 221280297Sjkim STORE_X509_VALID = 0x00, 222280297Sjkim STORE_X509_EXPIRED = 0x01, 223280297Sjkim STORE_X509_SUSPENDED = 0x02, 224280297Sjkim STORE_X509_REVOKED = 0x03 225280297Sjkim} STORE_CERTIFICATE_STATUS; 226160814Ssimon 227280297Sjkim/* 228280297Sjkim * Engine store functions will return a structure that contains all the 229280297Sjkim * necessary information, including revokation status for certificates. This 230280297Sjkim * is really not needed for application authors, as the ENGINE framework 231280297Sjkim * functions will extract the OpenSSL-specific information when at all 232280297Sjkim * possible. However, for engine authors, it's crucial to know this 233280297Sjkim * structure. 234280297Sjkim */ 235280297Sjkimtypedef struct STORE_OBJECT_st { 236280297Sjkim STORE_OBJECT_TYPES type; 237280297Sjkim union { 238280297Sjkim struct { 239280297Sjkim STORE_CERTIFICATE_STATUS status; 240280297Sjkim X509 *certificate; 241280297Sjkim } x509; 242280297Sjkim X509_CRL *crl; 243280297Sjkim EVP_PKEY *key; 244280297Sjkim BIGNUM *number; 245280297Sjkim BUF_MEM *arbitrary; 246280297Sjkim } data; 247280297Sjkim} STORE_OBJECT; 248160814SsimonDECLARE_STACK_OF(STORE_OBJECT) 249160814SsimonSTORE_OBJECT *STORE_OBJECT_new(void); 250160814Ssimonvoid STORE_OBJECT_free(STORE_OBJECT *data); 251160814Ssimon 252280297Sjkim/* 253280297Sjkim * The following functions handle the storage. They return 0, a negative 254280297Sjkim * number or NULL on error, anything else on success. 255280297Sjkim */ 256160814SsimonX509 *STORE_get_certificate(STORE *e, OPENSSL_ITEM attributes[], 257280297Sjkim OPENSSL_ITEM parameters[]); 258160814Ssimonint STORE_store_certificate(STORE *e, X509 *data, OPENSSL_ITEM attributes[], 259280297Sjkim OPENSSL_ITEM parameters[]); 260160814Ssimonint STORE_modify_certificate(STORE *e, OPENSSL_ITEM search_attributes[], 261280297Sjkim OPENSSL_ITEM add_attributes[], 262280297Sjkim OPENSSL_ITEM modify_attributes[], 263280297Sjkim OPENSSL_ITEM delete_attributes[], 264280297Sjkim OPENSSL_ITEM parameters[]); 265160814Ssimonint STORE_revoke_certificate(STORE *e, OPENSSL_ITEM attributes[], 266280297Sjkim OPENSSL_ITEM parameters[]); 267160814Ssimonint STORE_delete_certificate(STORE *e, OPENSSL_ITEM attributes[], 268280297Sjkim OPENSSL_ITEM parameters[]); 269160814Ssimonvoid *STORE_list_certificate_start(STORE *e, OPENSSL_ITEM attributes[], 270280297Sjkim OPENSSL_ITEM parameters[]); 271160814SsimonX509 *STORE_list_certificate_next(STORE *e, void *handle); 272160814Ssimonint STORE_list_certificate_end(STORE *e, void *handle); 273160814Ssimonint STORE_list_certificate_endp(STORE *e, void *handle); 274160814SsimonEVP_PKEY *STORE_generate_key(STORE *e, OPENSSL_ITEM attributes[], 275280297Sjkim OPENSSL_ITEM parameters[]); 276160814SsimonEVP_PKEY *STORE_get_private_key(STORE *e, OPENSSL_ITEM attributes[], 277280297Sjkim OPENSSL_ITEM parameters[]); 278160814Ssimonint STORE_store_private_key(STORE *e, EVP_PKEY *data, 279280297Sjkim OPENSSL_ITEM attributes[], 280280297Sjkim OPENSSL_ITEM parameters[]); 281160814Ssimonint STORE_modify_private_key(STORE *e, OPENSSL_ITEM search_attributes[], 282280297Sjkim OPENSSL_ITEM add_sttributes[], 283280297Sjkim OPENSSL_ITEM modify_attributes[], 284280297Sjkim OPENSSL_ITEM delete_attributes[], 285280297Sjkim OPENSSL_ITEM parameters[]); 286160814Ssimonint STORE_revoke_private_key(STORE *e, OPENSSL_ITEM attributes[], 287280297Sjkim OPENSSL_ITEM parameters[]); 288160814Ssimonint STORE_delete_private_key(STORE *e, OPENSSL_ITEM attributes[], 289280297Sjkim OPENSSL_ITEM parameters[]); 290160814Ssimonvoid *STORE_list_private_key_start(STORE *e, OPENSSL_ITEM attributes[], 291280297Sjkim OPENSSL_ITEM parameters[]); 292160814SsimonEVP_PKEY *STORE_list_private_key_next(STORE *e, void *handle); 293160814Ssimonint STORE_list_private_key_end(STORE *e, void *handle); 294160814Ssimonint STORE_list_private_key_endp(STORE *e, void *handle); 295160814SsimonEVP_PKEY *STORE_get_public_key(STORE *e, OPENSSL_ITEM attributes[], 296280297Sjkim OPENSSL_ITEM parameters[]); 297280297Sjkimint STORE_store_public_key(STORE *e, EVP_PKEY *data, 298280297Sjkim OPENSSL_ITEM attributes[], 299280297Sjkim OPENSSL_ITEM parameters[]); 300160814Ssimonint STORE_modify_public_key(STORE *e, OPENSSL_ITEM search_attributes[], 301280297Sjkim OPENSSL_ITEM add_sttributes[], 302280297Sjkim OPENSSL_ITEM modify_attributes[], 303280297Sjkim OPENSSL_ITEM delete_attributes[], 304280297Sjkim OPENSSL_ITEM parameters[]); 305160814Ssimonint STORE_revoke_public_key(STORE *e, OPENSSL_ITEM attributes[], 306280297Sjkim OPENSSL_ITEM parameters[]); 307160814Ssimonint STORE_delete_public_key(STORE *e, OPENSSL_ITEM attributes[], 308280297Sjkim OPENSSL_ITEM parameters[]); 309160814Ssimonvoid *STORE_list_public_key_start(STORE *e, OPENSSL_ITEM attributes[], 310280297Sjkim OPENSSL_ITEM parameters[]); 311160814SsimonEVP_PKEY *STORE_list_public_key_next(STORE *e, void *handle); 312160814Ssimonint STORE_list_public_key_end(STORE *e, void *handle); 313160814Ssimonint STORE_list_public_key_endp(STORE *e, void *handle); 314160814SsimonX509_CRL *STORE_generate_crl(STORE *e, OPENSSL_ITEM attributes[], 315280297Sjkim OPENSSL_ITEM parameters[]); 316160814SsimonX509_CRL *STORE_get_crl(STORE *e, OPENSSL_ITEM attributes[], 317280297Sjkim OPENSSL_ITEM parameters[]); 318160814Ssimonint STORE_store_crl(STORE *e, X509_CRL *data, OPENSSL_ITEM attributes[], 319280297Sjkim OPENSSL_ITEM parameters[]); 320160814Ssimonint STORE_modify_crl(STORE *e, OPENSSL_ITEM search_attributes[], 321280297Sjkim OPENSSL_ITEM add_sttributes[], 322280297Sjkim OPENSSL_ITEM modify_attributes[], 323280297Sjkim OPENSSL_ITEM delete_attributes[], 324280297Sjkim OPENSSL_ITEM parameters[]); 325160814Ssimonint STORE_delete_crl(STORE *e, OPENSSL_ITEM attributes[], 326280297Sjkim OPENSSL_ITEM parameters[]); 327160814Ssimonvoid *STORE_list_crl_start(STORE *e, OPENSSL_ITEM attributes[], 328280297Sjkim OPENSSL_ITEM parameters[]); 329160814SsimonX509_CRL *STORE_list_crl_next(STORE *e, void *handle); 330160814Ssimonint STORE_list_crl_end(STORE *e, void *handle); 331160814Ssimonint STORE_list_crl_endp(STORE *e, void *handle); 332160814Ssimonint STORE_store_number(STORE *e, BIGNUM *data, OPENSSL_ITEM attributes[], 333280297Sjkim OPENSSL_ITEM parameters[]); 334160814Ssimonint STORE_modify_number(STORE *e, OPENSSL_ITEM search_attributes[], 335280297Sjkim OPENSSL_ITEM add_sttributes[], 336280297Sjkim OPENSSL_ITEM modify_attributes[], 337280297Sjkim OPENSSL_ITEM delete_attributes[], 338280297Sjkim OPENSSL_ITEM parameters[]); 339160814SsimonBIGNUM *STORE_get_number(STORE *e, OPENSSL_ITEM attributes[], 340280297Sjkim OPENSSL_ITEM parameters[]); 341160814Ssimonint STORE_delete_number(STORE *e, OPENSSL_ITEM attributes[], 342280297Sjkim OPENSSL_ITEM parameters[]); 343160814Ssimonint STORE_store_arbitrary(STORE *e, BUF_MEM *data, OPENSSL_ITEM attributes[], 344280297Sjkim OPENSSL_ITEM parameters[]); 345160814Ssimonint STORE_modify_arbitrary(STORE *e, OPENSSL_ITEM search_attributes[], 346280297Sjkim OPENSSL_ITEM add_sttributes[], 347280297Sjkim OPENSSL_ITEM modify_attributes[], 348280297Sjkim OPENSSL_ITEM delete_attributes[], 349280297Sjkim OPENSSL_ITEM parameters[]); 350160814SsimonBUF_MEM *STORE_get_arbitrary(STORE *e, OPENSSL_ITEM attributes[], 351280297Sjkim OPENSSL_ITEM parameters[]); 352160814Ssimonint STORE_delete_arbitrary(STORE *e, OPENSSL_ITEM attributes[], 353280297Sjkim OPENSSL_ITEM parameters[]); 354160814Ssimon 355160814Ssimon/* Create and manipulate methods */ 356160814SsimonSTORE_METHOD *STORE_create_method(char *name); 357160814Ssimonvoid STORE_destroy_method(STORE_METHOD *store_method); 358160814Ssimon 359160814Ssimon/* These callback types are use for store handlers */ 360280297Sjkimtypedef int (*STORE_INITIALISE_FUNC_PTR) (STORE *); 361280297Sjkimtypedef void (*STORE_CLEANUP_FUNC_PTR) (STORE *); 362280297Sjkimtypedef STORE_OBJECT *(*STORE_GENERATE_OBJECT_FUNC_PTR)(STORE *, 363280297Sjkim STORE_OBJECT_TYPES 364280297Sjkim type, 365280297Sjkim OPENSSL_ITEM 366280297Sjkim attributes[], 367280297Sjkim OPENSSL_ITEM 368280297Sjkim parameters[]); 369280297Sjkimtypedef STORE_OBJECT *(*STORE_GET_OBJECT_FUNC_PTR)(STORE *, 370280297Sjkim STORE_OBJECT_TYPES type, 371280297Sjkim OPENSSL_ITEM attributes[], 372280297Sjkim OPENSSL_ITEM parameters[]); 373280297Sjkimtypedef void *(*STORE_START_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, 374280297Sjkim OPENSSL_ITEM attributes[], 375280297Sjkim OPENSSL_ITEM parameters[]); 376160814Ssimontypedef STORE_OBJECT *(*STORE_NEXT_OBJECT_FUNC_PTR)(STORE *, void *handle); 377280297Sjkimtypedef int (*STORE_END_OBJECT_FUNC_PTR) (STORE *, void *handle); 378280297Sjkimtypedef int (*STORE_HANDLE_OBJECT_FUNC_PTR) (STORE *, STORE_OBJECT_TYPES type, 379280297Sjkim OPENSSL_ITEM attributes[], 380280297Sjkim OPENSSL_ITEM parameters[]); 381280297Sjkimtypedef int (*STORE_STORE_OBJECT_FUNC_PTR) (STORE *, STORE_OBJECT_TYPES type, 382280297Sjkim STORE_OBJECT *data, 383280297Sjkim OPENSSL_ITEM attributes[], 384280297Sjkim OPENSSL_ITEM parameters[]); 385280297Sjkimtypedef int (*STORE_MODIFY_OBJECT_FUNC_PTR) (STORE *, STORE_OBJECT_TYPES type, 386280297Sjkim OPENSSL_ITEM search_attributes[], 387280297Sjkim OPENSSL_ITEM add_attributes[], 388280297Sjkim OPENSSL_ITEM modify_attributes[], 389280297Sjkim OPENSSL_ITEM delete_attributes[], 390280297Sjkim OPENSSL_ITEM parameters[]); 391280297Sjkimtypedef int (*STORE_GENERIC_FUNC_PTR) (STORE *, OPENSSL_ITEM attributes[], 392280297Sjkim OPENSSL_ITEM parameters[]); 393280297Sjkimtypedef int (*STORE_CTRL_FUNC_PTR) (STORE *, int cmd, long l, void *p, 394280297Sjkim void (*f) (void)); 395160814Ssimon 396280297Sjkimint STORE_method_set_initialise_function(STORE_METHOD *sm, 397280297Sjkim STORE_INITIALISE_FUNC_PTR init_f); 398280297Sjkimint STORE_method_set_cleanup_function(STORE_METHOD *sm, 399280297Sjkim STORE_CLEANUP_FUNC_PTR clean_f); 400280297Sjkimint STORE_method_set_generate_function(STORE_METHOD *sm, 401280297Sjkim STORE_GENERATE_OBJECT_FUNC_PTR 402280297Sjkim generate_f); 403280297Sjkimint STORE_method_set_get_function(STORE_METHOD *sm, 404280297Sjkim STORE_GET_OBJECT_FUNC_PTR get_f); 405280297Sjkimint STORE_method_set_store_function(STORE_METHOD *sm, 406280297Sjkim STORE_STORE_OBJECT_FUNC_PTR store_f); 407280297Sjkimint STORE_method_set_modify_function(STORE_METHOD *sm, 408280297Sjkim STORE_MODIFY_OBJECT_FUNC_PTR store_f); 409280297Sjkimint STORE_method_set_revoke_function(STORE_METHOD *sm, 410280297Sjkim STORE_HANDLE_OBJECT_FUNC_PTR revoke_f); 411280297Sjkimint STORE_method_set_delete_function(STORE_METHOD *sm, 412280297Sjkim STORE_HANDLE_OBJECT_FUNC_PTR delete_f); 413280297Sjkimint STORE_method_set_list_start_function(STORE_METHOD *sm, 414280297Sjkim STORE_START_OBJECT_FUNC_PTR 415280297Sjkim list_start_f); 416280297Sjkimint STORE_method_set_list_next_function(STORE_METHOD *sm, 417280297Sjkim STORE_NEXT_OBJECT_FUNC_PTR 418280297Sjkim list_next_f); 419280297Sjkimint STORE_method_set_list_end_function(STORE_METHOD *sm, 420280297Sjkim STORE_END_OBJECT_FUNC_PTR list_end_f); 421280297Sjkimint STORE_method_set_update_store_function(STORE_METHOD *sm, 422280297Sjkim STORE_GENERIC_FUNC_PTR); 423280297Sjkimint STORE_method_set_lock_store_function(STORE_METHOD *sm, 424280297Sjkim STORE_GENERIC_FUNC_PTR); 425280297Sjkimint STORE_method_set_unlock_store_function(STORE_METHOD *sm, 426280297Sjkim STORE_GENERIC_FUNC_PTR); 427280297Sjkimint STORE_method_set_ctrl_function(STORE_METHOD *sm, 428280297Sjkim STORE_CTRL_FUNC_PTR ctrl_f); 429160814Ssimon 430280297SjkimSTORE_INITIALISE_FUNC_PTR STORE_method_get_initialise_function(STORE_METHOD 431280297Sjkim *sm); 432160814SsimonSTORE_CLEANUP_FUNC_PTR STORE_method_get_cleanup_function(STORE_METHOD *sm); 433280297SjkimSTORE_GENERATE_OBJECT_FUNC_PTR STORE_method_get_generate_function(STORE_METHOD 434280297Sjkim *sm); 435160814SsimonSTORE_GET_OBJECT_FUNC_PTR STORE_method_get_get_function(STORE_METHOD *sm); 436160814SsimonSTORE_STORE_OBJECT_FUNC_PTR STORE_method_get_store_function(STORE_METHOD *sm); 437280297SjkimSTORE_MODIFY_OBJECT_FUNC_PTR STORE_method_get_modify_function(STORE_METHOD 438280297Sjkim *sm); 439280297SjkimSTORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_revoke_function(STORE_METHOD 440280297Sjkim *sm); 441280297SjkimSTORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_delete_function(STORE_METHOD 442280297Sjkim *sm); 443280297SjkimSTORE_START_OBJECT_FUNC_PTR STORE_method_get_list_start_function(STORE_METHOD 444280297Sjkim *sm); 445280297SjkimSTORE_NEXT_OBJECT_FUNC_PTR STORE_method_get_list_next_function(STORE_METHOD 446280297Sjkim *sm); 447280297SjkimSTORE_END_OBJECT_FUNC_PTR STORE_method_get_list_end_function(STORE_METHOD 448280297Sjkim *sm); 449280297SjkimSTORE_GENERIC_FUNC_PTR STORE_method_get_update_store_function(STORE_METHOD 450280297Sjkim *sm); 451160814SsimonSTORE_GENERIC_FUNC_PTR STORE_method_get_lock_store_function(STORE_METHOD *sm); 452280297SjkimSTORE_GENERIC_FUNC_PTR STORE_method_get_unlock_store_function(STORE_METHOD 453280297Sjkim *sm); 454160814SsimonSTORE_CTRL_FUNC_PTR STORE_method_get_ctrl_function(STORE_METHOD *sm); 455160814Ssimon 456160814Ssimon/* Method helper structures and functions. */ 457160814Ssimon 458280297Sjkim/* 459280297Sjkim * This structure is the result of parsing through the information in a list 460280297Sjkim * of OPENSSL_ITEMs. It stores all the necessary information in a structured 461280297Sjkim * way. 462280297Sjkim */ 463160814Ssimontypedef struct STORE_attr_info_st STORE_ATTR_INFO; 464160814Ssimon 465280297Sjkim/* 466280297Sjkim * Parse a list of OPENSSL_ITEMs and return a pointer to a STORE_ATTR_INFO. 467280297Sjkim * Note that we do this in the list form, since the list of OPENSSL_ITEMs can 468280297Sjkim * come in blocks separated with STORE_ATTR_OR. Note that the value returned 469280297Sjkim * by STORE_parse_attrs_next() must be freed with STORE_ATTR_INFO_free(). 470280297Sjkim */ 471160814Ssimonvoid *STORE_parse_attrs_start(OPENSSL_ITEM *attributes); 472160814SsimonSTORE_ATTR_INFO *STORE_parse_attrs_next(void *handle); 473160814Ssimonint STORE_parse_attrs_end(void *handle); 474160814Ssimonint STORE_parse_attrs_endp(void *handle); 475160814Ssimon 476160814Ssimon/* Creator and destructor */ 477160814SsimonSTORE_ATTR_INFO *STORE_ATTR_INFO_new(void); 478160814Ssimonint STORE_ATTR_INFO_free(STORE_ATTR_INFO *attrs); 479160814Ssimon 480160814Ssimon/* Manipulators */ 481280297Sjkimchar *STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs, 482280297Sjkim STORE_ATTR_TYPES code); 483160814Ssimonunsigned char *STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs, 484280297Sjkim STORE_ATTR_TYPES code); 485280297SjkimX509_NAME *STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs, 486280297Sjkim STORE_ATTR_TYPES code); 487280297SjkimBIGNUM *STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs, 488280297Sjkim STORE_ATTR_TYPES code); 489160814Ssimonint STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, 490280297Sjkim char *cstr, size_t cstr_size); 491160814Ssimonint STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, 492280297Sjkim unsigned char *sha1str, size_t sha1str_size); 493160814Ssimonint STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, 494280297Sjkim X509_NAME *dn); 495160814Ssimonint STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, 496280297Sjkim BIGNUM *number); 497160814Ssimonint STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, 498280297Sjkim char *cstr, size_t cstr_size); 499280297Sjkimint STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs, 500280297Sjkim STORE_ATTR_TYPES code, 501280297Sjkim unsigned char *sha1str, 502280297Sjkim size_t sha1str_size); 503160814Ssimonint STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, 504280297Sjkim X509_NAME *dn); 505280297Sjkimint STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs, 506280297Sjkim STORE_ATTR_TYPES code, BIGNUM *number); 507160814Ssimon 508280297Sjkim/* 509280297Sjkim * Compare on basis of a bit pattern formed by the STORE_ATTR_TYPES values in 510280297Sjkim * each contained attribute. 511280297Sjkim */ 512280297Sjkimint STORE_ATTR_INFO_compare(const STORE_ATTR_INFO *const *a, 513280297Sjkim const STORE_ATTR_INFO *const *b); 514280297Sjkim/* 515280297Sjkim * Check if the set of attributes in a is within the range of attributes set 516280297Sjkim * in b. 517280297Sjkim */ 518160814Ssimonint STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); 519160814Ssimon/* Check if the set of attributes in a are also set in b. */ 520160814Ssimonint STORE_ATTR_INFO_in(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); 521160814Ssimon/* Same as STORE_ATTR_INFO_in(), but also checks the attribute values. */ 522160814Ssimonint STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); 523160814Ssimon 524160814Ssimon/* BEGIN ERROR CODES */ 525280297Sjkim/* 526280297Sjkim * The following lines are auto generated by the script mkerr.pl. Any changes 527160814Ssimon * made after this point may be overwritten when the script is next run. 528160814Ssimon */ 529160814Ssimonvoid ERR_load_STORE_strings(void); 530160814Ssimon 531160814Ssimon/* Error codes for the STORE functions. */ 532160814Ssimon 533160814Ssimon/* Function codes. */ 534280297Sjkim# define STORE_F_MEM_DELETE 134 535280297Sjkim# define STORE_F_MEM_GENERATE 135 536280297Sjkim# define STORE_F_MEM_LIST_END 168 537280297Sjkim# define STORE_F_MEM_LIST_NEXT 136 538280297Sjkim# define STORE_F_MEM_LIST_START 137 539280297Sjkim# define STORE_F_MEM_MODIFY 169 540280297Sjkim# define STORE_F_MEM_STORE 138 541280297Sjkim# define STORE_F_STORE_ATTR_INFO_GET0_CSTR 139 542280297Sjkim# define STORE_F_STORE_ATTR_INFO_GET0_DN 140 543280297Sjkim# define STORE_F_STORE_ATTR_INFO_GET0_NUMBER 141 544280297Sjkim# define STORE_F_STORE_ATTR_INFO_GET0_SHA1STR 142 545280297Sjkim# define STORE_F_STORE_ATTR_INFO_MODIFY_CSTR 143 546280297Sjkim# define STORE_F_STORE_ATTR_INFO_MODIFY_DN 144 547280297Sjkim# define STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER 145 548280297Sjkim# define STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR 146 549280297Sjkim# define STORE_F_STORE_ATTR_INFO_SET_CSTR 147 550280297Sjkim# define STORE_F_STORE_ATTR_INFO_SET_DN 148 551280297Sjkim# define STORE_F_STORE_ATTR_INFO_SET_NUMBER 149 552280297Sjkim# define STORE_F_STORE_ATTR_INFO_SET_SHA1STR 150 553280297Sjkim# define STORE_F_STORE_CERTIFICATE 170 554280297Sjkim# define STORE_F_STORE_CTRL 161 555280297Sjkim# define STORE_F_STORE_DELETE_ARBITRARY 158 556280297Sjkim# define STORE_F_STORE_DELETE_CERTIFICATE 102 557280297Sjkim# define STORE_F_STORE_DELETE_CRL 103 558280297Sjkim# define STORE_F_STORE_DELETE_NUMBER 104 559280297Sjkim# define STORE_F_STORE_DELETE_PRIVATE_KEY 105 560280297Sjkim# define STORE_F_STORE_DELETE_PUBLIC_KEY 106 561280297Sjkim# define STORE_F_STORE_GENERATE_CRL 107 562280297Sjkim# define STORE_F_STORE_GENERATE_KEY 108 563280297Sjkim# define STORE_F_STORE_GET_ARBITRARY 159 564280297Sjkim# define STORE_F_STORE_GET_CERTIFICATE 109 565280297Sjkim# define STORE_F_STORE_GET_CRL 110 566280297Sjkim# define STORE_F_STORE_GET_NUMBER 111 567280297Sjkim# define STORE_F_STORE_GET_PRIVATE_KEY 112 568280297Sjkim# define STORE_F_STORE_GET_PUBLIC_KEY 113 569280297Sjkim# define STORE_F_STORE_LIST_CERTIFICATE_END 114 570280297Sjkim# define STORE_F_STORE_LIST_CERTIFICATE_ENDP 153 571280297Sjkim# define STORE_F_STORE_LIST_CERTIFICATE_NEXT 115 572280297Sjkim# define STORE_F_STORE_LIST_CERTIFICATE_START 116 573280297Sjkim# define STORE_F_STORE_LIST_CRL_END 117 574280297Sjkim# define STORE_F_STORE_LIST_CRL_ENDP 154 575280297Sjkim# define STORE_F_STORE_LIST_CRL_NEXT 118 576280297Sjkim# define STORE_F_STORE_LIST_CRL_START 119 577280297Sjkim# define STORE_F_STORE_LIST_PRIVATE_KEY_END 120 578280297Sjkim# define STORE_F_STORE_LIST_PRIVATE_KEY_ENDP 155 579280297Sjkim# define STORE_F_STORE_LIST_PRIVATE_KEY_NEXT 121 580280297Sjkim# define STORE_F_STORE_LIST_PRIVATE_KEY_START 122 581280297Sjkim# define STORE_F_STORE_LIST_PUBLIC_KEY_END 123 582280297Sjkim# define STORE_F_STORE_LIST_PUBLIC_KEY_ENDP 156 583280297Sjkim# define STORE_F_STORE_LIST_PUBLIC_KEY_NEXT 124 584280297Sjkim# define STORE_F_STORE_LIST_PUBLIC_KEY_START 125 585280297Sjkim# define STORE_F_STORE_MODIFY_ARBITRARY 162 586280297Sjkim# define STORE_F_STORE_MODIFY_CERTIFICATE 163 587280297Sjkim# define STORE_F_STORE_MODIFY_CRL 164 588280297Sjkim# define STORE_F_STORE_MODIFY_NUMBER 165 589280297Sjkim# define STORE_F_STORE_MODIFY_PRIVATE_KEY 166 590280297Sjkim# define STORE_F_STORE_MODIFY_PUBLIC_KEY 167 591280297Sjkim# define STORE_F_STORE_NEW_ENGINE 133 592280297Sjkim# define STORE_F_STORE_NEW_METHOD 132 593280297Sjkim# define STORE_F_STORE_PARSE_ATTRS_END 151 594280297Sjkim# define STORE_F_STORE_PARSE_ATTRS_ENDP 172 595280297Sjkim# define STORE_F_STORE_PARSE_ATTRS_NEXT 152 596280297Sjkim# define STORE_F_STORE_PARSE_ATTRS_START 171 597280297Sjkim# define STORE_F_STORE_REVOKE_CERTIFICATE 129 598280297Sjkim# define STORE_F_STORE_REVOKE_PRIVATE_KEY 130 599280297Sjkim# define STORE_F_STORE_REVOKE_PUBLIC_KEY 131 600280297Sjkim# define STORE_F_STORE_STORE_ARBITRARY 157 601280297Sjkim# define STORE_F_STORE_STORE_CERTIFICATE 100 602280297Sjkim# define STORE_F_STORE_STORE_CRL 101 603280297Sjkim# define STORE_F_STORE_STORE_NUMBER 126 604280297Sjkim# define STORE_F_STORE_STORE_PRIVATE_KEY 127 605280297Sjkim# define STORE_F_STORE_STORE_PUBLIC_KEY 128 606160814Ssimon 607160814Ssimon/* Reason codes. */ 608280297Sjkim# define STORE_R_ALREADY_HAS_A_VALUE 127 609280297Sjkim# define STORE_R_FAILED_DELETING_ARBITRARY 132 610280297Sjkim# define STORE_R_FAILED_DELETING_CERTIFICATE 100 611280297Sjkim# define STORE_R_FAILED_DELETING_KEY 101 612280297Sjkim# define STORE_R_FAILED_DELETING_NUMBER 102 613280297Sjkim# define STORE_R_FAILED_GENERATING_CRL 103 614280297Sjkim# define STORE_R_FAILED_GENERATING_KEY 104 615280297Sjkim# define STORE_R_FAILED_GETTING_ARBITRARY 133 616280297Sjkim# define STORE_R_FAILED_GETTING_CERTIFICATE 105 617280297Sjkim# define STORE_R_FAILED_GETTING_KEY 106 618280297Sjkim# define STORE_R_FAILED_GETTING_NUMBER 107 619280297Sjkim# define STORE_R_FAILED_LISTING_CERTIFICATES 108 620280297Sjkim# define STORE_R_FAILED_LISTING_KEYS 109 621280297Sjkim# define STORE_R_FAILED_MODIFYING_ARBITRARY 138 622280297Sjkim# define STORE_R_FAILED_MODIFYING_CERTIFICATE 139 623280297Sjkim# define STORE_R_FAILED_MODIFYING_CRL 140 624280297Sjkim# define STORE_R_FAILED_MODIFYING_NUMBER 141 625280297Sjkim# define STORE_R_FAILED_MODIFYING_PRIVATE_KEY 142 626280297Sjkim# define STORE_R_FAILED_MODIFYING_PUBLIC_KEY 143 627280297Sjkim# define STORE_R_FAILED_REVOKING_CERTIFICATE 110 628280297Sjkim# define STORE_R_FAILED_REVOKING_KEY 111 629280297Sjkim# define STORE_R_FAILED_STORING_ARBITRARY 134 630280297Sjkim# define STORE_R_FAILED_STORING_CERTIFICATE 112 631280297Sjkim# define STORE_R_FAILED_STORING_KEY 113 632280297Sjkim# define STORE_R_FAILED_STORING_NUMBER 114 633280297Sjkim# define STORE_R_NOT_IMPLEMENTED 128 634280297Sjkim# define STORE_R_NO_CONTROL_FUNCTION 144 635280297Sjkim# define STORE_R_NO_DELETE_ARBITRARY_FUNCTION 135 636280297Sjkim# define STORE_R_NO_DELETE_NUMBER_FUNCTION 115 637280297Sjkim# define STORE_R_NO_DELETE_OBJECT_FUNCTION 116 638280297Sjkim# define STORE_R_NO_GENERATE_CRL_FUNCTION 117 639280297Sjkim# define STORE_R_NO_GENERATE_OBJECT_FUNCTION 118 640280297Sjkim# define STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION 136 641280297Sjkim# define STORE_R_NO_GET_OBJECT_FUNCTION 119 642280297Sjkim# define STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION 120 643280297Sjkim# define STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION 131 644280297Sjkim# define STORE_R_NO_LIST_OBJECT_END_FUNCTION 121 645280297Sjkim# define STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION 122 646280297Sjkim# define STORE_R_NO_LIST_OBJECT_START_FUNCTION 123 647280297Sjkim# define STORE_R_NO_MODIFY_OBJECT_FUNCTION 145 648280297Sjkim# define STORE_R_NO_REVOKE_OBJECT_FUNCTION 124 649280297Sjkim# define STORE_R_NO_STORE 129 650280297Sjkim# define STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION 137 651280297Sjkim# define STORE_R_NO_STORE_OBJECT_FUNCTION 125 652280297Sjkim# define STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION 126 653280297Sjkim# define STORE_R_NO_VALUE 130 654160814Ssimon 655160814Ssimon#ifdef __cplusplus 656160814Ssimon} 657160814Ssimon#endif 658160814Ssimon#endif 659