OSSL_DECODER_CTX.3ossl 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)
  2. .\"
  3. .\" Standard preamble:
  4. .\" ========================================================================
  5. .de Sp \" Vertical space (when we can't use .PP)
  6. .if t .sp .5v
  7. .if n .sp
  8. ..
  9. .de Vb \" Begin verbatim text
  10. .ft CW
  11. .nf
  12. .ne \\$1
  13. ..
  14. .de Ve \" End verbatim text
  15. .ft R
  16. .fi
  17. ..
  18. .\" Set up some character translations and predefined strings. \*(-- will
  19. .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
  20. .\" double quote, and \*(R" will give a right double quote. \*(C+ will
  21. .\" give a nicer C++. Capital omega is used to do unbreakable dashes and
  22. .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
  23. .\" nothing in troff, for use with C<>.
  24. .tr \(*W-
  25. .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
  26. .ie n \{\
  27. . ds -- \(*W-
  28. . ds PI pi
  29. . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
  30. . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
  31. . ds L" ""
  32. . ds R" ""
  33. . ds C` ""
  34. . ds C' ""
  35. 'br\}
  36. .el\{\
  37. . ds -- \|\(em\|
  38. . ds PI \(*p
  39. . ds L" ``
  40. . ds R" ''
  41. . ds C`
  42. . ds C'
  43. 'br\}
  44. .\"
  45. .\" Escape single quotes in literal strings from groff's Unicode transform.
  46. .ie \n(.g .ds Aq \(aq
  47. .el .ds Aq '
  48. .\"
  49. .\" If the F register is >0, we'll generate index entries on stderr for
  50. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  51. .\" entries marked with X<> in POD. Of course, you'll have to process the
  52. .\" output yourself in some meaningful fashion.
  53. .\"
  54. .\" Avoid warning from groff about undefined register 'F'.
  55. .de IX
  56. ..
  57. .nr rF 0
  58. .if \n(.g .if rF .nr rF 1
  59. .if (\n(rF:(\n(.g==0)) \{\
  60. . if \nF \{\
  61. . de IX
  62. . tm Index:\\$1\t\\n%\t"\\$2"
  63. ..
  64. . if !\nF==2 \{\
  65. . nr % 0
  66. . nr F 2
  67. . \}
  68. . \}
  69. .\}
  70. .rr rF
  71. .\"
  72. .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
  73. .\" Fear. Run. Save yourself. No user-serviceable parts.
  74. . \" fudge factors for nroff and troff
  75. .if n \{\
  76. . ds #H 0
  77. . ds #V .8m
  78. . ds #F .3m
  79. . ds #[ \f1
  80. . ds #] \fP
  81. .\}
  82. .if t \{\
  83. . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
  84. . ds #V .6m
  85. . ds #F 0
  86. . ds #[ \&
  87. . ds #] \&
  88. .\}
  89. . \" simple accents for nroff and troff
  90. .if n \{\
  91. . ds ' \&
  92. . ds ` \&
  93. . ds ^ \&
  94. . ds , \&
  95. . ds ~ ~
  96. . ds /
  97. .\}
  98. .if t \{\
  99. . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
  100. . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
  101. . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
  102. . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
  103. . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
  104. . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
  105. .\}
  106. . \" troff and (daisy-wheel) nroff accents
  107. .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
  108. .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
  109. .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
  110. .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
  111. .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
  112. .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
  113. .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
  114. .ds ae a\h'-(\w'a'u*4/10)'e
  115. .ds Ae A\h'-(\w'A'u*4/10)'E
  116. . \" corrections for vroff
  117. .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
  118. .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
  119. . \" for low resolution devices (crt and lpr)
  120. .if \n(.H>23 .if \n(.V>19 \
  121. \{\
  122. . ds : e
  123. . ds 8 ss
  124. . ds o a
  125. . ds d- d\h'-1'\(ga
  126. . ds D- D\h'-1'\(hy
  127. . ds th \o'bp'
  128. . ds Th \o'LP'
  129. . ds ae ae
  130. . ds Ae AE
  131. .\}
  132. .rm #[ #] #H #V #F C
  133. .\" ========================================================================
  134. .\"
  135. .IX Title "OSSL_DECODER_CTX 3ossl"
  136. .TH OSSL_DECODER_CTX 3ossl "2024-09-03" "3.3.2" "OpenSSL"
  137. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  138. .\" way too many mistakes in technical documents.
  139. .if n .ad l
  140. .nh
  141. .SH "NAME"
  142. OSSL_DECODER_CTX,
  143. OSSL_DECODER_CTX_new,
  144. OSSL_DECODER_settable_ctx_params,
  145. OSSL_DECODER_CTX_set_params,
  146. OSSL_DECODER_CTX_free,
  147. OSSL_DECODER_CTX_set_selection,
  148. OSSL_DECODER_CTX_set_input_type,
  149. OSSL_DECODER_CTX_set_input_structure,
  150. OSSL_DECODER_CTX_add_decoder,
  151. OSSL_DECODER_CTX_add_extra,
  152. OSSL_DECODER_CTX_get_num_decoders,
  153. OSSL_DECODER_INSTANCE,
  154. OSSL_DECODER_CONSTRUCT,
  155. OSSL_DECODER_CLEANUP,
  156. OSSL_DECODER_CTX_set_construct,
  157. OSSL_DECODER_CTX_set_construct_data,
  158. OSSL_DECODER_CTX_set_cleanup,
  159. OSSL_DECODER_CTX_get_construct,
  160. OSSL_DECODER_CTX_get_construct_data,
  161. OSSL_DECODER_CTX_get_cleanup,
  162. OSSL_DECODER_export,
  163. OSSL_DECODER_INSTANCE_get_decoder,
  164. OSSL_DECODER_INSTANCE_get_decoder_ctx,
  165. OSSL_DECODER_INSTANCE_get_input_type,
  166. OSSL_DECODER_INSTANCE_get_input_structure
  167. \&\- Decoder context routines
  168. .SH "SYNOPSIS"
  169. .IX Header "SYNOPSIS"
  170. .Vb 1
  171. \& #include <openssl/decoder.h>
  172. \&
  173. \& typedef struct ossl_decoder_ctx_st OSSL_DECODER_CTX;
  174. \&
  175. \& OSSL_DECODER_CTX *OSSL_DECODER_CTX_new(void);
  176. \& const OSSL_PARAM *OSSL_DECODER_settable_ctx_params(OSSL_DECODER *decoder);
  177. \& int OSSL_DECODER_CTX_set_params(OSSL_DECODER_CTX *ctx,
  178. \& const OSSL_PARAM params[]);
  179. \& void OSSL_DECODER_CTX_free(OSSL_DECODER_CTX *ctx);
  180. \&
  181. \& int OSSL_DECODER_CTX_set_selection(OSSL_DECODER_CTX *ctx, int selection);
  182. \& int OSSL_DECODER_CTX_set_input_type(OSSL_DECODER_CTX *ctx,
  183. \& const char *input_type);
  184. \& int OSSL_DECODER_CTX_set_input_structure(OSSL_DECODER_CTX *ctx,
  185. \& const char *input_structure);
  186. \& int OSSL_DECODER_CTX_add_decoder(OSSL_DECODER_CTX *ctx, OSSL_DECODER *decoder);
  187. \& int OSSL_DECODER_CTX_add_extra(OSSL_DECODER_CTX *ctx,
  188. \& OSSL_LIB_CTX *libctx,
  189. \& const char *propq);
  190. \& int OSSL_DECODER_CTX_get_num_decoders(OSSL_DECODER_CTX *ctx);
  191. \&
  192. \& typedef struct ossl_decoder_instance_st OSSL_DECODER_INSTANCE;
  193. \& OSSL_DECODER *
  194. \& OSSL_DECODER_INSTANCE_get_decoder(OSSL_DECODER_INSTANCE *decoder_inst);
  195. \& void *
  196. \& OSSL_DECODER_INSTANCE_get_decoder_ctx(OSSL_DECODER_INSTANCE *decoder_inst);
  197. \& const char *
  198. \& OSSL_DECODER_INSTANCE_get_input_type(OSSL_DECODER_INSTANCE *decoder_inst);
  199. \& OSSL_DECODER_INSTANCE_get_input_structure(OSSL_DECODER_INSTANCE *decoder_inst,
  200. \& int *was_set);
  201. \&
  202. \& typedef int OSSL_DECODER_CONSTRUCT(OSSL_DECODER_INSTANCE *decoder_inst,
  203. \& const OSSL_PARAM *object,
  204. \& void *construct_data);
  205. \& typedef void OSSL_DECODER_CLEANUP(void *construct_data);
  206. \&
  207. \& int OSSL_DECODER_CTX_set_construct(OSSL_DECODER_CTX *ctx,
  208. \& OSSL_DECODER_CONSTRUCT *construct);
  209. \& int OSSL_DECODER_CTX_set_construct_data(OSSL_DECODER_CTX *ctx,
  210. \& void *construct_data);
  211. \& int OSSL_DECODER_CTX_set_cleanup(OSSL_DECODER_CTX *ctx,
  212. \& OSSL_DECODER_CLEANUP *cleanup);
  213. \& OSSL_DECODER_CONSTRUCT *OSSL_DECODER_CTX_get_construct(OSSL_DECODER_CTX *ctx);
  214. \& void *OSSL_DECODER_CTX_get_construct_data(OSSL_DECODER_CTX *ctx);
  215. \& OSSL_DECODER_CLEANUP *OSSL_DECODER_CTX_get_cleanup(OSSL_DECODER_CTX *ctx);
  216. \&
  217. \& int OSSL_DECODER_export(OSSL_DECODER_INSTANCE *decoder_inst,
  218. \& void *reference, size_t reference_sz,
  219. \& OSSL_CALLBACK *export_cb, void *export_cbarg);
  220. .Ve
  221. .SH "DESCRIPTION"
  222. .IX Header "DESCRIPTION"
  223. The \fB\s-1OSSL_DECODER_CTX\s0\fR holds data about multiple decoders, as needed to
  224. figure out what the input data is and to attempt to unpack it into one of
  225. several possible related results. This also includes chaining decoders, so
  226. the output from one can become the input for another. This allows having
  227. generic format decoders such as \s-1PEM\s0 to \s-1DER,\s0 as well as more specialized
  228. decoders like \s-1DER\s0 to \s-1RSA.\s0
  229. .PP
  230. The chains may be limited by specifying an input type, which is considered a
  231. starting point. This is both considered by \fBOSSL_DECODER_CTX_add_extra()\fR,
  232. which will stop adding one more decoder implementations when it has already
  233. added those that take the specified input type, and functions like
  234. \&\fBOSSL_DECODER_from_bio\fR\|(3), which will only start the decoding process with
  235. the decoder implementations that take that input type. For example, if the
  236. input type is set to \f(CW\*(C`DER\*(C'\fR, a \s-1PEM\s0 to \s-1DER\s0 decoder will be ignored.
  237. .PP
  238. The input type can also be \s-1NULL,\s0 which means that the caller doesn't know
  239. what type of input they have. In this case, \fBOSSL_DECODER_from_bio()\fR will
  240. simply try with one decoder implementation after the other, and thereby
  241. discover what kind of input the caller gave it.
  242. .PP
  243. For every decoding done, even an intermediary one, a constructor provided by
  244. the caller is called to attempt to construct an appropriate type / structure
  245. that the caller knows how to handle from the current decoding result.
  246. The constructor is set with \fBOSSL_DECODER_CTX_set_construct()\fR.
  247. .PP
  248. \&\fB\s-1OSSL_DECODER_INSTANCE\s0\fR is an opaque structure that contains data about the
  249. decoder that was just used, and that may be useful for the constructor.
  250. There are some functions to extract data from this type, described further
  251. down.
  252. .SS "Functions"
  253. .IX Subsection "Functions"
  254. \&\fBOSSL_DECODER_CTX_new()\fR creates a new empty \fB\s-1OSSL_DECODER_CTX\s0\fR.
  255. .PP
  256. \&\fBOSSL_DECODER_settable_ctx_params()\fR returns an \s-1\fBOSSL_PARAM\s0\fR\|(3) array of
  257. parameter descriptors.
  258. .PP
  259. \&\fBOSSL_DECODER_CTX_set_params()\fR attempts to set parameters specified with an
  260. \&\s-1\fBOSSL_PARAM\s0\fR\|(3) array \fIparams\fR. These parameters are passed to all
  261. decoders that have been added to the \fIctx\fR so far. Parameters that an
  262. implementation doesn't recognise should be ignored by it.
  263. .PP
  264. \&\fBOSSL_DECODER_CTX_free()\fR frees the given context \fIctx\fR.
  265. If the argument is \s-1NULL,\s0 nothing is done.
  266. .PP
  267. \&\fBOSSL_DECODER_CTX_add_decoder()\fR populates the \fB\s-1OSSL_DECODER_CTX\s0\fR \fIctx\fR with
  268. a decoder, to be used to attempt to decode some encoded input.
  269. .PP
  270. \&\fBOSSL_DECODER_CTX_add_extra()\fR finds decoders that generate input for already
  271. added decoders, and adds them as well. This is used to build decoder
  272. chains.
  273. .PP
  274. \&\fBOSSL_DECODER_CTX_set_input_type()\fR sets the starting input type. This limits
  275. the decoder chains to be considered, as explained in the general description
  276. above.
  277. .PP
  278. \&\fBOSSL_DECODER_CTX_set_input_structure()\fR sets the name of the structure that
  279. the input is expected to have. This may be used to determines what decoder
  280. implementations may be used. \s-1NULL\s0 is a valid input structure, when it's not
  281. relevant, or when the decoder implementations are expected to figure it out.
  282. .PP
  283. \&\fBOSSL_DECODER_CTX_get_num_decoders()\fR gets the number of decoders currently
  284. added to the context \fIctx\fR.
  285. .PP
  286. \&\fBOSSL_DECODER_CTX_set_construct()\fR sets the constructor \fIconstruct\fR.
  287. .PP
  288. \&\fBOSSL_DECODER_CTX_set_construct_data()\fR sets the constructor data that is
  289. passed to the constructor every time it's called.
  290. .PP
  291. \&\fBOSSL_DECODER_CTX_set_cleanup()\fR sets the constructor data \fIcleanup\fR
  292. function. This is called by \fBOSSL_DECODER_CTX_free\fR\|(3).
  293. .PP
  294. \&\fBOSSL_DECODER_CTX_get_construct()\fR, \fBOSSL_DECODER_CTX_get_construct_data()\fR and
  295. \&\fBOSSL_DECODER_CTX_get_cleanup()\fR return the values that have been set by
  296. \&\fBOSSL_DECODER_CTX_set_construct()\fR, \fBOSSL_DECODER_CTX_set_construct_data()\fR and
  297. \&\fBOSSL_DECODER_CTX_set_cleanup()\fR respectively.
  298. .PP
  299. \&\fBOSSL_DECODER_export()\fR is a fallback function for constructors that cannot
  300. use the data they get directly for diverse reasons. It takes the same
  301. decode instance \fIdecoder_inst\fR that the constructor got and an object
  302. \&\fIreference\fR, unpacks the object which it refers to, and exports it by
  303. creating an \s-1\fBOSSL_PARAM\s0\fR\|(3) array that it then passes to \fIexport_cb\fR,
  304. along with \fIexport_arg\fR.
  305. .SS "Constructor"
  306. .IX Subsection "Constructor"
  307. A \fB\s-1OSSL_DECODER_CONSTRUCT\s0\fR gets the following arguments:
  308. .IP "\fIdecoder_inst\fR" 4
  309. .IX Item "decoder_inst"
  310. The \fB\s-1OSSL_DECODER_INSTANCE\s0\fR for the decoder from which the constructor gets
  311. its data.
  312. .IP "\fIobject\fR" 4
  313. .IX Item "object"
  314. A provider-native object abstraction produced by the decoder. Further
  315. information on the provider-native object abstraction can be found in
  316. \&\fBprovider\-object\fR\|(7).
  317. .IP "\fIconstruct_data\fR" 4
  318. .IX Item "construct_data"
  319. The pointer that was set with \fBOSSL_DECODE_CTX_set_construct_data()\fR.
  320. .PP
  321. The constructor is expected to return 1 when the data it receives can be
  322. constructed, otherwise 0.
  323. .PP
  324. These utility functions may be used by a constructor:
  325. .PP
  326. \&\fBOSSL_DECODER_INSTANCE_get_decoder()\fR can be used to get the decoder
  327. implementation from a decoder instance \fIdecoder_inst\fR.
  328. .PP
  329. \&\fBOSSL_DECODER_INSTANCE_get_decoder_ctx()\fR can be used to get the decoder
  330. implementation's provider context from a decoder instance \fIdecoder_inst\fR.
  331. .PP
  332. \&\fBOSSL_DECODER_INSTANCE_get_input_type()\fR can be used to get the decoder
  333. implementation's input type from a decoder instance \fIdecoder_inst\fR.
  334. .PP
  335. \&\fBOSSL_DECODER_INSTANCE_get_input_structure()\fR can be used to get the input
  336. structure for the decoder implementation from a decoder instance
  337. \&\fIdecoder_inst\fR.
  338. This may be \s-1NULL.\s0
  339. .SH "RETURN VALUES"
  340. .IX Header "RETURN VALUES"
  341. \&\fBOSSL_DECODER_CTX_new()\fR returns a pointer to a \fB\s-1OSSL_DECODER_CTX\s0\fR, or \s-1NULL\s0
  342. if the context structure couldn't be allocated.
  343. .PP
  344. \&\fBOSSL_DECODER_settable_ctx_params()\fR returns an \s-1\fBOSSL_PARAM\s0\fR\|(3) array, or
  345. \&\s-1NULL\s0 if none is available.
  346. .PP
  347. \&\fBOSSL_DECODER_CTX_set_params()\fR returns 1 if all recognised parameters were
  348. valid, or 0 if one of them was invalid or caused some other failure in the
  349. implementation.
  350. .PP
  351. \&\fBOSSL_DECODER_CTX_add_decoder()\fR, \fBOSSL_DECODER_CTX_add_extra()\fR,
  352. \&\fBOSSL_DECODER_CTX_set_construct()\fR, \fBOSSL_DECODER_CTX_set_construct_data()\fR and
  353. \&\fBOSSL_DECODER_CTX_set_cleanup()\fR return 1 on success, or 0 on failure.
  354. .PP
  355. \&\fBOSSL_DECODER_CTX_get_construct()\fR, \fBOSSL_DECODER_CTX_get_construct_data()\fR and
  356. \&\fBOSSL_DECODER_CTX_get_cleanup()\fR return the current pointers to the
  357. constructor, the constructor data and the cleanup functions, respectively.
  358. .PP
  359. \&\fBOSSL_DECODER_CTX_num_decoders()\fR returns the current number of decoders. It
  360. returns 0 if \fIctx\fR is \s-1NULL.\s0
  361. .PP
  362. \&\fBOSSL_DECODER_export()\fR returns 1 on success, or 0 on failure.
  363. .PP
  364. \&\fBOSSL_DECODER_INSTANCE_decoder()\fR returns an \fB\s-1OSSL_DECODER\s0\fR pointer on
  365. success, or \s-1NULL\s0 on failure.
  366. .PP
  367. \&\fBOSSL_DECODER_INSTANCE_decoder_ctx()\fR returns a provider context pointer on
  368. success, or \s-1NULL\s0 on failure.
  369. .SH "SEE ALSO"
  370. .IX Header "SEE ALSO"
  371. \&\fBprovider\fR\|(7), \s-1\fBOSSL_DECODER\s0\fR\|(3), \fBOSSL_DECODER_from_bio\fR\|(3)
  372. .SH "HISTORY"
  373. .IX Header "HISTORY"
  374. The functions described here were added in OpenSSL 3.0.
  375. .SH "COPYRIGHT"
  376. .IX Header "COPYRIGHT"
  377. Copyright 2020\-2024 The OpenSSL Project Authors. All Rights Reserved.
  378. .PP
  379. Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use
  380. this file except in compliance with the License. You can obtain a copy
  381. in the file \s-1LICENSE\s0 in the source distribution or at
  382. <https://www.openssl.org/source/license.html>.