OSSL_STORE_LOADER.pod 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. =pod
  2. =head1 NAME
  3. OSSL_STORE_LOADER, OSSL_STORE_LOADER_CTX, OSSL_STORE_LOADER_new,
  4. OSSL_STORE_LOADER_get0_engine, OSSL_STORE_LOADER_get0_scheme,
  5. OSSL_STORE_LOADER_set_open, OSSL_STORE_LOADER_set_attach,
  6. OSSL_STORE_LOADER_set_ctrl, OSSL_STORE_LOADER_set_expect,
  7. OSSL_STORE_LOADER_set_find, OSSL_STORE_LOADER_set_load,
  8. OSSL_STORE_LOADER_set_eof, OSSL_STORE_LOADER_set_error,
  9. OSSL_STORE_LOADER_set_close,
  10. OSSL_STORE_LOADER_free, OSSL_STORE_register_loader,
  11. OSSL_STORE_unregister_loader,
  12. OSSL_STORE_open_fn, OSSL_STORE_attach_fn, OSSL_STORE_ctrl_fn,
  13. OSSL_STORE_expect_fn, OSSL_STORE_find_fn,
  14. OSSL_STORE_load_fn, OSSL_STORE_eof_fn, OSSL_STORE_error_fn,
  15. OSSL_STORE_close_fn - Types and functions to manipulate, register and
  16. unregister STORE loaders for different URI schemes
  17. =head1 SYNOPSIS
  18. #include <openssl/store.h>
  19. typedef struct ossl_store_loader_st OSSL_STORE_LOADER;
  20. OSSL_STORE_LOADER *OSSL_STORE_LOADER_new(ENGINE *e, const char *scheme);
  21. const ENGINE *OSSL_STORE_LOADER_get0_engine(const OSSL_STORE_LOADER
  22. *store_loader);
  23. const char *OSSL_STORE_LOADER_get0_scheme(const OSSL_STORE_LOADER
  24. *store_loader);
  25. /* struct ossl_store_loader_ctx_st is defined differently by each loader */
  26. typedef struct ossl_store_loader_ctx_st OSSL_STORE_LOADER_CTX;
  27. typedef OSSL_STORE_LOADER_CTX *(*OSSL_STORE_open_fn)(const char *uri,
  28. const UI_METHOD *ui_method,
  29. void *ui_data);
  30. int OSSL_STORE_LOADER_set_open(OSSL_STORE_LOADER *store_loader,
  31. OSSL_STORE_open_fn store_open_function);
  32. typedef OSSL_STORE_LOADER_CTX *(*OSSL_STORE_attach_fn)(const OSSL_STORE_LOADER
  33. *loader,
  34. BIO *bio,
  35. OPENSSL_CTX *libctx,
  36. const char *propq,
  37. const UI_METHOD
  38. *ui_method,
  39. void *ui_data);
  40. int OSSL_STORE_LOADER_set_attach(OSSL_STORE_LOADER *loader,
  41. OSSL_STORE_attach_fn attach_function);
  42. typedef int (*OSSL_STORE_ctrl_fn)(OSSL_STORE_LOADER_CTX *ctx, int cmd,
  43. va_list args);
  44. int OSSL_STORE_LOADER_set_ctrl(OSSL_STORE_LOADER *store_loader,
  45. OSSL_STORE_ctrl_fn store_ctrl_function);
  46. typedef int (*OSSL_STORE_expect_fn)(OSSL_STORE_LOADER_CTX *ctx, int expected);
  47. int OSSL_STORE_LOADER_set_expect(OSSL_STORE_LOADER *loader,
  48. OSSL_STORE_expect_fn expect_function);
  49. typedef int (*OSSL_STORE_find_fn)(OSSL_STORE_LOADER_CTX *ctx,
  50. OSSL_STORE_SEARCH *criteria);
  51. int OSSL_STORE_LOADER_set_find(OSSL_STORE_LOADER *loader,
  52. OSSL_STORE_find_fn find_function);
  53. typedef OSSL_STORE_INFO *(*OSSL_STORE_load_fn)(OSSL_STORE_LOADER_CTX *ctx,
  54. UI_METHOD *ui_method,
  55. void *ui_data);
  56. int OSSL_STORE_LOADER_set_load(OSSL_STORE_LOADER *store_loader,
  57. OSSL_STORE_load_fn store_load_function);
  58. typedef int (*OSSL_STORE_eof_fn)(OSSL_STORE_LOADER_CTX *ctx);
  59. int OSSL_STORE_LOADER_set_eof(OSSL_STORE_LOADER *store_loader,
  60. OSSL_STORE_eof_fn store_eof_function);
  61. typedef int (*OSSL_STORE_error_fn)(OSSL_STORE_LOADER_CTX *ctx);
  62. int OSSL_STORE_LOADER_set_error(OSSL_STORE_LOADER *store_loader,
  63. OSSL_STORE_error_fn store_error_function);
  64. typedef int (*OSSL_STORE_close_fn)(OSSL_STORE_LOADER_CTX *ctx);
  65. int OSSL_STORE_LOADER_set_close(OSSL_STORE_LOADER *store_loader,
  66. OSSL_STORE_close_fn store_close_function);
  67. void OSSL_STORE_LOADER_free(OSSL_STORE_LOADER *store_loader);
  68. int OSSL_STORE_register_loader(OSSL_STORE_LOADER *loader);
  69. OSSL_STORE_LOADER *OSSL_STORE_unregister_loader(const char *scheme);
  70. =head1 DESCRIPTION
  71. These functions help applications and engines to create loaders for
  72. schemes they support.
  73. =head2 Types
  74. B<OSSL_STORE_LOADER> is the type to hold a loader.
  75. It contains a scheme and the functions needed to implement
  76. OSSL_STORE_open(), OSSL_STORE_load(), OSSL_STORE_eof(), OSSL_STORE_error() and
  77. OSSL_STORE_close() for this scheme.
  78. B<OSSL_STORE_LOADER_CTX> is a type template, to be defined by each loader
  79. using B<struct ossl_store_loader_ctx_st { ... }>.
  80. B<OSSL_STORE_open_fn>, B<OSSL_STORE_ctrl_fn>, B<OSSL_STORE_expect_fn>,
  81. B<OSSL_STORE_find_fn>, B<OSSL_STORE_load_fn>, B<OSSL_STORE_eof_fn>,
  82. and B<OSSL_STORE_close_fn>
  83. are the function pointer types used within a STORE loader.
  84. The functions pointed at define the functionality of the given loader.
  85. =over 4
  86. =item B<OSSL_STORE_open_fn>
  87. This function takes a URI and is expected to interpret it in the best
  88. manner possible according to the scheme the loader implements, it also
  89. takes a B<UI_METHOD> and associated data, to be used any time
  90. something needs to be prompted for.
  91. Furthermore, this function is expected to initialize what needs to be
  92. initialized, to create a private data store (B<OSSL_STORE_LOADER_CTX>, see
  93. above), and to return it.
  94. If something goes wrong, this function is expected to return NULL.
  95. =item B<OSSL_STORE_open_fn>
  96. This function takes a B<BIO>, otherwise works like B<OSSL_STORE_open_fn>.
  97. =item B<OSSL_STORE_ctrl_fn>
  98. This function takes a B<OSSL_STORE_LOADER_CTX> pointer, a command number
  99. B<cmd> and a B<va_list> B<args> and is used to manipulate loader
  100. specific parameters.
  101. =begin comment
  102. Globally known command numbers are documented in L<OSSL_STORE_ctrl(3)>,
  103. along with what B<args> are expected with each of them.
  104. =end comment
  105. Loader specific command numbers must begin at B<OSSL_STORE_C_CUSTOM_START>.
  106. Any number below that is reserved for future globally known command
  107. numbers.
  108. This function is expected to return 1 on success, 0 on error.
  109. =item B<OSSL_STORE_expect_fn>
  110. This function takes a B<OSSL_STORE_LOADER_CTX> pointer and a B<OSSL_STORE_INFO>
  111. identity B<expected>, and is used to tell the loader what object type is
  112. expected.
  113. B<expected> may be zero to signify that no specific object type is expected.
  114. This function is expected to return 1 on success, 0 on error.
  115. =item B<OSSL_STORE_find_fn>
  116. This function takes a B<OSSL_STORE_LOADER_CTX> pointer and a
  117. B<OSSL_STORE_SEARCH> search criterion, and is used to tell the loader what
  118. to search for.
  119. When called with the loader context being B<NULL>, this function is expected
  120. to return 1 if the loader supports the criterion, otherwise 0.
  121. When called with the loader context being something other than B<NULL>, this
  122. function is expected to return 1 on success, 0 on error.
  123. =item B<OSSL_STORE_load_fn>
  124. This function takes a B<OSSL_STORE_LOADER_CTX> pointer and a B<UI_METHOD>
  125. with associated data.
  126. It's expected to load the next available data, mold it into a data
  127. structure that can be wrapped in a B<OSSL_STORE_INFO> using one of the
  128. L<OSSL_STORE_INFO(3)> functions.
  129. If no more data is available or an error occurs, this function is
  130. expected to return NULL.
  131. The B<OSSL_STORE_eof_fn> and B<OSSL_STORE_error_fn> functions must indicate if
  132. it was in fact the end of data or if an error occurred.
  133. Note that this function retrieves I<one> data item only.
  134. =item B<OSSL_STORE_eof_fn>
  135. This function takes a B<OSSL_STORE_LOADER_CTX> pointer and is expected to
  136. return 1 to indicate that the end of available data has been reached.
  137. It is otherwise expected to return 0.
  138. =item B<OSSL_STORE_error_fn>
  139. This function takes a B<OSSL_STORE_LOADER_CTX> pointer and is expected to
  140. return 1 to indicate that an error occurred in a previous call to the
  141. B<OSSL_STORE_load_fn> function.
  142. It is otherwise expected to return 0.
  143. =item B<OSSL_STORE_close_fn>
  144. This function takes a B<OSSL_STORE_LOADER_CTX> pointer and is expected to
  145. close or shut down what needs to be closed, and finally free the
  146. contents of the B<OSSL_STORE_LOADER_CTX> pointer.
  147. It returns 1 on success and 0 on error.
  148. =back
  149. =head2 Functions
  150. OSSL_STORE_LOADER_new() creates a new B<OSSL_STORE_LOADER>.
  151. It takes an B<ENGINE> B<e> and a string B<scheme>.
  152. B<scheme> must I<always> be set.
  153. Both B<e> and B<scheme> are used as is and must therefore be alive as
  154. long as the created loader is.
  155. OSSL_STORE_LOADER_get0_engine() returns the engine of the B<store_loader>.
  156. OSSL_STORE_LOADER_get0_scheme() returns the scheme of the B<store_loader>.
  157. OSSL_STORE_LOADER_set_open() sets the opener function for the
  158. B<store_loader>.
  159. OSSL_STORE_LOADER_set_attach() sets the attacher function for the
  160. B<store_loader>.
  161. OSSL_STORE_LOADER_set_ctrl() sets the control function for the
  162. B<store_loader>.
  163. OSSL_STORE_LOADER_set_expect() sets the expect function for the
  164. B<store_loader>.
  165. OSSL_STORE_LOADER_set_load() sets the loader function for the
  166. B<store_loader>.
  167. OSSL_STORE_LOADER_set_eof() sets the end of file checker function for the
  168. B<store_loader>.
  169. OSSL_STORE_LOADER_set_close() sets the closing function for the
  170. B<store_loader>.
  171. OSSL_STORE_LOADER_free() frees the given B<store_loader>.
  172. OSSL_STORE_register_loader() register the given B<store_loader> and thereby
  173. makes it available for use with OSSL_STORE_open(), OSSL_STORE_load(),
  174. OSSL_STORE_eof() and OSSL_STORE_close().
  175. OSSL_STORE_unregister_loader() unregister the store loader for the given
  176. B<scheme>.
  177. =head1 NOTES
  178. The B<file:> scheme has built in support.
  179. =head1 RETURN VALUES
  180. The functions with the types B<OSSL_STORE_open_fn>, B<OSSL_STORE_ctrl_fn>,
  181. B<OSSL_STORE_expect_fn>,
  182. B<OSSL_STORE_load_fn>, B<OSSL_STORE_eof_fn> and B<OSSL_STORE_close_fn> have the
  183. same return values as OSSL_STORE_open(), OSSL_STORE_ctrl(), OSSL_STORE_expect(),
  184. OSSL_STORE_load(), OSSL_STORE_eof() and OSSL_STORE_close(), respectively.
  185. OSSL_STORE_LOADER_new() returns a pointer to a B<OSSL_STORE_LOADER> on success,
  186. or B<NULL> on failure.
  187. OSSL_STORE_LOADER_set_open(), OSSL_STORE_LOADER_set_ctrl(),
  188. OSSL_STORE_LOADER_set_load(), OSSL_STORE_LOADER_set_eof() and
  189. OSSL_STORE_LOADER_set_close() return 1 on success, or 0 on failure.
  190. OSSL_STORE_register_loader() returns 1 on success, or 0 on failure.
  191. OSSL_STORE_unregister_loader() returns the unregistered loader on success,
  192. or B<NULL> on failure.
  193. =head1 SEE ALSO
  194. L<ossl_store(7)>, L<OSSL_STORE_open(3)>
  195. =head1 HISTORY
  196. OSSL_STORE_LOADER(), OSSL_STORE_LOADER_CTX(), OSSL_STORE_LOADER_new(),
  197. OSSL_STORE_LOADER_set0_scheme(), OSSL_STORE_LOADER_set_open(),
  198. OSSL_STORE_LOADER_set_ctrl(), OSSL_STORE_LOADER_set_load(),
  199. OSSL_STORE_LOADER_set_eof(), OSSL_STORE_LOADER_set_close(),
  200. OSSL_STORE_LOADER_free(), OSSL_STORE_register_loader(),
  201. OSSL_STORE_unregister_loader(), OSSL_STORE_open_fn(), OSSL_STORE_ctrl_fn(),
  202. OSSL_STORE_load_fn(), OSSL_STORE_eof_fn() and OSSL_STORE_close_fn()
  203. were added in OpenSSL 1.1.1.
  204. =head1 COPYRIGHT
  205. Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
  206. Licensed under the Apache License 2.0 (the "License"). You may not use
  207. this file except in compliance with the License. You can obtain a copy
  208. in the file LICENSE in the source distribution or at
  209. L<https://www.openssl.org/source/license.html>.
  210. =cut