provider-decoder.7ossl 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  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 "PROVIDER-DECODER 7ossl"
  136. .TH PROVIDER-DECODER 7ossl "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. provider\-decoder \- The OSSL_DECODER library <\-> provider functions
  143. .SH "SYNOPSIS"
  144. .IX Header "SYNOPSIS"
  145. .Vb 1
  146. \& #include <openssl/core_dispatch.h>
  147. \&
  148. \& /*
  149. \& * None of these are actual functions, but are displayed like this for
  150. \& * the function signatures for functions that are offered as function
  151. \& * pointers in OSSL_DISPATCH arrays.
  152. \& */
  153. \&
  154. \& /* Decoder parameter accessor and descriptor */
  155. \& const OSSL_PARAM *OSSL_FUNC_decoder_gettable_params(void *provctx);
  156. \& int OSSL_FUNC_decoder_get_params(OSSL_PARAM params[]);
  157. \&
  158. \& /* Functions to construct / destruct / manipulate the decoder context */
  159. \& void *OSSL_FUNC_decoder_newctx(void *provctx);
  160. \& void OSSL_FUNC_decoder_freectx(void *ctx);
  161. \& const OSSL_PARAM *OSSL_FUNC_decoder_settable_ctx_params(void *provctx);
  162. \& int OSSL_FUNC_decoder_set_ctx_params(void *ctx, const OSSL_PARAM params[]);
  163. \&
  164. \& /* Functions to check selection support */
  165. \& int OSSL_FUNC_decoder_does_selection(void *provctx, int selection);
  166. \&
  167. \& /* Functions to decode object data */
  168. \& int OSSL_FUNC_decoder_decode(void *ctx, OSSL_CORE_BIO *in,
  169. \& int selection,
  170. \& OSSL_CALLBACK *data_cb, void *data_cbarg,
  171. \& OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg);
  172. \&
  173. \& /* Functions to export a decoded object */
  174. \& int OSSL_FUNC_decoder_export_object(void *ctx,
  175. \& const void *objref, size_t objref_sz,
  176. \& OSSL_CALLBACK *export_cb,
  177. \& void *export_cbarg);
  178. .Ve
  179. .SH "DESCRIPTION"
  180. .IX Header "DESCRIPTION"
  181. \&\fIThe term \*(L"decode\*(R" is used throughout this manual. This includes but is
  182. not limited to deserialization as individual decoders can also do
  183. decoding into intermediate data formats.\fR
  184. .PP
  185. The \s-1DECODER\s0 operation is a generic method to create a provider-native
  186. object reference or intermediate decoded data from an encoded form
  187. read from the given \fB\s-1OSSL_CORE_BIO\s0\fR. If the caller wants to decode
  188. data from memory, it should provide a \fBBIO_s_mem\fR\|(3) \fB\s-1BIO\s0\fR. The decoded
  189. data or object reference is passed along with eventual metadata
  190. to the \fImetadata_cb\fR as \s-1\fBOSSL_PARAM\s0\fR\|(3) parameters.
  191. .PP
  192. The decoder doesn't need to know more about the \fB\s-1OSSL_CORE_BIO\s0\fR
  193. pointer than being able to pass it to the appropriate \s-1BIO\s0 upcalls (see
  194. \&\*(L"Core functions\*(R" in \fBprovider\-base\fR\|(7)).
  195. .PP
  196. The \s-1DECODER\s0 implementation may be part of a chain, where data is
  197. passed from one to the next. For example, there may be an
  198. implementation to decode an object from \s-1PEM\s0 to \s-1DER,\s0 and another one
  199. that decodes \s-1DER\s0 to a provider-native object.
  200. .PP
  201. The last decoding step in the decoding chain is usually supposed to create
  202. a provider-native object referenced by an object reference. To import
  203. that object into a different provider the \fBOSSL_FUNC_decoder_export_object()\fR
  204. can be called as the final step of the decoding process.
  205. .PP
  206. All \*(L"functions\*(R" mentioned here are passed as function pointers between
  207. \&\fIlibcrypto\fR and the provider in \s-1\fBOSSL_DISPATCH\s0\fR\|(3) arrays via
  208. \&\s-1\fBOSSL_ALGORITHM\s0\fR\|(3) arrays that are returned by the provider's
  209. \&\fBprovider_query_operation()\fR function
  210. (see \*(L"Provider Functions\*(R" in \fBprovider\-base\fR\|(7)).
  211. .PP
  212. All these \*(L"functions\*(R" have a corresponding function type definition
  213. named \fBOSSL_FUNC_{name}_fn\fR, and a helper function to retrieve the
  214. function pointer from an \s-1\fBOSSL_DISPATCH\s0\fR\|(3) element named
  215. \&\fBOSSL_FUNC_{name}\fR.
  216. For example, the \*(L"function\*(R" \fBOSSL_FUNC_decoder_decode()\fR has these:
  217. .PP
  218. .Vb 7
  219. \& typedef int
  220. \& (OSSL_FUNC_decoder_decode_fn)(void *ctx, OSSL_CORE_BIO *in,
  221. \& int selection,
  222. \& OSSL_CALLBACK *data_cb, void *data_cbarg,
  223. \& OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg);
  224. \& static ossl_inline OSSL_FUNC_decoder_decode_fn*
  225. \& OSSL_FUNC_decoder_decode(const OSSL_DISPATCH *opf);
  226. .Ve
  227. .PP
  228. \&\s-1\fBOSSL_DISPATCH\s0\fR\|(3) arrays are indexed by numbers that are provided as
  229. macros in \fBopenssl\-core_dispatch.h\fR\|(7), as follows:
  230. .PP
  231. .Vb 2
  232. \& OSSL_FUNC_decoder_get_params OSSL_FUNC_DECODER_GET_PARAMS
  233. \& OSSL_FUNC_decoder_gettable_params OSSL_FUNC_DECODER_GETTABLE_PARAMS
  234. \&
  235. \& OSSL_FUNC_decoder_newctx OSSL_FUNC_DECODER_NEWCTX
  236. \& OSSL_FUNC_decoder_freectx OSSL_FUNC_DECODER_FREECTX
  237. \& OSSL_FUNC_decoder_set_ctx_params OSSL_FUNC_DECODER_SET_CTX_PARAMS
  238. \& OSSL_FUNC_decoder_settable_ctx_params OSSL_FUNC_DECODER_SETTABLE_CTX_PARAMS
  239. \&
  240. \& OSSL_FUNC_decoder_does_selection OSSL_FUNC_DECODER_DOES_SELECTION
  241. \&
  242. \& OSSL_FUNC_decoder_decode OSSL_FUNC_DECODER_DECODE
  243. \&
  244. \& OSSL_FUNC_decoder_export_object OSSL_FUNC_DECODER_EXPORT_OBJECT
  245. .Ve
  246. .SS "Names and properties"
  247. .IX Subsection "Names and properties"
  248. The name of an implementation should match the target type of object
  249. it decodes. For example, an implementation that decodes an \s-1RSA\s0 key
  250. should be named \*(L"\s-1RSA\*(R".\s0 Likewise, an implementation that decodes \s-1DER\s0 data
  251. from \s-1PEM\s0 input should be named \*(L"\s-1DER\*(R".\s0
  252. .PP
  253. Properties can be used to further specify details about an implementation:
  254. .IP "input" 4
  255. .IX Item "input"
  256. This property is used to specify what format of input the implementation
  257. can decode.
  258. .Sp
  259. This property is \fImandatory\fR.
  260. .Sp
  261. OpenSSL providers recognize the following input types:
  262. .RS 4
  263. .IP "pem" 4
  264. .IX Item "pem"
  265. An implementation with that input type decodes \s-1PEM\s0 formatted data.
  266. .IP "der" 4
  267. .IX Item "der"
  268. An implementation with that input type decodes \s-1DER\s0 formatted data.
  269. .IP "msblob" 4
  270. .IX Item "msblob"
  271. An implementation with that input type decodes \s-1MSBLOB\s0 formatted data.
  272. .IP "pvk" 4
  273. .IX Item "pvk"
  274. An implementation with that input type decodes \s-1PVK\s0 formatted data.
  275. .RE
  276. .RS 4
  277. .RE
  278. .IP "structure" 4
  279. .IX Item "structure"
  280. This property is used to specify the structure that the decoded data is
  281. expected to have.
  282. .Sp
  283. This property is \fIoptional\fR.
  284. .Sp
  285. Structures currently recognised by built-in decoders:
  286. .RS 4
  287. .ie n .IP """type-specific""" 4
  288. .el .IP "``type-specific''" 4
  289. .IX Item "type-specific"
  290. Type specific structure.
  291. .ie n .IP """pkcs8""" 4
  292. .el .IP "``pkcs8''" 4
  293. .IX Item "pkcs8"
  294. Structure according to the PKCS#8 specification.
  295. .ie n .IP """SubjectPublicKeyInfo""" 4
  296. .el .IP "``SubjectPublicKeyInfo''" 4
  297. .IX Item "SubjectPublicKeyInfo"
  298. Encoding of public keys according to the Subject Public Key Info of \s-1RFC 5280.\s0
  299. .RE
  300. .RS 4
  301. .RE
  302. .PP
  303. The possible values of both these properties is open ended. A provider may
  304. very well specify input types and structures that libcrypto doesn't know
  305. anything about.
  306. .SS "Subset selections"
  307. .IX Subsection "Subset selections"
  308. Sometimes, an object has more than one subset of data that is interesting to
  309. treat separately or together. It's possible to specify what subsets are to
  310. be decoded, with a set of bits \fIselection\fR that are passed in an \fBint\fR.
  311. .PP
  312. This set of bits depend entirely on what kind of provider-side object is
  313. to be decoded. For example, those bits are assumed to be the same as those
  314. used with \fBprovider\-keymgmt\fR\|(7) (see \*(L"Key Objects\*(R" in \fBprovider\-keymgmt\fR\|(7)) when
  315. the object is an asymmetric keypair \- e.g., \fB\s-1OSSL_KEYMGMT_SELECT_PRIVATE_KEY\s0\fR
  316. if the object to be decoded is supposed to contain private key components.
  317. .PP
  318. \&\fBOSSL_FUNC_decoder_does_selection()\fR should tell if a particular implementation
  319. supports any of the combinations given by \fIselection\fR.
  320. .SS "Context functions"
  321. .IX Subsection "Context functions"
  322. \&\fBOSSL_FUNC_decoder_newctx()\fR returns a context to be used with the rest of
  323. the functions.
  324. .PP
  325. \&\fBOSSL_FUNC_decoder_freectx()\fR frees the given \fIctx\fR as created by
  326. \&\fBOSSL_FUNC_decoder_newctx()\fR.
  327. .PP
  328. \&\fBOSSL_FUNC_decoder_set_ctx_params()\fR sets context data according to parameters
  329. from \fIparams\fR that it recognises. Unrecognised parameters should be
  330. ignored.
  331. Passing \s-1NULL\s0 for \fIparams\fR should return true.
  332. .PP
  333. \&\fBOSSL_FUNC_decoder_settable_ctx_params()\fR returns a constant \s-1\fBOSSL_PARAM\s0\fR\|(3)
  334. array describing the parameters that \fBOSSL_FUNC_decoder_set_ctx_params()\fR
  335. can handle.
  336. .PP
  337. See \s-1\fBOSSL_PARAM\s0\fR\|(3) for further details on the parameters structure used by
  338. \&\fBOSSL_FUNC_decoder_set_ctx_params()\fR and \fBOSSL_FUNC_decoder_settable_ctx_params()\fR.
  339. .SS "Export function"
  340. .IX Subsection "Export function"
  341. When a provider-native object is created by a decoder it would be unsuitable
  342. for direct use with a foreign provider. The export function allows for
  343. exporting the object into that foreign provider if the foreign provider
  344. supports the type of the object and provides an import function.
  345. .PP
  346. \&\fBOSSL_FUNC_decoder_export_object()\fR should export the object of size \fIobjref_sz\fR
  347. referenced by \fIobjref\fR as an \s-1\fBOSSL_PARAM\s0\fR\|(3) array and pass that into the
  348. \&\fIexport_cb\fR as well as the given \fIexport_cbarg\fR.
  349. .SS "Decoding functions"
  350. .IX Subsection "Decoding functions"
  351. \&\fBOSSL_FUNC_decoder_decode()\fR should decode the data as read from
  352. the \fB\s-1OSSL_CORE_BIO\s0\fR \fIin\fR to produce decoded data or an object to be
  353. passed as reference in an \s-1\fBOSSL_PARAM\s0\fR\|(3) array along with possible other
  354. metadata that was decoded from the input. This \s-1\fBOSSL_PARAM\s0\fR\|(3) array is
  355. then passed to the \fIdata_cb\fR callback. The \fIselection\fR bits,
  356. if relevant, should determine what the input data should contain.
  357. The decoding functions also take an \s-1\fBOSSL_PASSPHRASE_CALLBACK\s0\fR\|(3) function
  358. pointer along with a pointer to application data \fIcbarg\fR, which should be
  359. used when a pass phrase prompt is needed.
  360. .PP
  361. It's important to understand that the return value from this function is
  362. interpreted as follows:
  363. .IP "True (1)" 4
  364. .IX Item "True (1)"
  365. This means \*(L"carry on the decoding process\*(R", and is meaningful even though
  366. this function couldn't decode the input into anything, because there may be
  367. another decoder implementation that can decode it into something.
  368. .Sp
  369. The \fIdata_cb\fR callback should never be called when this function can't
  370. decode the input into anything.
  371. .IP "False (0)" 4
  372. .IX Item "False (0)"
  373. This means \*(L"stop the decoding process\*(R", and is meaningful when the input
  374. could be decoded into some sort of object that this function understands,
  375. but further treatment of that object results into errors that won't be
  376. possible for some other decoder implementation to get a different result.
  377. .PP
  378. The conditions to stop the decoding process are at the discretion of the
  379. implementation.
  380. .SS "Decoder operation parameters"
  381. .IX Subsection "Decoder operation parameters"
  382. There are currently no operation parameters currently recognised by the
  383. built-in decoders.
  384. .PP
  385. Parameters currently recognised by the built-in pass phrase callback:
  386. .ie n .IP """info"" (\fB\s-1OSSL_PASSPHRASE_PARAM_INFO\s0\fR) <\s-1UTF8\s0 string>" 4
  387. .el .IP "``info'' (\fB\s-1OSSL_PASSPHRASE_PARAM_INFO\s0\fR) <\s-1UTF8\s0 string>" 4
  388. .IX Item "info (OSSL_PASSPHRASE_PARAM_INFO) <UTF8 string>"
  389. A string of information that will become part of the pass phrase
  390. prompt. This could be used to give the user information on what kind
  391. of object it's being prompted for.
  392. .SH "RETURN VALUES"
  393. .IX Header "RETURN VALUES"
  394. \&\fBOSSL_FUNC_decoder_newctx()\fR returns a pointer to a context, or \s-1NULL\s0 on
  395. failure.
  396. .PP
  397. \&\fBOSSL_FUNC_decoder_set_ctx_params()\fR returns 1, unless a recognised
  398. parameter was invalid or caused an error, for which 0 is returned.
  399. .PP
  400. \&\fBOSSL_FUNC_decoder_settable_ctx_params()\fR returns a pointer to an array of
  401. constant \s-1\fBOSSL_PARAM\s0\fR\|(3) elements.
  402. .PP
  403. \&\fBOSSL_FUNC_decoder_does_selection()\fR returns 1 if the decoder implementation
  404. supports any of the \fIselection\fR bits, otherwise 0.
  405. .PP
  406. \&\fBOSSL_FUNC_decoder_decode()\fR returns 1 to signal that the decoding process
  407. should continue, or 0 to signal that it should stop.
  408. .SH "SEE ALSO"
  409. .IX Header "SEE ALSO"
  410. \&\fBprovider\fR\|(7)
  411. .SH "HISTORY"
  412. .IX Header "HISTORY"
  413. The \s-1DECODER\s0 interface was introduced in OpenSSL 3.0.
  414. .SH "COPYRIGHT"
  415. .IX Header "COPYRIGHT"
  416. Copyright 2019\-2023 The OpenSSL Project Authors. All Rights Reserved.
  417. .PP
  418. Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use
  419. this file except in compliance with the License. You can obtain a copy
  420. in the file \s-1LICENSE\s0 in the source distribution or at
  421. <https://www.openssl.org/source/license.html>.