OSSL_STORE_LOADER.pod 10 KB

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