2
0

OSSL_STORE_open.pod 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. =pod
  2. =head1 NAME
  3. OSSL_STORE_CTX, OSSL_STORE_post_process_info_fn, OSSL_STORE_open,
  4. OSSL_STORE_ctrl, OSSL_STORE_load, OSSL_STORE_eof, OSSL_STORE_error,
  5. OSSL_STORE_close - Types and functions to read objects from a URI
  6. =head1 SYNOPSIS
  7. #include <openssl/store.h>
  8. typedef struct ossl_store_ctx_st OSSL_STORE_CTX;
  9. typedef OSSL_STORE_INFO *(*OSSL_STORE_post_process_info_fn)(OSSL_STORE_INFO *,
  10. void *);
  11. OSSL_STORE_CTX *OSSL_STORE_open(const char *uri, const UI_METHOD *ui_method,
  12. void *ui_data,
  13. OSSL_STORE_post_process_info_fn post_process,
  14. void *post_process_data);
  15. int OSSL_STORE_ctrl(OSSL_STORE_CTX *ctx, int cmd, ... /* args */);
  16. OSSL_STORE_INFO *OSSL_STORE_load(OSSL_STORE_CTX *ctx);
  17. int OSSL_STORE_eof(OSSL_STORE_CTX *ctx);
  18. int OSSL_STORE_error(OSSL_STORE_CTX *ctx);
  19. int OSSL_STORE_close(OSSL_STORE_CTX *ctx);
  20. =head1 DESCRIPTION
  21. These functions help the application to fetch supported objects (see
  22. L<OSSL_STORE_INFO(3)/SUPPORTED OBJECTS> for information on which those are)
  23. from a given URI (see L</SUPPORTED SCHEMES> for more information on
  24. the supported URI schemes).
  25. The general method to do so is to "open" the URI using OSSL_STORE_open(),
  26. read each available and supported object using OSSL_STORE_load() as long as
  27. OSSL_STORE_eof() hasn't been reached, and finish it off with OSSL_STORE_close().
  28. The retrieved information is stored in a B<OSSL_STORE_INFO>, which is further
  29. described in L<OSSL_STORE_INFO(3)>.
  30. =head2 Types
  31. B<OSSL_STORE_CTX> is a context variable that holds all the internal
  32. information for OSSL_STORE_open(), OSSL_STORE_load(), OSSL_STORE_eof() and
  33. OSSL_STORE_close() to work together.
  34. =head2 Functions
  35. OSSL_STORE_open() takes a uri or path B<uri>, password UI method
  36. B<ui_method> with associated data B<ui_data>, and post processing
  37. callback B<post_process> with associated data B<post_process_data>,
  38. opens a channel to the data located at that URI and returns a
  39. B<OSSL_STORE_CTX> with all necessary internal information.
  40. The given B<ui_method> and B<ui_data_data> will be reused by all
  41. functions that use B<OSSL_STORE_CTX> when interaction is needed.
  42. The given B<post_process> and B<post_process_data> will be reused by
  43. OSSL_STORE_load() to manipulate or drop the value to be returned.
  44. The B<post_process> function drops values by returning B<NULL>, which
  45. will cause OSSL_STORE_load() to start its process over with loading
  46. the next object, until B<post_process> returns something other than
  47. B<NULL>, or the end of data is reached as indicated by OSSL_STORE_eof().
  48. OSSL_STORE_ctrl() takes a B<OSSL_STORE_CTX>, and command number B<cmd> and
  49. more arguments not specified here.
  50. The available loader specific command numbers and arguments they each
  51. take depends on the loader that's used and is documented together with
  52. that loader.
  53. There are also global controls available:
  54. =over 4
  55. =item B<OSSL_STORE_C_USE_SECMEM>
  56. Controls if the loader should attempt to use secure memory for any
  57. allocated B<OSSL_STORE_INFO> and its contents.
  58. This control expects one argument, a pointer to an B<int> that is expected to
  59. have the value 1 (yes) or 0 (no).
  60. Any other value is an error.
  61. =back
  62. OSSL_STORE_load() takes a B<OSSL_STORE_CTX>, tries to load the next available
  63. object and return it wrapped with B<OSSL_STORE_INFO>.
  64. OSSL_STORE_eof() takes a B<OSSL_STORE_CTX> and checks if we've reached the end
  65. of data.
  66. OSSL_STORE_error() takes a B<OSSL_STORE_CTX> and checks if an error occurred in
  67. the last OSSL_STORE_load() call.
  68. Note that it may still be meaningful to try and load more objects, unless
  69. OSSL_STORE_eof() shows that the end of data has been reached.
  70. OSSL_STORE_close() takes a B<OSSL_STORE_CTX>, closes the channel that was opened
  71. by OSSL_STORE_open() and frees all other information that was stored in the
  72. B<OSSL_STORE_CTX>, as well as the B<OSSL_STORE_CTX> itself.
  73. =head1 SUPPORTED SCHEMES
  74. The basic supported scheme is B<file:>.
  75. Any other scheme can be added dynamically, using
  76. OSSL_STORE_register_loader().
  77. =head1 NOTES
  78. A string without a scheme prefix (that is, a non-URI string) is
  79. implicitly interpreted as using the F<file:> scheme.
  80. There are some tools that can be used together with
  81. OSSL_STORE_open() to determine if any failure is caused by an unparsable
  82. URI, or if it's a different error (such as memory allocation
  83. failures); if the URI was parsable but the scheme unregistered, the
  84. top error will have the reason C<OSSL_STORE_R_UNREGISTERED_SCHEME>.
  85. These functions make no direct assumption regarding the pass phrase received
  86. from the password callback.
  87. The loaders may make assumptions, however.
  88. For example, the B<file:> scheme loader inherits the assumptions made by
  89. OpenSSL functionality that handles the different file types; this is mostly
  90. relevant for PKCS#12 objects.
  91. See L<passphrase-encoding(7)> for further information.
  92. =head1 RETURN VALUES
  93. OSSL_STORE_open() returns a pointer to a B<OSSL_STORE_CTX> on success, or
  94. B<NULL> on failure.
  95. OSSL_STORE_load() returns a pointer to a B<OSSL_STORE_INFO> on success, or
  96. B<NULL> on error or when end of data is reached.
  97. Use OSSL_STORE_error() and OSSL_STORE_eof() to determine the meaning of a
  98. returned B<NULL>.
  99. OSSL_STORE_eof() returns 1 if the end of data has been reached, otherwise
  100. 0.
  101. OSSL_STORE_error() returns 1 if an error occurred in an OSSL_STORE_load() call,
  102. otherwise 0.
  103. OSSL_STORE_ctrl() and OSSL_STORE_close() returns 1 on success, or 0 on failure.
  104. =head1 SEE ALSO
  105. L<ossl_store(7)>, L<OSSL_STORE_INFO(3)>, L<OSSL_STORE_register_loader(3)>,
  106. L<passphrase-encoding(7)>
  107. =head1 HISTORY
  108. OSSL_STORE_CTX(), OSSL_STORE_post_process_info_fn(), OSSL_STORE_open(),
  109. OSSL_STORE_ctrl(), OSSL_STORE_load(), OSSL_STORE_eof() and OSSL_STORE_close()
  110. were added in OpenSSL 1.1.1.
  111. =head1 COPYRIGHT
  112. Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
  113. Licensed under the Apache License 2.0 (the "License"). You may not use
  114. this file except in compliance with the License. You can obtain a copy
  115. in the file LICENSE in the source distribution or at
  116. L<https://www.openssl.org/source/license.html>.
  117. =cut