OSSL_DECODER.3ossl 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. .\" -*- mode: troff; coding: utf-8 -*-
  2. .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
  3. .\"
  4. .\" Standard preamble:
  5. .\" ========================================================================
  6. .de Sp \" Vertical space (when we can't use .PP)
  7. .if t .sp .5v
  8. .if n .sp
  9. ..
  10. .de Vb \" Begin verbatim text
  11. .ft CW
  12. .nf
  13. .ne \\$1
  14. ..
  15. .de Ve \" End verbatim text
  16. .ft R
  17. .fi
  18. ..
  19. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
  20. .ie n \{\
  21. . ds C` ""
  22. . ds C' ""
  23. 'br\}
  24. .el\{\
  25. . ds C`
  26. . ds C'
  27. 'br\}
  28. .\"
  29. .\" Escape single quotes in literal strings from groff's Unicode transform.
  30. .ie \n(.g .ds Aq \(aq
  31. .el .ds Aq '
  32. .\"
  33. .\" If the F register is >0, we'll generate index entries on stderr for
  34. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  35. .\" entries marked with X<> in POD. Of course, you'll have to process the
  36. .\" output yourself in some meaningful fashion.
  37. .\"
  38. .\" Avoid warning from groff about undefined register 'F'.
  39. .de IX
  40. ..
  41. .nr rF 0
  42. .if \n(.g .if rF .nr rF 1
  43. .if (\n(rF:(\n(.g==0)) \{\
  44. . if \nF \{\
  45. . de IX
  46. . tm Index:\\$1\t\\n%\t"\\$2"
  47. ..
  48. . if !\nF==2 \{\
  49. . nr % 0
  50. . nr F 2
  51. . \}
  52. . \}
  53. .\}
  54. .rr rF
  55. .\" ========================================================================
  56. .\"
  57. .IX Title "OSSL_DECODER 3ossl"
  58. .TH OSSL_DECODER 3ossl 2025-01-17 3.4.0 OpenSSL
  59. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  60. .\" way too many mistakes in technical documents.
  61. .if n .ad l
  62. .nh
  63. .SH NAME
  64. OSSL_DECODER,
  65. OSSL_DECODER_fetch,
  66. OSSL_DECODER_up_ref,
  67. OSSL_DECODER_free,
  68. OSSL_DECODER_get0_provider,
  69. OSSL_DECODER_get0_properties,
  70. OSSL_DECODER_is_a,
  71. OSSL_DECODER_get0_name,
  72. OSSL_DECODER_get0_description,
  73. OSSL_DECODER_do_all_provided,
  74. OSSL_DECODER_names_do_all,
  75. OSSL_DECODER_gettable_params,
  76. OSSL_DECODER_get_params
  77. \&\- Decoder method routines
  78. .SH SYNOPSIS
  79. .IX Header "SYNOPSIS"
  80. .Vb 1
  81. \& #include <openssl/decoder.h>
  82. \&
  83. \& typedef struct ossl_decoder_st OSSL_DECODER;
  84. \&
  85. \& OSSL_DECODER *OSSL_DECODER_fetch(OSSL_LIB_CTX *ctx, const char *name,
  86. \& const char *properties);
  87. \& int OSSL_DECODER_up_ref(OSSL_DECODER *decoder);
  88. \& void OSSL_DECODER_free(OSSL_DECODER *decoder);
  89. \& const OSSL_PROVIDER *OSSL_DECODER_get0_provider(const OSSL_DECODER *decoder);
  90. \& const char *OSSL_DECODER_get0_properties(const OSSL_DECODER *decoder);
  91. \& int OSSL_DECODER_is_a(const OSSL_DECODER *decoder, const char *name);
  92. \& const char *OSSL_DECODER_get0_name(const OSSL_DECODER *decoder);
  93. \& const char *OSSL_DECODER_get0_description(const OSSL_DECODER *decoder);
  94. \& void OSSL_DECODER_do_all_provided(OSSL_LIB_CTX *libctx,
  95. \& void (*fn)(OSSL_DECODER *decoder, void *arg),
  96. \& void *arg);
  97. \& int OSSL_DECODER_names_do_all(const OSSL_DECODER *decoder,
  98. \& void (*fn)(const char *name, void *data),
  99. \& void *data);
  100. \& const OSSL_PARAM *OSSL_DECODER_gettable_params(OSSL_DECODER *decoder);
  101. \& int OSSL_DECODER_get_params(OSSL_DECODER_CTX *ctx, const OSSL_PARAM params[]);
  102. .Ve
  103. .SH DESCRIPTION
  104. .IX Header "DESCRIPTION"
  105. \&\fBOSSL_DECODER\fR is a method for decoders, which know how to
  106. decode encoded data into an object of some type that the rest
  107. of OpenSSL knows how to handle.
  108. .PP
  109. \&\fBOSSL_DECODER_fetch()\fR looks for an algorithm within the provider that
  110. has been loaded into the \fBOSSL_LIB_CTX\fR given by \fIctx\fR, having the
  111. name given by \fIname\fR and the properties given by \fIproperties\fR.
  112. The \fIname\fR determines what type of object the fetched decoder
  113. method is expected to be able to decode, and the properties are
  114. used to determine the expected output type.
  115. For known properties and the values they may have, please have a look
  116. in "Names and properties" in \fBprovider\-encoder\fR\|(7).
  117. .PP
  118. \&\fBOSSL_DECODER_up_ref()\fR increments the reference count for the given
  119. \&\fIdecoder\fR.
  120. .PP
  121. \&\fBOSSL_DECODER_free()\fR decrements the reference count for the given
  122. \&\fIdecoder\fR, and when the count reaches zero, frees it.
  123. If the argument is NULL, nothing is done.
  124. .PP
  125. \&\fBOSSL_DECODER_get0_provider()\fR returns the provider of the given
  126. \&\fIdecoder\fR.
  127. .PP
  128. \&\fBOSSL_DECODER_get0_properties()\fR returns the property definition associated
  129. with the given \fIdecoder\fR.
  130. .PP
  131. \&\fBOSSL_DECODER_is_a()\fR checks if \fIdecoder\fR is an implementation
  132. of an algorithm that's identifiable with \fIname\fR.
  133. .PP
  134. \&\fBOSSL_DECODER_get0_name()\fR returns the name used to fetch the given \fIdecoder\fR.
  135. .PP
  136. \&\fBOSSL_DECODER_get0_description()\fR returns a description of the \fIdecoder\fR, meant
  137. for display and human consumption. The description is at the discretion
  138. of the \fIdecoder\fR implementation.
  139. .PP
  140. \&\fBOSSL_DECODER_names_do_all()\fR traverses all names for the given
  141. \&\fIdecoder\fR, and calls \fIfn\fR with each name and \fIdata\fR as arguments.
  142. .PP
  143. \&\fBOSSL_DECODER_do_all_provided()\fR traverses all decoder
  144. implementations by all activated providers in the library context
  145. \&\fIlibctx\fR, and for each of the implementations, calls \fIfn\fR with the
  146. implementation method and \fIarg\fR as arguments.
  147. .PP
  148. \&\fBOSSL_DECODER_gettable_params()\fR returns an \fBOSSL_PARAM\fR\|(3)
  149. array of parameter descriptors.
  150. .PP
  151. \&\fBOSSL_DECODER_get_params()\fR attempts to get parameters specified
  152. with an \fBOSSL_PARAM\fR\|(3) array \fIparams\fR. Parameters that the
  153. implementation doesn't recognise should be ignored.
  154. .SH "RETURN VALUES"
  155. .IX Header "RETURN VALUES"
  156. \&\fBOSSL_DECODER_fetch()\fR returns a pointer to an OSSL_DECODER object,
  157. or NULL on error.
  158. .PP
  159. \&\fBOSSL_DECODER_up_ref()\fR returns 1 on success, or 0 on error.
  160. .PP
  161. \&\fBOSSL_DECODER_free()\fR doesn't return any value.
  162. .PP
  163. \&\fBOSSL_DECODER_get0_provider()\fR returns a pointer to a provider object, or
  164. NULL on error.
  165. .PP
  166. \&\fBOSSL_DECODER_get0_properties()\fR returns a pointer to a property
  167. definition string, or NULL on error.
  168. .PP
  169. \&\fBOSSL_DECODER_is_a()\fR returns 1 if \fIdecoder\fR was identifiable,
  170. otherwise 0.
  171. .PP
  172. \&\fBOSSL_DECODER_get0_name()\fR returns the algorithm name from the provided
  173. implementation for the given \fIdecoder\fR. Note that the \fIdecoder\fR may have
  174. multiple synonyms associated with it. In this case the first name from the
  175. algorithm definition is returned. Ownership of the returned string is retained
  176. by the \fIdecoder\fR object and should not be freed by the caller.
  177. .PP
  178. \&\fBOSSL_DECODER_get0_description()\fR returns a pointer to a description, or NULL if
  179. there isn't one.
  180. .PP
  181. \&\fBOSSL_DECODER_names_do_all()\fR returns 1 if the callback was called for all
  182. names. A return value of 0 means that the callback was not called for any names.
  183. .SH NOTES
  184. .IX Header "NOTES"
  185. \&\fBOSSL_DECODER_fetch()\fR may be called implicitly by other fetching
  186. functions, using the same library context and properties.
  187. Any other API that uses keys will typically do this.
  188. .SH EXAMPLES
  189. .IX Header "EXAMPLES"
  190. To list all decoders in a provider to a bio_out:
  191. .PP
  192. .Vb 3
  193. \& static void collect_decoders(OSSL_DECODER *decoder, void *stack)
  194. \& {
  195. \& STACK_OF(OSSL_DECODER) *decoder_stack = stack;
  196. \&
  197. \& sk_OSSL_DECODER_push(decoder_stack, decoder);
  198. \& OSSL_DECODER_up_ref(decoder);
  199. \& }
  200. \&
  201. \& void print_name(const char *name, void *vdata)
  202. \& {
  203. \& BIO *bio = vdata;
  204. \&
  205. \& BIO_printf(bio, "%s ", name);
  206. \& }
  207. \&
  208. \&
  209. \& STACK_OF(OSSL_DECODER) *decoders;
  210. \& int i;
  211. \&
  212. \& decoders = sk_OSSL_DECODER_new_null();
  213. \&
  214. \& BIO_printf(bio_out, "DECODERs provided by %s:\en", provider);
  215. \& OSSL_DECODER_do_all_provided(NULL, collect_decoders,
  216. \& decoders);
  217. \&
  218. \& for (i = 0; i < sk_OSSL_DECODER_num(decoders); i++) {
  219. \& OSSL_DECODER *decoder = sk_OSSL_DECODER_value(decoders, i);
  220. \&
  221. \& if (strcmp(OSSL_PROVIDER_get0_name(OSSL_DECODER_get0_provider(decoder)),
  222. \& provider) != 0)
  223. \& continue;
  224. \&
  225. \& if (OSSL_DECODER_names_do_all(decoder, print_name, bio_out))
  226. \& BIO_printf(bio_out, "\en");
  227. \& }
  228. \& sk_OSSL_DECODER_pop_free(decoders, OSSL_DECODER_free);
  229. .Ve
  230. .SH "SEE ALSO"
  231. .IX Header "SEE ALSO"
  232. \&\fBprovider\fR\|(7), \fBOSSL_DECODER_CTX\fR\|(3), \fBOSSL_DECODER_from_bio\fR\|(3),
  233. \&\fBOSSL_DECODER_CTX_new_for_pkey\fR\|(3), \fBOSSL_LIB_CTX\fR\|(3)
  234. .SH HISTORY
  235. .IX Header "HISTORY"
  236. The functions described here were added in OpenSSL 3.0.
  237. .SH COPYRIGHT
  238. .IX Header "COPYRIGHT"
  239. Copyright 2020\-2024 The OpenSSL Project Authors. All Rights Reserved.
  240. .PP
  241. Licensed under the Apache License 2.0 (the "License"). You may not use
  242. this file except in compliance with the License. You can obtain a copy
  243. in the file LICENSE in the source distribution or at
  244. <https://www.openssl.org/source/license.html>.