1295016Sjkim/* crypto/store/store.h */ 2280304Sjkim/* 3280304Sjkim * Written by Richard Levitte (richard@levitte.org) for the OpenSSL project 4280304Sjkim * 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 14280304Sjkim * 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 61280304Sjkim# define HEADER_STORE_H 62160814Ssimon 63280304Sjkim# include <openssl/opensslconf.h> 64238405Sjkim 65280304Sjkim# ifdef OPENSSL_NO_STORE 66280304Sjkim# error STORE is disabled. 67280304Sjkim# endif 68238405Sjkim 69280304Sjkim# include <openssl/ossl_typ.h> 70280304Sjkim# ifndef OPENSSL_NO_DEPRECATED 71280304Sjkim# include <openssl/evp.h> 72280304Sjkim# include <openssl/bn.h> 73280304Sjkim# include <openssl/x509.h> 74280304Sjkim# 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 84280304Sjkim/* 85280304Sjkim * All the following functions return 0, a negative number or NULL on error. 86280304Sjkim * When everything is fine, they return a positive value or a non-NULL 87280304Sjkim * pointer, all depending on their purpose. 88280304Sjkim */ 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 95280304Sjkim/* 96280304Sjkim * Give a user interface parametrised control commands. This can be used to 97280304Sjkim * send down an integer, a data pointer or a function pointer, as well as be 98280304Sjkim * used to get information from a STORE. 99280304Sjkim */ 100280304Sjkimint STORE_ctrl(STORE *store, int cmd, long i, void *p, void (*f) (void)); 101160814Ssimon 102280304Sjkim/* 103280304Sjkim * A control to set the directory with keys and certificates. Used by the 104280304Sjkim * built-in directory level method. 105280304Sjkim */ 106280304Sjkim# define STORE_CTRL_SET_DIRECTORY 0x0001 107280304Sjkim/* 108280304Sjkim * A control to set a file to load. Used by the built-in file level method. 109280304Sjkim */ 110280304Sjkim# define STORE_CTRL_SET_FILE 0x0002 111280304Sjkim/* 112280304Sjkim * A control to set a configuration file to load. Can be used by any method 113280304Sjkim * that wishes to load a configuration file. 114280304Sjkim */ 115280304Sjkim# define STORE_CTRL_SET_CONF_FILE 0x0003 116280304Sjkim/* 117280304Sjkim * A control to set a the section of the loaded configuration file. Can be 118280304Sjkim * used by any method that wishes to load a configuration file. 119280304Sjkim */ 120280304Sjkim# define STORE_CTRL_SET_CONF_SECTION 0x0004 121160814Ssimon 122160814Ssimon/* Some methods may use extra data */ 123280304Sjkim# define STORE_set_app_data(s,arg) STORE_set_ex_data(s,0,arg) 124280304Sjkim# 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, 126280304Sjkim CRYPTO_EX_dup *dup_func, 127280304Sjkim CRYPTO_EX_free *free_func); 128280304Sjkimint 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. */ 136280304Sjkim/* 137280304Sjkim * This is the in-memory method. It does everything except revoking and 138280304Sjkim * updating, and is of course volatile. It's used by other methods that have 139280304Sjkim * an in-memory cache. 140280304Sjkim */ 141160814Ssimonconst STORE_METHOD *STORE_Memory(void); 142280304Sjkim# if 0 /* Not yet implemented */ 143280304Sjkim/* 144280304Sjkim * This is the directory store. It does everything except revoking and 145280304Sjkim * updating, and uses STORE_Memory() to cache things in memory. 146280304Sjkim */ 147160814Ssimonconst STORE_METHOD *STORE_Directory(void); 148280304Sjkim/* 149280304Sjkim * This is the file store. It does everything except revoking and updating, 150280304Sjkim * and uses STORE_Memory() to cache things in memory. Certificates are added 151280304Sjkim * to it with the store operation, and it will only get cached certificates. 152280304Sjkim */ 153160814Ssimonconst STORE_METHOD *STORE_File(void); 154280304Sjkim# endif 155160814Ssimon 156280304Sjkim/* 157280304Sjkim * Store functions take a type code for the type of data they should store or 158280304Sjkim * fetch 159280304Sjkim */ 160280304Sjkimtypedef enum STORE_object_types { 161280304Sjkim STORE_OBJECT_TYPE_X509_CERTIFICATE = 0x01, /* X509 * */ 162280304Sjkim STORE_OBJECT_TYPE_X509_CRL = 0x02, /* X509_CRL * */ 163280304Sjkim STORE_OBJECT_TYPE_PRIVATE_KEY = 0x03, /* EVP_PKEY * */ 164280304Sjkim STORE_OBJECT_TYPE_PUBLIC_KEY = 0x04, /* EVP_PKEY * */ 165280304Sjkim STORE_OBJECT_TYPE_NUMBER = 0x05, /* BIGNUM * */ 166280304Sjkim STORE_OBJECT_TYPE_ARBITRARY = 0x06, /* BUF_MEM * */ 167280304Sjkim STORE_OBJECT_TYPE_NUM = 0x06 /* The amount of known object types */ 168280304Sjkim} STORE_OBJECT_TYPES; 169160814Ssimon/* List of text strings corresponding to the object types. */ 170280304Sjkimextern const char *const STORE_object_type_string[STORE_OBJECT_TYPE_NUM + 1]; 171160814Ssimon 172280304Sjkim/* 173280304Sjkim * Some store functions take a parameter list. Those parameters come with 174280304Sjkim * one of the following codes. The comments following the codes below 175280304Sjkim * indicate what type the value should be a pointer to. 176280304Sjkim */ 177280304Sjkimtypedef enum STORE_params { 178280304Sjkim STORE_PARAM_EVP_TYPE = 0x01, /* int */ 179280304Sjkim STORE_PARAM_BITS = 0x02, /* size_t */ 180280304Sjkim STORE_PARAM_KEY_PARAMETERS = 0x03, /* ??? */ 181280304Sjkim STORE_PARAM_KEY_NO_PARAMETERS = 0x04, /* N/A */ 182280304Sjkim STORE_PARAM_AUTH_PASSPHRASE = 0x05, /* char * */ 183280304Sjkim STORE_PARAM_AUTH_KRB5_TICKET = 0x06, /* void * */ 184280304Sjkim STORE_PARAM_TYPE_NUM = 0x06 /* The amount of known parameter types */ 185280304Sjkim} STORE_PARAM_TYPES; 186280304Sjkim/* 187280304Sjkim * Parameter value sizes. -1 means unknown, anything else is the required 188280304Sjkim * size. 189280304Sjkim */ 190280304Sjkimextern const int STORE_param_sizes[STORE_PARAM_TYPE_NUM + 1]; 191160814Ssimon 192280304Sjkim/* 193280304Sjkim * Store functions take attribute lists. Those attributes come with codes. 194280304Sjkim * The comments following the codes below indicate what type the value should 195280304Sjkim * be a pointer to. 196280304Sjkim */ 197280304Sjkimtypedef enum STORE_attribs { 198280304Sjkim STORE_ATTR_END = 0x00, 199280304Sjkim STORE_ATTR_FRIENDLYNAME = 0x01, /* C string */ 200280304Sjkim STORE_ATTR_KEYID = 0x02, /* 160 bit string (SHA1) */ 201280304Sjkim STORE_ATTR_ISSUERKEYID = 0x03, /* 160 bit string (SHA1) */ 202280304Sjkim STORE_ATTR_SUBJECTKEYID = 0x04, /* 160 bit string (SHA1) */ 203280304Sjkim STORE_ATTR_ISSUERSERIALHASH = 0x05, /* 160 bit string (SHA1) */ 204280304Sjkim STORE_ATTR_ISSUER = 0x06, /* X509_NAME * */ 205280304Sjkim STORE_ATTR_SERIAL = 0x07, /* BIGNUM * */ 206280304Sjkim STORE_ATTR_SUBJECT = 0x08, /* X509_NAME * */ 207280304Sjkim STORE_ATTR_CERTHASH = 0x09, /* 160 bit string (SHA1) */ 208280304Sjkim STORE_ATTR_EMAIL = 0x0a, /* C string */ 209280304Sjkim STORE_ATTR_FILENAME = 0x0b, /* C string */ 210280304Sjkim STORE_ATTR_TYPE_NUM = 0x0b, /* The amount of known attribute types */ 211280304Sjkim STORE_ATTR_OR = 0xff /* This is a special separator, which 212280304Sjkim * expresses the OR operation. */ 213280304Sjkim} STORE_ATTR_TYPES; 214280304Sjkim/* 215280304Sjkim * Attribute value sizes. -1 means unknown, anything else is the required 216280304Sjkim * size. 217280304Sjkim */ 218280304Sjkimextern const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM + 1]; 219160814Ssimon 220280304Sjkimtypedef enum STORE_certificate_status { 221280304Sjkim STORE_X509_VALID = 0x00, 222280304Sjkim STORE_X509_EXPIRED = 0x01, 223280304Sjkim STORE_X509_SUSPENDED = 0x02, 224280304Sjkim STORE_X509_REVOKED = 0x03 225280304Sjkim} STORE_CERTIFICATE_STATUS; 226160814Ssimon 227280304Sjkim/* 228280304Sjkim * Engine store functions will return a structure that contains all the 229280304Sjkim * necessary information, including revokation status for certificates. This 230280304Sjkim * is really not needed for application authors, as the ENGINE framework 231280304Sjkim * functions will extract the OpenSSL-specific information when at all 232280304Sjkim * possible. However, for engine authors, it's crucial to know this 233280304Sjkim * structure. 234280304Sjkim */ 235280304Sjkimtypedef struct STORE_OBJECT_st { 236280304Sjkim STORE_OBJECT_TYPES type; 237280304Sjkim union { 238280304Sjkim struct { 239280304Sjkim STORE_CERTIFICATE_STATUS status; 240280304Sjkim X509 *certificate; 241280304Sjkim } x509; 242280304Sjkim X509_CRL *crl; 243280304Sjkim EVP_PKEY *key; 244280304Sjkim BIGNUM *number; 245280304Sjkim BUF_MEM *arbitrary; 246280304Sjkim } data; 247280304Sjkim} STORE_OBJECT; 248160814SsimonDECLARE_STACK_OF(STORE_OBJECT) 249160814SsimonSTORE_OBJECT *STORE_OBJECT_new(void); 250160814Ssimonvoid STORE_OBJECT_free(STORE_OBJECT *data); 251160814Ssimon 252280304Sjkim/* 253280304Sjkim * The following functions handle the storage. They return 0, a negative 254280304Sjkim * number or NULL on error, anything else on success. 255280304Sjkim */ 256160814SsimonX509 *STORE_get_certificate(STORE *e, OPENSSL_ITEM attributes[], 257280304Sjkim OPENSSL_ITEM parameters[]); 258160814Ssimonint STORE_store_certificate(STORE *e, X509 *data, OPENSSL_ITEM attributes[], 259280304Sjkim OPENSSL_ITEM parameters[]); 260160814Ssimonint STORE_modify_certificate(STORE *e, OPENSSL_ITEM search_attributes[], 261280304Sjkim OPENSSL_ITEM add_attributes[], 262280304Sjkim OPENSSL_ITEM modify_attributes[], 263280304Sjkim OPENSSL_ITEM delete_attributes[], 264280304Sjkim OPENSSL_ITEM parameters[]); 265160814Ssimonint STORE_revoke_certificate(STORE *e, OPENSSL_ITEM attributes[], 266280304Sjkim OPENSSL_ITEM parameters[]); 267160814Ssimonint STORE_delete_certificate(STORE *e, OPENSSL_ITEM attributes[], 268280304Sjkim OPENSSL_ITEM parameters[]); 269160814Ssimonvoid *STORE_list_certificate_start(STORE *e, OPENSSL_ITEM attributes[], 270280304Sjkim 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[], 275280304Sjkim OPENSSL_ITEM parameters[]); 276160814SsimonEVP_PKEY *STORE_get_private_key(STORE *e, OPENSSL_ITEM attributes[], 277280304Sjkim OPENSSL_ITEM parameters[]); 278160814Ssimonint STORE_store_private_key(STORE *e, EVP_PKEY *data, 279280304Sjkim OPENSSL_ITEM attributes[], 280280304Sjkim OPENSSL_ITEM parameters[]); 281160814Ssimonint STORE_modify_private_key(STORE *e, OPENSSL_ITEM search_attributes[], 282280304Sjkim OPENSSL_ITEM add_sttributes[], 283280304Sjkim OPENSSL_ITEM modify_attributes[], 284280304Sjkim OPENSSL_ITEM delete_attributes[], 285280304Sjkim OPENSSL_ITEM parameters[]); 286160814Ssimonint STORE_revoke_private_key(STORE *e, OPENSSL_ITEM attributes[], 287280304Sjkim OPENSSL_ITEM parameters[]); 288160814Ssimonint STORE_delete_private_key(STORE *e, OPENSSL_ITEM attributes[], 289280304Sjkim OPENSSL_ITEM parameters[]); 290160814Ssimonvoid *STORE_list_private_key_start(STORE *e, OPENSSL_ITEM attributes[], 291280304Sjkim 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[], 296280304Sjkim OPENSSL_ITEM parameters[]); 297280304Sjkimint STORE_store_public_key(STORE *e, EVP_PKEY *data, 298280304Sjkim OPENSSL_ITEM attributes[], 299280304Sjkim OPENSSL_ITEM parameters[]); 300160814Ssimonint STORE_modify_public_key(STORE *e, OPENSSL_ITEM search_attributes[], 301280304Sjkim OPENSSL_ITEM add_sttributes[], 302280304Sjkim OPENSSL_ITEM modify_attributes[], 303280304Sjkim OPENSSL_ITEM delete_attributes[], 304280304Sjkim OPENSSL_ITEM parameters[]); 305160814Ssimonint STORE_revoke_public_key(STORE *e, OPENSSL_ITEM attributes[], 306280304Sjkim OPENSSL_ITEM parameters[]); 307160814Ssimonint STORE_delete_public_key(STORE *e, OPENSSL_ITEM attributes[], 308280304Sjkim OPENSSL_ITEM parameters[]); 309160814Ssimonvoid *STORE_list_public_key_start(STORE *e, OPENSSL_ITEM attributes[], 310280304Sjkim 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[], 315280304Sjkim OPENSSL_ITEM parameters[]); 316160814SsimonX509_CRL *STORE_get_crl(STORE *e, OPENSSL_ITEM attributes[], 317280304Sjkim OPENSSL_ITEM parameters[]); 318160814Ssimonint STORE_store_crl(STORE *e, X509_CRL *data, OPENSSL_ITEM attributes[], 319280304Sjkim OPENSSL_ITEM parameters[]); 320160814Ssimonint STORE_modify_crl(STORE *e, OPENSSL_ITEM search_attributes[], 321280304Sjkim OPENSSL_ITEM add_sttributes[], 322280304Sjkim OPENSSL_ITEM modify_attributes[], 323280304Sjkim OPENSSL_ITEM delete_attributes[], 324280304Sjkim OPENSSL_ITEM parameters[]); 325160814Ssimonint STORE_delete_crl(STORE *e, OPENSSL_ITEM attributes[], 326280304Sjkim OPENSSL_ITEM parameters[]); 327160814Ssimonvoid *STORE_list_crl_start(STORE *e, OPENSSL_ITEM attributes[], 328280304Sjkim 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[], 333280304Sjkim OPENSSL_ITEM parameters[]); 334160814Ssimonint STORE_modify_number(STORE *e, OPENSSL_ITEM search_attributes[], 335280304Sjkim OPENSSL_ITEM add_sttributes[], 336280304Sjkim OPENSSL_ITEM modify_attributes[], 337280304Sjkim OPENSSL_ITEM delete_attributes[], 338280304Sjkim OPENSSL_ITEM parameters[]); 339160814SsimonBIGNUM *STORE_get_number(STORE *e, OPENSSL_ITEM attributes[], 340280304Sjkim OPENSSL_ITEM parameters[]); 341160814Ssimonint STORE_delete_number(STORE *e, OPENSSL_ITEM attributes[], 342280304Sjkim OPENSSL_ITEM parameters[]); 343160814Ssimonint STORE_store_arbitrary(STORE *e, BUF_MEM *data, OPENSSL_ITEM attributes[], 344280304Sjkim OPENSSL_ITEM parameters[]); 345160814Ssimonint STORE_modify_arbitrary(STORE *e, OPENSSL_ITEM search_attributes[], 346280304Sjkim OPENSSL_ITEM add_sttributes[], 347280304Sjkim OPENSSL_ITEM modify_attributes[], 348280304Sjkim OPENSSL_ITEM delete_attributes[], 349280304Sjkim OPENSSL_ITEM parameters[]); 350160814SsimonBUF_MEM *STORE_get_arbitrary(STORE *e, OPENSSL_ITEM attributes[], 351280304Sjkim OPENSSL_ITEM parameters[]); 352160814Ssimonint STORE_delete_arbitrary(STORE *e, OPENSSL_ITEM attributes[], 353280304Sjkim 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 */ 360280304Sjkimtypedef int (*STORE_INITIALISE_FUNC_PTR) (STORE *); 361280304Sjkimtypedef void (*STORE_CLEANUP_FUNC_PTR) (STORE *); 362280304Sjkimtypedef STORE_OBJECT *(*STORE_GENERATE_OBJECT_FUNC_PTR)(STORE *, 363280304Sjkim STORE_OBJECT_TYPES 364280304Sjkim type, 365280304Sjkim OPENSSL_ITEM 366280304Sjkim attributes[], 367280304Sjkim OPENSSL_ITEM 368280304Sjkim parameters[]); 369280304Sjkimtypedef STORE_OBJECT *(*STORE_GET_OBJECT_FUNC_PTR)(STORE *, 370280304Sjkim STORE_OBJECT_TYPES type, 371280304Sjkim OPENSSL_ITEM attributes[], 372280304Sjkim OPENSSL_ITEM parameters[]); 373280304Sjkimtypedef void *(*STORE_START_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, 374280304Sjkim OPENSSL_ITEM attributes[], 375280304Sjkim OPENSSL_ITEM parameters[]); 376160814Ssimontypedef STORE_OBJECT *(*STORE_NEXT_OBJECT_FUNC_PTR)(STORE *, void *handle); 377280304Sjkimtypedef int (*STORE_END_OBJECT_FUNC_PTR) (STORE *, void *handle); 378280304Sjkimtypedef int (*STORE_HANDLE_OBJECT_FUNC_PTR) (STORE *, STORE_OBJECT_TYPES type, 379280304Sjkim OPENSSL_ITEM attributes[], 380280304Sjkim OPENSSL_ITEM parameters[]); 381280304Sjkimtypedef int (*STORE_STORE_OBJECT_FUNC_PTR) (STORE *, STORE_OBJECT_TYPES type, 382280304Sjkim STORE_OBJECT *data, 383280304Sjkim OPENSSL_ITEM attributes[], 384280304Sjkim OPENSSL_ITEM parameters[]); 385280304Sjkimtypedef int (*STORE_MODIFY_OBJECT_FUNC_PTR) (STORE *, STORE_OBJECT_TYPES type, 386280304Sjkim OPENSSL_ITEM search_attributes[], 387280304Sjkim OPENSSL_ITEM add_attributes[], 388280304Sjkim OPENSSL_ITEM modify_attributes[], 389280304Sjkim OPENSSL_ITEM delete_attributes[], 390280304Sjkim OPENSSL_ITEM parameters[]); 391280304Sjkimtypedef int (*STORE_GENERIC_FUNC_PTR) (STORE *, OPENSSL_ITEM attributes[], 392280304Sjkim OPENSSL_ITEM parameters[]); 393280304Sjkimtypedef int (*STORE_CTRL_FUNC_PTR) (STORE *, int cmd, long l, void *p, 394280304Sjkim void (*f) (void)); 395160814Ssimon 396280304Sjkimint STORE_method_set_initialise_function(STORE_METHOD *sm, 397280304Sjkim STORE_INITIALISE_FUNC_PTR init_f); 398280304Sjkimint STORE_method_set_cleanup_function(STORE_METHOD *sm, 399280304Sjkim STORE_CLEANUP_FUNC_PTR clean_f); 400280304Sjkimint STORE_method_set_generate_function(STORE_METHOD *sm, 401280304Sjkim STORE_GENERATE_OBJECT_FUNC_PTR 402280304Sjkim generate_f); 403280304Sjkimint STORE_method_set_get_function(STORE_METHOD *sm, 404280304Sjkim STORE_GET_OBJECT_FUNC_PTR get_f); 405280304Sjkimint STORE_method_set_store_function(STORE_METHOD *sm, 406280304Sjkim STORE_STORE_OBJECT_FUNC_PTR store_f); 407280304Sjkimint STORE_method_set_modify_function(STORE_METHOD *sm, 408280304Sjkim STORE_MODIFY_OBJECT_FUNC_PTR store_f); 409280304Sjkimint STORE_method_set_revoke_function(STORE_METHOD *sm, 410280304Sjkim STORE_HANDLE_OBJECT_FUNC_PTR revoke_f); 411280304Sjkimint STORE_method_set_delete_function(STORE_METHOD *sm, 412280304Sjkim STORE_HANDLE_OBJECT_FUNC_PTR delete_f); 413280304Sjkimint STORE_method_set_list_start_function(STORE_METHOD *sm, 414280304Sjkim STORE_START_OBJECT_FUNC_PTR 415280304Sjkim list_start_f); 416280304Sjkimint STORE_method_set_list_next_function(STORE_METHOD *sm, 417280304Sjkim STORE_NEXT_OBJECT_FUNC_PTR 418280304Sjkim list_next_f); 419280304Sjkimint STORE_method_set_list_end_function(STORE_METHOD *sm, 420280304Sjkim STORE_END_OBJECT_FUNC_PTR list_end_f); 421280304Sjkimint STORE_method_set_update_store_function(STORE_METHOD *sm, 422280304Sjkim STORE_GENERIC_FUNC_PTR); 423280304Sjkimint STORE_method_set_lock_store_function(STORE_METHOD *sm, 424280304Sjkim STORE_GENERIC_FUNC_PTR); 425280304Sjkimint STORE_method_set_unlock_store_function(STORE_METHOD *sm, 426280304Sjkim STORE_GENERIC_FUNC_PTR); 427280304Sjkimint STORE_method_set_ctrl_function(STORE_METHOD *sm, 428280304Sjkim STORE_CTRL_FUNC_PTR ctrl_f); 429160814Ssimon 430280304SjkimSTORE_INITIALISE_FUNC_PTR STORE_method_get_initialise_function(STORE_METHOD 431280304Sjkim *sm); 432160814SsimonSTORE_CLEANUP_FUNC_PTR STORE_method_get_cleanup_function(STORE_METHOD *sm); 433280304SjkimSTORE_GENERATE_OBJECT_FUNC_PTR STORE_method_get_generate_function(STORE_METHOD 434280304Sjkim *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); 437280304SjkimSTORE_MODIFY_OBJECT_FUNC_PTR STORE_method_get_modify_function(STORE_METHOD 438280304Sjkim *sm); 439280304SjkimSTORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_revoke_function(STORE_METHOD 440280304Sjkim *sm); 441280304SjkimSTORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_delete_function(STORE_METHOD 442280304Sjkim *sm); 443280304SjkimSTORE_START_OBJECT_FUNC_PTR STORE_method_get_list_start_function(STORE_METHOD 444280304Sjkim *sm); 445280304SjkimSTORE_NEXT_OBJECT_FUNC_PTR STORE_method_get_list_next_function(STORE_METHOD 446280304Sjkim *sm); 447280304SjkimSTORE_END_OBJECT_FUNC_PTR STORE_method_get_list_end_function(STORE_METHOD 448280304Sjkim *sm); 449280304SjkimSTORE_GENERIC_FUNC_PTR STORE_method_get_update_store_function(STORE_METHOD 450280304Sjkim *sm); 451160814SsimonSTORE_GENERIC_FUNC_PTR STORE_method_get_lock_store_function(STORE_METHOD *sm); 452280304SjkimSTORE_GENERIC_FUNC_PTR STORE_method_get_unlock_store_function(STORE_METHOD 453280304Sjkim *sm); 454160814SsimonSTORE_CTRL_FUNC_PTR STORE_method_get_ctrl_function(STORE_METHOD *sm); 455160814Ssimon 456160814Ssimon/* Method helper structures and functions. */ 457160814Ssimon 458280304Sjkim/* 459280304Sjkim * This structure is the result of parsing through the information in a list 460280304Sjkim * of OPENSSL_ITEMs. It stores all the necessary information in a structured 461280304Sjkim * way. 462280304Sjkim */ 463160814Ssimontypedef struct STORE_attr_info_st STORE_ATTR_INFO; 464160814Ssimon 465280304Sjkim/* 466280304Sjkim * Parse a list of OPENSSL_ITEMs and return a pointer to a STORE_ATTR_INFO. 467280304Sjkim * Note that we do this in the list form, since the list of OPENSSL_ITEMs can 468280304Sjkim * come in blocks separated with STORE_ATTR_OR. Note that the value returned 469280304Sjkim * by STORE_parse_attrs_next() must be freed with STORE_ATTR_INFO_free(). 470280304Sjkim */ 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 */ 481280304Sjkimchar *STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs, 482280304Sjkim STORE_ATTR_TYPES code); 483160814Ssimonunsigned char *STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs, 484280304Sjkim STORE_ATTR_TYPES code); 485280304SjkimX509_NAME *STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs, 486280304Sjkim STORE_ATTR_TYPES code); 487280304SjkimBIGNUM *STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs, 488280304Sjkim STORE_ATTR_TYPES code); 489160814Ssimonint STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, 490280304Sjkim char *cstr, size_t cstr_size); 491160814Ssimonint STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, 492280304Sjkim unsigned char *sha1str, size_t sha1str_size); 493160814Ssimonint STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, 494280304Sjkim X509_NAME *dn); 495160814Ssimonint STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, 496280304Sjkim BIGNUM *number); 497160814Ssimonint STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, 498280304Sjkim char *cstr, size_t cstr_size); 499280304Sjkimint STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs, 500280304Sjkim STORE_ATTR_TYPES code, 501280304Sjkim unsigned char *sha1str, 502280304Sjkim size_t sha1str_size); 503160814Ssimonint STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, 504280304Sjkim X509_NAME *dn); 505280304Sjkimint STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs, 506280304Sjkim STORE_ATTR_TYPES code, BIGNUM *number); 507160814Ssimon 508280304Sjkim/* 509280304Sjkim * Compare on basis of a bit pattern formed by the STORE_ATTR_TYPES values in 510280304Sjkim * each contained attribute. 511280304Sjkim */ 512280304Sjkimint STORE_ATTR_INFO_compare(const STORE_ATTR_INFO *const *a, 513280304Sjkim const STORE_ATTR_INFO *const *b); 514280304Sjkim/* 515280304Sjkim * Check if the set of attributes in a is within the range of attributes set 516280304Sjkim * in b. 517280304Sjkim */ 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 */ 525280304Sjkim/* 526280304Sjkim * 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. */ 534280304Sjkim# define STORE_F_MEM_DELETE 134 535280304Sjkim# define STORE_F_MEM_GENERATE 135 536280304Sjkim# define STORE_F_MEM_LIST_END 168 537280304Sjkim# define STORE_F_MEM_LIST_NEXT 136 538280304Sjkim# define STORE_F_MEM_LIST_START 137 539280304Sjkim# define STORE_F_MEM_MODIFY 169 540280304Sjkim# define STORE_F_MEM_STORE 138 541280304Sjkim# define STORE_F_STORE_ATTR_INFO_GET0_CSTR 139 542280304Sjkim# define STORE_F_STORE_ATTR_INFO_GET0_DN 140 543280304Sjkim# define STORE_F_STORE_ATTR_INFO_GET0_NUMBER 141 544280304Sjkim# define STORE_F_STORE_ATTR_INFO_GET0_SHA1STR 142 545280304Sjkim# define STORE_F_STORE_ATTR_INFO_MODIFY_CSTR 143 546280304Sjkim# define STORE_F_STORE_ATTR_INFO_MODIFY_DN 144 547280304Sjkim# define STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER 145 548280304Sjkim# define STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR 146 549280304Sjkim# define STORE_F_STORE_ATTR_INFO_SET_CSTR 147 550280304Sjkim# define STORE_F_STORE_ATTR_INFO_SET_DN 148 551280304Sjkim# define STORE_F_STORE_ATTR_INFO_SET_NUMBER 149 552280304Sjkim# define STORE_F_STORE_ATTR_INFO_SET_SHA1STR 150 553280304Sjkim# define STORE_F_STORE_CERTIFICATE 170 554280304Sjkim# define STORE_F_STORE_CTRL 161 555280304Sjkim# define STORE_F_STORE_DELETE_ARBITRARY 158 556280304Sjkim# define STORE_F_STORE_DELETE_CERTIFICATE 102 557280304Sjkim# define STORE_F_STORE_DELETE_CRL 103 558280304Sjkim# define STORE_F_STORE_DELETE_NUMBER 104 559280304Sjkim# define STORE_F_STORE_DELETE_PRIVATE_KEY 105 560280304Sjkim# define STORE_F_STORE_DELETE_PUBLIC_KEY 106 561280304Sjkim# define STORE_F_STORE_GENERATE_CRL 107 562280304Sjkim# define STORE_F_STORE_GENERATE_KEY 108 563280304Sjkim# define STORE_F_STORE_GET_ARBITRARY 159 564280304Sjkim# define STORE_F_STORE_GET_CERTIFICATE 109 565280304Sjkim# define STORE_F_STORE_GET_CRL 110 566280304Sjkim# define STORE_F_STORE_GET_NUMBER 111 567280304Sjkim# define STORE_F_STORE_GET_PRIVATE_KEY 112 568280304Sjkim# define STORE_F_STORE_GET_PUBLIC_KEY 113 569280304Sjkim# define STORE_F_STORE_LIST_CERTIFICATE_END 114 570280304Sjkim# define STORE_F_STORE_LIST_CERTIFICATE_ENDP 153 571280304Sjkim# define STORE_F_STORE_LIST_CERTIFICATE_NEXT 115 572280304Sjkim# define STORE_F_STORE_LIST_CERTIFICATE_START 116 573280304Sjkim# define STORE_F_STORE_LIST_CRL_END 117 574280304Sjkim# define STORE_F_STORE_LIST_CRL_ENDP 154 575280304Sjkim# define STORE_F_STORE_LIST_CRL_NEXT 118 576280304Sjkim# define STORE_F_STORE_LIST_CRL_START 119 577280304Sjkim# define STORE_F_STORE_LIST_PRIVATE_KEY_END 120 578280304Sjkim# define STORE_F_STORE_LIST_PRIVATE_KEY_ENDP 155 579280304Sjkim# define STORE_F_STORE_LIST_PRIVATE_KEY_NEXT 121 580280304Sjkim# define STORE_F_STORE_LIST_PRIVATE_KEY_START 122 581280304Sjkim# define STORE_F_STORE_LIST_PUBLIC_KEY_END 123 582280304Sjkim# define STORE_F_STORE_LIST_PUBLIC_KEY_ENDP 156 583280304Sjkim# define STORE_F_STORE_LIST_PUBLIC_KEY_NEXT 124 584280304Sjkim# define STORE_F_STORE_LIST_PUBLIC_KEY_START 125 585280304Sjkim# define STORE_F_STORE_MODIFY_ARBITRARY 162 586280304Sjkim# define STORE_F_STORE_MODIFY_CERTIFICATE 163 587280304Sjkim# define STORE_F_STORE_MODIFY_CRL 164 588280304Sjkim# define STORE_F_STORE_MODIFY_NUMBER 165 589280304Sjkim# define STORE_F_STORE_MODIFY_PRIVATE_KEY 166 590280304Sjkim# define STORE_F_STORE_MODIFY_PUBLIC_KEY 167 591280304Sjkim# define STORE_F_STORE_NEW_ENGINE 133 592280304Sjkim# define STORE_F_STORE_NEW_METHOD 132 593280304Sjkim# define STORE_F_STORE_PARSE_ATTRS_END 151 594280304Sjkim# define STORE_F_STORE_PARSE_ATTRS_ENDP 172 595280304Sjkim# define STORE_F_STORE_PARSE_ATTRS_NEXT 152 596280304Sjkim# define STORE_F_STORE_PARSE_ATTRS_START 171 597280304Sjkim# define STORE_F_STORE_REVOKE_CERTIFICATE 129 598280304Sjkim# define STORE_F_STORE_REVOKE_PRIVATE_KEY 130 599280304Sjkim# define STORE_F_STORE_REVOKE_PUBLIC_KEY 131 600280304Sjkim# define STORE_F_STORE_STORE_ARBITRARY 157 601280304Sjkim# define STORE_F_STORE_STORE_CERTIFICATE 100 602280304Sjkim# define STORE_F_STORE_STORE_CRL 101 603280304Sjkim# define STORE_F_STORE_STORE_NUMBER 126 604280304Sjkim# define STORE_F_STORE_STORE_PRIVATE_KEY 127 605280304Sjkim# define STORE_F_STORE_STORE_PUBLIC_KEY 128 606160814Ssimon 607160814Ssimon/* Reason codes. */ 608280304Sjkim# define STORE_R_ALREADY_HAS_A_VALUE 127 609280304Sjkim# define STORE_R_FAILED_DELETING_ARBITRARY 132 610280304Sjkim# define STORE_R_FAILED_DELETING_CERTIFICATE 100 611280304Sjkim# define STORE_R_FAILED_DELETING_KEY 101 612280304Sjkim# define STORE_R_FAILED_DELETING_NUMBER 102 613280304Sjkim# define STORE_R_FAILED_GENERATING_CRL 103 614280304Sjkim# define STORE_R_FAILED_GENERATING_KEY 104 615280304Sjkim# define STORE_R_FAILED_GETTING_ARBITRARY 133 616280304Sjkim# define STORE_R_FAILED_GETTING_CERTIFICATE 105 617280304Sjkim# define STORE_R_FAILED_GETTING_KEY 106 618280304Sjkim# define STORE_R_FAILED_GETTING_NUMBER 107 619280304Sjkim# define STORE_R_FAILED_LISTING_CERTIFICATES 108 620280304Sjkim# define STORE_R_FAILED_LISTING_KEYS 109 621280304Sjkim# define STORE_R_FAILED_MODIFYING_ARBITRARY 138 622280304Sjkim# define STORE_R_FAILED_MODIFYING_CERTIFICATE 139 623280304Sjkim# define STORE_R_FAILED_MODIFYING_CRL 140 624280304Sjkim# define STORE_R_FAILED_MODIFYING_NUMBER 141 625280304Sjkim# define STORE_R_FAILED_MODIFYING_PRIVATE_KEY 142 626280304Sjkim# define STORE_R_FAILED_MODIFYING_PUBLIC_KEY 143 627280304Sjkim# define STORE_R_FAILED_REVOKING_CERTIFICATE 110 628280304Sjkim# define STORE_R_FAILED_REVOKING_KEY 111 629280304Sjkim# define STORE_R_FAILED_STORING_ARBITRARY 134 630280304Sjkim# define STORE_R_FAILED_STORING_CERTIFICATE 112 631280304Sjkim# define STORE_R_FAILED_STORING_KEY 113 632280304Sjkim# define STORE_R_FAILED_STORING_NUMBER 114 633280304Sjkim# define STORE_R_NOT_IMPLEMENTED 128 634280304Sjkim# define STORE_R_NO_CONTROL_FUNCTION 144 635280304Sjkim# define STORE_R_NO_DELETE_ARBITRARY_FUNCTION 135 636280304Sjkim# define STORE_R_NO_DELETE_NUMBER_FUNCTION 115 637280304Sjkim# define STORE_R_NO_DELETE_OBJECT_FUNCTION 116 638280304Sjkim# define STORE_R_NO_GENERATE_CRL_FUNCTION 117 639280304Sjkim# define STORE_R_NO_GENERATE_OBJECT_FUNCTION 118 640280304Sjkim# define STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION 136 641280304Sjkim# define STORE_R_NO_GET_OBJECT_FUNCTION 119 642280304Sjkim# define STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION 120 643280304Sjkim# define STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION 131 644280304Sjkim# define STORE_R_NO_LIST_OBJECT_END_FUNCTION 121 645280304Sjkim# define STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION 122 646280304Sjkim# define STORE_R_NO_LIST_OBJECT_START_FUNCTION 123 647280304Sjkim# define STORE_R_NO_MODIFY_OBJECT_FUNCTION 145 648280304Sjkim# define STORE_R_NO_REVOKE_OBJECT_FUNCTION 124 649280304Sjkim# define STORE_R_NO_STORE 129 650280304Sjkim# define STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION 137 651280304Sjkim# define STORE_R_NO_STORE_OBJECT_FUNCTION 125 652280304Sjkim# define STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION 126 653280304Sjkim# define STORE_R_NO_VALUE 130 654160814Ssimon 655160814Ssimon#ifdef __cplusplus 656160814Ssimon} 657160814Ssimon#endif 658160814Ssimon#endif 659