]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - secure/lib/libcrypto/man/man3/EVP_PKEY_meth_new.3
MFC: r359060, r359061, r359066
[FreeBSD/FreeBSD.git] / secure / lib / libcrypto / man / man3 / EVP_PKEY_meth_new.3
1 .\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.40)
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sp \" Vertical space (when we can't use .PP)
6 .if t .sp .5v
7 .if n .sp
8 ..
9 .de Vb \" Begin verbatim text
10 .ft CW
11 .nf
12 .ne \\$1
13 ..
14 .de Ve \" End verbatim text
15 .ft R
16 .fi
17 ..
18 .\" Set up some character translations and predefined strings.  \*(-- will
19 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
20 .\" double quote, and \*(R" will give a right double quote.  \*(C+ will
21 .\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
22 .\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
23 .\" nothing in troff, for use with C<>.
24 .tr \(*W-
25 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
26 .ie n \{\
27 .    ds -- \(*W-
28 .    ds PI pi
29 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
30 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
31 .    ds L" ""
32 .    ds R" ""
33 .    ds C` ""
34 .    ds C' ""
35 'br\}
36 .el\{\
37 .    ds -- \|\(em\|
38 .    ds PI \(*p
39 .    ds L" ``
40 .    ds R" ''
41 .    ds C`
42 .    ds C'
43 'br\}
44 .\"
45 .\" Escape single quotes in literal strings from groff's Unicode transform.
46 .ie \n(.g .ds Aq \(aq
47 .el       .ds Aq '
48 .\"
49 .\" If the F register is >0, we'll generate index entries on stderr for
50 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
51 .\" entries marked with X<> in POD.  Of course, you'll have to process the
52 .\" output yourself in some meaningful fashion.
53 .\"
54 .\" Avoid warning from groff about undefined register 'F'.
55 .de IX
56 ..
57 .nr rF 0
58 .if \n(.g .if rF .nr rF 1
59 .if (\n(rF:(\n(.g==0)) \{\
60 .    if \nF \{\
61 .        de IX
62 .        tm Index:\\$1\t\\n%\t"\\$2"
63 ..
64 .        if !\nF==2 \{\
65 .            nr % 0
66 .            nr F 2
67 .        \}
68 .    \}
69 .\}
70 .rr rF
71 .\"
72 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
73 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
74 .    \" fudge factors for nroff and troff
75 .if n \{\
76 .    ds #H 0
77 .    ds #V .8m
78 .    ds #F .3m
79 .    ds #[ \f1
80 .    ds #] \fP
81 .\}
82 .if t \{\
83 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
84 .    ds #V .6m
85 .    ds #F 0
86 .    ds #[ \&
87 .    ds #] \&
88 .\}
89 .    \" simple accents for nroff and troff
90 .if n \{\
91 .    ds ' \&
92 .    ds ` \&
93 .    ds ^ \&
94 .    ds , \&
95 .    ds ~ ~
96 .    ds /
97 .\}
98 .if t \{\
99 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
100 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
101 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
102 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
103 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
104 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
105 .\}
106 .    \" troff and (daisy-wheel) nroff accents
107 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
108 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
109 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
110 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
111 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
112 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
113 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
114 .ds ae a\h'-(\w'a'u*4/10)'e
115 .ds Ae A\h'-(\w'A'u*4/10)'E
116 .    \" corrections for vroff
117 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
118 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
119 .    \" for low resolution devices (crt and lpr)
120 .if \n(.H>23 .if \n(.V>19 \
121 \{\
122 .    ds : e
123 .    ds 8 ss
124 .    ds o a
125 .    ds d- d\h'-1'\(ga
126 .    ds D- D\h'-1'\(hy
127 .    ds th \o'bp'
128 .    ds Th \o'LP'
129 .    ds ae ae
130 .    ds Ae AE
131 .\}
132 .rm #[ #] #H #V #F C
133 .\" ========================================================================
134 .\"
135 .IX Title "EVP_PKEY_METH_NEW 3"
136 .TH EVP_PKEY_METH_NEW 3 "2020-03-17" "1.1.1e" "OpenSSL"
137 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
138 .\" way too many mistakes in technical documents.
139 .if n .ad l
140 .nh
141 .SH "NAME"
142 EVP_PKEY_meth_new, EVP_PKEY_meth_free, EVP_PKEY_meth_copy, EVP_PKEY_meth_find, EVP_PKEY_meth_add0, EVP_PKEY_METHOD, EVP_PKEY_meth_set_init, EVP_PKEY_meth_set_copy, EVP_PKEY_meth_set_cleanup, EVP_PKEY_meth_set_paramgen, EVP_PKEY_meth_set_keygen, EVP_PKEY_meth_set_sign, EVP_PKEY_meth_set_verify, EVP_PKEY_meth_set_verify_recover, EVP_PKEY_meth_set_signctx, EVP_PKEY_meth_set_verifyctx, EVP_PKEY_meth_set_encrypt, EVP_PKEY_meth_set_decrypt, EVP_PKEY_meth_set_derive, EVP_PKEY_meth_set_ctrl, EVP_PKEY_meth_set_digestsign, EVP_PKEY_meth_set_digestverify, EVP_PKEY_meth_set_check, EVP_PKEY_meth_set_public_check, EVP_PKEY_meth_set_param_check, EVP_PKEY_meth_set_digest_custom, EVP_PKEY_meth_get_init, EVP_PKEY_meth_get_copy, EVP_PKEY_meth_get_cleanup, EVP_PKEY_meth_get_paramgen, EVP_PKEY_meth_get_keygen, EVP_PKEY_meth_get_sign, EVP_PKEY_meth_get_verify, EVP_PKEY_meth_get_verify_recover, EVP_PKEY_meth_get_signctx, EVP_PKEY_meth_get_verifyctx, EVP_PKEY_meth_get_encrypt, EVP_PKEY_meth_get_decrypt, EVP_PKEY_meth_get_derive, EVP_PKEY_meth_get_ctrl, EVP_PKEY_meth_get_digestsign, EVP_PKEY_meth_get_digestverify, EVP_PKEY_meth_get_check, EVP_PKEY_meth_get_public_check, EVP_PKEY_meth_get_param_check, EVP_PKEY_meth_get_digest_custom, EVP_PKEY_meth_remove \&\- manipulating EVP_PKEY_METHOD structure
143 .SH "SYNOPSIS"
144 .IX Header "SYNOPSIS"
145 .Vb 1
146 \& #include <openssl/evp.h>
147 \&
148 \& typedef struct evp_pkey_method_st EVP_PKEY_METHOD;
149 \&
150 \& EVP_PKEY_METHOD *EVP_PKEY_meth_new(int id, int flags);
151 \& void EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth);
152 \& void EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, const EVP_PKEY_METHOD *src);
153 \& const EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type);
154 \& int EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth);
155 \& int EVP_PKEY_meth_remove(const EVP_PKEY_METHOD *pmeth);
156 \&
157 \& void EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth,
158 \&                             int (*init) (EVP_PKEY_CTX *ctx));
159 \& void EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD *pmeth,
160 \&                             int (*copy) (EVP_PKEY_CTX *dst,
161 \&                                          EVP_PKEY_CTX *src));
162 \& void EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD *pmeth,
163 \&                                void (*cleanup) (EVP_PKEY_CTX *ctx));
164 \& void EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD *pmeth,
165 \&                                 int (*paramgen_init) (EVP_PKEY_CTX *ctx),
166 \&                                 int (*paramgen) (EVP_PKEY_CTX *ctx,
167 \&                                                  EVP_PKEY *pkey));
168 \& void EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD *pmeth,
169 \&                               int (*keygen_init) (EVP_PKEY_CTX *ctx),
170 \&                               int (*keygen) (EVP_PKEY_CTX *ctx,
171 \&                                              EVP_PKEY *pkey));
172 \& void EVP_PKEY_meth_set_sign(EVP_PKEY_METHOD *pmeth,
173 \&                             int (*sign_init) (EVP_PKEY_CTX *ctx),
174 \&                             int (*sign) (EVP_PKEY_CTX *ctx,
175 \&                                          unsigned char *sig, size_t *siglen,
176 \&                                          const unsigned char *tbs,
177 \&                                          size_t tbslen));
178 \& void EVP_PKEY_meth_set_verify(EVP_PKEY_METHOD *pmeth,
179 \&                               int (*verify_init) (EVP_PKEY_CTX *ctx),
180 \&                               int (*verify) (EVP_PKEY_CTX *ctx,
181 \&                                              const unsigned char *sig,
182 \&                                              size_t siglen,
183 \&                                              const unsigned char *tbs,
184 \&                                              size_t tbslen));
185 \& void EVP_PKEY_meth_set_verify_recover(EVP_PKEY_METHOD *pmeth,
186 \&                                       int (*verify_recover_init) (EVP_PKEY_CTX
187 \&                                                                   *ctx),
188 \&                                       int (*verify_recover) (EVP_PKEY_CTX
189 \&                                                              *ctx,
190 \&                                                              unsigned char
191 \&                                                              *sig,
192 \&                                                              size_t *siglen,
193 \&                                                              const unsigned
194 \&                                                              char *tbs,
195 \&                                                              size_t tbslen));
196 \& void EVP_PKEY_meth_set_signctx(EVP_PKEY_METHOD *pmeth,
197 \&                                int (*signctx_init) (EVP_PKEY_CTX *ctx,
198 \&                                                     EVP_MD_CTX *mctx),
199 \&                                int (*signctx) (EVP_PKEY_CTX *ctx,
200 \&                                                unsigned char *sig,
201 \&                                                size_t *siglen,
202 \&                                                EVP_MD_CTX *mctx));
203 \& void EVP_PKEY_meth_set_verifyctx(EVP_PKEY_METHOD *pmeth,
204 \&                                  int (*verifyctx_init) (EVP_PKEY_CTX *ctx,
205 \&                                                         EVP_MD_CTX *mctx),
206 \&                                  int (*verifyctx) (EVP_PKEY_CTX *ctx,
207 \&                                                    const unsigned char *sig,
208 \&                                                    int siglen,
209 \&                                                    EVP_MD_CTX *mctx));
210 \& void EVP_PKEY_meth_set_encrypt(EVP_PKEY_METHOD *pmeth,
211 \&                                int (*encrypt_init) (EVP_PKEY_CTX *ctx),
212 \&                                int (*encryptfn) (EVP_PKEY_CTX *ctx,
213 \&                                                  unsigned char *out,
214 \&                                                  size_t *outlen,
215 \&                                                  const unsigned char *in,
216 \&                                                  size_t inlen));
217 \& void EVP_PKEY_meth_set_decrypt(EVP_PKEY_METHOD *pmeth,
218 \&                                int (*decrypt_init) (EVP_PKEY_CTX *ctx),
219 \&                                int (*decrypt) (EVP_PKEY_CTX *ctx,
220 \&                                                unsigned char *out,
221 \&                                                size_t *outlen,
222 \&                                                const unsigned char *in,
223 \&                                                size_t inlen));
224 \& void EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD *pmeth,
225 \&                               int (*derive_init) (EVP_PKEY_CTX *ctx),
226 \&                               int (*derive) (EVP_PKEY_CTX *ctx,
227 \&                                              unsigned char *key,
228 \&                                              size_t *keylen));
229 \& void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth,
230 \&                             int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1,
231 \&                                          void *p2),
232 \&                             int (*ctrl_str) (EVP_PKEY_CTX *ctx,
233 \&                                              const char *type,
234 \&                                              const char *value));
235 \& void EVP_PKEY_meth_set_digestsign(EVP_PKEY_METHOD *pmeth,
236 \&                                   int (*digestsign) (EVP_MD_CTX *ctx,
237 \&                                                      unsigned char *sig,
238 \&                                                      size_t *siglen,
239 \&                                                      const unsigned char *tbs,
240 \&                                                      size_t tbslen));
241 \& void EVP_PKEY_meth_set_digestverify(EVP_PKEY_METHOD *pmeth,
242 \&                                     int (*digestverify) (EVP_MD_CTX *ctx,
243 \&                                                          const unsigned char *sig,
244 \&                                                          size_t siglen,
245 \&                                                          const unsigned char *tbs,
246 \&                                                          size_t tbslen));
247 \& void EVP_PKEY_meth_set_check(EVP_PKEY_METHOD *pmeth,
248 \&                              int (*check) (EVP_PKEY *pkey));
249 \& void EVP_PKEY_meth_set_public_check(EVP_PKEY_METHOD *pmeth,
250 \&                                     int (*check) (EVP_PKEY *pkey));
251 \& void EVP_PKEY_meth_set_param_check(EVP_PKEY_METHOD *pmeth,
252 \&                                    int (*check) (EVP_PKEY *pkey));
253 \& void EVP_PKEY_meth_set_digest_custom(EVP_PKEY_METHOD *pmeth,
254 \&                                     int (*digest_custom) (EVP_PKEY_CTX *ctx,
255 \&                                                           EVP_MD_CTX *mctx));
256 \&
257 \& void EVP_PKEY_meth_get_init(const EVP_PKEY_METHOD *pmeth,
258 \&                             int (**pinit) (EVP_PKEY_CTX *ctx));
259 \& void EVP_PKEY_meth_get_copy(const EVP_PKEY_METHOD *pmeth,
260 \&                             int (**pcopy) (EVP_PKEY_CTX *dst,
261 \&                                            EVP_PKEY_CTX *src));
262 \& void EVP_PKEY_meth_get_cleanup(const EVP_PKEY_METHOD *pmeth,
263 \&                                void (**pcleanup) (EVP_PKEY_CTX *ctx));
264 \& void EVP_PKEY_meth_get_paramgen(const EVP_PKEY_METHOD *pmeth,
265 \&                                 int (**pparamgen_init) (EVP_PKEY_CTX *ctx),
266 \&                                 int (**pparamgen) (EVP_PKEY_CTX *ctx,
267 \&                                                    EVP_PKEY *pkey));
268 \& void EVP_PKEY_meth_get_keygen(const EVP_PKEY_METHOD *pmeth,
269 \&                               int (**pkeygen_init) (EVP_PKEY_CTX *ctx),
270 \&                               int (**pkeygen) (EVP_PKEY_CTX *ctx,
271 \&                                                EVP_PKEY *pkey));
272 \& void EVP_PKEY_meth_get_sign(const EVP_PKEY_METHOD *pmeth,
273 \&                             int (**psign_init) (EVP_PKEY_CTX *ctx),
274 \&                             int (**psign) (EVP_PKEY_CTX *ctx,
275 \&                                            unsigned char *sig, size_t *siglen,
276 \&                                            const unsigned char *tbs,
277 \&                                            size_t tbslen));
278 \& void EVP_PKEY_meth_get_verify(const EVP_PKEY_METHOD *pmeth,
279 \&                               int (**pverify_init) (EVP_PKEY_CTX *ctx),
280 \&                               int (**pverify) (EVP_PKEY_CTX *ctx,
281 \&                                                const unsigned char *sig,
282 \&                                                size_t siglen,
283 \&                                                const unsigned char *tbs,
284 \&                                                size_t tbslen));
285 \& void EVP_PKEY_meth_get_verify_recover(const EVP_PKEY_METHOD *pmeth,
286 \&                                       int (**pverify_recover_init) (EVP_PKEY_CTX
287 \&                                                                     *ctx),
288 \&                                       int (**pverify_recover) (EVP_PKEY_CTX
289 \&                                                                *ctx,
290 \&                                                                unsigned char
291 \&                                                                *sig,
292 \&                                                                size_t *siglen,
293 \&                                                                const unsigned
294 \&                                                                char *tbs,
295 \&                                                                size_t tbslen));
296 \& void EVP_PKEY_meth_get_signctx(const EVP_PKEY_METHOD *pmeth,
297 \&                                int (**psignctx_init) (EVP_PKEY_CTX *ctx,
298 \&                                                       EVP_MD_CTX *mctx),
299 \&                                int (**psignctx) (EVP_PKEY_CTX *ctx,
300 \&                                                  unsigned char *sig,
301 \&                                                  size_t *siglen,
302 \&                                                  EVP_MD_CTX *mctx));
303 \& void EVP_PKEY_meth_get_verifyctx(const EVP_PKEY_METHOD *pmeth,
304 \&                                  int (**pverifyctx_init) (EVP_PKEY_CTX *ctx,
305 \&                                                           EVP_MD_CTX *mctx),
306 \&                                  int (**pverifyctx) (EVP_PKEY_CTX *ctx,
307 \&                                                      const unsigned char *sig,
308 \&                                                      int siglen,
309 \&                                                      EVP_MD_CTX *mctx));
310 \& void EVP_PKEY_meth_get_encrypt(const EVP_PKEY_METHOD *pmeth,
311 \&                                int (**pencrypt_init) (EVP_PKEY_CTX *ctx),
312 \&                                int (**pencryptfn) (EVP_PKEY_CTX *ctx,
313 \&                                                    unsigned char *out,
314 \&                                                    size_t *outlen,
315 \&                                                    const unsigned char *in,
316 \&                                                    size_t inlen));
317 \& void EVP_PKEY_meth_get_decrypt(const EVP_PKEY_METHOD *pmeth,
318 \&                                int (**pdecrypt_init) (EVP_PKEY_CTX *ctx),
319 \&                                int (**pdecrypt) (EVP_PKEY_CTX *ctx,
320 \&                                                  unsigned char *out,
321 \&                                                  size_t *outlen,
322 \&                                                  const unsigned char *in,
323 \&                                                  size_t inlen));
324 \& void EVP_PKEY_meth_get_derive(const EVP_PKEY_METHOD *pmeth,
325 \&                               int (**pderive_init) (EVP_PKEY_CTX *ctx),
326 \&                               int (**pderive) (EVP_PKEY_CTX *ctx,
327 \&                                                unsigned char *key,
328 \&                                                size_t *keylen));
329 \& void EVP_PKEY_meth_get_ctrl(const EVP_PKEY_METHOD *pmeth,
330 \&                             int (**pctrl) (EVP_PKEY_CTX *ctx, int type, int p1,
331 \&                                            void *p2),
332 \&                             int (**pctrl_str) (EVP_PKEY_CTX *ctx,
333 \&                                                const char *type,
334 \&                                                const char *value));
335 \& void EVP_PKEY_meth_get_digestsign(EVP_PKEY_METHOD *pmeth,
336 \&                                   int (**digestsign) (EVP_MD_CTX *ctx,
337 \&                                                       unsigned char *sig,
338 \&                                                       size_t *siglen,
339 \&                                                       const unsigned char *tbs,
340 \&                                                       size_t tbslen));
341 \& void EVP_PKEY_meth_get_digestverify(EVP_PKEY_METHOD *pmeth,
342 \&                                     int (**digestverify) (EVP_MD_CTX *ctx,
343 \&                                                           const unsigned char *sig,
344 \&                                                           size_t siglen,
345 \&                                                           const unsigned char *tbs,
346 \&                                                           size_t tbslen));
347 \& void EVP_PKEY_meth_get_check(const EVP_PKEY_METHOD *pmeth,
348 \&                              int (**pcheck) (EVP_PKEY *pkey));
349 \& void EVP_PKEY_meth_get_public_check(const EVP_PKEY_METHOD *pmeth,
350 \&                                     int (**pcheck) (EVP_PKEY *pkey));
351 \& void EVP_PKEY_meth_get_param_check(const EVP_PKEY_METHOD *pmeth,
352 \&                                    int (**pcheck) (EVP_PKEY *pkey));
353 \& void EVP_PKEY_meth_get_digest_custom(EVP_PKEY_METHOD *pmeth,
354 \&                                     int (**pdigest_custom) (EVP_PKEY_CTX *ctx,
355 \&                                                             EVP_MD_CTX *mctx));
356 .Ve
357 .SH "DESCRIPTION"
358 .IX Header "DESCRIPTION"
359 \&\fB\s-1EVP_PKEY_METHOD\s0\fR is a structure which holds a set of methods for a
360 specific public key cryptographic algorithm. Those methods are usually
361 used to perform different jobs, such as generating a key, signing or
362 verifying, encrypting or decrypting, etc.
363 .PP
364 There are two places where the \fB\s-1EVP_PKEY_METHOD\s0\fR objects are stored: one
365 is a built-in static array representing the standard methods for different
366 algorithms, and the other one is a stack of user-defined application-specific
367 methods, which can be manipulated by using \fBEVP_PKEY_meth_add0\fR\|(3).
368 .PP
369 The \fB\s-1EVP_PKEY_METHOD\s0\fR objects are usually referenced by \fB\s-1EVP_PKEY_CTX\s0\fR
370 objects.
371 .SS "Methods"
372 .IX Subsection "Methods"
373 The methods are the underlying implementations of a particular public key
374 algorithm present by the \fB\s-1EVP_PKEY_CTX\s0\fR object.
375 .PP
376 .Vb 3
377 \& int (*init) (EVP_PKEY_CTX *ctx);
378 \& int (*copy) (EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src);
379 \& void (*cleanup) (EVP_PKEY_CTX *ctx);
380 .Ve
381 .PP
382 The \fBinit()\fR method is called to initialize algorithm-specific data when a new
383 \&\fB\s-1EVP_PKEY_CTX\s0\fR is created. As opposed to \fBinit()\fR, the \fBcleanup()\fR method is called
384 when an \fB\s-1EVP_PKEY_CTX\s0\fR is freed. The \fBcopy()\fR method is called when an \fB\s-1EVP_PKEY_CTX\s0\fR
385 is being duplicated. Refer to \fBEVP_PKEY_CTX_new\fR\|(3), \fBEVP_PKEY_CTX_new_id\fR\|(3),
386 \&\fBEVP_PKEY_CTX_free\fR\|(3) and \fBEVP_PKEY_CTX_dup\fR\|(3).
387 .PP
388 .Vb 2
389 \& int (*paramgen_init) (EVP_PKEY_CTX *ctx);
390 \& int (*paramgen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
391 .Ve
392 .PP
393 The \fBparamgen_init()\fR and \fBparamgen()\fR methods deal with key parameter generation.
394 They are called by \fBEVP_PKEY_paramgen_init\fR\|(3) and \fBEVP_PKEY_paramgen\fR\|(3) to
395 handle the parameter generation process.
396 .PP
397 .Vb 2
398 \& int (*keygen_init) (EVP_PKEY_CTX *ctx);
399 \& int (*keygen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
400 .Ve
401 .PP
402 The \fBkeygen_init()\fR and \fBkeygen()\fR methods are used to generate the actual key for
403 the specified algorithm. They are called by \fBEVP_PKEY_keygen_init\fR\|(3) and
404 \&\fBEVP_PKEY_keygen\fR\|(3).
405 .PP
406 .Vb 3
407 \& int (*sign_init) (EVP_PKEY_CTX *ctx);
408 \& int (*sign) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
409 \&              const unsigned char *tbs, size_t tbslen);
410 .Ve
411 .PP
412 The \fBsign_init()\fR and \fBsign()\fR methods are used to generate the signature of a
413 piece of data using a private key. They are called by \fBEVP_PKEY_sign_init\fR\|(3)
414 and \fBEVP_PKEY_sign\fR\|(3).
415 .PP
416 .Vb 4
417 \& int (*verify_init) (EVP_PKEY_CTX *ctx);
418 \& int (*verify) (EVP_PKEY_CTX *ctx,
419 \&                const unsigned char *sig, size_t siglen,
420 \&                const unsigned char *tbs, size_t tbslen);
421 .Ve
422 .PP
423 The \fBverify_init()\fR and \fBverify()\fR methods are used to verify whether a signature is
424 valid. They are called by \fBEVP_PKEY_verify_init\fR\|(3) and \fBEVP_PKEY_verify\fR\|(3).
425 .PP
426 .Vb 4
427 \& int (*verify_recover_init) (EVP_PKEY_CTX *ctx);
428 \& int (*verify_recover) (EVP_PKEY_CTX *ctx,
429 \&                        unsigned char *rout, size_t *routlen,
430 \&                        const unsigned char *sig, size_t siglen);
431 .Ve
432 .PP
433 The \fBverify_recover_init()\fR and \fBverify_recover()\fR methods are used to verify a
434 signature and then recover the digest from the signature (for instance, a
435 signature that was generated by \s-1RSA\s0 signing algorithm). They are called by
436 \&\fBEVP_PKEY_verify_recover_init\fR\|(3) and \fBEVP_PKEY_verify_recover\fR\|(3).
437 .PP
438 .Vb 3
439 \& int (*signctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
440 \& int (*signctx) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
441 \&                 EVP_MD_CTX *mctx);
442 .Ve
443 .PP
444 The \fBsignctx_init()\fR and \fBsignctx()\fR methods are used to sign a digest present by
445 a \fB\s-1EVP_MD_CTX\s0\fR object. They are called by the EVP_DigestSign functions. See
446 \&\fBEVP_DigestSignInit\fR\|(3) for details.
447 .PP
448 .Vb 3
449 \& int (*verifyctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
450 \& int (*verifyctx) (EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen,
451 \&                   EVP_MD_CTX *mctx);
452 .Ve
453 .PP
454 The \fBverifyctx_init()\fR and \fBverifyctx()\fR methods are used to verify a signature
455 against the data in a \fB\s-1EVP_MD_CTX\s0\fR object. They are called by the various
456 EVP_DigestVerify functions. See \fBEVP_DigestVerifyInit\fR\|(3) for details.
457 .PP
458 .Vb 3
459 \& int (*encrypt_init) (EVP_PKEY_CTX *ctx);
460 \& int (*encrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
461 \&                 const unsigned char *in, size_t inlen);
462 .Ve
463 .PP
464 The \fBencrypt_init()\fR and \fBencrypt()\fR methods are used to encrypt a piece of data.
465 They are called by \fBEVP_PKEY_encrypt_init\fR\|(3) and \fBEVP_PKEY_encrypt\fR\|(3).
466 .PP
467 .Vb 3
468 \& int (*decrypt_init) (EVP_PKEY_CTX *ctx);
469 \& int (*decrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
470 \&                 const unsigned char *in, size_t inlen);
471 .Ve
472 .PP
473 The \fBdecrypt_init()\fR and \fBdecrypt()\fR methods are used to decrypt a piece of data.
474 They are called by \fBEVP_PKEY_decrypt_init\fR\|(3) and \fBEVP_PKEY_decrypt\fR\|(3).
475 .PP
476 .Vb 2
477 \& int (*derive_init) (EVP_PKEY_CTX *ctx);
478 \& int (*derive) (EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);
479 .Ve
480 .PP
481 The \fBderive_init()\fR and \fBderive()\fR methods are used to derive the shared secret
482 from a public key algorithm (for instance, the \s-1DH\s0 algorithm). They are called by
483 \&\fBEVP_PKEY_derive_init\fR\|(3) and \fBEVP_PKEY_derive\fR\|(3).
484 .PP
485 .Vb 2
486 \& int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1, void *p2);
487 \& int (*ctrl_str) (EVP_PKEY_CTX *ctx, const char *type, const char *value);
488 .Ve
489 .PP
490 The \fBctrl()\fR and \fBctrl_str()\fR methods are used to adjust algorithm-specific
491 settings. See \fBEVP_PKEY_CTX_ctrl\fR\|(3) and related functions for details.
492 .PP
493 .Vb 5
494 \& int (*digestsign) (EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen,
495 \&                    const unsigned char *tbs, size_t tbslen);
496 \& int (*digestverify) (EVP_MD_CTX *ctx, const unsigned char *sig,
497 \&                      size_t siglen, const unsigned char *tbs,
498 \&                      size_t tbslen);
499 .Ve
500 .PP
501 The \fBdigestsign()\fR and \fBdigestverify()\fR methods are used to generate or verify
502 a signature in a one-shot mode. They could be called by \fBEVP_DigestSign\fR\|(3)
503 and \fBEVP_DigestVerify\fR\|(3).
504 .PP
505 .Vb 3
506 \& int (*check) (EVP_PKEY *pkey);
507 \& int (*public_check) (EVP_PKEY *pkey);
508 \& int (*param_check) (EVP_PKEY *pkey);
509 .Ve
510 .PP
511 The \fBcheck()\fR, \fBpublic_check()\fR and \fBparam_check()\fR methods are used to validate a
512 key-pair, the public component and parameters respectively for a given \fBpkey\fR.
513 They could be called by \fBEVP_PKEY_check\fR\|(3), \fBEVP_PKEY_public_check\fR\|(3) and
514 \&\fBEVP_PKEY_param_check\fR\|(3) respectively.
515 .PP
516 .Vb 1
517 \& int (*digest_custom) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
518 .Ve
519 .PP
520 The \fBdigest_custom()\fR method is used to generate customized digest content before
521 the real message is passed to functions like \fBEVP_DigestSignUpdate\fR\|(3) or
522 \&\fBEVP_DigestVerifyInit\fR\|(3). This is usually required by some public key
523 signature algorithms like \s-1SM2\s0 which requires a hashed prefix to the message to
524 be signed. The \fBdigest_custom()\fR function will be called by \fBEVP_DigestSignInit\fR\|(3)
525 and \fBEVP_DigestVerifyInit\fR\|(3).
526 .SS "Functions"
527 .IX Subsection "Functions"
528 \&\fBEVP_PKEY_meth_new()\fR creates and returns a new \fB\s-1EVP_PKEY_METHOD\s0\fR object,
529 and associates the given \fBid\fR and \fBflags\fR. The following flags are
530 supported:
531 .PP
532 .Vb 2
533 \& EVP_PKEY_FLAG_AUTOARGLEN
534 \& EVP_PKEY_FLAG_SIGCTX_CUSTOM
535 .Ve
536 .PP
537 If an \fB\s-1EVP_PKEY_METHOD\s0\fR is set with the \fB\s-1EVP_PKEY_FLAG_AUTOARGLEN\s0\fR flag, the
538 maximum size of the output buffer will be automatically calculated or checked
539 in corresponding \s-1EVP\s0 methods by the \s-1EVP\s0 framework. Thus the implementations of
540 these methods don't need to care about handling the case of returning output
541 buffer size by themselves. For details on the output buffer size, refer to
542 \&\fBEVP_PKEY_sign\fR\|(3).
543 .PP
544 The \fB\s-1EVP_PKEY_FLAG_SIGCTX_CUSTOM\s0\fR is used to indicate the \fBsignctx()\fR method
545 of an \fB\s-1EVP_PKEY_METHOD\s0\fR is always called by the \s-1EVP\s0 framework while doing a
546 digest signing operation by calling \fBEVP_DigestSignFinal\fR\|(3).
547 .PP
548 \&\fBEVP_PKEY_meth_free()\fR frees an existing \fB\s-1EVP_PKEY_METHOD\s0\fR pointed by
549 \&\fBpmeth\fR.
550 .PP
551 \&\fBEVP_PKEY_meth_copy()\fR copies an \fB\s-1EVP_PKEY_METHOD\s0\fR object from \fBsrc\fR
552 to \fBdst\fR.
553 .PP
554 \&\fBEVP_PKEY_meth_find()\fR finds an \fB\s-1EVP_PKEY_METHOD\s0\fR object with the \fBid\fR.
555 This function first searches through the user-defined method objects and
556 then the built-in objects.
557 .PP
558 \&\fBEVP_PKEY_meth_add0()\fR adds \fBpmeth\fR to the user defined stack of methods.
559 .PP
560 \&\fBEVP_PKEY_meth_remove()\fR removes an \fB\s-1EVP_PKEY_METHOD\s0\fR object added by
561 \&\fBEVP_PKEY_meth_add0()\fR.
562 .PP
563 The EVP_PKEY_meth_set functions set the corresponding fields of
564 \&\fB\s-1EVP_PKEY_METHOD\s0\fR structure with the arguments passed.
565 .PP
566 The EVP_PKEY_meth_get functions get the corresponding fields of
567 \&\fB\s-1EVP_PKEY_METHOD\s0\fR structure to the arguments provided.
568 .SH "RETURN VALUES"
569 .IX Header "RETURN VALUES"
570 \&\fBEVP_PKEY_meth_new()\fR returns a pointer to a new \fB\s-1EVP_PKEY_METHOD\s0\fR
571 object or returns \s-1NULL\s0 on error.
572 .PP
573 \&\fBEVP_PKEY_meth_free()\fR and \fBEVP_PKEY_meth_copy()\fR do not return values.
574 .PP
575 \&\fBEVP_PKEY_meth_find()\fR returns a pointer to the found \fB\s-1EVP_PKEY_METHOD\s0\fR
576 object or returns \s-1NULL\s0 if not found.
577 .PP
578 \&\fBEVP_PKEY_meth_add0()\fR returns 1 if method is added successfully or 0
579 if an error occurred.
580 .PP
581 \&\fBEVP_PKEY_meth_remove()\fR returns 1 if method is removed successfully or
582 0 if an error occurred.
583 .PP
584 All EVP_PKEY_meth_set and EVP_PKEY_meth_get functions have no return
585 values. For the 'get' functions, function pointers are returned by
586 arguments.
587 .SH "COPYRIGHT"
588 .IX Header "COPYRIGHT"
589 Copyright 2017\-2019 The OpenSSL Project Authors. All Rights Reserved.
590 .PP
591 Licensed under the OpenSSL license (the \*(L"License\*(R").  You may not use
592 this file except in compliance with the License.  You can obtain a copy
593 in the file \s-1LICENSE\s0 in the source distribution or at
594 <https://www.openssl.org/source/license.html>.