xref: /freebsd/secure/lib/libcrypto/man/man7/provider-decoder.7 (revision 2e3507c25e42292b45a5482e116d278f5515d04d)
Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)

Standard preamble:
========================================================================
..
..
.. Set up some character translations and predefined strings. \*(-- will
give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
double quote, and \*(R" will give a right double quote. \*(C+ will
give a nicer C++. Capital omega is used to do unbreakable dashes and
therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
nothing in troff, for use with C<>.
.tr \(*W- . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\}
Escape single quotes in literal strings from groff's Unicode transform.

If the F register is >0, we'll generate index entries on stderr for
titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
entries marked with X<> in POD. Of course, you'll have to process the
output yourself in some meaningful fashion.

Avoid warning from groff about undefined register 'F'.
.. .nr rF 0 . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] .\} . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents . \" corrections for vroff . \" for low resolution devices (crt and lpr) \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} ========================================================================

Title "PROVIDER-DECODER 7ossl"
PROVIDER-DECODER 7ossl "2023-09-19" "3.0.11" "OpenSSL"
For nroff, turn off justification. Always turn off hyphenation; it makes
way too many mistakes in technical documents.
"NAME"
provider-decoder - The OSSL_DECODER library <-> provider functions
"SYNOPSIS"
Header "SYNOPSIS" .Vb 1 #include <openssl/core_dispatch.h> \& /* * None of these are actual functions, but are displayed like this for * the function signatures for functions that are offered as function * pointers in OSSL_DISPATCH arrays. */ \& /* Decoder parameter accessor and descriptor */ const OSSL_PARAM *OSSL_FUNC_decoder_gettable_params(void *provctx); int OSSL_FUNC_decoder_get_params(OSSL_PARAM params[]); \& /* Functions to construct / destruct / manipulate the decoder context */ void *OSSL_FUNC_decoder_newctx(void *provctx); void OSSL_FUNC_decoder_freectx(void *ctx); const OSSL_PARAM *OSSL_FUNC_decoder_settable_ctx_params(void *provctx); int OSSL_FUNC_decoder_set_ctx_params(void *ctx, const OSSL_PARAM params[]); \& /* Functions to check selection support */ int OSSL_FUNC_decoder_does_selection(void *provctx, int selection); \& /* Functions to decode object data */ int OSSL_FUNC_decoder_decode(void *ctx, OSSL_CORE_BIO *in, int selection, OSSL_CALLBACK *data_cb, void *data_cbarg, OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg); \& /* Functions to export a decoded object */ int OSSL_FUNC_decoder_export_object(void *ctx, const void *objref, size_t objref_sz, OSSL_CALLBACK *export_cb, void *export_cbarg); .Ve
"DESCRIPTION"
Header "DESCRIPTION" \fIThe term \*(L"decode\*(R" is used throughout this manual. This includes but is not limited to deserialization as individual decoders can also do decoding into intermediate data formats.

The \s-1DECODER\s0 operation is a generic method to create a provider-native object reference or intermediate decoded data from an encoded form read from the given \s-1OSSL_CORE_BIO\s0. If the caller wants to decode data from memory, it should provide a BIO_s_mem\|(3) \s-1BIO\s0. The decoded data or object reference is passed along with eventual metadata to the metadata_cb as \s-1OSSL_PARAM\s0\|(3) parameters.

The decoder doesn't need to know more about the \s-1OSSL_CORE_BIO\s0 pointer than being able to pass it to the appropriate \s-1BIO\s0 upcalls (see \*(L"Core functions\*(R" in provider-base\|(7)).

The \s-1DECODER\s0 implementation may be part of a chain, where data is passed from one to the next. For example, there may be an implementation to decode an object from \s-1PEM\s0 to \s-1DER,\s0 and another one that decodes \s-1DER\s0 to a provider-native object.

The last decoding step in the decoding chain is usually supposed to create a provider-native object referenced by an object reference. To import that object into a different provider the OSSL_FUNC_decoder_export_object() can be called as the final step of the decoding process.

All \*(L"functions\*(R" mentioned here are passed as function pointers between \fIlibcrypto and the provider in \s-1OSSL_DISPATCH\s0\|(3) arrays via \s-1OSSL_ALGORITHM\s0\|(3) arrays that are returned by the provider's \fBprovider_query_operation() function (see \*(L"Provider Functions\*(R" in provider-base\|(7)).

All these \*(L"functions\*(R" have a corresponding function type definition named OSSL_FUNC_{name}_fn, and a helper function to retrieve the function pointer from an \s-1OSSL_DISPATCH\s0\|(3) element named \fBOSSL_FUNC_{name}. For example, the \*(L"function\*(R" OSSL_FUNC_decoder_decode() has these:

.Vb 7 typedef int (OSSL_FUNC_decoder_decode_fn)(void *ctx, OSSL_CORE_BIO *in, int selection, OSSL_CALLBACK *data_cb, void *data_cbarg, OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg); static ossl_inline OSSL_FUNC_decoder_decode_fn* OSSL_FUNC_decoder_decode(const OSSL_DISPATCH *opf); .Ve

\s-1OSSL_DISPATCH\s0\|(3) arrays are indexed by numbers that are provided as macros in openssl-core_dispatch.h\|(7), as follows:

.Vb 2 OSSL_FUNC_decoder_get_params OSSL_FUNC_DECODER_GET_PARAMS OSSL_FUNC_decoder_gettable_params OSSL_FUNC_DECODER_GETTABLE_PARAMS \& OSSL_FUNC_decoder_newctx OSSL_FUNC_DECODER_NEWCTX OSSL_FUNC_decoder_freectx OSSL_FUNC_DECODER_FREECTX OSSL_FUNC_decoder_set_ctx_params OSSL_FUNC_DECODER_SET_CTX_PARAMS OSSL_FUNC_decoder_settable_ctx_params OSSL_FUNC_DECODER_SETTABLE_CTX_PARAMS \& OSSL_FUNC_decoder_does_selection OSSL_FUNC_DECODER_DOES_SELECTION \& OSSL_FUNC_decoder_decode OSSL_FUNC_DECODER_DECODE \& OSSL_FUNC_decoder_export_object OSSL_FUNC_DECODER_EXPORT_OBJECT .Ve

"Names and properties"
Subsection "Names and properties" The name of an implementation should match the target type of object it decodes. For example, an implementation that decodes an \s-1RSA\s0 key should be named \*(L"\s-1RSA\*(R".\s0 Likewise, an implementation that decodes \s-1DER\s0 data from \s-1PEM\s0 input should be named \*(L"\s-1DER\*(R".\s0

Properties can be used to further specify details about an implementation:

"input" 4
Item "input" This property is used to specify what format of input the implementation can decode. .Sp This property is mandatory. .Sp OpenSSL providers recognize the following input types:

"pem" 4
Item "pem" An implementation with that input type decodes \s-1PEM\s0 formatted data.
"der" 4
Item "der" An implementation with that input type decodes \s-1DER\s0 formatted data.
"msblob" 4
Item "msblob" An implementation with that input type decodes \s-1MSBLOB\s0 formatted data.
"pvk" 4
Item "pvk" An implementation with that input type decodes \s-1PVK\s0 formatted data.

"structure" 4
Item "structure" This property is used to specify the structure that the decoded data is expected to have. .Sp This property is optional. .Sp Structures currently recognised by built-in decoders:

Item "type-specific" Type specific structure. Item "pkcs8" Structure according to the PKCS#8 specification. Item "SubjectPublicKeyInfo" Encoding of public keys according to the Subject Public Key Info of \s-1RFC 5280.\s0

The possible values of both these properties is open ended. A provider may very well specify input types and structures that libcrypto doesn't know anything about.

"Subset selections"
Subsection "Subset selections" Sometimes, an object has more than one subset of data that is interesting to treat separately or together. It's possible to specify what subsets are to be decoded, with a set of bits selection that are passed in an int.

This set of bits depend entirely on what kind of provider-side object is to be decoded. For example, those bits are assumed to be the same as those used with provider-keymgmt\|(7) (see \*(L"Key Objects\*(R" in provider-keymgmt\|(7)) when the object is an asymmetric keypair - e.g., \s-1OSSL_KEYMGMT_SELECT_PRIVATE_KEY\s0 if the object to be decoded is supposed to contain private key components.

\fBOSSL_FUNC_decoder_does_selection() should tell if a particular implementation supports any of the combinations given by selection.

"Context functions"
Subsection "Context functions" \fBOSSL_FUNC_decoder_newctx() returns a context to be used with the rest of the functions.

\fBOSSL_FUNC_decoder_freectx() frees the given ctx as created by \fBOSSL_FUNC_decoder_newctx().

\fBOSSL_FUNC_decoder_set_ctx_params() sets context data according to parameters from params that it recognises. Unrecognised parameters should be ignored. Passing \s-1NULL\s0 for params should return true.

\fBOSSL_FUNC_decoder_settable_ctx_params() returns a constant \s-1OSSL_PARAM\s0\|(3) array describing the parameters that OSSL_FUNC_decoder_set_ctx_params() can handle.

See \s-1OSSL_PARAM\s0\|(3) for further details on the parameters structure used by \fBOSSL_FUNC_decoder_set_ctx_params() and OSSL_FUNC_decoder_settable_ctx_params().

"Export function"
Subsection "Export function" When a provider-native object is created by a decoder it would be unsuitable for direct use with a foreign provider. The export function allows for exporting the object into that foreign provider if the foreign provider supports the type of the object and provides an import function.

\fBOSSL_FUNC_decoder_export_object() should export the object of size objref_sz referenced by objref as an \s-1OSSL_PARAM\s0\|(3) array and pass that into the \fIexport_cb as well as the given export_cbarg.

"Decoding functions"
Subsection "Decoding functions" \fBOSSL_FUNC_decoder_decode() should decode the data as read from the \s-1OSSL_CORE_BIO\s0 in to produce decoded data or an object to be passed as reference in an \s-1OSSL_PARAM\s0\|(3) array along with possible other metadata that was decoded from the input. This \s-1OSSL_PARAM\s0\|(3) array is then passed to the data_cb callback. The selection bits, if relevant, should determine what the input data should contain. The decoding functions also take an \s-1OSSL_PASSPHRASE_CALLBACK\s0\|(3) function pointer along with a pointer to application data cbarg, which should be used when a pass phrase prompt is needed.

It's important to understand that the return value from this function is interpreted as follows:

"True (1)" 4
Item "True (1)" This means \*(L"carry on the decoding process\*(R", and is meaningful even though this function couldn't decode the input into anything, because there may be another decoder implementation that can decode it into something. .Sp The data_cb callback should never be called when this function can't decode the input into anything.
"False (0)" 4
Item "False (0)" This means \*(L"stop the decoding process\*(R", and is meaningful when the input could be decoded into some sort of object that this function understands, but further treatment of that object results into errors that won't be possible for some other decoder implementation to get a different result.

The conditions to stop the decoding process are at the discretion of the implementation.

"Decoder operation parameters"
Subsection "Decoder operation parameters" There are currently no operation parameters currently recognised by the built-in decoders.

Parameters currently recognised by the built-in pass phrase callback: Item "info (OSSL_PASSPHRASE_PARAM_INFO) <UTF8 string>" A string of information that will become part of the pass phrase prompt. This could be used to give the user information on what kind of object it's being prompted for.

"RETURN VALUES"
Header "RETURN VALUES" \fBOSSL_FUNC_decoder_newctx() returns a pointer to a context, or \s-1NULL\s0 on failure.

\fBOSSL_FUNC_decoder_set_ctx_params() returns 1, unless a recognised parameter was invalid or caused an error, for which 0 is returned.

\fBOSSL_FUNC_decoder_settable_ctx_params() returns a pointer to an array of constant \s-1OSSL_PARAM\s0\|(3) elements.

\fBOSSL_FUNC_decoder_does_selection() returns 1 if the decoder implementation supports any of the selection bits, otherwise 0.

\fBOSSL_FUNC_decoder_decode() returns 1 to signal that the decoding process should continue, or 0 to signal that it should stop.

"SEE ALSO"
Header "SEE ALSO" \fBprovider\|(7)
"HISTORY"
Header "HISTORY" The \s-1DECODER\s0 interface was introduced in OpenSSL 3.0.
"COPYRIGHT"
Header "COPYRIGHT" Copyright 2019-2023 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use this file except in compliance with the License. You can obtain a copy in the file \s-1LICENSE\s0 in the source distribution or at <https://www.openssl.org/source/license.html>.