Debian Codegraph @

upstream/debian-unstable/man3/EVP_PKEY_meth_new.3ssl

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 "EVP_PKEY_METH_NEW 3SSL"
58 .TH EVP_PKEY_METH_NEW 3SSL 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 EVP_PKEY_meth_new, EVP_PKEY_meth_free, EVP_PKEY_meth_copy, EVP_PKEY_meth_find,
65 EVP_PKEY_meth_add0, EVP_PKEY_METHOD,
66 EVP_PKEY_meth_set_init, EVP_PKEY_meth_set_copy, EVP_PKEY_meth_set_cleanup,
67 EVP_PKEY_meth_set_paramgen, EVP_PKEY_meth_set_keygen, EVP_PKEY_meth_set_sign,
68 EVP_PKEY_meth_set_verify, EVP_PKEY_meth_set_verify_recover, EVP_PKEY_meth_set_signctx,
69 EVP_PKEY_meth_set_verifyctx, EVP_PKEY_meth_set_encrypt, EVP_PKEY_meth_set_decrypt,
70 EVP_PKEY_meth_set_derive, EVP_PKEY_meth_set_ctrl,
71 EVP_PKEY_meth_set_digestsign, EVP_PKEY_meth_set_digestverify,
72 EVP_PKEY_meth_set_check,
73 EVP_PKEY_meth_set_public_check, EVP_PKEY_meth_set_param_check,
74 EVP_PKEY_meth_set_digest_custom,
75 EVP_PKEY_meth_get_init, EVP_PKEY_meth_get_copy, EVP_PKEY_meth_get_cleanup,
76 EVP_PKEY_meth_get_paramgen, EVP_PKEY_meth_get_keygen, EVP_PKEY_meth_get_sign,
77 EVP_PKEY_meth_get_verify, EVP_PKEY_meth_get_verify_recover, EVP_PKEY_meth_get_signctx,
78 EVP_PKEY_meth_get_verifyctx, EVP_PKEY_meth_get_encrypt, EVP_PKEY_meth_get_decrypt,
79 EVP_PKEY_meth_get_derive, EVP_PKEY_meth_get_ctrl,
80 EVP_PKEY_meth_get_digestsign, EVP_PKEY_meth_get_digestverify,
81 EVP_PKEY_meth_get_check,
82 EVP_PKEY_meth_get_public_check, EVP_PKEY_meth_get_param_check,
83 EVP_PKEY_meth_get_digest_custom,
84 EVP_PKEY_meth_remove
85 \&\- manipulating EVP_PKEY_METHOD structure
86 .SH SYNOPSIS
87 .IX Header "SYNOPSIS"
88 .Vb 1
89 \& #include <openssl/evp.h>
90 .Ve
91 .PP
92 The following functions have been deprecated since OpenSSL 3.0, and can be
93 hidden entirely by defining \fBOPENSSL_API_COMPAT\fR with a suitable version value,
94 see \fBopenssl_user_macros\fR\|(7):
95 .PP
96 .Vb 1
97 \& typedef struct evp_pkey_method_st EVP_PKEY_METHOD;
98 \&
99 \& EVP_PKEY_METHOD *EVP_PKEY_meth_new(int id, int flags);
100 \& void EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth);
101 \& void EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, const EVP_PKEY_METHOD *src);
102 \& const EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type);
103 \& int EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth);
104 \& int EVP_PKEY_meth_remove(const EVP_PKEY_METHOD *pmeth);
105 \&
106 \& void EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth,
107 \& int (*init) (EVP_PKEY_CTX *ctx));
108 \& void EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD *pmeth,
109 \& int (*copy) (EVP_PKEY_CTX *dst,
110 \& const EVP_PKEY_CTX *src));
111 \& void EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD *pmeth,
112 \& void (*cleanup) (EVP_PKEY_CTX *ctx));
113 \& void EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD *pmeth,
114 \& int (*paramgen_init) (EVP_PKEY_CTX *ctx),
115 \& int (*paramgen) (EVP_PKEY_CTX *ctx,
116 \& EVP_PKEY *pkey));
117 \& void EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD *pmeth,
118 \& int (*keygen_init) (EVP_PKEY_CTX *ctx),
119 \& int (*keygen) (EVP_PKEY_CTX *ctx,
120 \& EVP_PKEY *pkey));
121 \& void EVP_PKEY_meth_set_sign(EVP_PKEY_METHOD *pmeth,
122 \& int (*sign_init) (EVP_PKEY_CTX *ctx),
123 \& int (*sign) (EVP_PKEY_CTX *ctx,
124 \& unsigned char *sig, size_t *siglen,
125 \& const unsigned char *tbs,
126 \& size_t tbslen));
127 \& void EVP_PKEY_meth_set_verify(EVP_PKEY_METHOD *pmeth,
128 \& int (*verify_init) (EVP_PKEY_CTX *ctx),
129 \& int (*verify) (EVP_PKEY_CTX *ctx,
130 \& const unsigned char *sig,
131 \& size_t siglen,
132 \& const unsigned char *tbs,
133 \& size_t tbslen));
134 \& void EVP_PKEY_meth_set_verify_recover(EVP_PKEY_METHOD *pmeth,
135 \& int (*verify_recover_init) (EVP_PKEY_CTX
136 \& *ctx),
137 \& int (*verify_recover) (EVP_PKEY_CTX
138 \& *ctx,
139 \& unsigned char
140 \& *sig,
141 \& size_t *siglen,
142 \& const unsigned
143 \& char *tbs,
144 \& size_t tbslen));
145 \& void EVP_PKEY_meth_set_signctx(EVP_PKEY_METHOD *pmeth,
146 \& int (*signctx_init) (EVP_PKEY_CTX *ctx,
147 \& EVP_MD_CTX *mctx),
148 \& int (*signctx) (EVP_PKEY_CTX *ctx,
149 \& unsigned char *sig,
150 \& size_t *siglen,
151 \& EVP_MD_CTX *mctx));
152 \& void EVP_PKEY_meth_set_verifyctx(EVP_PKEY_METHOD *pmeth,
153 \& int (*verifyctx_init) (EVP_PKEY_CTX *ctx,
154 \& EVP_MD_CTX *mctx),
155 \& int (*verifyctx) (EVP_PKEY_CTX *ctx,
156 \& const unsigned char *sig,
157 \& int siglen,
158 \& EVP_MD_CTX *mctx));
159 \& void EVP_PKEY_meth_set_encrypt(EVP_PKEY_METHOD *pmeth,
160 \& int (*encrypt_init) (EVP_PKEY_CTX *ctx),
161 \& int (*encryptfn) (EVP_PKEY_CTX *ctx,
162 \& unsigned char *out,
163 \& size_t *outlen,
164 \& const unsigned char *in,
165 \& size_t inlen));
166 \& void EVP_PKEY_meth_set_decrypt(EVP_PKEY_METHOD *pmeth,
167 \& int (*decrypt_init) (EVP_PKEY_CTX *ctx),
168 \& int (*decrypt) (EVP_PKEY_CTX *ctx,
169 \& unsigned char *out,
170 \& size_t *outlen,
171 \& const unsigned char *in,
172 \& size_t inlen));
173 \& void EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD *pmeth,
174 \& int (*derive_init) (EVP_PKEY_CTX *ctx),
175 \& int (*derive) (EVP_PKEY_CTX *ctx,
176 \& unsigned char *key,
177 \& size_t *keylen));
178 \& void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth,
179 \& int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1,
180 \& void *p2),
181 \& int (*ctrl_str) (EVP_PKEY_CTX *ctx,
182 \& const char *type,
183 \& const char *value));
184 \& void EVP_PKEY_meth_set_digestsign(EVP_PKEY_METHOD *pmeth,
185 \& int (*digestsign) (EVP_MD_CTX *ctx,
186 \& unsigned char *sig,
187 \& size_t *siglen,
188 \& const unsigned char *tbs,
189 \& size_t tbslen));
190 \& void EVP_PKEY_meth_set_digestverify(EVP_PKEY_METHOD *pmeth,
191 \& int (*digestverify) (EVP_MD_CTX *ctx,
192 \& const unsigned char *sig,
193 \& size_t siglen,
194 \& const unsigned char *tbs,
195 \& size_t tbslen));
196 \& void EVP_PKEY_meth_set_check(EVP_PKEY_METHOD *pmeth,
197 \& int (*check) (EVP_PKEY *pkey));
198 \& void EVP_PKEY_meth_set_public_check(EVP_PKEY_METHOD *pmeth,
199 \& int (*check) (EVP_PKEY *pkey));
200 \& void EVP_PKEY_meth_set_param_check(EVP_PKEY_METHOD *pmeth,
201 \& int (*check) (EVP_PKEY *pkey));
202 \& void EVP_PKEY_meth_set_digest_custom(EVP_PKEY_METHOD *pmeth,
203 \& int (*digest_custom) (EVP_PKEY_CTX *ctx,
204 \& EVP_MD_CTX *mctx));
205 \&
206 \& void EVP_PKEY_meth_get_init(const EVP_PKEY_METHOD *pmeth,
207 \& int (**pinit) (EVP_PKEY_CTX *ctx));
208 \& void EVP_PKEY_meth_get_copy(const EVP_PKEY_METHOD *pmeth,
209 \& int (**pcopy) (EVP_PKEY_CTX *dst,
210 \& EVP_PKEY_CTX *src));
211 \& void EVP_PKEY_meth_get_cleanup(const EVP_PKEY_METHOD *pmeth,
212 \& void (**pcleanup) (EVP_PKEY_CTX *ctx));
213 \& void EVP_PKEY_meth_get_paramgen(const EVP_PKEY_METHOD *pmeth,
214 \& int (**pparamgen_init) (EVP_PKEY_CTX *ctx),
215 \& int (**pparamgen) (EVP_PKEY_CTX *ctx,
216 \& EVP_PKEY *pkey));
217 \& void EVP_PKEY_meth_get_keygen(const EVP_PKEY_METHOD *pmeth,
218 \& int (**pkeygen_init) (EVP_PKEY_CTX *ctx),
219 \& int (**pkeygen) (EVP_PKEY_CTX *ctx,
220 \& EVP_PKEY *pkey));
221 \& void EVP_PKEY_meth_get_sign(const EVP_PKEY_METHOD *pmeth,
222 \& int (**psign_init) (EVP_PKEY_CTX *ctx),
223 \& int (**psign) (EVP_PKEY_CTX *ctx,
224 \& unsigned char *sig, size_t *siglen,
225 \& const unsigned char *tbs,
226 \& size_t tbslen));
227 \& void EVP_PKEY_meth_get_verify(const EVP_PKEY_METHOD *pmeth,
228 \& int (**pverify_init) (EVP_PKEY_CTX *ctx),
229 \& int (**pverify) (EVP_PKEY_CTX *ctx,
230 \& const unsigned char *sig,
231 \& size_t siglen,
232 \& const unsigned char *tbs,
233 \& size_t tbslen));
234 \& void EVP_PKEY_meth_get_verify_recover(const EVP_PKEY_METHOD *pmeth,
235 \& int (**pverify_recover_init) (EVP_PKEY_CTX
236 \& *ctx),
237 \& int (**pverify_recover) (EVP_PKEY_CTX
238 \& *ctx,
239 \& unsigned char
240 \& *sig,
241 \& size_t *siglen,
242 \& const unsigned
243 \& char *tbs,
244 \& size_t tbslen));
245 \& void EVP_PKEY_meth_get_signctx(const EVP_PKEY_METHOD *pmeth,
246 \& int (**psignctx_init) (EVP_PKEY_CTX *ctx,
247 \& EVP_MD_CTX *mctx),
248 \& int (**psignctx) (EVP_PKEY_CTX *ctx,
249 \& unsigned char *sig,
250 \& size_t *siglen,
251 \& EVP_MD_CTX *mctx));
252 \& void EVP_PKEY_meth_get_verifyctx(const EVP_PKEY_METHOD *pmeth,
253 \& int (**pverifyctx_init) (EVP_PKEY_CTX *ctx,
254 \& EVP_MD_CTX *mctx),
255 \& int (**pverifyctx) (EVP_PKEY_CTX *ctx,
256 \& const unsigned char *sig,
257 \& int siglen,
258 \& EVP_MD_CTX *mctx));
259 \& void EVP_PKEY_meth_get_encrypt(const EVP_PKEY_METHOD *pmeth,
260 \& int (**pencrypt_init) (EVP_PKEY_CTX *ctx),
261 \& int (**pencryptfn) (EVP_PKEY_CTX *ctx,
262 \& unsigned char *out,
263 \& size_t *outlen,
264 \& const unsigned char *in,
265 \& size_t inlen));
266 \& void EVP_PKEY_meth_get_decrypt(const EVP_PKEY_METHOD *pmeth,
267 \& int (**pdecrypt_init) (EVP_PKEY_CTX *ctx),
268 \& int (**pdecrypt) (EVP_PKEY_CTX *ctx,
269 \& unsigned char *out,
270 \& size_t *outlen,
271 \& const unsigned char *in,
272 \& size_t inlen));
273 \& void EVP_PKEY_meth_get_derive(const EVP_PKEY_METHOD *pmeth,
274 \& int (**pderive_init) (EVP_PKEY_CTX *ctx),
275 \& int (**pderive) (EVP_PKEY_CTX *ctx,
276 \& unsigned char *key,
277 \& size_t *keylen));
278 \& void EVP_PKEY_meth_get_ctrl(const EVP_PKEY_METHOD *pmeth,
279 \& int (**pctrl) (EVP_PKEY_CTX *ctx, int type, int p1,
280 \& void *p2),
281 \& int (**pctrl_str) (EVP_PKEY_CTX *ctx,
282 \& const char *type,
283 \& const char *value));
284 \& void EVP_PKEY_meth_get_digestsign(const EVP_PKEY_METHOD *pmeth,
285 \& int (**digestsign) (EVP_MD_CTX *ctx,
286 \& unsigned char *sig,
287 \& size_t *siglen,
288 \& const unsigned char *tbs,
289 \& size_t tbslen));
290 \& void EVP_PKEY_meth_get_digestverify(const EVP_PKEY_METHOD *pmeth,
291 \& int (**digestverify) (EVP_MD_CTX *ctx,
292 \& const unsigned char *sig,
293 \& size_t siglen,
294 \& const unsigned char *tbs,
295 \& size_t tbslen));
296 \& void EVP_PKEY_meth_get_check(const EVP_PKEY_METHOD *pmeth,
297 \& int (**pcheck) (EVP_PKEY *pkey));
298 \& void EVP_PKEY_meth_get_public_check(const EVP_PKEY_METHOD *pmeth,
299 \& int (**pcheck) (EVP_PKEY *pkey));
300 \& void EVP_PKEY_meth_get_param_check(const EVP_PKEY_METHOD *pmeth,
301 \& int (**pcheck) (EVP_PKEY *pkey));
302 \& void EVP_PKEY_meth_get_digest_custom(const EVP_PKEY_METHOD *pmeth,
303 \& int (**pdigest_custom) (EVP_PKEY_CTX *ctx,
304 \& EVP_MD_CTX *mctx));
305 .Ve
306 .SH DESCRIPTION
307 .IX Header "DESCRIPTION"
308 All of the functions described on this page are deprecated.
309 Applications should instead use the OSSL_PROVIDER APIs.
310 .PP
311 \&\fBEVP_PKEY_METHOD\fR is a structure which holds a set of methods for a
312 specific public key cryptographic algorithm. Those methods are usually
313 used to perform different jobs, such as generating a key, signing or
314 verifying, encrypting or decrypting, etc.
315 .PP
316 There are two places where the \fBEVP_PKEY_METHOD\fR objects are stored: one
317 is a built-in static array representing the standard methods for different
318 algorithms, and the other one is a stack of user-defined application-specific
319 methods, which can be manipulated by using \fBEVP_PKEY_meth_add0\fR\|(3).
320 .PP
321 The \fBEVP_PKEY_METHOD\fR objects are usually referenced by \fBEVP_PKEY_CTX\fR
322 objects.
323 .SS Methods
324 .IX Subsection "Methods"
325 The methods are the underlying implementations of a particular public key
326 algorithm present by the \fBEVP_PKEY_CTX\fR object.
327 .PP
328 .Vb 3
329 \& int (*init) (EVP_PKEY_CTX *ctx);
330 \& int (*copy) (EVP_PKEY_CTX *dst, const EVP_PKEY_CTX *src);
331 \& void (*cleanup) (EVP_PKEY_CTX *ctx);
332 .Ve
333 .PP
334 The \fBinit()\fR method is called to initialize algorithm-specific data when a new
335 \&\fBEVP_PKEY_CTX\fR is created. As opposed to \fBinit()\fR, the \fBcleanup()\fR method is called
336 when an \fBEVP_PKEY_CTX\fR is freed. The \fBcopy()\fR method is called when an \fBEVP_PKEY_CTX\fR
337 is being duplicated. Refer to \fBEVP_PKEY_CTX_new\fR\|(3), \fBEVP_PKEY_CTX_new_id\fR\|(3),
338 \&\fBEVP_PKEY_CTX_free\fR\|(3) and \fBEVP_PKEY_CTX_dup\fR\|(3).
339 .PP
340 .Vb 2
341 \& int (*paramgen_init) (EVP_PKEY_CTX *ctx);
342 \& int (*paramgen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
343 .Ve
344 .PP
345 The \fBparamgen_init()\fR and \fBparamgen()\fR methods deal with key parameter generation.
346 They are called by \fBEVP_PKEY_paramgen_init\fR\|(3) and \fBEVP_PKEY_paramgen\fR\|(3) to
347 handle the parameter generation process.
348 .PP
349 .Vb 2
350 \& int (*keygen_init) (EVP_PKEY_CTX *ctx);
351 \& int (*keygen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
352 .Ve
353 .PP
354 The \fBkeygen_init()\fR and \fBkeygen()\fR methods are used to generate the actual key for
355 the specified algorithm. They are called by \fBEVP_PKEY_keygen_init\fR\|(3) and
356 \&\fBEVP_PKEY_keygen\fR\|(3).
357 .PP
358 .Vb 3
359 \& int (*sign_init) (EVP_PKEY_CTX *ctx);
360 \& int (*sign) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
361 \& const unsigned char *tbs, size_t tbslen);
362 .Ve
363 .PP
364 The \fBsign_init()\fR and \fBsign()\fR methods are used to generate the signature of a
365 piece of data using a private key. They are called by \fBEVP_PKEY_sign_init\fR\|(3)
366 and \fBEVP_PKEY_sign\fR\|(3).
367 .PP
368 .Vb 4
369 \& int (*verify_init) (EVP_PKEY_CTX *ctx);
370 \& int (*verify) (EVP_PKEY_CTX *ctx,
371 \& const unsigned char *sig, size_t siglen,
372 \& const unsigned char *tbs, size_t tbslen);
373 .Ve
374 .PP
375 The \fBverify_init()\fR and \fBverify()\fR methods are used to verify whether a signature is
376 valid. They are called by \fBEVP_PKEY_verify_init\fR\|(3) and \fBEVP_PKEY_verify\fR\|(3).
377 .PP
378 .Vb 4
379 \& int (*verify_recover_init) (EVP_PKEY_CTX *ctx);
380 \& int (*verify_recover) (EVP_PKEY_CTX *ctx,
381 \& unsigned char *rout, size_t *routlen,
382 \& const unsigned char *sig, size_t siglen);
383 .Ve
384 .PP
385 The \fBverify_recover_init()\fR and \fBverify_recover()\fR methods are used to verify a
386 signature and then recover the digest from the signature (for instance, a
387 signature that was generated by RSA signing algorithm). They are called by
388 \&\fBEVP_PKEY_verify_recover_init\fR\|(3) and \fBEVP_PKEY_verify_recover\fR\|(3).
389 .PP
390 .Vb 3
391 \& int (*signctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
392 \& int (*signctx) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
393 \& EVP_MD_CTX *mctx);
394 .Ve
395 .PP
396 The \fBsignctx_init()\fR and \fBsignctx()\fR methods are used to sign a digest present by
397 a \fBEVP_MD_CTX\fR object. They are called by the EVP_DigestSign functions. See
398 \&\fBEVP_DigestSignInit\fR\|(3) for details.
399 .PP
400 .Vb 3
401 \& int (*verifyctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
402 \& int (*verifyctx) (EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen,
403 \& EVP_MD_CTX *mctx);
404 .Ve
405 .PP
406 The \fBverifyctx_init()\fR and \fBverifyctx()\fR methods are used to verify a signature
407 against the data in a \fBEVP_MD_CTX\fR object. They are called by the various
408 EVP_DigestVerify functions. See \fBEVP_DigestVerifyInit\fR\|(3) for details.
409 .PP
410 .Vb 3
411 \& int (*encrypt_init) (EVP_PKEY_CTX *ctx);
412 \& int (*encrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
413 \& const unsigned char *in, size_t inlen);
414 .Ve
415 .PP
416 The \fBencrypt_init()\fR and \fBencrypt()\fR methods are used to encrypt a piece of data.
417 They are called by \fBEVP_PKEY_encrypt_init\fR\|(3) and \fBEVP_PKEY_encrypt\fR\|(3).
418 .PP
419 .Vb 3
420 \& int (*decrypt_init) (EVP_PKEY_CTX *ctx);
421 \& int (*decrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
422 \& const unsigned char *in, size_t inlen);
423 .Ve
424 .PP
425 The \fBdecrypt_init()\fR and \fBdecrypt()\fR methods are used to decrypt a piece of data.
426 They are called by \fBEVP_PKEY_decrypt_init\fR\|(3) and \fBEVP_PKEY_decrypt\fR\|(3).
427 .PP
428 .Vb 2
429 \& int (*derive_init) (EVP_PKEY_CTX *ctx);
430 \& int (*derive) (EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);
431 .Ve
432 .PP
433 The \fBderive_init()\fR and \fBderive()\fR methods are used to derive the shared secret
434 from a public key algorithm (for instance, the DH algorithm). They are called by
435 \&\fBEVP_PKEY_derive_init\fR\|(3) and \fBEVP_PKEY_derive\fR\|(3).
436 .PP
437 .Vb 2
438 \& int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1, void *p2);
439 \& int (*ctrl_str) (EVP_PKEY_CTX *ctx, const char *type, const char *value);
440 .Ve
441 .PP
442 The \fBctrl()\fR and \fBctrl_str()\fR methods are used to adjust algorithm-specific
443 settings. See \fBEVP_PKEY_CTX_ctrl\fR\|(3) and related functions for details.
444 .PP
445 .Vb 5
446 \& int (*digestsign) (EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen,
447 \& const unsigned char *tbs, size_t tbslen);
448 \& int (*digestverify) (EVP_MD_CTX *ctx, const unsigned char *sig,
449 \& size_t siglen, const unsigned char *tbs,
450 \& size_t tbslen);
451 .Ve
452 .PP
453 The \fBdigestsign()\fR and \fBdigestverify()\fR methods are used to generate or verify
454 a signature in a one-shot mode. They could be called by \fBEVP_DigestSign\fR\|(3)
455 and \fBEVP_DigestVerify\fR\|(3).
456 .PP
457 .Vb 3
458 \& int (*check) (EVP_PKEY *pkey);
459 \& int (*public_check) (EVP_PKEY *pkey);
460 \& int (*param_check) (EVP_PKEY *pkey);
461 .Ve
462 .PP
463 The \fBcheck()\fR, \fBpublic_check()\fR and \fBparam_check()\fR methods are used to validate a
464 key-pair, the public component and parameters respectively for a given \fBpkey\fR.
465 They could be called by \fBEVP_PKEY_check\fR\|(3), \fBEVP_PKEY_public_check\fR\|(3) and
466 \&\fBEVP_PKEY_param_check\fR\|(3) respectively.
467 .PP
468 .Vb 1
469 \& int (*digest_custom) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
470 .Ve
471 .PP
472 The \fBdigest_custom()\fR method is used to generate customized digest content before
473 the real message is passed to functions like \fBEVP_DigestSignUpdate\fR\|(3) or
474 \&\fBEVP_DigestVerifyInit\fR\|(3). This is usually required by some public key
475 signature algorithms like SM2 which requires a hashed prefix to the message to
476 be signed. The \fBdigest_custom()\fR function will be called by \fBEVP_DigestSignInit\fR\|(3)
477 and \fBEVP_DigestVerifyInit\fR\|(3).
478 .SS Functions
479 .IX Subsection "Functions"
480 \&\fBEVP_PKEY_meth_new()\fR creates and returns a new \fBEVP_PKEY_METHOD\fR object,
481 and associates the given \fBid\fR and \fBflags\fR. The following flags are
482 supported:
483 .PP
484 .Vb 2
485 \& EVP_PKEY_FLAG_AUTOARGLEN
486 \& EVP_PKEY_FLAG_SIGCTX_CUSTOM
487 .Ve
488 .PP
489 If an \fBEVP_PKEY_METHOD\fR is set with the \fBEVP_PKEY_FLAG_AUTOARGLEN\fR flag, the
490 maximum size of the output buffer will be automatically calculated or checked
491 in corresponding EVP methods by the EVP framework. Thus the implementations of
492 these methods don't need to care about handling the case of returning output
493 buffer size by themselves. For details on the output buffer size, refer to
494 \&\fBEVP_PKEY_sign\fR\|(3).
495 .PP
496 The \fBEVP_PKEY_FLAG_SIGCTX_CUSTOM\fR is used to indicate the \fBsignctx()\fR method
497 of an \fBEVP_PKEY_METHOD\fR is always called by the EVP framework while doing a
498 digest signing operation by calling \fBEVP_DigestSignFinal\fR\|(3).
499 .PP
500 \&\fBEVP_PKEY_meth_free()\fR frees an existing \fBEVP_PKEY_METHOD\fR pointed by
501 \&\fBpmeth\fR. If the argument is NULL, nothing is done.
502 .PP
503 \&\fBEVP_PKEY_meth_copy()\fR copies an \fBEVP_PKEY_METHOD\fR object from \fBsrc\fR
504 to \fBdst\fR.
505 .PP
506 \&\fBEVP_PKEY_meth_find()\fR finds an \fBEVP_PKEY_METHOD\fR object with the \fBid\fR.
507 This function first searches through the user-defined method objects and
508 then the built-in objects.
509 .PP
510 \&\fBEVP_PKEY_meth_add0()\fR adds \fBpmeth\fR to the user defined stack of methods.
511 .PP
512 \&\fBEVP_PKEY_meth_remove()\fR removes an \fBEVP_PKEY_METHOD\fR object added by
513 \&\fBEVP_PKEY_meth_add0()\fR.
514 .PP
515 The EVP_PKEY_meth_set functions set the corresponding fields of
516 \&\fBEVP_PKEY_METHOD\fR structure with the arguments passed.
517 .PP
518 The EVP_PKEY_meth_get functions get the corresponding fields of
519 \&\fBEVP_PKEY_METHOD\fR structure to the arguments provided.
520 .SH "RETURN VALUES"
521 .IX Header "RETURN VALUES"
522 \&\fBEVP_PKEY_meth_new()\fR returns a pointer to a new \fBEVP_PKEY_METHOD\fR
523 object or returns NULL on error.
524 .PP
525 \&\fBEVP_PKEY_meth_free()\fR and \fBEVP_PKEY_meth_copy()\fR do not return values.
526 .PP
527 \&\fBEVP_PKEY_meth_find()\fR returns a pointer to the found \fBEVP_PKEY_METHOD\fR
528 object or returns NULL if not found.
529 .PP
530 \&\fBEVP_PKEY_meth_add0()\fR returns 1 if method is added successfully or 0
531 if an error occurred.
532 .PP
533 \&\fBEVP_PKEY_meth_remove()\fR returns 1 if method is removed successfully or
534 0 if an error occurred.
535 .PP
536 All EVP_PKEY_meth_set and EVP_PKEY_meth_get functions have no return
537 values. For the 'get' functions, function pointers are returned by
538 arguments.
539 .SH HISTORY
540 .IX Header "HISTORY"
541 All of these functions were deprecated in OpenSSL 3.0.
542 .PP
543 The signature of the \fIcopy\fR functional argument of \fBEVP_PKEY_meth_set_copy()\fR
544 has changed in OpenSSL 3.0 so its \fIsrc\fR parameter is now constified.
545 .SH COPYRIGHT
546 .IX Header "COPYRIGHT"
547 Copyright 2017\-2024 The OpenSSL Project Authors. All Rights Reserved.
548 .PP
549 Licensed under the Apache License 2.0 (the "License"). You may not use
550 this file except in compliance with the License. You can obtain a copy
551 in the file LICENSE in the source distribution or at
552 <https://www.openssl.org/source/license.html>.