Debian Codegraph @

upstream/debian-unstable/man7/provider-asym_cipher.7ssl

raw
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-ASYM_CIPHER 7SSL"
58 .TH PROVIDER-ASYM_CIPHER 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\-asym_cipher \- The asym_cipher library <\-> provider functions
65 .SH SYNOPSIS
66 .IX Header "SYNOPSIS"
67 .Vb 2
68 \& #include <openssl/core_dispatch.h>
69 \& #include <openssl/core_names.h>
70 \&
71 \& /*
72 \& * None of these are actual functions, but are displayed like this for
73 \& * the function signatures for functions that are offered as function
74 \& * pointers in OSSL_DISPATCH arrays.
75 \& */
76 \&
77 \& /* Context management */
78 \& void *OSSL_FUNC_asym_cipher_newctx(void *provctx);
79 \& void OSSL_FUNC_asym_cipher_freectx(void *ctx);
80 \& void *OSSL_FUNC_asym_cipher_dupctx(void *ctx);
81 \&
82 \& /* Encryption */
83 \& int OSSL_FUNC_asym_cipher_encrypt_init(void *ctx, void *provkey,
84 \& const OSSL_PARAM params[]);
85 \& int OSSL_FUNC_asym_cipher_encrypt(void *ctx, unsigned char *out, size_t *outlen,
86 \& size_t outsize, const unsigned char *in,
87 \& size_t inlen);
88 \&
89 \& /* Decryption */
90 \& int OSSL_FUNC_asym_cipher_decrypt_init(void *ctx, void *provkey,
91 \& const OSSL_PARAM params[]);
92 \& int OSSL_FUNC_asym_cipher_decrypt(void *ctx, unsigned char *out, size_t *outlen,
93 \& size_t outsize, const unsigned char *in,
94 \& size_t inlen);
95 \&
96 \& /* Asymmetric Cipher parameters */
97 \& int OSSL_FUNC_asym_cipher_get_ctx_params(void *ctx, OSSL_PARAM params[]);
98 \& const OSSL_PARAM *OSSL_FUNC_asym_cipher_gettable_ctx_params(void *provctx);
99 \& int OSSL_FUNC_asym_cipher_set_ctx_params(void *ctx, const OSSL_PARAM params[]);
100 \& const OSSL_PARAM *OSSL_FUNC_asym_cipher_settable_ctx_params(void *provctx);
101 .Ve
102 .SH DESCRIPTION
103 .IX Header "DESCRIPTION"
104 This documentation is primarily aimed at provider authors. See \fBprovider\fR\|(7)
105 for further information.
106 .PP
107 The asymmetric cipher (OSSL_OP_ASYM_CIPHER) operation enables providers to
108 implement asymmetric cipher algorithms and make them available to applications
109 via the API functions \fBEVP_PKEY_encrypt\fR\|(3),
110 \&\fBEVP_PKEY_decrypt\fR\|(3) and
111 other related functions).
112 .PP
113 All "functions" mentioned here are passed as function pointers between
114 \&\fIlibcrypto\fR and the provider in \fBOSSL_DISPATCH\fR\|(3) arrays via
115 \&\fBOSSL_ALGORITHM\fR\|(3) arrays that are returned by the provider's
116 \&\fBprovider_query_operation()\fR function
117 (see "Provider Functions" in \fBprovider\-base\fR\|(7)).
118 .PP
119 All these "functions" have a corresponding function type definition
120 named \fBOSSL_FUNC_{name}_fn\fR, and a helper function to retrieve the
121 function pointer from an \fBOSSL_DISPATCH\fR\|(3) element named
122 \&\fBOSSL_FUNC_{name}\fR.
123 For example, the "function" \fBOSSL_FUNC_asym_cipher_newctx()\fR has these:
124 .PP
125 .Vb 3
126 \& typedef void *(OSSL_FUNC_asym_cipher_newctx_fn)(void *provctx);
127 \& static ossl_inline OSSL_FUNC_asym_cipher_newctx_fn
128 \& OSSL_FUNC_asym_cipher_newctx(const OSSL_DISPATCH *opf);
129 .Ve
130 .PP
131 \&\fBOSSL_DISPATCH\fR\|(3) arrays are indexed by numbers that are provided as
132 macros in \fBopenssl\-core_dispatch.h\fR\|(7), as follows:
133 .PP
134 .Vb 3
135 \& OSSL_FUNC_asym_cipher_newctx OSSL_FUNC_ASYM_CIPHER_NEWCTX
136 \& OSSL_FUNC_asym_cipher_freectx OSSL_FUNC_ASYM_CIPHER_FREECTX
137 \& OSSL_FUNC_asym_cipher_dupctx OSSL_FUNC_ASYM_CIPHER_DUPCTX
138 \&
139 \& OSSL_FUNC_asym_cipher_encrypt_init OSSL_FUNC_ASYM_CIPHER_ENCRYPT_INIT
140 \& OSSL_FUNC_asym_cipher_encrypt OSSL_FUNC_ASYM_CIPHER_ENCRYPT
141 \&
142 \& OSSL_FUNC_asym_cipher_decrypt_init OSSL_FUNC_ASYM_CIPHER_DECRYPT_INIT
143 \& OSSL_FUNC_asym_cipher_decrypt OSSL_FUNC_ASYM_CIPHER_DECRYPT
144 \&
145 \& OSSL_FUNC_asym_cipher_get_ctx_params OSSL_FUNC_ASYM_CIPHER_GET_CTX_PARAMS
146 \& OSSL_FUNC_asym_cipher_gettable_ctx_params OSSL_FUNC_ASYM_CIPHER_GETTABLE_CTX_PARAMS
147 \& OSSL_FUNC_asym_cipher_set_ctx_params OSSL_FUNC_ASYM_CIPHER_SET_CTX_PARAMS
148 \& OSSL_FUNC_asym_cipher_settable_ctx_params OSSL_FUNC_ASYM_CIPHER_SETTABLE_CTX_PARAMS
149 .Ve
150 .PP
151 An asymmetric cipher algorithm implementation may not implement all of these
152 functions.
153 In order to be a consistent set of functions a provider must implement
154 OSSL_FUNC_asym_cipher_newctx and OSSL_FUNC_asym_cipher_freectx.
155 It must also implement both of OSSL_FUNC_asym_cipher_encrypt_init and
156 OSSL_FUNC_asym_cipher_encrypt, or both of OSSL_FUNC_asym_cipher_decrypt_init and
157 OSSL_FUNC_asym_cipher_decrypt.
158 OSSL_FUNC_asym_cipher_get_ctx_params is optional but if it is present then so must
159 OSSL_FUNC_asym_cipher_gettable_ctx_params.
160 Similarly, OSSL_FUNC_asym_cipher_set_ctx_params is optional but if it is present then
161 so must OSSL_FUNC_asym_cipher_settable_ctx_params.
162 .PP
163 An asymmetric cipher algorithm must also implement some mechanism for generating,
164 loading or importing keys via the key management (OSSL_OP_KEYMGMT) operation.
165 See \fBprovider\-keymgmt\fR\|(7) for further details.
166 .SS "Context Management Functions"
167 .IX Subsection "Context Management Functions"
168 \&\fBOSSL_FUNC_asym_cipher_newctx()\fR should create and return a pointer to a provider side
169 structure for holding context information during an asymmetric cipher operation.
170 A pointer to this context will be passed back in a number of the other
171 asymmetric cipher operation function calls.
172 The parameter \fIprovctx\fR is the provider context generated during provider
173 initialisation (see \fBprovider\fR\|(7)).
174 .PP
175 \&\fBOSSL_FUNC_asym_cipher_freectx()\fR is passed a pointer to the provider side asymmetric
176 cipher context in the \fIctx\fR parameter.
177 This function should free any resources associated with that context.
178 .PP
179 \&\fBOSSL_FUNC_asym_cipher_dupctx()\fR should duplicate the provider side asymmetric cipher
180 context in the \fIctx\fR parameter and return the duplicate copy.
181 .SS "Encryption Functions"
182 .IX Subsection "Encryption Functions"
183 \&\fBOSSL_FUNC_asym_cipher_encrypt_init()\fR initialises a context for an asymmetric encryption
184 given a provider side asymmetric cipher context in the \fIctx\fR parameter, and a
185 pointer to a provider key object in the \fIprovkey\fR parameter.
186 The \fIparams\fR, if not NULL, should be set on the context in a manner similar to
187 using \fBOSSL_FUNC_asym_cipher_set_ctx_params()\fR.
188 The key object should have been previously generated, loaded or imported into
189 the provider using the key management (OSSL_OP_KEYMGMT) operation (see \fBprovider\-keymgmt\fR\|(7)).
190 \&\fBOSSL_FUNC_asym_cipher_encrypt()\fR performs the actual encryption itself.
191 A previously initialised asymmetric cipher context is passed in the \fIctx\fR
192 parameter.
193 The data to be encrypted is pointed to by the \fIin\fR parameter which is \fIinlen\fR
194 bytes long.
195 Unless \fIout\fR is NULL, the encrypted data should be written to the location
196 pointed to by the \fIout\fR parameter and it should not exceed \fIoutsize\fR bytes in
197 length.
198 The length of the encrypted data should be written to \fI*outlen\fR.
199 If \fIout\fR is NULL then the maximum length of the encrypted data should be
200 written to \fI*outlen\fR.
201 .SS "Decryption Functions"
202 .IX Subsection "Decryption Functions"
203 \&\fBOSSL_FUNC_asym_cipher_decrypt_init()\fR initialises a context for an asymmetric decryption
204 given a provider side asymmetric cipher context in the \fIctx\fR parameter, and a
205 pointer to a provider key object in the \fIprovkey\fR parameter.
206 The \fIparams\fR, if not NULL, should be set on the context in a manner similar to
207 using \fBOSSL_FUNC_asym_cipher_set_ctx_params()\fR.
208 The key object should have been previously generated, loaded or imported into
209 the provider using the key management (OSSL_OP_KEYMGMT) operation (see
210 \&\fBprovider\-keymgmt\fR\|(7)).
211 .PP
212 \&\fBOSSL_FUNC_asym_cipher_decrypt()\fR performs the actual decryption itself.
213 A previously initialised asymmetric cipher context is passed in the \fIctx\fR
214 parameter.
215 The data to be decrypted is pointed to by the \fIin\fR parameter which is \fIinlen\fR
216 bytes long.
217 Unless \fIout\fR is NULL, the decrypted data should be written to the location
218 pointed to by the \fIout\fR parameter and it should not exceed \fIoutsize\fR bytes in
219 length.
220 The length of the decrypted data should be written to \fI*outlen\fR.
221 If \fIout\fR is NULL then the maximum length of the decrypted data should be
222 written to \fI*outlen\fR.
223 .SS "Asymmetric Cipher Parameters"
224 .IX Subsection "Asymmetric Cipher Parameters"
225 See \fBOSSL_PARAM\fR\|(3) for further details on the parameters structure used by
226 the \fBOSSL_FUNC_asym_cipher_get_ctx_params()\fR and \fBOSSL_FUNC_asym_cipher_set_ctx_params()\fR
227 functions.
228 .PP
229 \&\fBOSSL_FUNC_asym_cipher_get_ctx_params()\fR gets asymmetric cipher parameters associated
230 with the given provider side asymmetric cipher context \fIctx\fR and stores them in
231 \&\fIparams\fR.
232 Passing NULL for \fIparams\fR should return true.
233 .PP
234 \&\fBOSSL_FUNC_asym_cipher_set_ctx_params()\fR sets the asymmetric cipher parameters associated
235 with the given provider side asymmetric cipher context \fIctx\fR to \fIparams\fR.
236 Any parameter settings are additional to any that were previously set.
237 Passing NULL for \fIparams\fR should return true.
238 .PP
239 Parameters currently recognised by built-in asymmetric cipher algorithms are as
240 follows.
241 Not all parameters are relevant to, or are understood by all asymmetric cipher
242 algorithms:
243 .IP """pad-mode"" (\fBOSSL_ASYM_CIPHER_PARAM_PAD_MODE\fR) <UTF8 string> OR <integer>" 4
244 .IX Item """pad-mode"" (OSSL_ASYM_CIPHER_PARAM_PAD_MODE) <UTF8 string> OR <integer>"
245 The type of padding to be used. The interpretation of this value will depend
246 on the algorithm in use.
247 .IP """digest"" (\fBOSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST\fR) <UTF8 string>" 4
248 .IX Item """digest"" (OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST) <UTF8 string>"
249 Gets or sets the name of the OAEP digest algorithm used when OAEP padding is in
250 use.
251 .IP """digest"" (\fBOSSL_ASYM_CIPHER_PARAM_DIGEST\fR) <UTF8 string>" 4
252 .IX Item """digest"" (OSSL_ASYM_CIPHER_PARAM_DIGEST) <UTF8 string>"
253 Gets or sets the name of the digest algorithm used by the algorithm (where
254 applicable).
255 .IP """digest-props"" (\fBOSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST_PROPS\fR) <UTF8 string>" 4
256 .IX Item """digest-props"" (OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST_PROPS) <UTF8 string>"
257 Gets or sets the properties to use when fetching the OAEP digest algorithm.
258 .IP """digest-props"" (\fBOSSL_ASYM_CIPHER_PARAM_DIGEST_PROPS\fR) <UTF8 string>" 4
259 .IX Item """digest-props"" (OSSL_ASYM_CIPHER_PARAM_DIGEST_PROPS) <UTF8 string>"
260 Gets or sets the properties to use when fetching the cipher digest algorithm.
261 .IP """mgf1\-digest"" (\fBOSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST\fR) <UTF8 string>" 4
262 .IX Item """mgf1-digest"" (OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST) <UTF8 string>"
263 Gets or sets the name of the MGF1 digest algorithm used when OAEP or PSS padding
264 is in use.
265 .IP """mgf1\-digest\-props"" (\fBOSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST_PROPS\fR) <UTF8 string>" 4
266 .IX Item """mgf1-digest-props"" (OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST_PROPS) <UTF8 string>"
267 Gets or sets the properties to use when fetching the MGF1 digest algorithm.
268 .IP """oaep-label"" (\fBOSSL_ASYM_CIPHER_PARAM_OAEP_LABEL\fR) <octet string ptr>" 4
269 .IX Item """oaep-label"" (OSSL_ASYM_CIPHER_PARAM_OAEP_LABEL) <octet string ptr>"
270 Gets the OAEP label used when OAEP padding is in use.
271 .IP """oaep-label"" (\fBOSSL_ASYM_CIPHER_PARAM_OAEP_LABEL\fR) <octet string>" 4
272 .IX Item """oaep-label"" (OSSL_ASYM_CIPHER_PARAM_OAEP_LABEL) <octet string>"
273 Sets the OAEP label used when OAEP padding is in use.
274 .IP """tls-client-version"" (\fBOSSL_ASYM_CIPHER_PARAM_TLS_CLIENT_VERSION\fR) <unsigned integer>" 4
275 .IX Item """tls-client-version"" (OSSL_ASYM_CIPHER_PARAM_TLS_CLIENT_VERSION) <unsigned integer>"
276 The TLS protocol version first requested by the client.
277 .IP """tls-negotiated-version"" (\fBOSSL_ASYM_CIPHER_PARAM_TLS_CLIENT_VERSION\fR) <unsigned integer>" 4
278 .IX Item """tls-negotiated-version"" (OSSL_ASYM_CIPHER_PARAM_TLS_CLIENT_VERSION) <unsigned integer>"
279 The negotiated TLS protocol version.
280 .IP """implicit-rejection"" (\fBOSSL_ASYM_CIPHER_PARAM_IMPLICIT_REJECTION\fR) <unsigned integer>" 4
281 .IX Item """implicit-rejection"" (OSSL_ASYM_CIPHER_PARAM_IMPLICIT_REJECTION) <unsigned integer>"
282 Gets or sets the use of the implicit rejection mechanism for RSA PKCS#1 v1.5
283 decryption. When set (non zero value), the decryption API will return
284 a deterministically random value if the PKCS#1 v1.5 padding check fails.
285 This makes exploitation of the Bleichenbacher significantly harder, even
286 if the code using the RSA decryption API is not implemented in side-channel
287 free manner. Set by default in OpenSSL providers.
288 .PP
289 The OpenSSL FIPS provider also supports the following parameters:
290 .IP """fips-indicator"" (\fBOSSL_ASYM_CIPHER_PARAM_FIPS_APPROVED_INDICATOR\fR) <integer>" 4
291 .IX Item """fips-indicator"" (OSSL_ASYM_CIPHER_PARAM_FIPS_APPROVED_INDICATOR) <integer>"
292 A getter that returns 1 if the operation is FIPS approved, or 0 otherwise.
293 This may be used after calling either \fBOSSL_FUNC_asym_cipher_encrypt()\fR or
294 \&\fBOSSL_FUNC_asym_cipher_decrypt()\fR. It may return 0 if "key-check" is set to 0.
295 .IP """key-check"" (\fBOSSL_ASYM_CIPHER_PARAM_FIPS_KEY_CHECK\fR) <integer>" 4
296 .IX Item """key-check"" (OSSL_ASYM_CIPHER_PARAM_FIPS_KEY_CHECK) <integer>"
297 If required this parameter should be set using either
298 \&\fBOSSL_FUNC_asym_cipher_encrypt_init()\fR or \fBOSSL_FUNC_asym_cipher_decrypt_init()\fR.
299 The default value of 1 causes an error during the init if the key is not FIPS
300 approved (e.g. The key has a security strength of less than 112 bits). Setting
301 this to 0 will ignore the error and set the approved "fips-indicator" to 0.
302 This option breaks FIPS compliance if it causes the approved "fips-indicator"
303 to return 0.
304 .PP
305 \&\fBOSSL_FUNC_asym_cipher_gettable_ctx_params()\fR and \fBOSSL_FUNC_asym_cipher_settable_ctx_params()\fR
306 get a constant \fBOSSL_PARAM\fR\|(3) array that describes the gettable and settable
307 parameters, i.e. parameters that can be used with \fBOSSL_FUNC_asym_cipherget_ctx_params()\fR
308 and \fBOSSL_FUNC_asym_cipher_set_ctx_params()\fR respectively.
309 .SH "RETURN VALUES"
310 .IX Header "RETURN VALUES"
311 \&\fBOSSL_FUNC_asym_cipher_newctx()\fR and \fBOSSL_FUNC_asym_cipher_dupctx()\fR should return the newly
312 created provider side asymmetric cipher context, or NULL on failure.
313 .PP
314 All other functions should return 1 for success or 0 on error.
315 .SH "SEE ALSO"
316 .IX Header "SEE ALSO"
317 \&\fBprovider\fR\|(7)
318 .SH HISTORY
319 .IX Header "HISTORY"
320 The provider ASYM_CIPHER interface was introduced in OpenSSL 3.0.
321 The Asymmetric Cipher Parameters "fips-indicator" and "key-check"
322 were added in OpenSSL 3.4.
323 .SH COPYRIGHT
324 .IX Header "COPYRIGHT"
325 Copyright 2019\-2025 The OpenSSL Project Authors. All Rights Reserved.
326 .PP
327 Licensed under the Apache License 2.0 (the "License"). You may not use
328 this file except in compliance with the License. You can obtain a copy
329 in the file LICENSE in the source distribution or at
330 <https://www.openssl.org/source/license.html>.