PROVIDER-DECODER(7ossl)
๐ฆ NAME ๐ฆ
Okay bestie, welcome to PROVIDER-DECODER(7ossl) from OpenSSL ๐ This is the whole vibe for provider-decoder โ The OSSL_DECODER library <-> provider functions. Periodt. ๐
โจ SYNOPSIS โจ
No cap, none of these are actual functions โ theyโre shown like this because theyโre the function signatures for functions offered as function pointers in OSSL_DISPATCH arrays:
#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);
๐ธ DESCRIPTION ๐ธ
โDecodeโ is used all throughout this manual, and itโs giving big umbrella energy. It includes deserialization โ but it is not limited to that, because individual decoders can also do decoding into intermediate data formats. ๐ซ
The DECODER operation is a generic method to create a provider-native object reference or intermediate decoded data from an encoded form read from the given OSSL_CORE_BIO. If the caller wants to decode data from memory, it should provide a BIO_s_mem(3) BIO. The decoded data or object reference is passed along with eventual metadata to the metadata_cb as OSSL_PARAM(3) parameters. ๐ซถ
The decoder doesnโt need to know more about the OSSL_CORE_BIO pointer than being able to pass it to the appropriate BIO upcalls โ see โCore functionsโ in provider-base(7). Easy. ๐
The DECODER implementation may be part of a chain, where data is passed from one decoder to the next. For example, there may be an implementation to decode an object from PEM to DER, and another one that decodes DER to a provider-native object. Itโs literally a relay race. ๐โโ๏ธโจ
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, OSSL_FUNC_decoder_export_object() can be called as the final step of the decoding process. ๐
All the โfunctionsโ mentioned here are passed as function pointers between libcrypto and the provider in OSSL_DISPATCH(3) arrays via OSSL_ALGORITHM(3) arrays that are returned by the providerโs provider_query_operation() function โ see โProvider Functionsโ in provider-base(7). ๐ง
All of these โfunctionsโ have a corresponding function type definition named OSSL_FUNC_{name}_fn, and a helper function to retrieve the function pointer from an OSSL_DISPATCH(3) element named OSSL_FUNC_{name}. For example, the โfunctionโ OSSL_FUNC_decoder_decode() has these:
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);
OSSL_DISPATCH(3) arrays are indexed by numbers that are provided as macros in openssl-core_dispatch.h(7), as follows:
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
๐ Names and properties ๐
The name of an implementation should match the target type of object it decodes. For example, an implementation that decodes an RSA key should be named RSA. Likewise, an implementation that decodes DER data from PEM input should be named DER. Name it what it is, bestie. ๐
Properties, as defined in the OSSL_ALGORITHM(3) array element of each decoder implementation, can be used to further specify details about an implementation:
inputโ This property is used to specify what format of input the implementation can decode. This property is mandatory. OpenSSL providers recognize the following input types:pemโ An implementation with that input type decodes PEM formatted data.derโ An implementation with that input type decodes DER formatted data.msblobโ An implementation with that input type decodes MSBLOB formatted data.pvkโ An implementation with that input type decodes PVK formatted data.
structureโ This property is used to specify the structure that the decoded data is expected to have. This property is optional. Structures currently recognised by built-in decoders:"type-specific"โ Type specific structure."pkcs8"โ Structure according to the PKCS#8 specification."SubjectPublicKeyInfo"โ Encoding of public keys according to the Subject Public Key Info of RFC 5280.
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. Itโs giving โprovider has main character energy.โ ๐โจ
๐ 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 โKey Objectsโ in provider-keymgmt(7)) when the object is an asymmetric keypair โ e.g., OSSL_KEYMGMT_SELECT_PRIVATE_KEY if the object to be decoded is supposed to contain private key components. ๐
OSSL_FUNC_decoder_does_selection() should tell if a particular implementation supports any of the combinations given by selection. Vibe check: does it support the bits or not? ๐ซ
๐ฆ Context functions ๐ฆ
OSSL_FUNC_decoder_newctx()returns a context to be used with the rest of the functions.OSSL_FUNC_decoder_freectx()frees the givenctxas created byOSSL_FUNC_decoder_newctx().OSSL_FUNC_decoder_set_ctx_params()sets context data according to parameters fromparamsthat it recognises. Unrecognised parameters should be ignored. PassingNULLforparamsshould return true.OSSL_FUNC_decoder_settable_ctx_params()returns a constantOSSL_PARAM(3)array describing the parameters thatOSSL_FUNC_decoder_set_ctx_params()can handle.
See OSSL_PARAM(3) for further details on the parameters structure used by OSSL_FUNC_decoder_set_ctx_params() and OSSL_FUNC_decoder_settable_ctx_params(). ๐โจ
๐ 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. Itโs literally the โlet me introduce you to my other providerโ moment. ๐ซถ
OSSL_FUNC_decoder_export_object() should export the object of size objref_sz referenced by objref as an OSSL_PARAM(3) array and pass that into the export_cb as well as the given export_cbarg. Slay. ๐
๐ Decoding functions ๐
OSSL_FUNC_decoder_decode() should decode the data as read from the OSSL_CORE_BIO in to produce decoded data or an object to be passed as reference in an OSSL_PARAM(3) array along with possible other metadata that was decoded from the input. This OSSL_PARAM(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 OSSL_PASSPHRASE_CALLBACK(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) โ This means โcarry on the decoding processโ, 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. Thedata_cbcallback should never be called when this function canโt decode the input into anything. - False (
0) โ This means โstop the decoding processโ, 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. So like, implementationโs choice, no cap. ๐
๐ Decoder operation parameters ๐
There are currently no operation parameters currently recognised by the built-in decoders. None. Zero. ๐
Parameters currently recognised by the built-in pass phrase callback:
"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 โญ
OSSL_FUNC_decoder_newctx()returns a pointer to a context, orNULLon failure.OSSL_FUNC_decoder_set_ctx_params()returns1, unless a recognised parameter was invalid or caused an error, for which0is returned.OSSL_FUNC_decoder_settable_ctx_params()returns a pointer to an array of constantOSSL_PARAM(3)elements.OSSL_FUNC_decoder_does_selection()returns1if the decoder implementation supports any of theselectionbits, otherwise0.OSSL_FUNC_decoder_decode()returns1to signal that the decoding process should continue, or0to signal that it should stop.
๐ฅ SEE ALSO ๐ฅ
๐ HISTORY ๐
The DECODER interface was introduced in OpenSSL 3.0. โจ
๐ COPYRIGHT (the legal bit, bestie โ read it, it's short) ๐
Copyright 2019-2025 The OpenSSL Project Authors. All Rights Reserved.
Okay so fr, here's the deal: this whole thing is licensed under the Apache License 2.0 (that's "the License" btw, capital L, she's official ๐ ). You may not use this file except in compliance with the License โ like, that's not optional, that's the whole vibe check for using it ๐ซถ.
Wanna actually read the License? It's right there in the file LICENSE in the source distribution, or you can grab a copy at:
https://www.openssl.org/source/license.html
No cap, if you skip the License, that's on you โ using this file is literally you agreeing to be in compliance with it. So go read it, it's giving "important paperwork" energy but you'll survive ๐
โจ and that's a wrap on PROVIDER-DECODER(7ossl), bestie! โจ
This icon slayed out of the OpenSSL source distro at version 3.5.6, dated 2026-04-07 โ go build something iconic with it, mwah ๐๐๐ฆ
๐ฆ where this page comes from
- freebsd 15.1: base 15.1
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms