OSSL_STORE_LOADER.pod 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. =pod
  2. =head1 NAME
  3. OSSL_STORE_LOADER,
  4. OSSL_STORE_LOADER_fetch,
  5. OSSL_STORE_LOADER_up_ref,
  6. OSSL_STORE_LOADER_free,
  7. OSSL_STORE_LOADER_provider,
  8. OSSL_STORE_LOADER_properties,
  9. OSSL_STORE_LOADER_is_a,
  10. OSSL_STORE_LOADER_number,
  11. OSSL_STORE_LOADER_do_all_provided,
  12. OSSL_STORE_LOADER_names_do_all,
  13. OSSL_STORE_LOADER_CTX, OSSL_STORE_LOADER_new,
  14. OSSL_STORE_LOADER_get0_engine, OSSL_STORE_LOADER_get0_scheme,
  15. OSSL_STORE_LOADER_set_open, OSSL_STORE_LOADER_set_open_ex,
  16. OSSL_STORE_LOADER_set_attach, OSSL_STORE_LOADER_set_ctrl,
  17. OSSL_STORE_LOADER_set_expect, OSSL_STORE_LOADER_set_find,
  18. OSSL_STORE_LOADER_set_load, OSSL_STORE_LOADER_set_eof,
  19. OSSL_STORE_LOADER_set_error, OSSL_STORE_LOADER_set_close,
  20. OSSL_STORE_register_loader, OSSL_STORE_unregister_loader,
  21. OSSL_STORE_open_fn, OSSL_STORE_open_ex_fn,
  22. OSSL_STORE_attach_fn, OSSL_STORE_ctrl_fn,
  23. OSSL_STORE_expect_fn, OSSL_STORE_find_fn,
  24. OSSL_STORE_load_fn, OSSL_STORE_eof_fn, OSSL_STORE_error_fn,
  25. OSSL_STORE_close_fn - Types and functions to manipulate, register and
  26. unregister STORE loaders for different URI schemes
  27. =head1 SYNOPSIS
  28. #include <openssl/store.h>
  29. typedef struct ossl_store_loader_st OSSL_STORE_LOADER;
  30. OSSL_STORE_LOADER *OSSL_STORE_LOADER_fetch(const char *scheme,
  31. OSSL_LIB_CTX *libctx,
  32. const char *properties);
  33. int OSSL_STORE_LOADER_up_ref(OSSL_STORE_LOADER *loader);
  34. void OSSL_STORE_LOADER_free(OSSL_STORE_LOADER *loader);
  35. const OSSL_PROVIDER *OSSL_STORE_LOADER_provider(const OSSL_STORE_LOADER *
  36. loader);
  37. const char *OSSL_STORE_LOADER_properties(const OSSL_STORE_LOADER *loader);
  38. int OSSL_STORE_LOADER_number(const OSSL_STORE_LOADER *loader);
  39. int OSSL_STORE_LOADER_is_a(const OSSL_STORE_LOADER *loader,
  40. const char *scheme);
  41. void OSSL_STORE_LOADER_do_all_provided(OSSL_LIB_CTX *libctx,
  42. void (*fn)(OSSL_STORE_LOADER *loader,
  43. void *arg),
  44. void *arg);
  45. void OSSL_STORE_LOADER_names_do_all(const OSSL_STORE_LOADER *loader,
  46. void (*fn)(const char *name, void *data),
  47. void *data);
  48. Deprecated since OpenSSL 3.0, can be hidden entirely by defining
  49. B<OPENSSL_API_COMPAT> with a suitable version value, see
  50. L<openssl_user_macros(7)>:
  51. OSSL_STORE_LOADER *OSSL_STORE_LOADER_new(ENGINE *e, const char *scheme);
  52. const ENGINE *OSSL_STORE_LOADER_get0_engine(const OSSL_STORE_LOADER
  53. *store_loader);
  54. const char *OSSL_STORE_LOADER_get0_scheme(const OSSL_STORE_LOADER
  55. *store_loader);
  56. /* struct ossl_store_loader_ctx_st is defined differently by each loader */
  57. typedef struct ossl_store_loader_ctx_st OSSL_STORE_LOADER_CTX;
  58. typedef OSSL_STORE_LOADER_CTX *(*OSSL_STORE_open_fn)(
  59. const char *uri, const UI_METHOD *ui_method, void *ui_data);
  60. int OSSL_STORE_LOADER_set_open(OSSL_STORE_LOADER *store_loader,
  61. OSSL_STORE_open_fn store_open_function);
  62. typedef OSSL_STORE_LOADER_CTX *(*OSSL_STORE_open_ex_fn)(
  63. const char *uri, const UI_METHOD *ui_method, void *ui_data);
  64. int OSSL_STORE_LOADER_set_open_ex
  65. (OSSL_STORE_LOADER *store_loader,
  66. OSSL_STORE_open_ex_fn store_open_ex_function);
  67. typedef OSSL_STORE_LOADER_CTX *(*OSSL_STORE_attach_fn)
  68. (const OSSL_STORE_LOADER *loader, BIO *bio,
  69. OSSL_LIB_CTX *libctx, const char *propq,
  70. const UI_METHOD *ui_method, void *ui_data);
  71. int OSSL_STORE_LOADER_set_attach(OSSL_STORE_LOADER *loader,
  72. OSSL_STORE_attach_fn attach_function);
  73. typedef int (*OSSL_STORE_ctrl_fn)(OSSL_STORE_LOADER_CTX *ctx, int cmd,
  74. va_list args);
  75. int OSSL_STORE_LOADER_set_ctrl(OSSL_STORE_LOADER *store_loader,
  76. OSSL_STORE_ctrl_fn store_ctrl_function);
  77. typedef int (*OSSL_STORE_expect_fn)(OSSL_STORE_LOADER_CTX *ctx, int expected);
  78. int OSSL_STORE_LOADER_set_expect(OSSL_STORE_LOADER *loader,
  79. OSSL_STORE_expect_fn expect_function);
  80. typedef int (*OSSL_STORE_find_fn)(OSSL_STORE_LOADER_CTX *ctx,
  81. OSSL_STORE_SEARCH *criteria);
  82. int OSSL_STORE_LOADER_set_find(OSSL_STORE_LOADER *loader,
  83. OSSL_STORE_find_fn find_function);
  84. typedef OSSL_STORE_INFO *(*OSSL_STORE_load_fn)(OSSL_STORE_LOADER_CTX *ctx,
  85. UI_METHOD *ui_method,
  86. void *ui_data);
  87. int OSSL_STORE_LOADER_set_load(OSSL_STORE_LOADER *store_loader,
  88. OSSL_STORE_load_fn store_load_function);
  89. typedef int (*OSSL_STORE_eof_fn)(OSSL_STORE_LOADER_CTX *ctx);
  90. int OSSL_STORE_LOADER_set_eof(OSSL_STORE_LOADER *store_loader,
  91. OSSL_STORE_eof_fn store_eof_function);
  92. typedef int (*OSSL_STORE_error_fn)(OSSL_STORE_LOADER_CTX *ctx);
  93. int OSSL_STORE_LOADER_set_error(OSSL_STORE_LOADER *store_loader,
  94. OSSL_STORE_error_fn store_error_function);
  95. typedef int (*OSSL_STORE_close_fn)(OSSL_STORE_LOADER_CTX *ctx);
  96. int OSSL_STORE_LOADER_set_close(OSSL_STORE_LOADER *store_loader,
  97. OSSL_STORE_close_fn store_close_function);
  98. void OSSL_STORE_LOADER_free(OSSL_STORE_LOADER *store_loader);
  99. int OSSL_STORE_register_loader(OSSL_STORE_LOADER *loader);
  100. OSSL_STORE_LOADER *OSSL_STORE_unregister_loader(const char *scheme);
  101. =head1 DESCRIPTION
  102. B<OSSL_STORE_LOADER> is a method for OSSL_STORE loaders, which implement
  103. OSSL_STORE_open(), OSSL_STORE_open_ex(), OSSL_STORE_load(),
  104. OSSL_STORE_eof(), OSSL_STORE_error() and OSSL_STORE_close() for specific
  105. storage schemes.
  106. OSSL_STORE_LOADER_fetch() looks for an implementation for a storage
  107. I<scheme> within the providers that has been loaded into the B<OSSL_LIB_CTX>
  108. given by I<ctx>, and with the properties given by I<properties>.
  109. OSSL_STORE_LOADER_up_ref() increments the reference count for the given
  110. I<loader>.
  111. OSSL_STORE_LOADER_free() decrements the reference count for the given
  112. I<loader>, and when the count reaches zero, frees it.
  113. OSSL_STORE_LOADER_provider() returns the provider of the given
  114. I<loader>.
  115. OSSL_STORE_LOADER_properties() returns the property definition associated
  116. with the given I<loader>.
  117. OSSL_STORE_LOADER_is_a() checks if I<loader> is an implementation
  118. of an algorithm that's identifiable with I<scheme>.
  119. OSSL_STORE_LOADER_number() returns the internal dynamic number assigned
  120. to the given I<loader>.
  121. OSSL_STORE_LOADER_do_all_provided() traverses all store implementations
  122. by all activated providers in the library context I<libctx>, and for each
  123. of the implementations, calls I<fn> with the implementation method and
  124. I<data> as arguments.
  125. OSSL_STORE_LOADER_names_do_all() traverses all names for the given
  126. I<loader>, and calls I<fn> with each name and I<data>.
  127. =head2 Legacy Types and Functions (deprecated)
  128. These functions help applications and engines to create loaders for
  129. schemes they support. These are all deprecated and discouraged in favour of
  130. provider implementations, see L<provider-storemgmt(7)>.
  131. B<OSSL_STORE_LOADER_CTX> is a type template, to be defined by each loader
  132. using C<struct ossl_store_loader_ctx_st { ... }>.
  133. B<OSSL_STORE_open_fn>, B<OSSL_STORE_open_ex_fn>,
  134. B<OSSL_STORE_ctrl_fn>, B<OSSL_STORE_expect_fn>, B<OSSL_STORE_find_fn>,
  135. B<OSSL_STORE_load_fn>, B<OSSL_STORE_eof_fn>, and B<OSSL_STORE_close_fn>
  136. are the function pointer types used within a STORE loader.
  137. The functions pointed at define the functionality of the given loader.
  138. =over 4
  139. =item B<OSSL_STORE_open_fn> and B<OSSL_STORE_open_ex_fn>
  140. B<OSSL_STORE_open_ex_fn> takes a URI and is expected to
  141. interpret it in the best manner possible according to the scheme the
  142. loader implements. It also takes a B<UI_METHOD> and associated data,
  143. to be used any time something needs to be prompted for, as well as a
  144. library context I<libctx> with an associated property query I<propq>,
  145. to be used when fetching necessary algorithms to perform the loads.
  146. Furthermore, this function is expected to initialize what needs to be
  147. initialized, to create a private data store (B<OSSL_STORE_LOADER_CTX>,
  148. see above), and to return it.
  149. If something goes wrong, this function is expected to return NULL.
  150. B<OSSL_STORE_open_fn> does the same thing as
  151. B<OSSL_STORE_open_ex_fn> but uses NULL for the library
  152. context I<libctx> and property query I<propq>.
  153. =item B<OSSL_STORE_attach_fn>
  154. This function takes a B<BIO>, otherwise works like
  155. B<OSSL_STORE_open_ex_fn>.
  156. =item B<OSSL_STORE_ctrl_fn>
  157. This function takes a B<OSSL_STORE_LOADER_CTX> pointer, a command number
  158. I<cmd> and a B<va_list> I<args> and is used to manipulate loader
  159. specific parameters.
  160. =begin comment
  161. Globally known command numbers are documented in L<OSSL_STORE_ctrl(3)>,
  162. along with what I<args> are expected with each of them.
  163. =end comment
  164. Loader specific command numbers must begin at B<OSSL_STORE_C_CUSTOM_START>.
  165. Any number below that is reserved for future globally known command
  166. numbers.
  167. This function is expected to return 1 on success, 0 on error.
  168. =item B<OSSL_STORE_expect_fn>
  169. This function takes a B<OSSL_STORE_LOADER_CTX> pointer and a B<OSSL_STORE_INFO>
  170. identity I<expected>, and is used to tell the loader what object type is
  171. expected.
  172. I<expected> may be zero to signify that no specific object type is expected.
  173. This function is expected to return 1 on success, 0 on error.
  174. =item B<OSSL_STORE_find_fn>
  175. This function takes a B<OSSL_STORE_LOADER_CTX> pointer and a
  176. B<OSSL_STORE_SEARCH> search criterion, and is used to tell the loader what
  177. to search for.
  178. When called with the loader context being NULL, this function is expected
  179. to return 1 if the loader supports the criterion, otherwise 0.
  180. When called with the loader context being something other than NULL, this
  181. function is expected to return 1 on success, 0 on error.
  182. =item B<OSSL_STORE_load_fn>
  183. This function takes a B<OSSL_STORE_LOADER_CTX> pointer and a B<UI_METHOD>
  184. with associated data.
  185. It's expected to load the next available data, mold it into a data
  186. structure that can be wrapped in a B<OSSL_STORE_INFO> using one of the
  187. L<OSSL_STORE_INFO(3)> functions.
  188. If no more data is available or an error occurs, this function is
  189. expected to return NULL.
  190. The B<OSSL_STORE_eof_fn> and B<OSSL_STORE_error_fn> functions must indicate if
  191. it was in fact the end of data or if an error occurred.
  192. Note that this function retrieves I<one> data item only.
  193. =item B<OSSL_STORE_eof_fn>
  194. This function takes a B<OSSL_STORE_LOADER_CTX> pointer and is expected to
  195. return 1 to indicate that the end of available data has been reached.
  196. It is otherwise expected to return 0.
  197. =item B<OSSL_STORE_error_fn>
  198. This function takes a B<OSSL_STORE_LOADER_CTX> pointer and is expected to
  199. return 1 to indicate that an error occurred in a previous call to the
  200. B<OSSL_STORE_load_fn> function.
  201. It is otherwise expected to return 0.
  202. =item B<OSSL_STORE_close_fn>
  203. This function takes a B<OSSL_STORE_LOADER_CTX> pointer and is expected to
  204. close or shut down what needs to be closed, and finally free the
  205. contents of the B<OSSL_STORE_LOADER_CTX> pointer.
  206. It returns 1 on success and 0 on error.
  207. =back
  208. OSSL_STORE_LOADER_new() creates a new B<OSSL_STORE_LOADER>.
  209. It takes an B<ENGINE> I<e> and a string I<scheme>.
  210. I<scheme> must I<always> be set.
  211. Both I<e> and I<scheme> are used as is and must therefore be alive as
  212. long as the created loader is.
  213. OSSL_STORE_LOADER_get0_engine() returns the engine of the I<store_loader>.
  214. OSSL_STORE_LOADER_get0_scheme() returns the scheme of the I<store_loader>.
  215. OSSL_STORE_LOADER_set_open() sets the opener function for the
  216. I<store_loader>.
  217. OSSL_STORE_LOADER_set_open_ex() sets the opener with library context
  218. function for the I<store_loader>.
  219. OSSL_STORE_LOADER_set_attach() sets the attacher function for the
  220. I<store_loader>.
  221. OSSL_STORE_LOADER_set_ctrl() sets the control function for the
  222. I<store_loader>.
  223. OSSL_STORE_LOADER_set_expect() sets the expect function for the
  224. I<store_loader>.
  225. OSSL_STORE_LOADER_set_load() sets the loader function for the
  226. I<store_loader>.
  227. OSSL_STORE_LOADER_set_eof() sets the end of file checker function for the
  228. I<store_loader>.
  229. OSSL_STORE_LOADER_set_close() sets the closing function for the
  230. I<store_loader>.
  231. OSSL_STORE_LOADER_free() frees the given I<store_loader>.
  232. OSSL_STORE_register_loader() register the given I<store_loader> and
  233. thereby makes it available for use with OSSL_STORE_open(),
  234. OSSL_STORE_open_ex(), OSSL_STORE_load(), OSSL_STORE_eof()
  235. and OSSL_STORE_close().
  236. OSSL_STORE_unregister_loader() unregister the store loader for the given
  237. I<scheme>.
  238. =head1 RETURN VALUES
  239. OSSL_STORE_LOADER_fetch() returns a pointer to an OSSL_STORE_LOADER object,
  240. or NULL on error.
  241. OSSL_STORE_LOADER_up_ref() returns 1 on success, or 0 on error.
  242. OSSL_STORE_LOADER_free() doesn't return any value.
  243. OSSL_STORE_LOADER_provider() returns a pointer to a provider object, or
  244. NULL on error.
  245. OSSL_STORE_LOADER_properties() returns a pointer to a property
  246. definition string, or NULL on error.
  247. OSSL_STORE_LOADER_is_a() returns 1 if I<loader> was identifiable,
  248. otherwise 0.
  249. OSSL_STORE_LOADER_number() returns an integer.
  250. The functions with the types B<OSSL_STORE_open_fn>,
  251. B<OSSL_STORE_open_ex_fn>, B<OSSL_STORE_ctrl_fn>,
  252. B<OSSL_STORE_expect_fn>, B<OSSL_STORE_load_fn>, B<OSSL_STORE_eof_fn>
  253. and B<OSSL_STORE_close_fn> have the same return values as OSSL_STORE_open(),
  254. OSSL_STORE_open_ex(), OSSL_STORE_ctrl(), OSSL_STORE_expect(),
  255. OSSL_STORE_load(), OSSL_STORE_eof() and OSSL_STORE_close(), respectively.
  256. OSSL_STORE_LOADER_new() returns a pointer to a B<OSSL_STORE_LOADER> on success,
  257. or NULL on failure.
  258. OSSL_STORE_LOADER_set_open(), OSSL_STORE_LOADER_set_open_ex(),
  259. OSSL_STORE_LOADER_set_ctrl(), OSSL_STORE_LOADER_set_load(),
  260. OSSL_STORE_LOADER_set_eof() and OSSL_STORE_LOADER_set_close() return 1
  261. on success, or 0 on failure.
  262. OSSL_STORE_register_loader() returns 1 on success, or 0 on failure.
  263. OSSL_STORE_unregister_loader() returns the unregistered loader on success,
  264. or NULL on failure.
  265. =head1 SEE ALSO
  266. L<ossl_store(7)>, L<OSSL_STORE_open(3)>, L<OSSL_LIB_CTX(3)>,
  267. L<provider-storemgmt(7)>
  268. =head1 HISTORY
  269. OSSL_STORE_LOADER_fetch(), OSSL_STORE_LOADER_up_ref(),
  270. OSSL_STORE_LOADER_free(), OSSL_STORE_LOADER_provider(),
  271. OSSL_STORE_LOADER_properties(), OSSL_STORE_LOADER_is_a(),
  272. OSSL_STORE_LOADER_number(), OSSL_STORE_LOADER_do_all_provided() and
  273. OSSL_STORE_LOADER_names_do_all() were added in OpenSSL 3.0.
  274. OSSL_STORE_open_ex_fn() was added in OpenSSL 3.0.
  275. B<OSSL_STORE_LOADER>, B<OSSL_STORE_LOADER_CTX>, OSSL_STORE_LOADER_new(),
  276. OSSL_STORE_LOADER_set0_scheme(), OSSL_STORE_LOADER_set_open(),
  277. OSSL_STORE_LOADER_set_ctrl(), OSSL_STORE_LOADER_set_load(),
  278. OSSL_STORE_LOADER_set_eof(), OSSL_STORE_LOADER_set_close(),
  279. OSSL_STORE_LOADER_free(), OSSL_STORE_register_loader(),
  280. OSSL_STORE_unregister_loader(), OSSL_STORE_open_fn(), OSSL_STORE_ctrl_fn(),
  281. OSSL_STORE_load_fn(), OSSL_STORE_eof_fn() and OSSL_STORE_close_fn()
  282. were added in OpenSSL 1.1.1, and became deprecated in OpenSSL 3.0.
  283. =head1 COPYRIGHT
  284. Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
  285. Licensed under the Apache License 2.0 (the "License"). You may not use
  286. this file except in compliance with the License. You can obtain a copy
  287. in the file LICENSE in the source distribution or at
  288. L<https://www.openssl.org/source/license.html>.
  289. =cut