OSSL_STORE_INFO.pod 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. =pod
  2. =head1 NAME
  3. OSSL_STORE_INFO, OSSL_STORE_INFO_get_type, OSSL_STORE_INFO_get0_NAME,
  4. OSSL_STORE_INFO_get0_NAME_description,
  5. OSSL_STORE_INFO_get0_PARAMS, OSSL_STORE_INFO_get0_PUBKEY,
  6. OSSL_STORE_INFO_get0_PKEY, OSSL_STORE_INFO_get0_CERT, OSSL_STORE_INFO_get0_CRL,
  7. OSSL_STORE_INFO_get1_NAME, OSSL_STORE_INFO_get1_NAME_description,
  8. OSSL_STORE_INFO_get1_PARAMS, OSSL_STORE_INFO_get1_PUBKEY,
  9. OSSL_STORE_INFO_get1_PKEY, OSSL_STORE_INFO_get1_CERT, OSSL_STORE_INFO_get1_CRL,
  10. OSSL_STORE_INFO_type_string, OSSL_STORE_INFO_free,
  11. OSSL_STORE_INFO_new_NAME, OSSL_STORE_INFO_set0_NAME_description,
  12. OSSL_STORE_INFO_new_PARAMS, OSSL_STORE_INFO_new_PUBKEY,
  13. OSSL_STORE_INFO_new_PKEY, OSSL_STORE_INFO_new_CERT, OSSL_STORE_INFO_new_CRL,
  14. OSSL_STORE_INFO_new, OSSL_STORE_INFO_get0_data
  15. - Functions to manipulate OSSL_STORE_INFO objects
  16. =head1 SYNOPSIS
  17. #include <openssl/store.h>
  18. typedef struct ossl_store_info_st OSSL_STORE_INFO;
  19. int OSSL_STORE_INFO_get_type(const OSSL_STORE_INFO *store_info);
  20. const char *OSSL_STORE_INFO_get0_NAME(const OSSL_STORE_INFO *store_info);
  21. char *OSSL_STORE_INFO_get1_NAME(const OSSL_STORE_INFO *store_info);
  22. const char *OSSL_STORE_INFO_get0_NAME_description(const OSSL_STORE_INFO
  23. *store_info);
  24. char *OSSL_STORE_INFO_get1_NAME_description(const OSSL_STORE_INFO *store_info);
  25. EVP_PKEY *OSSL_STORE_INFO_get0_PARAMS(const OSSL_STORE_INFO *store_info);
  26. EVP_PKEY *OSSL_STORE_INFO_get1_PARAMS(const OSSL_STORE_INFO *store_info);
  27. EVP_PKEY *OSSL_STORE_INFO_get0_PUBKEY(const OSSL_STORE_INFO *info);
  28. EVP_PKEY *OSSL_STORE_INFO_get1_PUBKEY(const OSSL_STORE_INFO *info);
  29. EVP_PKEY *OSSL_STORE_INFO_get0_PKEY(const OSSL_STORE_INFO *store_info);
  30. EVP_PKEY *OSSL_STORE_INFO_get1_PKEY(const OSSL_STORE_INFO *store_info);
  31. X509 *OSSL_STORE_INFO_get0_CERT(const OSSL_STORE_INFO *store_info);
  32. X509 *OSSL_STORE_INFO_get1_CERT(const OSSL_STORE_INFO *store_info);
  33. X509_CRL *OSSL_STORE_INFO_get0_CRL(const OSSL_STORE_INFO *store_info);
  34. X509_CRL *OSSL_STORE_INFO_get1_CRL(const OSSL_STORE_INFO *store_info);
  35. const char *OSSL_STORE_INFO_type_string(int type);
  36. void OSSL_STORE_INFO_free(OSSL_STORE_INFO *store_info);
  37. OSSL_STORE_INFO *OSSL_STORE_INFO_new_NAME(char *name);
  38. int OSSL_STORE_INFO_set0_NAME_description(OSSL_STORE_INFO *info, char *desc);
  39. OSSL_STORE_INFO *OSSL_STORE_INFO_new_PARAMS(DSA *dsa_params);
  40. OSSL_STORE_INFO *OSSL_STORE_INFO_new_PUBKEY(EVP_PKEY *pubkey);
  41. OSSL_STORE_INFO *OSSL_STORE_INFO_new_PKEY(EVP_PKEY *pkey);
  42. OSSL_STORE_INFO *OSSL_STORE_INFO_new_CERT(X509 *x509);
  43. OSSL_STORE_INFO *OSSL_STORE_INFO_new_CRL(X509_CRL *crl);
  44. OSSL_STORE_INFO *OSSL_STORE_INFO_new(int type, void *data);
  45. void *OSSL_STORE_INFO_get0_data(int type, const OSSL_STORE_INFO *info);
  46. =head1 DESCRIPTION
  47. These functions are primarily useful for applications to retrieve
  48. supported objects from B<OSSL_STORE_INFO> objects and for scheme specific
  49. loaders to create B<OSSL_STORE_INFO> holders.
  50. =head2 Types
  51. B<OSSL_STORE_INFO> is an opaque type that's just an intermediary holder for
  52. the objects that have been retrieved by OSSL_STORE_load() and similar functions.
  53. Supported OpenSSL type object can be extracted using one of
  54. STORE_INFO_get0_<TYPE>() where <TYPE> can be NAME, PARAMS, PKEY, CERT, or CRL.
  55. The life time of this extracted object is as long as the life time of
  56. the B<OSSL_STORE_INFO> it was extracted from, so care should be taken not
  57. to free the latter too early.
  58. As an alternative, STORE_INFO_get1_<TYPE>() extracts a duplicate (or the
  59. same object with its reference count increased), which can be used
  60. after the containing B<OSSL_STORE_INFO> has been freed.
  61. The object returned by STORE_INFO_get1_<TYPE>() must be freed separately
  62. by the caller.
  63. See L</SUPPORTED OBJECTS> for more information on the types that are supported.
  64. =head2 Functions
  65. OSSL_STORE_INFO_get_type() takes a B<OSSL_STORE_INFO> and returns the STORE
  66. type number for the object inside.
  67. STORE_INFO_get_type_string() takes a STORE type number and returns a
  68. short string describing it.
  69. OSSL_STORE_INFO_get0_NAME(), OSSL_STORE_INFO_get0_NAME_description(),
  70. OSSL_STORE_INFO_get0_PARAMS(), OSSL_STORE_INFO_get0_PUBKEY(),
  71. OSSL_STORE_INFO_get0_PKEY(), OSSL_STORE_INFO_get0_CERT(),
  72. OSSL_STORE_INFO_get0_CRL()
  73. all take a B<OSSL_STORE_INFO> and return the object it holds if the
  74. B<OSSL_STORE_INFO> type (as returned by OSSL_STORE_INFO_get_type())
  75. matches the function, otherwise NULL.
  76. OSSL_STORE_INFO_get1_NAME(), OSSL_STORE_INFO_get1_NAME_description(),
  77. OSSL_STORE_INFO_get1_PARAMS(), OSSL_STORE_INFO_get1_PUBKEY(),
  78. OSSL_STORE_INFO_get1_PKEY(), OSSL_STORE_INFO_get1_CERT() and
  79. OSSL_STORE_INFO_get1_CRL()
  80. all take a B<OSSL_STORE_INFO> and return a duplicate the object it
  81. holds if the B<OSSL_STORE_INFO> type (as returned by
  82. OSSL_STORE_INFO_get_type()) matches the function, otherwise NULL.
  83. OSSL_STORE_INFO_free() frees a B<OSSL_STORE_INFO> and its contained type.
  84. OSSL_STORE_INFO_new_NAME() , OSSL_STORE_INFO_new_PARAMS(),
  85. , OSSL_STORE_INFO_new_PUBKEY(), OSSL_STORE_INFO_new_PKEY(),
  86. OSSL_STORE_INFO_new_CERT() and OSSL_STORE_INFO_new_CRL()
  87. create a B<OSSL_STORE_INFO> object to hold the given input object.
  88. On success the input object is consumed.
  89. Additionally, for B<OSSL_STORE_INFO_NAME> objects,
  90. OSSL_STORE_INFO_set0_NAME_description() can be used to add an extra
  91. description.
  92. This description is meant to be human readable and should be used for
  93. information printout.
  94. OSSL_STORE_INFO_new() creates a B<OSSL_STORE_INFO> with an arbitrary I<type>
  95. number and I<data> structure. It's the responsibility of the caller to
  96. define type numbers other than the ones defined by F<< <openssl/store.h> >>,
  97. and to handle freeing the associated data structure on their own.
  98. I<Using type numbers that are defined by F<< <openssl/store.h> >> may cause
  99. undefined behaviours, including crashes>.
  100. OSSL_STORE_INFO_get0_data() returns the data pointer that was passed to
  101. OSSL_STORE_INFO_new() if I<type> matches the type number in I<info>.
  102. OSSL_STORE_INFO_new() and OSSL_STORE_INFO_get0_data() may be useful for
  103. applications that define their own STORE data, but must be used with care.
  104. =head1 SUPPORTED OBJECTS
  105. Currently supported object types are:
  106. =over 4
  107. =item OSSL_STORE_INFO_NAME
  108. A name is exactly that, a name.
  109. It's like a name in a directory, but formatted as a complete URI.
  110. For example, the path in URI C<file:/foo/bar/> could include a file
  111. named C<cookie.pem>, and in that case, the returned B<OSSL_STORE_INFO_NAME>
  112. object would have the URI C<file:/foo/bar/cookie.pem>, which can be
  113. used by the application to get the objects in that file.
  114. This can be applied to all schemes that can somehow support a listing
  115. of object URIs.
  116. For C<file:> URIs that are used without the explicit scheme, the
  117. returned name will be the path of each object, so if C</foo/bar> was
  118. given and that path has the file C<cookie.pem>, the name
  119. C</foo/bar/cookie.pem> will be returned.
  120. The returned URI is considered canonical and must be unique and permanent
  121. for the storage where the object (or collection of objects) resides.
  122. Each loader is responsible for ensuring that it only returns canonical
  123. URIs.
  124. However, it's possible that certain schemes allow an object (or collection
  125. thereof) to be reached with alternative URIs; just because one URI is
  126. canonical doesn't mean that other variants can't be used.
  127. At the discretion of the loader that was used to get these names, an
  128. extra description may be attached as well.
  129. =item OSSL_STORE_INFO_PARAMS
  130. Key parameters.
  131. =item OSSL_STORE_INFO_PKEY
  132. A keypair or just a private key (possibly with key parameters).
  133. =item OSSL_STORE_INFO_PUBKEY
  134. A public key (possibly with key parameters).
  135. =item OSSL_STORE_INFO_CERT
  136. An X.509 certificate.
  137. =item OSSL_STORE_INFO_CRL
  138. A X.509 certificate revocation list.
  139. =back
  140. =head1 RETURN VALUES
  141. OSSL_STORE_INFO_get_type() returns the STORE type number of the given
  142. B<OSSL_STORE_INFO>.
  143. There is no error value.
  144. OSSL_STORE_INFO_get0_NAME(), OSSL_STORE_INFO_get0_NAME_description(),
  145. OSSL_STORE_INFO_get0_PARAMS(), OSSL_STORE_INFO_get0_PKEY(),
  146. OSSL_STORE_INFO_get0_CERT() and OSSL_STORE_INFO_get0_CRL() all return
  147. a pointer to the OpenSSL object on success, NULL otherwise.
  148. OSSL_STORE_INFO_get1_NAME(), OSSL_STORE_INFO_get1_NAME_description(),
  149. OSSL_STORE_INFO_get1_PARAMS(), OSSL_STORE_INFO_get1_PKEY(),
  150. OSSL_STORE_INFO_get1_CERT() and OSSL_STORE_INFO_get1_CRL() all return
  151. a pointer to a duplicate of the OpenSSL object on success, NULL otherwise.
  152. OSSL_STORE_INFO_type_string() returns a string on success, or NULL on
  153. failure.
  154. OSSL_STORE_INFO_new_NAME(), OSSL_STORE_INFO_new_PARAMS(),
  155. OSSL_STORE_INFO_new_PKEY(), OSSL_STORE_INFO_new_CERT() and
  156. OSSL_STORE_INFO_new_CRL() return a B<OSSL_STORE_INFO>
  157. pointer on success, or NULL on failure.
  158. OSSL_STORE_INFO_set0_NAME_description() returns 1 on success, or 0 on
  159. failure.
  160. =head1 SEE ALSO
  161. L<ossl_store(7)>, L<OSSL_STORE_open(3)>, L<OSSL_STORE_register_loader(3)>
  162. =head1 HISTORY
  163. The OSSL_STORE API was added in OpenSSL 1.1.1.
  164. The OSSL_STORE_INFO_PUBKEY object type was added in OpenSSL 3.0.
  165. =head1 COPYRIGHT
  166. Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
  167. Licensed under the Apache License 2.0 (the "License"). You may not use
  168. this file except in compliance with the License. You can obtain a copy
  169. in the file LICENSE in the source distribution or at
  170. L<https://www.openssl.org/source/license.html>.
  171. =cut