]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - secure/lib/libcrypto/man/EVP_PKEY_meth_new.3
Merge OpenSSL 1.0.2s.
[FreeBSD/FreeBSD.git] / secure / lib / libcrypto / man / EVP_PKEY_meth_new.3
1 .\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35)
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 "2019-05-28" "1.0.2s" "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,
143 EVP_PKEY_meth_add0, EVP_PKEY_METHOD,
144 EVP_PKEY_meth_set_init, EVP_PKEY_meth_set_copy, EVP_PKEY_meth_set_cleanup,
145 EVP_PKEY_meth_set_paramgen, EVP_PKEY_meth_set_keygen, EVP_PKEY_meth_set_sign,
146 EVP_PKEY_meth_set_verify, EVP_PKEY_meth_set_verify_recover, EVP_PKEY_meth_set_signctx,
147 EVP_PKEY_meth_set_verifyctx, EVP_PKEY_meth_set_encrypt, EVP_PKEY_meth_set_decrypt,
148 EVP_PKEY_meth_set_derive, EVP_PKEY_meth_set_ctrl,
149 EVP_PKEY_meth_get_init, EVP_PKEY_meth_get_copy, EVP_PKEY_meth_get_cleanup,
150 EVP_PKEY_meth_get_paramgen, EVP_PKEY_meth_get_keygen, EVP_PKEY_meth_get_sign,
151 EVP_PKEY_meth_get_verify, EVP_PKEY_meth_get_verify_recover, EVP_PKEY_meth_get_signctx,
152 EVP_PKEY_meth_get_verifyctx, EVP_PKEY_meth_get_encrypt, EVP_PKEY_meth_get_decrypt,
153 EVP_PKEY_meth_get_derive, EVP_PKEY_meth_get_ctrl
154 \&\- manipulating EVP_PKEY_METHOD structure
155 .SH "SYNOPSIS"
156 .IX Header "SYNOPSIS"
157 .Vb 1
158 \& #include <openssl/evp.h>
159 \&
160 \& typedef struct evp_pkey_method_st EVP_PKEY_METHOD;
161 \&
162 \& EVP_PKEY_METHOD *EVP_PKEY_meth_new(int id, int flags);
163 \& void EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth);
164 \& void EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, const EVP_PKEY_METHOD *src);
165 \& const EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type);
166 \& int EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth);
167 \&
168 \& void EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth,
169 \&                             int (*init) (EVP_PKEY_CTX *ctx));
170 \& void EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD *pmeth,
171 \&                             int (*copy) (EVP_PKEY_CTX *dst,
172 \&                                          EVP_PKEY_CTX *src));
173 \& void EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD *pmeth,
174 \&                                void (*cleanup) (EVP_PKEY_CTX *ctx));
175 \& void EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD *pmeth,
176 \&                                 int (*paramgen_init) (EVP_PKEY_CTX *ctx),
177 \&                                 int (*paramgen) (EVP_PKEY_CTX *ctx,
178 \&                                                  EVP_PKEY *pkey));
179 \& void EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD *pmeth,
180 \&                               int (*keygen_init) (EVP_PKEY_CTX *ctx),
181 \&                               int (*keygen) (EVP_PKEY_CTX *ctx,
182 \&                                              EVP_PKEY *pkey));
183 \& void EVP_PKEY_meth_set_sign(EVP_PKEY_METHOD *pmeth,
184 \&                             int (*sign_init) (EVP_PKEY_CTX *ctx),
185 \&                             int (*sign) (EVP_PKEY_CTX *ctx,
186 \&                                          unsigned char *sig, size_t *siglen,
187 \&                                          const unsigned char *tbs,
188 \&                                          size_t tbslen));
189 \& void EVP_PKEY_meth_set_verify(EVP_PKEY_METHOD *pmeth,
190 \&                               int (*verify_init) (EVP_PKEY_CTX *ctx),
191 \&                               int (*verify) (EVP_PKEY_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_verify_recover(EVP_PKEY_METHOD *pmeth,
197 \&                                       int (*verify_recover_init) (EVP_PKEY_CTX
198 \&                                                                   *ctx),
199 \&                                       int (*verify_recover) (EVP_PKEY_CTX
200 \&                                                              *ctx,
201 \&                                                              unsigned char
202 \&                                                              *sig,
203 \&                                                              size_t *siglen,
204 \&                                                              const unsigned
205 \&                                                              char *tbs,
206 \&                                                              size_t tbslen));
207 \& void EVP_PKEY_meth_set_signctx(EVP_PKEY_METHOD *pmeth,
208 \&                                int (*signctx_init) (EVP_PKEY_CTX *ctx,
209 \&                                                     EVP_MD_CTX *mctx),
210 \&                                int (*signctx) (EVP_PKEY_CTX *ctx,
211 \&                                                unsigned char *sig,
212 \&                                                size_t *siglen,
213 \&                                                EVP_MD_CTX *mctx));
214 \& void EVP_PKEY_meth_set_verifyctx(EVP_PKEY_METHOD *pmeth,
215 \&                                  int (*verifyctx_init) (EVP_PKEY_CTX *ctx,
216 \&                                                         EVP_MD_CTX *mctx),
217 \&                                  int (*verifyctx) (EVP_PKEY_CTX *ctx,
218 \&                                                    const unsigned char *sig,
219 \&                                                    int siglen,
220 \&                                                    EVP_MD_CTX *mctx));
221 \& void EVP_PKEY_meth_set_encrypt(EVP_PKEY_METHOD *pmeth,
222 \&                                int (*encrypt_init) (EVP_PKEY_CTX *ctx),
223 \&                                int (*encryptfn) (EVP_PKEY_CTX *ctx,
224 \&                                                  unsigned char *out,
225 \&                                                  size_t *outlen,
226 \&                                                  const unsigned char *in,
227 \&                                                  size_t inlen));
228 \& void EVP_PKEY_meth_set_decrypt(EVP_PKEY_METHOD *pmeth,
229 \&                                int (*decrypt_init) (EVP_PKEY_CTX *ctx),
230 \&                                int (*decrypt) (EVP_PKEY_CTX *ctx,
231 \&                                                unsigned char *out,
232 \&                                                size_t *outlen,
233 \&                                                const unsigned char *in,
234 \&                                                size_t inlen));
235 \& void EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD *pmeth,
236 \&                               int (*derive_init) (EVP_PKEY_CTX *ctx),
237 \&                               int (*derive) (EVP_PKEY_CTX *ctx,
238 \&                                              unsigned char *key,
239 \&                                              size_t *keylen));
240 \& void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth,
241 \&                             int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1,
242 \&                                          void *p2),
243 \&                             int (*ctrl_str) (EVP_PKEY_CTX *ctx,
244 \&                                              const char *type,
245 \&                                              const char *value));
246 \&
247 \& void EVP_PKEY_meth_get_init(EVP_PKEY_METHOD *pmeth,
248 \&                             int (**pinit) (EVP_PKEY_CTX *ctx));
249 \& void EVP_PKEY_meth_get_copy(EVP_PKEY_METHOD *pmeth,
250 \&                             int (**pcopy) (EVP_PKEY_CTX *dst,
251 \&                                            EVP_PKEY_CTX *src));
252 \& void EVP_PKEY_meth_get_cleanup(EVP_PKEY_METHOD *pmeth,
253 \&                                void (**pcleanup) (EVP_PKEY_CTX *ctx));
254 \& void EVP_PKEY_meth_get_paramgen(EVP_PKEY_METHOD *pmeth,
255 \&                                 int (**pparamgen_init) (EVP_PKEY_CTX *ctx),
256 \&                                 int (**pparamgen) (EVP_PKEY_CTX *ctx,
257 \&                                                    EVP_PKEY *pkey));
258 \& void EVP_PKEY_meth_get_keygen(EVP_PKEY_METHOD *pmeth,
259 \&                               int (**pkeygen_init) (EVP_PKEY_CTX *ctx),
260 \&                               int (**pkeygen) (EVP_PKEY_CTX *ctx,
261 \&                                                EVP_PKEY *pkey));
262 \& void EVP_PKEY_meth_get_sign(EVP_PKEY_METHOD *pmeth,
263 \&                             int (**psign_init) (EVP_PKEY_CTX *ctx),
264 \&                             int (**psign) (EVP_PKEY_CTX *ctx,
265 \&                                            unsigned char *sig, size_t *siglen,
266 \&                                            const unsigned char *tbs,
267 \&                                            size_t tbslen));
268 \& void EVP_PKEY_meth_get_verify(EVP_PKEY_METHOD *pmeth,
269 \&                               int (**pverify_init) (EVP_PKEY_CTX *ctx),
270 \&                               int (**pverify) (EVP_PKEY_CTX *ctx,
271 \&                                                const unsigned char *sig,
272 \&                                                size_t siglen,
273 \&                                                const unsigned char *tbs,
274 \&                                                size_t tbslen));
275 \& void EVP_PKEY_meth_get_verify_recover(EVP_PKEY_METHOD *pmeth,
276 \&                                       int (**pverify_recover_init) (EVP_PKEY_CTX
277 \&                                                                     *ctx),
278 \&                                       int (**pverify_recover) (EVP_PKEY_CTX
279 \&                                                                *ctx,
280 \&                                                                unsigned char
281 \&                                                                *sig,
282 \&                                                                size_t *siglen,
283 \&                                                                const unsigned
284 \&                                                                char *tbs,
285 \&                                                                size_t tbslen));
286 \& void EVP_PKEY_meth_get_signctx(EVP_PKEY_METHOD *pmeth,
287 \&                                int (**psignctx_init) (EVP_PKEY_CTX *ctx,
288 \&                                                       EVP_MD_CTX *mctx),
289 \&                                int (**psignctx) (EVP_PKEY_CTX *ctx,
290 \&                                                  unsigned char *sig,
291 \&                                                  size_t *siglen,
292 \&                                                  EVP_MD_CTX *mctx));
293 \& void EVP_PKEY_meth_get_verifyctx(EVP_PKEY_METHOD *pmeth,
294 \&                                  int (**pverifyctx_init) (EVP_PKEY_CTX *ctx,
295 \&                                                           EVP_MD_CTX *mctx),
296 \&                                  int (**pverifyctx) (EVP_PKEY_CTX *ctx,
297 \&                                                      const unsigned char *sig,
298 \&                                                      int siglen,
299 \&                                                      EVP_MD_CTX *mctx));
300 \& void EVP_PKEY_meth_get_encrypt(EVP_PKEY_METHOD *pmeth,
301 \&                                int (**pencrypt_init) (EVP_PKEY_CTX *ctx),
302 \&                                int (**pencryptfn) (EVP_PKEY_CTX *ctx,
303 \&                                                    unsigned char *out,
304 \&                                                    size_t *outlen,
305 \&                                                    const unsigned char *in,
306 \&                                                    size_t inlen));
307 \& void EVP_PKEY_meth_get_decrypt(EVP_PKEY_METHOD *pmeth,
308 \&                                int (**pdecrypt_init) (EVP_PKEY_CTX *ctx),
309 \&                                int (**pdecrypt) (EVP_PKEY_CTX *ctx,
310 \&                                                  unsigned char *out,
311 \&                                                  size_t *outlen,
312 \&                                                  const unsigned char *in,
313 \&                                                  size_t inlen));
314 \& void EVP_PKEY_meth_get_derive(EVP_PKEY_METHOD *pmeth,
315 \&                               int (**pderive_init) (EVP_PKEY_CTX *ctx),
316 \&                               int (**pderive) (EVP_PKEY_CTX *ctx,
317 \&                                                unsigned char *key,
318 \&                                                size_t *keylen));
319 \& void EVP_PKEY_meth_get_ctrl(EVP_PKEY_METHOD *pmeth,
320 \&                             int (**pctrl) (EVP_PKEY_CTX *ctx, int type, int p1,
321 \&                                            void *p2),
322 \&                             int (**pctrl_str) (EVP_PKEY_CTX *ctx,
323 \&                                                const char *type,
324 \&                                                const char *value));
325 .Ve
326 .SH "DESCRIPTION"
327 .IX Header "DESCRIPTION"
328 \&\fB\s-1EVP_PKEY_METHOD\s0\fR is a structure which holds a set of methods for a
329 specific public key cryptographic algorithm. Those methods are usually
330 used to perform different jobs, such as generating a key, signing or
331 verifying, encrypting or decrypting, etc.
332 .PP
333 There are two places where the \fB\s-1EVP_PKEY_METHOD\s0\fR objects are stored: one
334 is a built-in static array representing the standard methods for different
335 algorithms, and the other one is a stack of user-defined application-specific
336 methods, which can be manipulated by using \fBEVP_PKEY_meth_add0\fR\|(3).
337 .PP
338 The \fB\s-1EVP_PKEY_METHOD\s0\fR objects are usually referenced by \fB\s-1EVP_PKEY_CTX\s0\fR
339 objects.
340 .SS "Methods"
341 .IX Subsection "Methods"
342 The methods are the underlying implementations of a particular public key
343 algorithm present by the \fB\s-1EVP_PKEY_CTX\s0\fR object.
344 .PP
345 .Vb 3
346 \& int (*init) (EVP_PKEY_CTX *ctx);
347 \& int (*copy) (EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src);
348 \& void (*cleanup) (EVP_PKEY_CTX *ctx);
349 .Ve
350 .PP
351 The \fBinit()\fR method is called to initialize algorithm-specific data when a new
352 \&\fB\s-1EVP_PKEY_CTX\s0\fR is created. As opposed to \fBinit()\fR, the \fBcleanup()\fR method is called
353 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
354 is being duplicated. Refer to \fBEVP_PKEY_CTX_new\fR\|(3), \fBEVP_PKEY_CTX_new_id\fR\|(3),
355 \&\fBEVP_PKEY_CTX_free\fR\|(3) and \fBEVP_PKEY_CTX_dup\fR\|(3).
356 .PP
357 .Vb 2
358 \& int (*paramgen_init) (EVP_PKEY_CTX *ctx);
359 \& int (*paramgen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
360 .Ve
361 .PP
362 The \fBparamgen_init()\fR and \fBparamgen()\fR methods deal with key parameter generation.
363 They are called by \fBEVP_PKEY_paramgen_init\fR\|(3) and \fBEVP_PKEY_paramgen\fR\|(3) to
364 handle the parameter generation process.
365 .PP
366 .Vb 2
367 \& int (*keygen_init) (EVP_PKEY_CTX *ctx);
368 \& int (*keygen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
369 .Ve
370 .PP
371 The \fBkeygen_init()\fR and \fBkeygen()\fR methods are used to generate the actual key for
372 the specified algorithm. They are called by \fBEVP_PKEY_keygen_init\fR\|(3) and
373 \&\fBEVP_PKEY_keygen\fR\|(3).
374 .PP
375 .Vb 3
376 \& int (*sign_init) (EVP_PKEY_CTX *ctx);
377 \& int (*sign) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
378 \&              const unsigned char *tbs, size_t tbslen);
379 .Ve
380 .PP
381 The \fBsign_init()\fR and \fBsign()\fR methods are used to generate the signature of a
382 piece of data using a private key. They are called by \fBEVP_PKEY_sign_init\fR\|(3)
383 and \fBEVP_PKEY_sign\fR\|(3).
384 .PP
385 .Vb 4
386 \& int (*verify_init) (EVP_PKEY_CTX *ctx);
387 \& int (*verify) (EVP_PKEY_CTX *ctx,
388 \&                const unsigned char *sig, size_t siglen,
389 \&                const unsigned char *tbs, size_t tbslen);
390 .Ve
391 .PP
392 The \fBverify_init()\fR and \fBverify()\fR methods are used to verify whether a signature is
393 valid. They are called by \fBEVP_PKEY_verify_init\fR\|(3) and \fBEVP_PKEY_verify\fR\|(3).
394 .PP
395 .Vb 4
396 \& int (*verify_recover_init) (EVP_PKEY_CTX *ctx);
397 \& int (*verify_recover) (EVP_PKEY_CTX *ctx,
398 \&                        unsigned char *rout, size_t *routlen,
399 \&                        const unsigned char *sig, size_t siglen);
400 .Ve
401 .PP
402 The \fBverify_recover_init()\fR and \fBverify_recover()\fR methods are used to verify a
403 signature and then recover the digest from the signature (for instance, a
404 signature that was generated by \s-1RSA\s0 signing algorithm). They are called by
405 \&\fBEVP_PKEY_verify_recover_init\fR\|(3) and \fBEVP_PKEY_verify_recover\fR\|(3).
406 .PP
407 .Vb 3
408 \& int (*signctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
409 \& int (*signctx) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
410 \&                 EVP_MD_CTX *mctx);
411 .Ve
412 .PP
413 The \fBsignctx_init()\fR and \fBsignctx()\fR methods are used to sign a digest present by
414 a \fB\s-1EVP_MD_CTX\s0\fR object. They are called by the EVP_DigestSign functions. See
415 \&\fBEVP_DigestSignInit\fR\|(3) for detail.
416 .PP
417 .Vb 3
418 \& int (*verifyctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
419 \& int (*verifyctx) (EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen,
420 \&                   EVP_MD_CTX *mctx);
421 .Ve
422 .PP
423 The \fBverifyctx_init()\fR and \fBverifyctx()\fR methods are used to verify a signature
424 against the data in a \fB\s-1EVP_MD_CTX\s0\fR object. They are called by the various
425 EVP_DigestVerify functions. See \fBEVP_DigestVerifyInit\fR\|(3) for detail.
426 .PP
427 .Vb 3
428 \& int (*encrypt_init) (EVP_PKEY_CTX *ctx);
429 \& int (*encrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
430 \&                 const unsigned char *in, size_t inlen);
431 .Ve
432 .PP
433 The \fBencrypt_init()\fR and \fBencrypt()\fR methods are used to encrypt a piece of data.
434 They are called by \fBEVP_PKEY_encrypt_init\fR\|(3) and \fBEVP_PKEY_encrypt\fR\|(3).
435 .PP
436 .Vb 3
437 \& int (*decrypt_init) (EVP_PKEY_CTX *ctx);
438 \& int (*decrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
439 \&                 const unsigned char *in, size_t inlen);
440 .Ve
441 .PP
442 The \fBdecrypt_init()\fR and \fBdecrypt()\fR methods are used to decrypt a piece of data.
443 They are called by \fBEVP_PKEY_decrypt_init\fR\|(3) and \fBEVP_PKEY_decrypt\fR\|(3).
444 .PP
445 .Vb 2
446 \& int (*derive_init) (EVP_PKEY_CTX *ctx);
447 \& int (*derive) (EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);
448 .Ve
449 .PP
450 The \fBderive_init()\fR and \fBderive()\fR methods are used to derive the shared secret
451 from a public key algorithm (for instance, the \s-1DH\s0 algorithm). They are called by
452 \&\fBEVP_PKEY_derive_init\fR\|(3) and \fBEVP_PKEY_derive\fR\|(3).
453 .PP
454 .Vb 2
455 \& int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1, void *p2);
456 \& int (*ctrl_str) (EVP_PKEY_CTX *ctx, const char *type, const char *value);
457 .Ve
458 .PP
459 The \fBctrl()\fR and \fBctrl_str()\fR methods are used to adjust algorithm-specific
460 settings. See \fBEVP_PKEY_CTX_ctrl\fR\|(3) and related functions for detail.
461 .PP
462 .Vb 5
463 \& int (*digestsign) (EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen,
464 \&                    const unsigned char *tbs, size_t tbslen);
465 \& int (*digestverify) (EVP_MD_CTX *ctx, const unsigned char *sig,
466 \&                      size_t siglen, const unsigned char *tbs,
467 \&                      size_t tbslen);
468 .Ve
469 .PP
470 The \fBdigestsign()\fR and \fBdigestverify()\fR methods are used to generate or verify
471 a signature in a one-shot mode. They could be called by \fBEVP_DigetSign\fR\|(3)
472 and \fBEVP_DigestVerify\fR\|(3).
473 .SS "Functions"
474 .IX Subsection "Functions"
475 \&\fBEVP_PKEY_meth_new()\fR creates and returns a new \fB\s-1EVP_PKEY_METHOD\s0\fR object,
476 and associates the given \fBid\fR and \fBflags\fR. The following flags are
477 supported:
478 .PP
479 .Vb 2
480 \& EVP_PKEY_FLAG_AUTOARGLEN
481 \& EVP_PKEY_FLAG_SIGCTX_CUSTOM
482 .Ve
483 .PP
484 If an \fB\s-1EVP_PKEY_METHOD\s0\fR is set with the \fB\s-1EVP_PKEY_FLAG_AUTOARGLEN\s0\fR flag, the
485 maximum size of the output buffer will be automatically calculated or checked
486 in corresponding \s-1EVP\s0 methods by the \s-1EVP\s0 framework. Thus the implementations of
487 these methods don't need to care about handling the case of returning output
488 buffer size by themselves. For details on the output buffer size, refer to
489 \&\fBEVP_PKEY_sign\fR\|(3).
490 .PP
491 The \fB\s-1EVP_PKEY_FLAG_SIGCTX_CUSTOM\s0\fR is used to indicate the \fBsignctx()\fR method
492 of an \fB\s-1EVP_PKEY_METHOD\s0\fR is always called by the \s-1EVP\s0 framework while doing a
493 digest signing operation by calling \fBEVP_DigestSignFinal\fR\|(3).
494 .PP
495 \&\fBEVP_PKEY_meth_free()\fR frees an existing \fB\s-1EVP_PKEY_METHOD\s0\fR pointed by
496 \&\fBpmeth\fR.
497 .PP
498 \&\fBEVP_PKEY_meth_copy()\fR copies an \fB\s-1EVP_PKEY_METHOD\s0\fR object from \fBsrc\fR
499 to \fBdst\fR.
500 .PP
501 \&\fBEVP_PKEY_meth_find()\fR finds an \fB\s-1EVP_PKEY_METHOD\s0\fR object with the \fBid\fR.
502 This function first searches through the user-defined method objects and
503 then the built-in objects.
504 .PP
505 \&\fBEVP_PKEY_meth_add0()\fR adds \fBpmeth\fR to the user defined stack of methods.
506 .PP
507 The EVP_PKEY_meth_set functions set the corresponding fields of
508 \&\fB\s-1EVP_PKEY_METHOD\s0\fR structure with the arguments passed.
509 .PP
510 The EVP_PKEY_meth_get functions get the corresponding fields of
511 \&\fB\s-1EVP_PKEY_METHOD\s0\fR structure to the arguments provided.
512 .SH "RETURN VALUES"
513 .IX Header "RETURN VALUES"
514 \&\fBEVP_PKEY_meth_new()\fR returns a pointer to a new \fB\s-1EVP_PKEY_METHOD\s0\fR
515 object or returns \s-1NULL\s0 on error.
516 .PP
517 \&\fBEVP_PKEY_meth_free()\fR and \fBEVP_PKEY_meth_copy()\fR do not return values.
518 .PP
519 \&\fBEVP_PKEY_meth_find()\fR returns a pointer to the found \fB\s-1EVP_PKEY_METHOD\s0\fR
520 object or returns \s-1NULL\s0 if not found.
521 .PP
522 \&\fBEVP_PKEY_meth_add0()\fR returns 1 if method is added successfully or 0
523 if an error occurred.
524 .PP
525 All EVP_PKEY_meth_set and EVP_PKEY_meth_get functions have no return
526 values. For the 'get' functions, function pointers are returned by
527 arguments.
528 .SH "COPYRIGHT"
529 .IX Header "COPYRIGHT"
530 Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
531 .PP
532 Licensed under the OpenSSL license (the \*(L"License\*(R").  You may not use
533 this file except in compliance with the License.  You can obtain a copy
534 in the file \s-1LICENSE\s0 in the source distribution or at
535 <https://www.openssl.org/source/license.html>.