store.h 32 KB

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