2
0

OSSL_STORE_LOADER.pod 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  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_get0_provider,
  8. OSSL_STORE_LOADER_get0_properties,
  9. OSSL_STORE_LOADER_is_a,
  10. OSSL_STORE_LOADER_get0_description,
  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(OSSL_LIB_CTX *libctx,
  31. const char *scheme,
  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_get0_provider(const OSSL_STORE_LOADER *
  36. loader);
  37. const char *OSSL_STORE_LOADER_get0_properties(const OSSL_STORE_LOADER *loader);
  38. const char *OSSL_STORE_LOADER_get0_description(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 (*user_fn)(OSSL_STORE_LOADER *loader,
  43. void *arg),
  44. void *user_arg);
  45. int OSSL_STORE_LOADER_names_do_all(const OSSL_STORE_LOADER *loader,
  46. void (*fn)(const char *name, void *data),
  47. void *data);
  48. The following functions have been deprecated since OpenSSL 3.0, and can be
  49. hidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value,
  50. see 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<libctx>, 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_get0_provider() returns the provider of the given
  114. I<loader>.
  115. OSSL_STORE_LOADER_get0_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_get0_description() returns a description of the I<loader>, meant
  120. for display and human consumption. The description is at the discretion of the
  121. I<loader> implementation.
  122. OSSL_STORE_LOADER_do_all_provided() traverses all store implementations
  123. by all activated providers in the library context I<libctx>, and for each
  124. of the implementations, calls I<user_fn> with the implementation method and
  125. I<user_arg> as arguments.
  126. OSSL_STORE_LOADER_names_do_all() traverses all names for the given
  127. I<loader>, and calls I<fn> with each name and I<data>.
  128. =head2 Legacy Types and Functions (deprecated)
  129. These functions help applications and engines to create loaders for
  130. schemes they support. These are all deprecated and discouraged in favour of
  131. provider implementations, see L<provider-storemgmt(7)>.
  132. B<OSSL_STORE_LOADER_CTX> is a type template, to be defined by each loader
  133. using C<struct ossl_store_loader_ctx_st { ... }>.
  134. B<OSSL_STORE_open_fn>, B<OSSL_STORE_open_ex_fn>,
  135. B<OSSL_STORE_ctrl_fn>, B<OSSL_STORE_expect_fn>, B<OSSL_STORE_find_fn>,
  136. B<OSSL_STORE_load_fn>, B<OSSL_STORE_eof_fn>, and B<OSSL_STORE_close_fn>
  137. are the function pointer types used within a STORE loader.
  138. The functions pointed at define the functionality of the given loader.
  139. =over 4
  140. =item B<OSSL_STORE_open_fn> and B<OSSL_STORE_open_ex_fn>
  141. B<OSSL_STORE_open_ex_fn> takes a URI and is expected to
  142. interpret it in the best manner possible according to the scheme the
  143. loader implements. It also takes a B<UI_METHOD> and associated data,
  144. to be used any time something needs to be prompted for, as well as a
  145. library context I<libctx> with an associated property query I<propq>,
  146. to be used when fetching necessary algorithms to perform the loads.
  147. Furthermore, this function is expected to initialize what needs to be
  148. initialized, to create a private data store (B<OSSL_STORE_LOADER_CTX>,
  149. see above), and to return it.
  150. If something goes wrong, this function is expected to return NULL.
  151. B<OSSL_STORE_open_fn> does the same thing as
  152. B<OSSL_STORE_open_ex_fn> but uses NULL for the library
  153. context I<libctx> and property query I<propq>.
  154. =item B<OSSL_STORE_attach_fn>
  155. This function takes a B<BIO>, otherwise works like
  156. B<OSSL_STORE_open_ex_fn>.
  157. =item B<OSSL_STORE_ctrl_fn>
  158. This function takes a B<OSSL_STORE_LOADER_CTX> pointer, a command number
  159. I<cmd> and a B<va_list> I<args> and is used to manipulate loader
  160. specific parameters.
  161. =begin comment
  162. Globally known command numbers are documented in L<OSSL_STORE_ctrl(3)>,
  163. along with what I<args> are expected with each of them.
  164. =end comment
  165. Loader specific command numbers must begin at B<OSSL_STORE_C_CUSTOM_START>.
  166. Any number below that is reserved for future globally known command
  167. numbers.
  168. This function is expected to return 1 on success, 0 on error.
  169. =item B<OSSL_STORE_expect_fn>
  170. This function takes a B<OSSL_STORE_LOADER_CTX> pointer and a B<OSSL_STORE_INFO>
  171. identity I<expected>, and is used to tell the loader what object type is
  172. expected.
  173. I<expected> may be zero to signify that no specific object type is expected.
  174. This function is expected to return 1 on success, 0 on error.
  175. =item B<OSSL_STORE_find_fn>
  176. This function takes a B<OSSL_STORE_LOADER_CTX> pointer and a
  177. B<OSSL_STORE_SEARCH> search criterion, and is used to tell the loader what
  178. to search for.
  179. When called with the loader context being NULL, this function is expected
  180. to return 1 if the loader supports the criterion, otherwise 0.
  181. When called with the loader context being something other than NULL, this
  182. function is expected to return 1 on success, 0 on error.
  183. =item B<OSSL_STORE_load_fn>
  184. This function takes a B<OSSL_STORE_LOADER_CTX> pointer and a B<UI_METHOD>
  185. with associated data.
  186. It's expected to load the next available data, mold it into a data
  187. structure that can be wrapped in a B<OSSL_STORE_INFO> using one of the
  188. L<OSSL_STORE_INFO(3)> functions.
  189. If no more data is available or an error occurs, this function is
  190. expected to return NULL.
  191. The B<OSSL_STORE_eof_fn> and B<OSSL_STORE_error_fn> functions must indicate if
  192. it was in fact the end of data or if an error occurred.
  193. Note that this function retrieves I<one> data item only.
  194. =item B<OSSL_STORE_eof_fn>
  195. This function takes a B<OSSL_STORE_LOADER_CTX> pointer and is expected to
  196. return 1 to indicate that the end of available data has been reached.
  197. It is otherwise expected to return 0.
  198. =item B<OSSL_STORE_error_fn>
  199. This function takes a B<OSSL_STORE_LOADER_CTX> pointer and is expected to
  200. return 1 to indicate that an error occurred in a previous call to the
  201. B<OSSL_STORE_load_fn> function.
  202. It is otherwise expected to return 0.
  203. =item B<OSSL_STORE_close_fn>
  204. This function takes a B<OSSL_STORE_LOADER_CTX> pointer and is expected to
  205. close or shut down what needs to be closed, and finally free the
  206. contents of the B<OSSL_STORE_LOADER_CTX> pointer.
  207. It returns 1 on success and 0 on error.
  208. =back
  209. OSSL_STORE_LOADER_new() creates a new B<OSSL_STORE_LOADER>.
  210. It takes an B<ENGINE> I<e> and a string I<scheme>.
  211. I<scheme> must I<always> be set.
  212. Both I<e> and I<scheme> are used as is and must therefore be alive as
  213. long as the created loader is.
  214. OSSL_STORE_LOADER_get0_engine() returns the engine of the I<store_loader>.
  215. OSSL_STORE_LOADER_get0_scheme() returns the scheme of the I<store_loader>.
  216. OSSL_STORE_LOADER_set_open() sets the opener function for the
  217. I<store_loader>.
  218. OSSL_STORE_LOADER_set_open_ex() sets the opener with library context
  219. function for the I<store_loader>.
  220. OSSL_STORE_LOADER_set_attach() sets the attacher function for the
  221. I<store_loader>.
  222. OSSL_STORE_LOADER_set_ctrl() sets the control function for the
  223. I<store_loader>.
  224. OSSL_STORE_LOADER_set_expect() sets the expect function for the
  225. I<store_loader>.
  226. OSSL_STORE_LOADER_set_load() sets the loader function for the
  227. I<store_loader>.
  228. OSSL_STORE_LOADER_set_eof() sets the end of file checker function for the
  229. I<store_loader>.
  230. OSSL_STORE_LOADER_set_close() sets the closing function for the
  231. I<store_loader>.
  232. OSSL_STORE_LOADER_free() frees the given I<store_loader>.
  233. OSSL_STORE_register_loader() register the given I<store_loader> and
  234. thereby makes it available for use with OSSL_STORE_open(),
  235. OSSL_STORE_open_ex(), OSSL_STORE_load(), OSSL_STORE_eof()
  236. and OSSL_STORE_close().
  237. OSSL_STORE_unregister_loader() unregister the store loader for the given
  238. I<scheme>.
  239. =head1 RETURN VALUES
  240. OSSL_STORE_LOADER_fetch() returns a pointer to an OSSL_STORE_LOADER object,
  241. or NULL on error.
  242. OSSL_STORE_LOADER_up_ref() returns 1 on success, or 0 on error.
  243. OSSL_STORE_LOADER_names_do_all() returns 1 if the callback was called for all
  244. names. A return value of 0 means that the callback was not called for any names.
  245. OSSL_STORE_LOADER_free() doesn't return any value.
  246. OSSL_STORE_LOADER_get0_provider() returns a pointer to a provider object, or
  247. NULL on error.
  248. OSSL_STORE_LOADER_get0_properties() returns a pointer to a property
  249. definition string, or NULL on error.
  250. OSSL_STORE_LOADER_is_a() returns 1 if I<loader> was identifiable,
  251. otherwise 0.
  252. OSSL_STORE_LOADER_get0_description() returns a pointer to a description, or NULL if
  253. there isn't one.
  254. The functions with the types B<OSSL_STORE_open_fn>,
  255. B<OSSL_STORE_open_ex_fn>, B<OSSL_STORE_ctrl_fn>,
  256. B<OSSL_STORE_expect_fn>, B<OSSL_STORE_load_fn>, B<OSSL_STORE_eof_fn>
  257. and B<OSSL_STORE_close_fn> have the same return values as OSSL_STORE_open(),
  258. OSSL_STORE_open_ex(), OSSL_STORE_ctrl(), OSSL_STORE_expect(),
  259. OSSL_STORE_load(), OSSL_STORE_eof() and OSSL_STORE_close(), respectively.
  260. OSSL_STORE_LOADER_new() returns a pointer to a B<OSSL_STORE_LOADER> on success,
  261. or NULL on failure.
  262. OSSL_STORE_LOADER_set_open(), OSSL_STORE_LOADER_set_open_ex(),
  263. OSSL_STORE_LOADER_set_ctrl(), OSSL_STORE_LOADER_set_load(),
  264. OSSL_STORE_LOADER_set_eof() and OSSL_STORE_LOADER_set_close() return 1
  265. on success, or 0 on failure.
  266. OSSL_STORE_register_loader() returns 1 on success, or 0 on failure.
  267. OSSL_STORE_unregister_loader() returns the unregistered loader on success,
  268. or NULL on failure.
  269. =head1 SEE ALSO
  270. L<ossl_store(7)>, L<OSSL_STORE_open(3)>, L<OSSL_LIB_CTX(3)>,
  271. L<provider-storemgmt(7)>
  272. =head1 HISTORY
  273. OSSL_STORE_LOADER_fetch(), OSSL_STORE_LOADER_up_ref(),
  274. OSSL_STORE_LOADER_free(), OSSL_STORE_LOADER_get0_provider(),
  275. OSSL_STORE_LOADER_get0_properties(), OSSL_STORE_LOADER_is_a(),
  276. OSSL_STORE_LOADER_do_all_provided() and
  277. OSSL_STORE_LOADER_names_do_all() were added in OpenSSL 3.0.
  278. OSSL_STORE_open_ex_fn() was added in OpenSSL 3.0.
  279. B<OSSL_STORE_LOADER>, B<OSSL_STORE_LOADER_CTX>, OSSL_STORE_LOADER_new(),
  280. OSSL_STORE_LOADER_set0_scheme(), OSSL_STORE_LOADER_get0_scheme(),
  281. OSSL_STORE_LOADER_get0_engine(), OSSL_STORE_LOADER_set_expect(),
  282. OSSL_STORE_LOADER_set_find(), OSSL_STORE_LOADER_set_attach(),
  283. OSSL_STORE_LOADER_set_open_ex(), OSSL_STORE_LOADER_set_open(),
  284. OSSL_STORE_LOADER_set_ctrl(),
  285. OSSL_STORE_LOADER_set_load(), OSSL_STORE_LOADER_set_eof(),
  286. OSSL_STORE_LOADER_set_close(), OSSL_STORE_LOADER_free(),
  287. OSSL_STORE_register_loader(), OSSL_STORE_LOADER_set_error(),
  288. OSSL_STORE_unregister_loader(), OSSL_STORE_open_fn(), OSSL_STORE_ctrl_fn(),
  289. OSSL_STORE_load_fn(), OSSL_STORE_eof_fn() and OSSL_STORE_close_fn()
  290. were added in OpenSSL 1.1.1, and became deprecated in OpenSSL 3.0.
  291. =head1 COPYRIGHT
  292. Copyright 2016-2022 The OpenSSL Project Authors. All Rights Reserved.
  293. Licensed under the Apache License 2.0 (the "License"). You may not use
  294. this file except in compliance with the License. You can obtain a copy
  295. in the file LICENSE in the source distribution or at
  296. L<https://www.openssl.org/source/license.html>.
  297. =cut