01fa8461bf877d240aea2fb895b568c40d47c1f2
[openssl.git] / include / openssl / store.h
1 /*
2  * Written by Richard Levitte (richard@levitte.org) for the OpenSSL project
3  * 2003.
4  */
5 /* ====================================================================
6  * Copyright (c) 2003 The OpenSSL Project.  All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in
17  *    the documentation and/or other materials provided with the
18  *    distribution.
19  *
20  * 3. All advertising materials mentioning features or use of this
21  *    software must display the following acknowledgment:
22  *    "This product includes software developed by the OpenSSL Project
23  *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24  *
25  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26  *    endorse or promote products derived from this software without
27  *    prior written permission. For written permission, please contact
28  *    openssl-core@openssl.org.
29  *
30  * 5. Products derived from this software may not be called "OpenSSL"
31  *    nor may "OpenSSL" appear in their names without prior written
32  *    permission of the OpenSSL Project.
33  *
34  * 6. Redistributions of any form whatsoever must retain the following
35  *    acknowledgment:
36  *    "This product includes software developed by the OpenSSL Project
37  *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38  *
39  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
43  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50  * OF THE POSSIBILITY OF SUCH DAMAGE.
51  * ====================================================================
52  *
53  * This product includes cryptographic software written by Eric Young
54  * (eay@cryptsoft.com).  This product includes software written by Tim
55  * Hudson (tjh@cryptsoft.com).
56  *
57  */
58
59 #ifndef HEADER_STORE_H
60 # define HEADER_STORE_H
61
62 # include <openssl/opensslconf.h>
63
64 # ifdef OPENSSL_NO_STORE
65 #  error STORE is disabled.
66 # endif
67
68 # include <openssl/ossl_typ.h>
69 # if OPENSSL_API_COMPAT < 0x10100000L
70 #  include <openssl/evp.h>
71 #  include <openssl/bn.h>
72 #  include <openssl/x509.h>
73 # endif
74
75 #ifdef  __cplusplus
76 extern "C" {
77 #endif
78
79 /* Already defined in ossl_typ.h */
80 /* typedef struct store_st STORE; */
81 /* typedef struct store_method_st STORE_METHOD; */
82
83 /*
84  * All the following functions return 0, a negative number or NULL on error.
85  * When everything is fine, they return a positive value or a non-NULL
86  * pointer, all depending on their purpose.
87  */
88
89 /* Creators and destructor.   */
90 STORE *STORE_new_method(const STORE_METHOD *method);
91 STORE *STORE_new_engine(ENGINE *engine);
92 void STORE_free(STORE *ui);
93
94 /*
95  * Give a user interface parametrised control commands.  This can be used to
96  * send down an integer, a data pointer or a function pointer, as well as be
97  * used to get information from a STORE.
98  */
99 int STORE_ctrl(STORE *store, int cmd, long i, void *p, void (*f) (void));
100
101 /*
102  * A control to set the directory with keys and certificates.  Used by the
103  * built-in directory level method.
104  */
105 # define STORE_CTRL_SET_DIRECTORY        0x0001
106 /*
107  * A control to set a file to load.  Used by the built-in file level method.
108  */
109 # define STORE_CTRL_SET_FILE             0x0002
110 /*
111  * A control to set a configuration file to load.  Can be used by any method
112  * that wishes to load a configuration file.
113  */
114 # define STORE_CTRL_SET_CONF_FILE        0x0003
115 /*
116  * A control to set a the section of the loaded configuration file.  Can be
117  * used by any method that wishes to load a configuration file.
118  */
119 # define STORE_CTRL_SET_CONF_SECTION     0x0004
120
121 /* Some methods may use extra data */
122 # define STORE_set_app_data(s,arg)       STORE_set_ex_data(s,0,arg)
123 # define STORE_get_app_data(s)           STORE_get_ex_data(s,0)
124
125 #define STORE_get_ex_new_index(l, p, newf, dupf, freef) \
126     CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_STORE, l, p, newf, dupf, freef)
127 int STORE_set_ex_data(STORE *r, int idx, void *arg);
128 void *STORE_get_ex_data(STORE *r, int idx);
129
130 /* Use specific methods instead of the built-in one */
131 const STORE_METHOD *STORE_get_method(STORE *store);
132 const STORE_METHOD *STORE_set_method(STORE *store, const STORE_METHOD *meth);
133
134 /* The standard OpenSSL methods. */
135 /*
136  * This is the in-memory method.  It does everything except revoking and
137  * updating, and is of course volatile.  It's used by other methods that have
138  * an in-memory cache.
139  */
140 const STORE_METHOD *STORE_Memory(void);
141 # if 0                          /* Not yet implemented */
142 /*
143  * This is the directory store.  It does everything except revoking and
144  * updating, and uses STORE_Memory() to cache things in memory.
145  */
146 const STORE_METHOD *STORE_Directory(void);
147 /*
148  * This is the file store.  It does everything except revoking and updating,
149  * and uses STORE_Memory() to cache things in memory.  Certificates are added
150  * to it with the store operation, and it will only get cached certificates.
151  */
152 const STORE_METHOD *STORE_File(void);
153 # endif
154
155 /*
156  * Store functions take a type code for the type of data they should store or
157  * fetch
158  */
159 typedef enum STORE_object_types {
160     STORE_OBJECT_TYPE_X509_CERTIFICATE = 0x01, /* X509 * */
161     STORE_OBJECT_TYPE_X509_CRL = 0x02, /* X509_CRL * */
162     STORE_OBJECT_TYPE_PRIVATE_KEY = 0x03, /* EVP_PKEY * */
163     STORE_OBJECT_TYPE_PUBLIC_KEY = 0x04, /* EVP_PKEY * */
164     STORE_OBJECT_TYPE_NUMBER = 0x05, /* BIGNUM * */
165     STORE_OBJECT_TYPE_ARBITRARY = 0x06, /* BUF_MEM * */
166     STORE_OBJECT_TYPE_NUM = 0x06 /* The amount of known object types */
167 } STORE_OBJECT_TYPES;
168 /* List of text strings corresponding to the object types. */
169 extern const char *const STORE_object_type_string[STORE_OBJECT_TYPE_NUM + 1];
170
171 /*
172  * Some store functions take a parameter list.  Those parameters come with
173  * one of the following codes. The comments following the codes below
174  * indicate what type the value should be a pointer to.
175  */
176 typedef enum STORE_params {
177     STORE_PARAM_EVP_TYPE = 0x01, /* int */
178     STORE_PARAM_BITS = 0x02,    /* size_t */
179     STORE_PARAM_KEY_PARAMETERS = 0x03, /* ??? */
180     STORE_PARAM_KEY_NO_PARAMETERS = 0x04, /* N/A */
181     STORE_PARAM_AUTH_PASSPHRASE = 0x05, /* char * */
182     STORE_PARAM_TYPE_NUM = 0x05 /* The amount of known parameter types */
183 } STORE_PARAM_TYPES;
184 /*
185  * Parameter value sizes.  -1 means unknown, anything else is the required
186  * size.
187  */
188 extern const int STORE_param_sizes[STORE_PARAM_TYPE_NUM + 1];
189
190 /*
191  * Store functions take attribute lists.  Those attributes come with codes.
192  * The comments following the codes below indicate what type the value should
193  * be a pointer to.
194  */
195 typedef enum STORE_attribs {
196     STORE_ATTR_END = 0x00,
197     STORE_ATTR_FRIENDLYNAME = 0x01, /* C string */
198     STORE_ATTR_KEYID = 0x02,    /* 160 bit string (SHA1) */
199     STORE_ATTR_ISSUERKEYID = 0x03, /* 160 bit string (SHA1) */
200     STORE_ATTR_SUBJECTKEYID = 0x04, /* 160 bit string (SHA1) */
201     STORE_ATTR_ISSUERSERIALHASH = 0x05, /* 160 bit string (SHA1) */
202     STORE_ATTR_ISSUER = 0x06,   /* X509_NAME * */
203     STORE_ATTR_SERIAL = 0x07,   /* BIGNUM * */
204     STORE_ATTR_SUBJECT = 0x08,  /* X509_NAME * */
205     STORE_ATTR_CERTHASH = 0x09, /* 160 bit string (SHA1) */
206     STORE_ATTR_EMAIL = 0x0a,    /* C string */
207     STORE_ATTR_FILENAME = 0x0b, /* C string */
208     STORE_ATTR_TYPE_NUM = 0x0b, /* The amount of known attribute types */
209     STORE_ATTR_OR = 0xff        /* This is a special separator, which
210                                  * expresses the OR operation.  */
211 } STORE_ATTR_TYPES;
212 /*
213  * Attribute value sizes.  -1 means unknown, anything else is the required
214  * size.
215  */
216 extern const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM + 1];
217
218 typedef enum STORE_certificate_status {
219     STORE_X509_VALID = 0x00,
220     STORE_X509_EXPIRED = 0x01,
221     STORE_X509_SUSPENDED = 0x02,
222     STORE_X509_REVOKED = 0x03
223 } STORE_CERTIFICATE_STATUS;
224
225 /*
226  * Engine store functions will return a structure that contains all the
227  * necessary information, including revokation status for certificates.  This
228  * is really not needed for application authors, as the ENGINE framework
229  * functions will extract the OpenSSL-specific information when at all
230  * possible.  However, for engine authors, it's crucial to know this
231  * structure.
232  */
233 typedef struct STORE_OBJECT_st {
234     STORE_OBJECT_TYPES type;
235     union {
236         struct {
237             STORE_CERTIFICATE_STATUS status;
238             X509 *certificate;
239         } x509;
240         X509_CRL *crl;
241         EVP_PKEY *key;
242         BIGNUM *number;
243         BUF_MEM *arbitrary;
244     } data;
245 } STORE_OBJECT;
246 DEFINE_STACK_OF(STORE_OBJECT)
247 STORE_OBJECT *STORE_OBJECT_new(void);
248 void STORE_OBJECT_free(STORE_OBJECT *data);
249
250 /* A generic structure to pass assorted data in a expandable way */
251 typedef struct openssl_item_st {
252     int code;
253     void *value;                /* Not used for flag attributes */
254     size_t value_size;          /* Max size of value for output, length for
255                                  * input */
256     size_t *value_length;       /* Returned length of value for output */
257 } OPENSSL_ITEM;
258
259 /*
260  * The following functions handle the storage. They return 0, a negative
261  * number or NULL on error, anything else on success.
262  */
263 X509 *STORE_get_certificate(STORE *e, OPENSSL_ITEM attributes[],
264                             OPENSSL_ITEM parameters[]);
265 int STORE_store_certificate(STORE *e, X509 *data, OPENSSL_ITEM attributes[],
266                             OPENSSL_ITEM parameters[]);
267 int STORE_modify_certificate(STORE *e, OPENSSL_ITEM search_attributes[],
268                              OPENSSL_ITEM add_attributes[],
269                              OPENSSL_ITEM modify_attributes[],
270                              OPENSSL_ITEM delete_attributes[],
271                              OPENSSL_ITEM parameters[]);
272 int STORE_revoke_certificate(STORE *e, OPENSSL_ITEM attributes[],
273                              OPENSSL_ITEM parameters[]);
274 int STORE_delete_certificate(STORE *e, OPENSSL_ITEM attributes[],
275                              OPENSSL_ITEM parameters[]);
276 void *STORE_list_certificate_start(STORE *e, OPENSSL_ITEM attributes[],
277                                    OPENSSL_ITEM parameters[]);
278 X509 *STORE_list_certificate_next(STORE *e, void *handle);
279 int STORE_list_certificate_end(STORE *e, void *handle);
280 int STORE_list_certificate_endp(STORE *e, void *handle);
281 EVP_PKEY *STORE_generate_key(STORE *e, OPENSSL_ITEM attributes[],
282                              OPENSSL_ITEM parameters[]);
283 EVP_PKEY *STORE_get_private_key(STORE *e, OPENSSL_ITEM attributes[],
284                                 OPENSSL_ITEM parameters[]);
285 int STORE_store_private_key(STORE *e, EVP_PKEY *data,
286                             OPENSSL_ITEM attributes[],
287                             OPENSSL_ITEM parameters[]);
288 int STORE_modify_private_key(STORE *e, OPENSSL_ITEM search_attributes[],
289                              OPENSSL_ITEM add_sttributes[],
290                              OPENSSL_ITEM modify_attributes[],
291                              OPENSSL_ITEM delete_attributes[],
292                              OPENSSL_ITEM parameters[]);
293 int STORE_revoke_private_key(STORE *e, OPENSSL_ITEM attributes[],
294                              OPENSSL_ITEM parameters[]);
295 int STORE_delete_private_key(STORE *e, OPENSSL_ITEM attributes[],
296                              OPENSSL_ITEM parameters[]);
297 void *STORE_list_private_key_start(STORE *e, OPENSSL_ITEM attributes[],
298                                    OPENSSL_ITEM parameters[]);
299 EVP_PKEY *STORE_list_private_key_next(STORE *e, void *handle);
300 int STORE_list_private_key_end(STORE *e, void *handle);
301 int STORE_list_private_key_endp(STORE *e, void *handle);
302 EVP_PKEY *STORE_get_public_key(STORE *e, OPENSSL_ITEM attributes[],
303                                OPENSSL_ITEM parameters[]);
304 int STORE_store_public_key(STORE *e, EVP_PKEY *data,
305                            OPENSSL_ITEM attributes[],
306                            OPENSSL_ITEM parameters[]);
307 int STORE_modify_public_key(STORE *e, OPENSSL_ITEM search_attributes[],
308                             OPENSSL_ITEM add_sttributes[],
309                             OPENSSL_ITEM modify_attributes[],
310                             OPENSSL_ITEM delete_attributes[],
311                             OPENSSL_ITEM parameters[]);
312 int STORE_revoke_public_key(STORE *e, OPENSSL_ITEM attributes[],
313                             OPENSSL_ITEM parameters[]);
314 int STORE_delete_public_key(STORE *e, OPENSSL_ITEM attributes[],
315                             OPENSSL_ITEM parameters[]);
316 void *STORE_list_public_key_start(STORE *e, OPENSSL_ITEM attributes[],
317                                   OPENSSL_ITEM parameters[]);
318 EVP_PKEY *STORE_list_public_key_next(STORE *e, void *handle);
319 int STORE_list_public_key_end(STORE *e, void *handle);
320 int STORE_list_public_key_endp(STORE *e, void *handle);
321 X509_CRL *STORE_generate_crl(STORE *e, OPENSSL_ITEM attributes[],
322                              OPENSSL_ITEM parameters[]);
323 X509_CRL *STORE_get_crl(STORE *e, OPENSSL_ITEM attributes[],
324                         OPENSSL_ITEM parameters[]);
325 int STORE_store_crl(STORE *e, X509_CRL *data, OPENSSL_ITEM attributes[],
326                     OPENSSL_ITEM parameters[]);
327 int STORE_modify_crl(STORE *e, OPENSSL_ITEM search_attributes[],
328                      OPENSSL_ITEM add_sttributes[],
329                      OPENSSL_ITEM modify_attributes[],
330                      OPENSSL_ITEM delete_attributes[],
331                      OPENSSL_ITEM parameters[]);
332 int STORE_delete_crl(STORE *e, OPENSSL_ITEM attributes[],
333                      OPENSSL_ITEM parameters[]);
334 void *STORE_list_crl_start(STORE *e, OPENSSL_ITEM attributes[],
335                            OPENSSL_ITEM parameters[]);
336 X509_CRL *STORE_list_crl_next(STORE *e, void *handle);
337 int STORE_list_crl_end(STORE *e, void *handle);
338 int STORE_list_crl_endp(STORE *e, void *handle);
339 int STORE_store_number(STORE *e, BIGNUM *data, OPENSSL_ITEM attributes[],
340                        OPENSSL_ITEM parameters[]);
341 int STORE_modify_number(STORE *e, OPENSSL_ITEM search_attributes[],
342                         OPENSSL_ITEM add_sttributes[],
343                         OPENSSL_ITEM modify_attributes[],
344                         OPENSSL_ITEM delete_attributes[],
345                         OPENSSL_ITEM parameters[]);
346 BIGNUM *STORE_get_number(STORE *e, OPENSSL_ITEM attributes[],
347                          OPENSSL_ITEM parameters[]);
348 int STORE_delete_number(STORE *e, OPENSSL_ITEM attributes[],
349                         OPENSSL_ITEM parameters[]);
350 int STORE_store_arbitrary(STORE *e, BUF_MEM *data, OPENSSL_ITEM attributes[],
351                           OPENSSL_ITEM parameters[]);
352 int STORE_modify_arbitrary(STORE *e, OPENSSL_ITEM search_attributes[],
353                            OPENSSL_ITEM add_sttributes[],
354                            OPENSSL_ITEM modify_attributes[],
355                            OPENSSL_ITEM delete_attributes[],
356                            OPENSSL_ITEM parameters[]);
357 BUF_MEM *STORE_get_arbitrary(STORE *e, OPENSSL_ITEM attributes[],
358                              OPENSSL_ITEM parameters[]);
359 int STORE_delete_arbitrary(STORE *e, OPENSSL_ITEM attributes[],
360                            OPENSSL_ITEM parameters[]);
361
362 /* Create and manipulate methods */
363 STORE_METHOD *STORE_create_method(char *name);
364 void STORE_destroy_method(STORE_METHOD *store_method);
365
366 /* These callback types are use for store handlers */
367 typedef int (*STORE_INITIALISE_FUNC_PTR) (STORE *);
368 typedef void (*STORE_CLEANUP_FUNC_PTR) (STORE *);
369 typedef STORE_OBJECT *(*STORE_GENERATE_OBJECT_FUNC_PTR)(STORE *,
370                                                         STORE_OBJECT_TYPES
371                                                         type,
372                                                         OPENSSL_ITEM
373                                                         attributes[],
374                                                         OPENSSL_ITEM
375                                                         parameters[]);
376 typedef STORE_OBJECT *(*STORE_GET_OBJECT_FUNC_PTR)(STORE *,
377                                                    STORE_OBJECT_TYPES type,
378                                                    OPENSSL_ITEM attributes[],
379                                                    OPENSSL_ITEM parameters[]);
380 typedef void *(*STORE_START_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type,
381                                              OPENSSL_ITEM attributes[],
382                                              OPENSSL_ITEM parameters[]);
383 typedef STORE_OBJECT *(*STORE_NEXT_OBJECT_FUNC_PTR)(STORE *, void *handle);
384 typedef int (*STORE_END_OBJECT_FUNC_PTR) (STORE *, void *handle);
385 typedef int (*STORE_HANDLE_OBJECT_FUNC_PTR) (STORE *, STORE_OBJECT_TYPES type,
386                                              OPENSSL_ITEM attributes[],
387                                              OPENSSL_ITEM parameters[]);
388 typedef int (*STORE_STORE_OBJECT_FUNC_PTR) (STORE *, STORE_OBJECT_TYPES type,
389                                             STORE_OBJECT *data,
390                                             OPENSSL_ITEM attributes[],
391                                             OPENSSL_ITEM parameters[]);
392 typedef int (*STORE_MODIFY_OBJECT_FUNC_PTR) (STORE *, STORE_OBJECT_TYPES type,
393                                              OPENSSL_ITEM search_attributes[],
394                                              OPENSSL_ITEM add_attributes[],
395                                              OPENSSL_ITEM modify_attributes[],
396                                              OPENSSL_ITEM delete_attributes[],
397                                              OPENSSL_ITEM parameters[]);
398 typedef int (*STORE_GENERIC_FUNC_PTR) (STORE *, OPENSSL_ITEM attributes[],
399                                        OPENSSL_ITEM parameters[]);
400 typedef int (*STORE_CTRL_FUNC_PTR) (STORE *, int cmd, long l, void *p,
401                                     void (*f) (void));
402
403 int STORE_method_set_initialise_function(STORE_METHOD *sm,
404                                          STORE_INITIALISE_FUNC_PTR init_f);
405 int STORE_method_set_cleanup_function(STORE_METHOD *sm,
406                                       STORE_CLEANUP_FUNC_PTR clean_f);
407 int STORE_method_set_generate_function(STORE_METHOD *sm,
408                                        STORE_GENERATE_OBJECT_FUNC_PTR
409                                        generate_f);
410 int STORE_method_set_get_function(STORE_METHOD *sm,
411                                   STORE_GET_OBJECT_FUNC_PTR get_f);
412 int STORE_method_set_store_function(STORE_METHOD *sm,
413                                     STORE_STORE_OBJECT_FUNC_PTR store_f);
414 int STORE_method_set_modify_function(STORE_METHOD *sm,
415                                      STORE_MODIFY_OBJECT_FUNC_PTR store_f);
416 int STORE_method_set_revoke_function(STORE_METHOD *sm,
417                                      STORE_HANDLE_OBJECT_FUNC_PTR revoke_f);
418 int STORE_method_set_delete_function(STORE_METHOD *sm,
419                                      STORE_HANDLE_OBJECT_FUNC_PTR delete_f);
420 int STORE_method_set_list_start_function(STORE_METHOD *sm,
421                                          STORE_START_OBJECT_FUNC_PTR
422                                          list_start_f);
423 int STORE_method_set_list_next_function(STORE_METHOD *sm,
424                                         STORE_NEXT_OBJECT_FUNC_PTR
425                                         list_next_f);
426 int STORE_method_set_list_end_function(STORE_METHOD *sm,
427                                        STORE_END_OBJECT_FUNC_PTR list_end_f);
428 int STORE_method_set_update_store_function(STORE_METHOD *sm,
429                                            STORE_GENERIC_FUNC_PTR);
430 int STORE_method_set_lock_store_function(STORE_METHOD *sm,
431                                          STORE_GENERIC_FUNC_PTR);
432 int STORE_method_set_unlock_store_function(STORE_METHOD *sm,
433                                            STORE_GENERIC_FUNC_PTR);
434 int STORE_method_set_ctrl_function(STORE_METHOD *sm,
435                                    STORE_CTRL_FUNC_PTR ctrl_f);
436
437 STORE_INITIALISE_FUNC_PTR STORE_method_get_initialise_function(STORE_METHOD
438                                                                *sm);
439 STORE_CLEANUP_FUNC_PTR STORE_method_get_cleanup_function(STORE_METHOD *sm);
440 STORE_GENERATE_OBJECT_FUNC_PTR STORE_method_get_generate_function(STORE_METHOD
441                                                                   *sm);
442 STORE_GET_OBJECT_FUNC_PTR STORE_method_get_get_function(STORE_METHOD *sm);
443 STORE_STORE_OBJECT_FUNC_PTR STORE_method_get_store_function(STORE_METHOD *sm);
444 STORE_MODIFY_OBJECT_FUNC_PTR STORE_method_get_modify_function(STORE_METHOD
445                                                               *sm);
446 STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_revoke_function(STORE_METHOD
447                                                               *sm);
448 STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_delete_function(STORE_METHOD
449                                                               *sm);
450 STORE_START_OBJECT_FUNC_PTR STORE_method_get_list_start_function(STORE_METHOD
451                                                                  *sm);
452 STORE_NEXT_OBJECT_FUNC_PTR STORE_method_get_list_next_function(STORE_METHOD
453                                                                *sm);
454 STORE_END_OBJECT_FUNC_PTR STORE_method_get_list_end_function(STORE_METHOD
455                                                              *sm);
456 STORE_GENERIC_FUNC_PTR STORE_method_get_update_store_function(STORE_METHOD
457                                                               *sm);
458 STORE_GENERIC_FUNC_PTR STORE_method_get_lock_store_function(STORE_METHOD *sm);
459 STORE_GENERIC_FUNC_PTR STORE_method_get_unlock_store_function(STORE_METHOD
460                                                               *sm);
461 STORE_CTRL_FUNC_PTR STORE_method_get_ctrl_function(STORE_METHOD *sm);
462
463 /* Method helper structures and functions. */
464
465 /*
466  * This structure is the result of parsing through the information in a list
467  * of OPENSSL_ITEMs.  It stores all the necessary information in a structured
468  * way.
469  */
470 typedef struct STORE_attr_info_st STORE_ATTR_INFO;
471
472 /*
473  * Parse a list of OPENSSL_ITEMs and return a pointer to a STORE_ATTR_INFO.
474  * Note that we do this in the list form, since the list of OPENSSL_ITEMs can
475  * come in blocks separated with STORE_ATTR_OR.  Note that the value returned
476  * by STORE_parse_attrs_next() must be freed with STORE_ATTR_INFO_free().
477  */
478 void *STORE_parse_attrs_start(OPENSSL_ITEM *attributes);
479 STORE_ATTR_INFO *STORE_parse_attrs_next(void *handle);
480 int STORE_parse_attrs_end(void *handle);
481 int STORE_parse_attrs_endp(void *handle);
482
483 /* Creator and destructor */
484 STORE_ATTR_INFO *STORE_ATTR_INFO_new(void);
485 int STORE_ATTR_INFO_free(STORE_ATTR_INFO *attrs);
486
487 /* Manipulators */
488 char *STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs,
489                                 STORE_ATTR_TYPES code);
490 unsigned char *STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs,
491                                             STORE_ATTR_TYPES code);
492 X509_NAME *STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs,
493                                    STORE_ATTR_TYPES code);
494 BIGNUM *STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs,
495                                     STORE_ATTR_TYPES code);
496 int STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
497                              char *cstr, size_t cstr_size);
498 int STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
499                                 unsigned char *sha1str, size_t sha1str_size);
500 int STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
501                            X509_NAME *dn);
502 int STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
503                                BIGNUM *number);
504 int STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
505                                 char *cstr, size_t cstr_size);
506 int STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs,
507                                    STORE_ATTR_TYPES code,
508                                    unsigned char *sha1str,
509                                    size_t sha1str_size);
510 int STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
511                               X509_NAME *dn);
512 int STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs,
513                                   STORE_ATTR_TYPES code, BIGNUM *number);
514
515 /*
516  * Compare on basis of a bit pattern formed by the STORE_ATTR_TYPES values in
517  * each contained attribute.
518  */
519 int STORE_ATTR_INFO_compare(const STORE_ATTR_INFO *const *a,
520                             const STORE_ATTR_INFO *const *b);
521 /*
522  * Check if the set of attributes in a is within the range of attributes set
523  * in b.
524  */
525 int STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b);
526 /* Check if the set of attributes in a are also set in b. */
527 int STORE_ATTR_INFO_in(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b);
528 /* Same as STORE_ATTR_INFO_in(), but also checks the attribute values. */
529 int STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b);
530
531 /* BEGIN ERROR CODES */
532 /*
533  * The following lines are auto generated by the script mkerr.pl. Any changes
534  * made after this point may be overwritten when the script is next run.
535  */
536 void ERR_load_STORE_strings(void);
537
538 /* Error codes for the STORE functions. */
539
540 /* Function codes. */
541 # define STORE_F_MEM_DELETE                               134
542 # define STORE_F_MEM_GENERATE                             135
543 # define STORE_F_MEM_LIST_END                             168
544 # define STORE_F_MEM_LIST_NEXT                            136
545 # define STORE_F_MEM_LIST_START                           137
546 # define STORE_F_MEM_MODIFY                               169
547 # define STORE_F_MEM_STORE                                138
548 # define STORE_F_STORE_ATTR_INFO_GET0_CSTR                139
549 # define STORE_F_STORE_ATTR_INFO_GET0_DN                  140
550 # define STORE_F_STORE_ATTR_INFO_GET0_NUMBER              141
551 # define STORE_F_STORE_ATTR_INFO_GET0_SHA1STR             142
552 # define STORE_F_STORE_ATTR_INFO_MODIFY_CSTR              143
553 # define STORE_F_STORE_ATTR_INFO_MODIFY_DN                144
554 # define STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER            145
555 # define STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR           146
556 # define STORE_F_STORE_ATTR_INFO_SET_CSTR                 147
557 # define STORE_F_STORE_ATTR_INFO_SET_DN                   148
558 # define STORE_F_STORE_ATTR_INFO_SET_NUMBER               149
559 # define STORE_F_STORE_ATTR_INFO_SET_SHA1STR              150
560 # define STORE_F_STORE_CERTIFICATE                        170
561 # define STORE_F_STORE_CTRL                               161
562 # define STORE_F_STORE_DELETE_ARBITRARY                   158
563 # define STORE_F_STORE_DELETE_CERTIFICATE                 102
564 # define STORE_F_STORE_DELETE_CRL                         103
565 # define STORE_F_STORE_DELETE_NUMBER                      104
566 # define STORE_F_STORE_DELETE_PRIVATE_KEY                 105
567 # define STORE_F_STORE_DELETE_PUBLIC_KEY                  106
568 # define STORE_F_STORE_GENERATE_CRL                       107
569 # define STORE_F_STORE_GENERATE_KEY                       108
570 # define STORE_F_STORE_GET_ARBITRARY                      159
571 # define STORE_F_STORE_GET_CERTIFICATE                    109
572 # define STORE_F_STORE_GET_CRL                            110
573 # define STORE_F_STORE_GET_NUMBER                         111
574 # define STORE_F_STORE_GET_PRIVATE_KEY                    112
575 # define STORE_F_STORE_GET_PUBLIC_KEY                     113
576 # define STORE_F_STORE_LIST_CERTIFICATE_END               114
577 # define STORE_F_STORE_LIST_CERTIFICATE_ENDP              153
578 # define STORE_F_STORE_LIST_CERTIFICATE_NEXT              115
579 # define STORE_F_STORE_LIST_CERTIFICATE_START             116
580 # define STORE_F_STORE_LIST_CRL_END                       117
581 # define STORE_F_STORE_LIST_CRL_ENDP                      154
582 # define STORE_F_STORE_LIST_CRL_NEXT                      118
583 # define STORE_F_STORE_LIST_CRL_START                     119
584 # define STORE_F_STORE_LIST_PRIVATE_KEY_END               120
585 # define STORE_F_STORE_LIST_PRIVATE_KEY_ENDP              155
586 # define STORE_F_STORE_LIST_PRIVATE_KEY_NEXT              121
587 # define STORE_F_STORE_LIST_PRIVATE_KEY_START             122
588 # define STORE_F_STORE_LIST_PUBLIC_KEY_END                123
589 # define STORE_F_STORE_LIST_PUBLIC_KEY_ENDP               156
590 # define STORE_F_STORE_LIST_PUBLIC_KEY_NEXT               124
591 # define STORE_F_STORE_LIST_PUBLIC_KEY_START              125
592 # define STORE_F_STORE_MODIFY_ARBITRARY                   162
593 # define STORE_F_STORE_MODIFY_CERTIFICATE                 163
594 # define STORE_F_STORE_MODIFY_CRL                         164
595 # define STORE_F_STORE_MODIFY_NUMBER                      165
596 # define STORE_F_STORE_MODIFY_PRIVATE_KEY                 166
597 # define STORE_F_STORE_MODIFY_PUBLIC_KEY                  167
598 # define STORE_F_STORE_NEW_ENGINE                         133
599 # define STORE_F_STORE_NEW_METHOD                         132
600 # define STORE_F_STORE_PARSE_ATTRS_END                    151
601 # define STORE_F_STORE_PARSE_ATTRS_ENDP                   172
602 # define STORE_F_STORE_PARSE_ATTRS_NEXT                   152
603 # define STORE_F_STORE_PARSE_ATTRS_START                  171
604 # define STORE_F_STORE_REVOKE_CERTIFICATE                 129
605 # define STORE_F_STORE_REVOKE_PRIVATE_KEY                 130
606 # define STORE_F_STORE_REVOKE_PUBLIC_KEY                  131
607 # define STORE_F_STORE_STORE_ARBITRARY                    157
608 # define STORE_F_STORE_STORE_CERTIFICATE                  100
609 # define STORE_F_STORE_STORE_CRL                          101
610 # define STORE_F_STORE_STORE_NUMBER                       126
611 # define STORE_F_STORE_STORE_PRIVATE_KEY                  127
612 # define STORE_F_STORE_STORE_PUBLIC_KEY                   128
613
614 /* Reason codes. */
615 # define STORE_R_ALREADY_HAS_A_VALUE                      127
616 # define STORE_R_FAILED_DELETING_ARBITRARY                132
617 # define STORE_R_FAILED_DELETING_CERTIFICATE              100
618 # define STORE_R_FAILED_DELETING_KEY                      101
619 # define STORE_R_FAILED_DELETING_NUMBER                   102
620 # define STORE_R_FAILED_GENERATING_CRL                    103
621 # define STORE_R_FAILED_GENERATING_KEY                    104
622 # define STORE_R_FAILED_GETTING_ARBITRARY                 133
623 # define STORE_R_FAILED_GETTING_CERTIFICATE               105
624 # define STORE_R_FAILED_GETTING_KEY                       106
625 # define STORE_R_FAILED_GETTING_NUMBER                    107
626 # define STORE_R_FAILED_LISTING_CERTIFICATES              108
627 # define STORE_R_FAILED_LISTING_KEYS                      109
628 # define STORE_R_FAILED_MODIFYING_ARBITRARY               138
629 # define STORE_R_FAILED_MODIFYING_CERTIFICATE             139
630 # define STORE_R_FAILED_MODIFYING_CRL                     140
631 # define STORE_R_FAILED_MODIFYING_NUMBER                  141
632 # define STORE_R_FAILED_MODIFYING_PRIVATE_KEY             142
633 # define STORE_R_FAILED_MODIFYING_PUBLIC_KEY              143
634 # define STORE_R_FAILED_REVOKING_CERTIFICATE              110
635 # define STORE_R_FAILED_REVOKING_KEY                      111
636 # define STORE_R_FAILED_STORING_ARBITRARY                 134
637 # define STORE_R_FAILED_STORING_CERTIFICATE               112
638 # define STORE_R_FAILED_STORING_KEY                       113
639 # define STORE_R_FAILED_STORING_NUMBER                    114
640 # define STORE_R_NOT_IMPLEMENTED                          128
641 # define STORE_R_NO_CONTROL_FUNCTION                      144
642 # define STORE_R_NO_DELETE_ARBITRARY_FUNCTION             135
643 # define STORE_R_NO_DELETE_NUMBER_FUNCTION                115
644 # define STORE_R_NO_DELETE_OBJECT_FUNCTION                116
645 # define STORE_R_NO_GENERATE_CRL_FUNCTION                 117
646 # define STORE_R_NO_GENERATE_OBJECT_FUNCTION              118
647 # define STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION         136
648 # define STORE_R_NO_GET_OBJECT_FUNCTION                   119
649 # define STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION            120
650 # define STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION             131
651 # define STORE_R_NO_LIST_OBJECT_END_FUNCTION              121
652 # define STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION             122
653 # define STORE_R_NO_LIST_OBJECT_START_FUNCTION            123
654 # define STORE_R_NO_MODIFY_OBJECT_FUNCTION                145
655 # define STORE_R_NO_REVOKE_OBJECT_FUNCTION                124
656 # define STORE_R_NO_STORE                                 129
657 # define STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION       137
658 # define STORE_R_NO_STORE_OBJECT_FUNCTION                 125
659 # define STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION          126
660 # define STORE_R_NO_VALUE                                 130
661
662 #ifdef  __cplusplus
663 }
664 #endif
665 #endif