| 1 |
.\" -*- mode: troff; coding: utf-8 -*- |
| 2 |
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) |
| 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 "PROVIDER-ENCODER 7SSL" |
| 58 |
.TH PROVIDER-ENCODER 7SSL 2026-04-07 3.6.2 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 |
provider\-encoder \- The OSSL_ENCODER library <\-> provider functions |
| 65 |
.SH SYNOPSIS |
| 66 |
.IX Header "SYNOPSIS" |
| 67 |
.Vb 1 |
| 68 |
\& #include <openssl/core_dispatch.h> |
| 69 |
\& |
| 70 |
\& /* |
| 71 |
\& * None of these are actual functions, but are displayed like this for |
| 72 |
\& * the function signatures for functions that are offered as function |
| 73 |
\& * pointers in OSSL_DISPATCH arrays. |
| 74 |
\& */ |
| 75 |
\& |
| 76 |
\& /* Encoder parameter accessor and descriptor */ |
| 77 |
\& const OSSL_PARAM *OSSL_FUNC_encoder_gettable_params(void *provctx); |
| 78 |
\& int OSSL_FUNC_encoder_get_params(OSSL_PARAM params[]); |
| 79 |
\& |
| 80 |
\& /* Functions to construct / destruct / manipulate the encoder context */ |
| 81 |
\& void *OSSL_FUNC_encoder_newctx(void *provctx); |
| 82 |
\& void OSSL_FUNC_encoder_freectx(void *ctx); |
| 83 |
\& int OSSL_FUNC_encoder_set_ctx_params(void *ctx, const OSSL_PARAM params[]); |
| 84 |
\& const OSSL_PARAM *OSSL_FUNC_encoder_settable_ctx_params(void *provctx); |
| 85 |
\& |
| 86 |
\& /* Functions to check selection support */ |
| 87 |
\& int OSSL_FUNC_encoder_does_selection(void *provctx, int selection); |
| 88 |
\& |
| 89 |
\& /* Functions to encode object data */ |
| 90 |
\& int OSSL_FUNC_encoder_encode(void *ctx, OSSL_CORE_BIO *out, |
| 91 |
\& const void *obj_raw, |
| 92 |
\& const OSSL_PARAM obj_abstract[], |
| 93 |
\& int selection, |
| 94 |
\& OSSL_PASSPHRASE_CALLBACK *cb, |
| 95 |
\& void *cbarg); |
| 96 |
\& |
| 97 |
\& /* Functions to import and free a temporary object to be encoded */ |
| 98 |
\& void *OSSL_FUNC_encoder_import_object(void *ctx, int selection, |
| 99 |
\& const OSSL_PARAM params[]); |
| 100 |
\& void OSSL_FUNC_encoder_free_object(void *obj); |
| 101 |
.Ve |
| 102 |
.SH DESCRIPTION |
| 103 |
.IX Header "DESCRIPTION" |
| 104 |
\&\fIWe use the wide term "encode" in this manual. This includes but is |
| 105 |
not limited to serialization.\fR |
| 106 |
.PP |
| 107 |
The ENCODER operation is a generic method to encode a provider-native |
| 108 |
object (\fIobj_raw\fR) or an object abstraction (\fIobject_abstract\fR, see |
| 109 |
\&\fBprovider\-object\fR\|(7)) into an encoded form, and write the result to |
| 110 |
the given OSSL_CORE_BIO. If the caller wants to get the encoded |
| 111 |
stream to memory, it should provide a \fBBIO_s_mem\fR\|(3) \fBBIO\fR. |
| 112 |
.PP |
| 113 |
The encoder doesn't need to know more about the \fBOSSL_CORE_BIO\fR |
| 114 |
pointer than being able to pass it to the appropriate BIO upcalls (see |
| 115 |
"Core functions" in \fBprovider\-base\fR\|(7)). |
| 116 |
.PP |
| 117 |
The ENCODER implementation may be part of a chain, where data is |
| 118 |
passed from one to the next. For example, there may be an |
| 119 |
implementation to encode an object to DER (that object is assumed to |
| 120 |
be provider-native and thereby passed via \fIobj_raw\fR), and another one |
| 121 |
that encodes DER to PEM (that one would receive the DER encoding via |
| 122 |
\&\fIobj_abstract\fR). |
| 123 |
.PP |
| 124 |
The encoding using the \fBOSSL_PARAM\fR\|(3) array form allows a |
| 125 |
encoder to be used for data that's been exported from another |
| 126 |
provider, and thereby allow them to exist independently of each |
| 127 |
other. |
| 128 |
.PP |
| 129 |
The encoding using a provider side object can only be safely used |
| 130 |
with provider data coming from the same provider, for example keys |
| 131 |
with the KEYMGMT provider. |
| 132 |
.PP |
| 133 |
All "functions" mentioned here are passed as function pointers between |
| 134 |
\&\fIlibcrypto\fR and the provider in \fBOSSL_DISPATCH\fR\|(3) arrays via |
| 135 |
\&\fBOSSL_ALGORITHM\fR\|(3) arrays that are returned by the provider's |
| 136 |
\&\fBprovider_query_operation()\fR function |
| 137 |
(see "Provider Functions" in \fBprovider\-base\fR\|(7)). |
| 138 |
.PP |
| 139 |
All these "functions" have a corresponding function type definition |
| 140 |
named \fBOSSL_FUNC_{name}_fn\fR, and a helper function to retrieve the |
| 141 |
function pointer from an \fBOSSL_DISPATCH\fR\|(3) element named |
| 142 |
\&\fBOSSL_FUNC_{name}\fR. |
| 143 |
For example, the "function" \fBOSSL_FUNC_encoder_encode()\fR has these: |
| 144 |
.PP |
| 145 |
.Vb 8 |
| 146 |
\& typedef int |
| 147 |
\& (OSSL_FUNC_encoder_encode_fn)(void *ctx, OSSL_CORE_BIO *out, |
| 148 |
\& const void *obj_raw, |
| 149 |
\& const OSSL_PARAM obj_abstract[], |
| 150 |
\& int selection, |
| 151 |
\& OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg); |
| 152 |
\& static ossl_inline OSSL_FUNC_encoder_encode_fn |
| 153 |
\& OSSL_FUNC_encoder_encode(const OSSL_DISPATCH *opf); |
| 154 |
.Ve |
| 155 |
.PP |
| 156 |
\&\fBOSSL_DISPATCH\fR\|(3) arrays are indexed by numbers that are provided as |
| 157 |
macros in \fBopenssl\-core_dispatch.h\fR\|(7), as follows: |
| 158 |
.PP |
| 159 |
.Vb 2 |
| 160 |
\& OSSL_FUNC_encoder_get_params OSSL_FUNC_ENCODER_GET_PARAMS |
| 161 |
\& OSSL_FUNC_encoder_gettable_params OSSL_FUNC_ENCODER_GETTABLE_PARAMS |
| 162 |
\& |
| 163 |
\& OSSL_FUNC_encoder_newctx OSSL_FUNC_ENCODER_NEWCTX |
| 164 |
\& OSSL_FUNC_encoder_freectx OSSL_FUNC_ENCODER_FREECTX |
| 165 |
\& OSSL_FUNC_encoder_set_ctx_params OSSL_FUNC_ENCODER_SET_CTX_PARAMS |
| 166 |
\& OSSL_FUNC_encoder_settable_ctx_params OSSL_FUNC_ENCODER_SETTABLE_CTX_PARAMS |
| 167 |
\& |
| 168 |
\& OSSL_FUNC_encoder_does_selection OSSL_FUNC_ENCODER_DOES_SELECTION |
| 169 |
\& |
| 170 |
\& OSSL_FUNC_encoder_encode OSSL_FUNC_ENCODER_ENCODE |
| 171 |
\& |
| 172 |
\& OSSL_FUNC_encoder_import_object OSSL_FUNC_ENCODER_IMPORT_OBJECT |
| 173 |
\& OSSL_FUNC_encoder_free_object OSSL_FUNC_ENCODER_FREE_OBJECT |
| 174 |
.Ve |
| 175 |
.SS "Names and properties" |
| 176 |
.IX Subsection "Names and properties" |
| 177 |
The name of an implementation should match the type of object it handles. |
| 178 |
For example, an implementation that encodes an RSA key should be named "RSA". |
| 179 |
Likewise, an implementation that further encodes DER should be named "DER". |
| 180 |
.PP |
| 181 |
Properties, as defined in the \fBOSSL_ALGORITHM\fR\|(3) array element of each |
| 182 |
decoder implementation, can be used to further specify details about an |
| 183 |
implementation: |
| 184 |
.IP output 4 |
| 185 |
.IX Item "output" |
| 186 |
This property is used to specify what type of output the implementation |
| 187 |
produces. |
| 188 |
.Sp |
| 189 |
This property is \fImandatory\fR. |
| 190 |
.Sp |
| 191 |
OpenSSL providers recognize the following output types: |
| 192 |
.RS 4 |
| 193 |
.IP text 4 |
| 194 |
.IX Item "text" |
| 195 |
An implementation with that output type outputs human readable text, making |
| 196 |
that implementation suitable for \f(CW\*(C`\-text\*(C'\fR output in diverse \fBopenssl\fR\|(1) |
| 197 |
commands. |
| 198 |
.IP pem 4 |
| 199 |
.IX Item "pem" |
| 200 |
An implementation with that output type outputs PEM formatted data. |
| 201 |
.IP der 4 |
| 202 |
.IX Item "der" |
| 203 |
An implementation with that output type outputs DER formatted data. |
| 204 |
.IP msblob 4 |
| 205 |
.IX Item "msblob" |
| 206 |
An implementation with that output type outputs MSBLOB formatted data. |
| 207 |
.IP pvk 4 |
| 208 |
.IX Item "pvk" |
| 209 |
An implementation with that output type outputs PVK formatted data. |
| 210 |
.RE |
| 211 |
.RS 4 |
| 212 |
.RE |
| 213 |
.IP structure 4 |
| 214 |
.IX Item "structure" |
| 215 |
This property is used to specify the structure that is used for the encoded |
| 216 |
object. An example could be \f(CW\*(C`pkcs8\*(C'\fR, to specify explicitly that an object |
| 217 |
(presumably an asymmetric key pair, in this case) will be wrapped in a |
| 218 |
PKCS#8 structure as part of the encoding. |
| 219 |
.Sp |
| 220 |
This property is \fIoptional\fR. |
| 221 |
.PP |
| 222 |
The possible values of both these properties is open ended. A provider may |
| 223 |
very well specify output types and structures that libcrypto doesn't know |
| 224 |
anything about. |
| 225 |
.SS "Subset selections" |
| 226 |
.IX Subsection "Subset selections" |
| 227 |
Sometimes, an object has more than one subset of data that is interesting to |
| 228 |
treat separately or together. It's possible to specify what subsets are to |
| 229 |
be encoded, with a set of bits \fIselection\fR that are passed in an \fBint\fR. |
| 230 |
.PP |
| 231 |
This set of bits depend entirely on what kind of provider-side object is |
| 232 |
passed. For example, those bits are assumed to be the same as those used |
| 233 |
with \fBprovider\-keymgmt\fR\|(7) (see "Key Objects" in \fBprovider\-keymgmt\fR\|(7)) when |
| 234 |
the object is an asymmetric keypair. |
| 235 |
.PP |
| 236 |
ENCODER implementations are free to regard the \fIselection\fR as a set of |
| 237 |
hints, but must do so with care. In the end, the output must make sense, |
| 238 |
and if there's a corresponding decoder, the resulting decoded object must |
| 239 |
match the original object that was encoded. |
| 240 |
.PP |
| 241 |
\&\fBOSSL_FUNC_encoder_does_selection()\fR should tell if a particular implementation |
| 242 |
supports any of the combinations given by \fIselection\fR. |
| 243 |
.SS "Context functions" |
| 244 |
.IX Subsection "Context functions" |
| 245 |
\&\fBOSSL_FUNC_encoder_newctx()\fR returns a context to be used with the rest of |
| 246 |
the functions. |
| 247 |
.PP |
| 248 |
\&\fBOSSL_FUNC_encoder_freectx()\fR frees the given \fIctx\fR, if it was created by |
| 249 |
\&\fBOSSL_FUNC_encoder_newctx()\fR. |
| 250 |
.PP |
| 251 |
\&\fBOSSL_FUNC_encoder_set_ctx_params()\fR sets context data according to parameters |
| 252 |
from \fIparams\fR that it recognises. Unrecognised parameters should be |
| 253 |
ignored. |
| 254 |
Passing NULL for \fIparams\fR should return true. |
| 255 |
.PP |
| 256 |
\&\fBOSSL_FUNC_encoder_settable_ctx_params()\fR returns a constant \fBOSSL_PARAM\fR\|(3) |
| 257 |
array describing the parameters that \fBOSSL_FUNC_encoder_set_ctx_params()\fR |
| 258 |
can handle. |
| 259 |
.PP |
| 260 |
See \fBOSSL_PARAM\fR\|(3) for further details on the parameters structure used by |
| 261 |
\&\fBOSSL_FUNC_encoder_set_ctx_params()\fR and \fBOSSL_FUNC_encoder_settable_ctx_params()\fR. |
| 262 |
.SS "Import functions" |
| 263 |
.IX Subsection "Import functions" |
| 264 |
A provider-native object may be associated with a foreign provider, and may |
| 265 |
therefore be unsuitable for direct use with a given ENCODER implementation. |
| 266 |
Provided that the foreign provider's implementation to handle the object has |
| 267 |
a function to export that object in \fBOSSL_PARAM\fR\|(3) array form, the ENCODER |
| 268 |
implementation should be able to import that array and create a suitable |
| 269 |
object to be passed to \fBOSSL_FUNC_encoder_encode()\fR's \fIobj_raw\fR. |
| 270 |
.PP |
| 271 |
\&\fBOSSL_FUNC_encoder_import_object()\fR should import the subset of \fIparams\fR |
| 272 |
given with \fIselection\fR to create a provider-native object that can be |
| 273 |
passed as \fIobj_raw\fR to \fBOSSL_FUNC_encoder_encode()\fR. |
| 274 |
.PP |
| 275 |
\&\fBOSSL_FUNC_encoder_free_object()\fR should free the object that was created with |
| 276 |
\&\fBOSSL_FUNC_encoder_import_object()\fR. |
| 277 |
.SS "Encoding functions" |
| 278 |
.IX Subsection "Encoding functions" |
| 279 |
\&\fBOSSL_FUNC_encoder_encode()\fR should take a provider-native object (in |
| 280 |
\&\fIobj_raw\fR) or an object abstraction (in \fIobj_abstract\fR), and should output |
| 281 |
the object in encoded form to the \fBOSSL_CORE_BIO\fR. The \fIselection\fR bits, |
| 282 |
if relevant, should determine in greater detail what will be output. |
| 283 |
The encoding functions also take an \fBOSSL_PASSPHRASE_CALLBACK\fR\|(3) function |
| 284 |
pointer along with a pointer to application data \fIcbarg\fR, which should be |
| 285 |
used when a pass phrase prompt is needed. |
| 286 |
.SS "Encoder operation parameters" |
| 287 |
.IX Subsection "Encoder operation parameters" |
| 288 |
Operation parameters currently recognised by built-in encoders are as |
| 289 |
follows: |
| 290 |
.IP """cipher"" (\fBOSSL_ENCODER_PARAM_CIPHER\fR) <UTF8 string>" 4 |
| 291 |
.IX Item """cipher"" (OSSL_ENCODER_PARAM_CIPHER) <UTF8 string>" |
| 292 |
The name of the encryption cipher to be used when generating encrypted |
| 293 |
encoding. This is used when encoding private keys, as well as |
| 294 |
other objects that need protection. |
| 295 |
.Sp |
| 296 |
If this name is invalid for the encoding implementation, the |
| 297 |
implementation should refuse to perform the encoding, i.e. |
| 298 |
\&\fBOSSL_FUNC_encoder_encode_data()\fR and \fBOSSL_FUNC_encoder_encode_object()\fR |
| 299 |
should return an error. |
| 300 |
.IP """properties"" (\fBOSSL_ENCODER_PARAM_PROPERTIES\fR) <UTF8 string>" 4 |
| 301 |
.IX Item """properties"" (OSSL_ENCODER_PARAM_PROPERTIES) <UTF8 string>" |
| 302 |
The properties to be queried when trying to fetch the algorithm given |
| 303 |
with the "cipher" parameter. |
| 304 |
This must be given together with the "cipher" parameter to be |
| 305 |
considered valid. |
| 306 |
.Sp |
| 307 |
The encoding implementation isn't obligated to use this value. |
| 308 |
However, it is recommended that implementations that do not handle |
| 309 |
property strings return an error on receiving this parameter unless |
| 310 |
its value NULL or the empty string. |
| 311 |
.IP """save-parameters"" (\fBOSSL_ENCODER_PARAM_SAVE_PARAMETERS\fR) <integer>" 4 |
| 312 |
.IX Item """save-parameters"" (OSSL_ENCODER_PARAM_SAVE_PARAMETERS) <integer>" |
| 313 |
If set to 0 disables saving of key domain parameters. Default is 1. |
| 314 |
It currently has an effect only on DSA keys. |
| 315 |
.PP |
| 316 |
Parameters currently recognised by the built-in pass phrase callback: |
| 317 |
.IP """info"" (\fBOSSL_PASSPHRASE_PARAM_INFO\fR) <UTF8 string>" 4 |
| 318 |
.IX Item """info"" (OSSL_PASSPHRASE_PARAM_INFO) <UTF8 string>" |
| 319 |
A string of information that will become part of the pass phrase |
| 320 |
prompt. This could be used to give the user information on what kind |
| 321 |
of object it's being prompted for. |
| 322 |
.SH "RETURN VALUES" |
| 323 |
.IX Header "RETURN VALUES" |
| 324 |
\&\fBOSSL_FUNC_encoder_newctx()\fR returns a pointer to a context, or NULL on |
| 325 |
failure. |
| 326 |
.PP |
| 327 |
\&\fBOSSL_FUNC_encoder_set_ctx_params()\fR returns 1, unless a recognised |
| 328 |
parameter was invalid or caused an error, for which 0 is returned. |
| 329 |
.PP |
| 330 |
\&\fBOSSL_FUNC_encoder_settable_ctx_params()\fR returns a pointer to an array of |
| 331 |
constant \fBOSSL_PARAM\fR\|(3) elements. |
| 332 |
.PP |
| 333 |
\&\fBOSSL_FUNC_encoder_does_selection()\fR returns 1 if the encoder implementation |
| 334 |
supports any of the \fIselection\fR bits, otherwise 0. |
| 335 |
.PP |
| 336 |
\&\fBOSSL_FUNC_encoder_encode()\fR returns 1 on success, or 0 on failure. |
| 337 |
.SH "SEE ALSO" |
| 338 |
.IX Header "SEE ALSO" |
| 339 |
\&\fBprovider\fR\|(7) |
| 340 |
.SH HISTORY |
| 341 |
.IX Header "HISTORY" |
| 342 |
The ENCODER interface was introduced in OpenSSL 3.0. |
| 343 |
.SH COPYRIGHT |
| 344 |
.IX Header "COPYRIGHT" |
| 345 |
Copyright 2019\-2025 The OpenSSL Project Authors. All Rights Reserved. |
| 346 |
.PP |
| 347 |
Licensed under the Apache License 2.0 (the "License"). You may not use |
| 348 |
this file except in compliance with the License. You can obtain a copy |
| 349 |
in the file LICENSE in the source distribution or at |
| 350 |
<https://www.openssl.org/source/license.html>. |