]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - secure/lib/libcrypto/man/EVP_PKEY_meth_new.3
MFV r339226 (peter): Record merge of serf-1.3.9.
[FreeBSD/FreeBSD.git] / secure / lib / libcrypto / man / EVP_PKEY_meth_new.3
1 .\" Automatically generated by Pod::Man 4.09 (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 .if !\nF .nr F 0
58 .if \nF>0 \{\
59 .    de IX
60 .    tm Index:\\$1\t\\n%\t"\\$2"
61 ..
62 .    if !\nF==2 \{\
63 .        nr % 0
64 .        nr F 2
65 .    \}
66 .\}
67 .\"
68 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
70 .    \" fudge factors for nroff and troff
71 .if n \{\
72 .    ds #H 0
73 .    ds #V .8m
74 .    ds #F .3m
75 .    ds #[ \f1
76 .    ds #] \fP
77 .\}
78 .if t \{\
79 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80 .    ds #V .6m
81 .    ds #F 0
82 .    ds #[ \&
83 .    ds #] \&
84 .\}
85 .    \" simple accents for nroff and troff
86 .if n \{\
87 .    ds ' \&
88 .    ds ` \&
89 .    ds ^ \&
90 .    ds , \&
91 .    ds ~ ~
92 .    ds /
93 .\}
94 .if t \{\
95 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101 .\}
102 .    \" troff and (daisy-wheel) nroff accents
103 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110 .ds ae a\h'-(\w'a'u*4/10)'e
111 .ds Ae A\h'-(\w'A'u*4/10)'E
112 .    \" corrections for vroff
113 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115 .    \" for low resolution devices (crt and lpr)
116 .if \n(.H>23 .if \n(.V>19 \
117 \{\
118 .    ds : e
119 .    ds 8 ss
120 .    ds o a
121 .    ds d- d\h'-1'\(ga
122 .    ds D- D\h'-1'\(hy
123 .    ds th \o'bp'
124 .    ds Th \o'LP'
125 .    ds ae ae
126 .    ds Ae AE
127 .\}
128 .rm #[ #] #H #V #F C
129 .\" ========================================================================
130 .\"
131 .IX Title "EVP_PKEY_METH_NEW 3"
132 .TH EVP_PKEY_METH_NEW 3 "2018-09-11" "1.1.1" "OpenSSL"
133 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
134 .\" way too many mistakes in technical documents.
135 .if n .ad l
136 .nh
137 .SH "NAME"
138 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_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_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
139 .SH "SYNOPSIS"
140 .IX Header "SYNOPSIS"
141 .Vb 1
142 \& #include <openssl/evp.h>
143 \&
144 \& typedef struct evp_pkey_method_st EVP_PKEY_METHOD;
145 \&
146 \& EVP_PKEY_METHOD *EVP_PKEY_meth_new(int id, int flags);
147 \& void EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth);
148 \& void EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, const EVP_PKEY_METHOD *src);
149 \& const EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type);
150 \& int EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth);
151 \& int EVP_PKEY_meth_remove(const EVP_PKEY_METHOD *pmeth);
152 \&
153 \& void EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth,
154 \&                             int (*init) (EVP_PKEY_CTX *ctx));
155 \& void EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD *pmeth,
156 \&                             int (*copy) (EVP_PKEY_CTX *dst,
157 \&                                          EVP_PKEY_CTX *src));
158 \& void EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD *pmeth,
159 \&                                void (*cleanup) (EVP_PKEY_CTX *ctx));
160 \& void EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD *pmeth,
161 \&                                 int (*paramgen_init) (EVP_PKEY_CTX *ctx),
162 \&                                 int (*paramgen) (EVP_PKEY_CTX *ctx,
163 \&                                                  EVP_PKEY *pkey));
164 \& void EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD *pmeth,
165 \&                               int (*keygen_init) (EVP_PKEY_CTX *ctx),
166 \&                               int (*keygen) (EVP_PKEY_CTX *ctx,
167 \&                                              EVP_PKEY *pkey));
168 \& void EVP_PKEY_meth_set_sign(EVP_PKEY_METHOD *pmeth,
169 \&                             int (*sign_init) (EVP_PKEY_CTX *ctx),
170 \&                             int (*sign) (EVP_PKEY_CTX *ctx,
171 \&                                          unsigned char *sig, size_t *siglen,
172 \&                                          const unsigned char *tbs,
173 \&                                          size_t tbslen));
174 \& void EVP_PKEY_meth_set_verify(EVP_PKEY_METHOD *pmeth,
175 \&                               int (*verify_init) (EVP_PKEY_CTX *ctx),
176 \&                               int (*verify) (EVP_PKEY_CTX *ctx,
177 \&                                              const unsigned char *sig,
178 \&                                              size_t siglen,
179 \&                                              const unsigned char *tbs,
180 \&                                              size_t tbslen));
181 \& void EVP_PKEY_meth_set_verify_recover(EVP_PKEY_METHOD *pmeth,
182 \&                                       int (*verify_recover_init) (EVP_PKEY_CTX
183 \&                                                                   *ctx),
184 \&                                       int (*verify_recover) (EVP_PKEY_CTX
185 \&                                                              *ctx,
186 \&                                                              unsigned char
187 \&                                                              *sig,
188 \&                                                              size_t *siglen,
189 \&                                                              const unsigned
190 \&                                                              char *tbs,
191 \&                                                              size_t tbslen));
192 \& void EVP_PKEY_meth_set_signctx(EVP_PKEY_METHOD *pmeth,
193 \&                                int (*signctx_init) (EVP_PKEY_CTX *ctx,
194 \&                                                     EVP_MD_CTX *mctx),
195 \&                                int (*signctx) (EVP_PKEY_CTX *ctx,
196 \&                                                unsigned char *sig,
197 \&                                                size_t *siglen,
198 \&                                                EVP_MD_CTX *mctx));
199 \& void EVP_PKEY_meth_set_verifyctx(EVP_PKEY_METHOD *pmeth,
200 \&                                  int (*verifyctx_init) (EVP_PKEY_CTX *ctx,
201 \&                                                         EVP_MD_CTX *mctx),
202 \&                                  int (*verifyctx) (EVP_PKEY_CTX *ctx,
203 \&                                                    const unsigned char *sig,
204 \&                                                    int siglen,
205 \&                                                    EVP_MD_CTX *mctx));
206 \& void EVP_PKEY_meth_set_encrypt(EVP_PKEY_METHOD *pmeth,
207 \&                                int (*encrypt_init) (EVP_PKEY_CTX *ctx),
208 \&                                int (*encryptfn) (EVP_PKEY_CTX *ctx,
209 \&                                                  unsigned char *out,
210 \&                                                  size_t *outlen,
211 \&                                                  const unsigned char *in,
212 \&                                                  size_t inlen));
213 \& void EVP_PKEY_meth_set_decrypt(EVP_PKEY_METHOD *pmeth,
214 \&                                int (*decrypt_init) (EVP_PKEY_CTX *ctx),
215 \&                                int (*decrypt) (EVP_PKEY_CTX *ctx,
216 \&                                                unsigned char *out,
217 \&                                                size_t *outlen,
218 \&                                                const unsigned char *in,
219 \&                                                size_t inlen));
220 \& void EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD *pmeth,
221 \&                               int (*derive_init) (EVP_PKEY_CTX *ctx),
222 \&                               int (*derive) (EVP_PKEY_CTX *ctx,
223 \&                                              unsigned char *key,
224 \&                                              size_t *keylen));
225 \& void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth,
226 \&                             int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1,
227 \&                                          void *p2),
228 \&                             int (*ctrl_str) (EVP_PKEY_CTX *ctx,
229 \&                                              const char *type,
230 \&                                              const char *value));
231 \& void EVP_PKEY_meth_set_check(EVP_PKEY_METHOD *pmeth,
232 \&                              int (*check) (EVP_PKEY *pkey));
233 \& void EVP_PKEY_meth_set_public_check(EVP_PKEY_METHOD *pmeth,
234 \&                                     int (*check) (EVP_PKEY *pkey));
235 \& void EVP_PKEY_meth_set_param_check(EVP_PKEY_METHOD *pmeth,
236 \&                                    int (*check) (EVP_PKEY *pkey));
237 \& void EVP_PKEY_meth_set_digest_custom(EVP_PKEY_METHOD *pmeth,
238 \&                                     int (*digest_custom) (EVP_PKEY_CTX *ctx,
239 \&                                                           EVP_MD_CTX *mctx));
240 \&
241 \& void EVP_PKEY_meth_get_init(const EVP_PKEY_METHOD *pmeth,
242 \&                             int (**pinit) (EVP_PKEY_CTX *ctx));
243 \& void EVP_PKEY_meth_get_copy(const EVP_PKEY_METHOD *pmeth,
244 \&                             int (**pcopy) (EVP_PKEY_CTX *dst,
245 \&                                            EVP_PKEY_CTX *src));
246 \& void EVP_PKEY_meth_get_cleanup(const EVP_PKEY_METHOD *pmeth,
247 \&                                void (**pcleanup) (EVP_PKEY_CTX *ctx));
248 \& void EVP_PKEY_meth_get_paramgen(const EVP_PKEY_METHOD *pmeth,
249 \&                                 int (**pparamgen_init) (EVP_PKEY_CTX *ctx),
250 \&                                 int (**pparamgen) (EVP_PKEY_CTX *ctx,
251 \&                                                    EVP_PKEY *pkey));
252 \& void EVP_PKEY_meth_get_keygen(const EVP_PKEY_METHOD *pmeth,
253 \&                               int (**pkeygen_init) (EVP_PKEY_CTX *ctx),
254 \&                               int (**pkeygen) (EVP_PKEY_CTX *ctx,
255 \&                                                EVP_PKEY *pkey));
256 \& void EVP_PKEY_meth_get_sign(const EVP_PKEY_METHOD *pmeth,
257 \&                             int (**psign_init) (EVP_PKEY_CTX *ctx),
258 \&                             int (**psign) (EVP_PKEY_CTX *ctx,
259 \&                                            unsigned char *sig, size_t *siglen,
260 \&                                            const unsigned char *tbs,
261 \&                                            size_t tbslen));
262 \& void EVP_PKEY_meth_get_verify(const EVP_PKEY_METHOD *pmeth,
263 \&                               int (**pverify_init) (EVP_PKEY_CTX *ctx),
264 \&                               int (**pverify) (EVP_PKEY_CTX *ctx,
265 \&                                                const unsigned char *sig,
266 \&                                                size_t siglen,
267 \&                                                const unsigned char *tbs,
268 \&                                                size_t tbslen));
269 \& void EVP_PKEY_meth_get_verify_recover(const EVP_PKEY_METHOD *pmeth,
270 \&                                       int (**pverify_recover_init) (EVP_PKEY_CTX
271 \&                                                                     *ctx),
272 \&                                       int (**pverify_recover) (EVP_PKEY_CTX
273 \&                                                                *ctx,
274 \&                                                                unsigned char
275 \&                                                                *sig,
276 \&                                                                size_t *siglen,
277 \&                                                                const unsigned
278 \&                                                                char *tbs,
279 \&                                                                size_t tbslen));
280 \& void EVP_PKEY_meth_get_signctx(const EVP_PKEY_METHOD *pmeth,
281 \&                                int (**psignctx_init) (EVP_PKEY_CTX *ctx,
282 \&                                                       EVP_MD_CTX *mctx),
283 \&                                int (**psignctx) (EVP_PKEY_CTX *ctx,
284 \&                                                  unsigned char *sig,
285 \&                                                  size_t *siglen,
286 \&                                                  EVP_MD_CTX *mctx));
287 \& void EVP_PKEY_meth_get_verifyctx(const EVP_PKEY_METHOD *pmeth,
288 \&                                  int (**pverifyctx_init) (EVP_PKEY_CTX *ctx,
289 \&                                                           EVP_MD_CTX *mctx),
290 \&                                  int (**pverifyctx) (EVP_PKEY_CTX *ctx,
291 \&                                                      const unsigned char *sig,
292 \&                                                      int siglen,
293 \&                                                      EVP_MD_CTX *mctx));
294 \& void EVP_PKEY_meth_get_encrypt(const EVP_PKEY_METHOD *pmeth,
295 \&                                int (**pencrypt_init) (EVP_PKEY_CTX *ctx),
296 \&                                int (**pencryptfn) (EVP_PKEY_CTX *ctx,
297 \&                                                    unsigned char *out,
298 \&                                                    size_t *outlen,
299 \&                                                    const unsigned char *in,
300 \&                                                    size_t inlen));
301 \& void EVP_PKEY_meth_get_decrypt(const EVP_PKEY_METHOD *pmeth,
302 \&                                int (**pdecrypt_init) (EVP_PKEY_CTX *ctx),
303 \&                                int (**pdecrypt) (EVP_PKEY_CTX *ctx,
304 \&                                                  unsigned char *out,
305 \&                                                  size_t *outlen,
306 \&                                                  const unsigned char *in,
307 \&                                                  size_t inlen));
308 \& void EVP_PKEY_meth_get_derive(const EVP_PKEY_METHOD *pmeth,
309 \&                               int (**pderive_init) (EVP_PKEY_CTX *ctx),
310 \&                               int (**pderive) (EVP_PKEY_CTX *ctx,
311 \&                                                unsigned char *key,
312 \&                                                size_t *keylen));
313 \& void EVP_PKEY_meth_get_ctrl(const EVP_PKEY_METHOD *pmeth,
314 \&                             int (**pctrl) (EVP_PKEY_CTX *ctx, int type, int p1,
315 \&                                            void *p2),
316 \&                             int (**pctrl_str) (EVP_PKEY_CTX *ctx,
317 \&                                                const char *type,
318 \&                                                const char *value));
319 \& void EVP_PKEY_meth_get_check(const EVP_PKEY_METHOD *pmeth,
320 \&                              int (**pcheck) (EVP_PKEY *pkey));
321 \& void EVP_PKEY_meth_get_public_check(const EVP_PKEY_METHOD *pmeth,
322 \&                                     int (**pcheck) (EVP_PKEY *pkey));
323 \& void EVP_PKEY_meth_get_param_check(const EVP_PKEY_METHOD *pmeth,
324 \&                                    int (**pcheck) (EVP_PKEY *pkey));
325 \& void EVP_PKEY_meth_get_digest_custom(EVP_PKEY_METHOD *pmeth,
326 \&                                     int (**pdigest_custom) (EVP_PKEY_CTX *ctx,
327 \&                                                             EVP_MD_CTX *mctx));
328 .Ve
329 .SH "DESCRIPTION"
330 .IX Header "DESCRIPTION"
331 \&\fB\s-1EVP_PKEY_METHOD\s0\fR is a structure which holds a set of methods for a
332 specific public key cryptographic algorithm. Those methods are usually
333 used to perform different jobs, such as generating a key, signing or
334 verifying, encrypting or decrypting, etc.
335 .PP
336 There are two places where the \fB\s-1EVP_PKEY_METHOD\s0\fR objects are stored: one
337 is a built-in static array representing the standard methods for different
338 algorithms, and the other one is a stack of user-defined application-specific
339 methods, which can be manipulated by using \fIEVP_PKEY_meth_add0\fR\|(3).
340 .PP
341 The \fB\s-1EVP_PKEY_METHOD\s0\fR objects are usually referenced by \fB\s-1EVP_PKEY_CTX\s0\fR
342 objects.
343 .SS "Methods"
344 .IX Subsection "Methods"
345 The methods are the underlying implementations of a particular public key
346 algorithm present by the \fB\s-1EVP_PKEY_CTX\s0\fR object.
347 .PP
348 .Vb 3
349 \& int (*init) (EVP_PKEY_CTX *ctx);
350 \& int (*copy) (EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src);
351 \& void (*cleanup) (EVP_PKEY_CTX *ctx);
352 .Ve
353 .PP
354 The \fIinit()\fR method is called to initialize algorithm-specific data when a new
355 \&\fB\s-1EVP_PKEY_CTX\s0\fR is created. As opposed to \fIinit()\fR, the \fIcleanup()\fR method is called
356 when an \fB\s-1EVP_PKEY_CTX\s0\fR is freed. The \fIcopy()\fR method is called when an \fB\s-1EVP_PKEY_CTX\s0\fR
357 is being duplicated. Refer to \fIEVP_PKEY_CTX_new\fR\|(3), \fIEVP_PKEY_CTX_new_id\fR\|(3),
358 \&\fIEVP_PKEY_CTX_free\fR\|(3) and \fIEVP_PKEY_CTX_dup\fR\|(3).
359 .PP
360 .Vb 2
361 \& int (*paramgen_init) (EVP_PKEY_CTX *ctx);
362 \& int (*paramgen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
363 .Ve
364 .PP
365 The \fIparamgen_init()\fR and \fIparamgen()\fR methods deal with key parameter generation.
366 They are called by \fIEVP_PKEY_paramgen_init\fR\|(3) and \fIEVP_PKEY_paramgen\fR\|(3) to
367 handle the parameter generation process.
368 .PP
369 .Vb 2
370 \& int (*keygen_init) (EVP_PKEY_CTX *ctx);
371 \& int (*keygen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
372 .Ve
373 .PP
374 The \fIkeygen_init()\fR and \fIkeygen()\fR methods are used to generate the actual key for
375 the specified algorithm. They are called by \fIEVP_PKEY_keygen_init\fR\|(3) and
376 \&\fIEVP_PKEY_keygen\fR\|(3).
377 .PP
378 .Vb 3
379 \& int (*sign_init) (EVP_PKEY_CTX *ctx);
380 \& int (*sign) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
381 \&              const unsigned char *tbs, size_t tbslen);
382 .Ve
383 .PP
384 The \fIsign_init()\fR and \fIsign()\fR methods are used to generate the signature of a
385 piece of data using a private key. They are called by \fIEVP_PKEY_sign_init\fR\|(3)
386 and \fIEVP_PKEY_sign\fR\|(3).
387 .PP
388 .Vb 4
389 \& int (*verify_init) (EVP_PKEY_CTX *ctx);
390 \& int (*verify) (EVP_PKEY_CTX *ctx,
391 \&                const unsigned char *sig, size_t siglen,
392 \&                const unsigned char *tbs, size_t tbslen);
393 .Ve
394 .PP
395 The \fIverify_init()\fR and \fIverify()\fR methods are used to verify whether a signature is
396 valid. They are called by \fIEVP_PKEY_verify_init\fR\|(3) and \fIEVP_PKEY_verify\fR\|(3).
397 .PP
398 .Vb 4
399 \& int (*verify_recover_init) (EVP_PKEY_CTX *ctx);
400 \& int (*verify_recover) (EVP_PKEY_CTX *ctx,
401 \&                        unsigned char *rout, size_t *routlen,
402 \&                        const unsigned char *sig, size_t siglen);
403 .Ve
404 .PP
405 The \fIverify_recover_init()\fR and \fIverify_recover()\fR methods are used to verify a
406 signature and then recover the digest from the signature (for instance, a
407 signature that was generated by \s-1RSA\s0 signing algorithm). They are called by
408 \&\fIEVP_PKEY_verify_recover_init\fR\|(3) and \fIEVP_PKEY_verify_recover\fR\|(3).
409 .PP
410 .Vb 3
411 \& int (*signctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
412 \& int (*signctx) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
413 \&                 EVP_MD_CTX *mctx);
414 .Ve
415 .PP
416 The \fIsignctx_init()\fR and \fIsignctx()\fR methods are used to sign a digest present by
417 a \fB\s-1EVP_MD_CTX\s0\fR object. They are called by the EVP_DigestSign functions. See
418 \&\fIEVP_DigestSignInit\fR\|(3) for detail.
419 .PP
420 .Vb 3
421 \& int (*verifyctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
422 \& int (*verifyctx) (EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen,
423 \&                   EVP_MD_CTX *mctx);
424 .Ve
425 .PP
426 The \fIverifyctx_init()\fR and \fIverifyctx()\fR methods are used to verify a signature
427 against the data in a \fB\s-1EVP_MD_CTX\s0\fR object. They are called by the various
428 EVP_DigestVerify functions. See \fIEVP_DigestVerifyInit\fR\|(3) for detail.
429 .PP
430 .Vb 3
431 \& int (*encrypt_init) (EVP_PKEY_CTX *ctx);
432 \& int (*encrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
433 \&                 const unsigned char *in, size_t inlen);
434 .Ve
435 .PP
436 The \fIencrypt_init()\fR and \fIencrypt()\fR methods are used to encrypt a piece of data.
437 They are called by \fIEVP_PKEY_encrypt_init\fR\|(3) and \fIEVP_PKEY_encrypt\fR\|(3).
438 .PP
439 .Vb 3
440 \& int (*decrypt_init) (EVP_PKEY_CTX *ctx);
441 \& int (*decrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
442 \&                 const unsigned char *in, size_t inlen);
443 .Ve
444 .PP
445 The \fIdecrypt_init()\fR and \fIdecrypt()\fR methods are used to decrypt a piece of data.
446 They are called by \fIEVP_PKEY_decrypt_init\fR\|(3) and \fIEVP_PKEY_decrypt\fR\|(3).
447 .PP
448 .Vb 2
449 \& int (*derive_init) (EVP_PKEY_CTX *ctx);
450 \& int (*derive) (EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);
451 .Ve
452 .PP
453 The \fIderive_init()\fR and \fIderive()\fR methods are used to derive the shared secret
454 from a public key algorithm (for instance, the \s-1DH\s0 algorithm). They are called by
455 \&\fIEVP_PKEY_derive_init\fR\|(3) and \fIEVP_PKEY_derive\fR\|(3).
456 .PP
457 .Vb 2
458 \& int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1, void *p2);
459 \& int (*ctrl_str) (EVP_PKEY_CTX *ctx, const char *type, const char *value);
460 .Ve
461 .PP
462 The \fIctrl()\fR and \fIctrl_str()\fR methods are used to adjust algorithm-specific
463 settings. See \fIEVP_PKEY_CTX_ctrl\fR\|(3) and related functions for detail.
464 .PP
465 .Vb 5
466 \& int (*digestsign) (EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen,
467 \&                    const unsigned char *tbs, size_t tbslen);
468 \& int (*digestverify) (EVP_MD_CTX *ctx, const unsigned char *sig,
469 \&                      size_t siglen, const unsigned char *tbs,
470 \&                      size_t tbslen);
471 .Ve
472 .PP
473 The \fIdigestsign()\fR and \fIdigestverify()\fR methods are used to generate or verify
474 a signature in a one-shot mode. They could be called by \fIEVP_DigetSign\fR\|(3)
475 and \fIEVP_DigestVerify\fR\|(3).
476 .PP
477 .Vb 3
478 \& int (*check) (EVP_PKEY *pkey);
479 \& int (*public_check) (EVP_PKEY *pkey);
480 \& int (*param_check) (EVP_PKEY *pkey);
481 .Ve
482 .PP
483 The \fIcheck()\fR, \fIpublic_check()\fR and \fIparam_check()\fR methods are used to validate a
484 key-pair, the public component and parameters respectively for a given \fBpkey\fR.
485 They could be called by \fIEVP_PKEY_check\fR\|(3), \fIEVP_PKEY_public_check\fR\|(3) and
486 \&\fIEVP_PKEY_param_check\fR\|(3) respectively.
487 .PP
488 .Vb 1
489 \& int (*digest_custom) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
490 .Ve
491 .PP
492 The \fIdigest_custom()\fR method is used to generate customized digest content before
493 the real message is passed to functions like \fIEVP_DigestSignUpdate\fR\|(3) or
494 \&\fIEVP_DigestVerifyInit\fR\|(3). This is usually required by some public key
495 signature algorithms like \s-1SM2\s0 which requires a hashed prefix to the message to
496 be signed. The \fIdigest_custom()\fR function will be called by \fIEVP_DigestSignInit\fR\|(3)
497 and \fIEVP_DigestVerifyInit\fR\|(3).
498 .SS "Functions"
499 .IX Subsection "Functions"
500 \&\fIEVP_PKEY_meth_new()\fR creates and returns a new \fB\s-1EVP_PKEY_METHOD\s0\fR object,
501 and associates the given \fBid\fR and \fBflags\fR. The following flags are
502 supported:
503 .PP
504 .Vb 2
505 \& EVP_PKEY_FLAG_AUTOARGLEN
506 \& EVP_PKEY_FLAG_SIGCTX_CUSTOM
507 .Ve
508 .PP
509 If an \fB\s-1EVP_PKEY_METHOD\s0\fR is set with the \fB\s-1EVP_PKEY_FLAG_AUTOARGLEN\s0\fR flag, the
510 maximum size of the output buffer will be automatically calculated or checked
511 in corresponding \s-1EVP\s0 methods by the \s-1EVP\s0 framework. Thus the implementations of
512 these methods don't need to care about handling the case of returning output
513 buffer size by themselves. For details on the output buffer size, refer to
514 \&\fIEVP_PKEY_sign\fR\|(3).
515 .PP
516 The \fB\s-1EVP_PKEY_FLAG_SIGCTX_CUSTOM\s0\fR is used to indicate the \fIsignctx()\fR method
517 of an \fB\s-1EVP_PKEY_METHOD\s0\fR is always called by the \s-1EVP\s0 framework while doing a
518 digest signing operation by calling \fIEVP_DigestSignFinal\fR\|(3).
519 .PP
520 \&\fIEVP_PKEY_meth_free()\fR frees an existing \fB\s-1EVP_PKEY_METHOD\s0\fR pointed by
521 \&\fBpmeth\fR.
522 .PP
523 \&\fIEVP_PKEY_meth_copy()\fR copies an \fB\s-1EVP_PKEY_METHOD\s0\fR object from \fBsrc\fR
524 to \fBdst\fR.
525 .PP
526 \&\fIEVP_PKEY_meth_find()\fR finds an \fB\s-1EVP_PKEY_METHOD\s0\fR object with the \fBid\fR.
527 This function first searches through the user-defined method objects and
528 then the built-in objects.
529 .PP
530 \&\fIEVP_PKEY_meth_add0()\fR adds \fBpmeth\fR to the user defined stack of methods.
531 .PP
532 \&\fIEVP_PKEY_meth_remove()\fR removes an \fB\s-1EVP_PKEY_METHOD\s0\fR object added by
533 \&\fIEVP_PKEY_meth_add0()\fR.
534 .PP
535 The EVP_PKEY_meth_set functions set the corresponding fields of
536 \&\fB\s-1EVP_PKEY_METHOD\s0\fR structure with the arguments passed.
537 .PP
538 The EVP_PKEY_meth_get functions get the corresponding fields of
539 \&\fB\s-1EVP_PKEY_METHOD\s0\fR structure to the arguments provided.
540 .SH "RETURN VALUES"
541 .IX Header "RETURN VALUES"
542 \&\fIEVP_PKEY_meth_new()\fR returns a pointer to a new \fB\s-1EVP_PKEY_METHOD\s0\fR
543 object or returns \s-1NULL\s0 on error.
544 .PP
545 \&\fIEVP_PKEY_meth_free()\fR and \fIEVP_PKEY_meth_copy()\fR do not return values.
546 .PP
547 \&\fIEVP_PKEY_meth_find()\fR returns a pointer to the found \fB\s-1EVP_PKEY_METHOD\s0\fR
548 object or returns \s-1NULL\s0 if not found.
549 .PP
550 \&\fIEVP_PKEY_meth_add0()\fR returns 1 if method is added successfully or 0
551 if an error occurred.
552 .PP
553 \&\fIEVP_PKEY_meth_remove()\fR returns 1 if method is removed successfully or
554 0 if an error occurred.
555 .PP
556 All EVP_PKEY_meth_set and EVP_PKEY_meth_get functions have no return
557 values. For the 'get' functions, function pointers are returned by
558 arguments.
559 .SH "COPYRIGHT"
560 .IX Header "COPYRIGHT"
561 Copyright 2017\-2018 The OpenSSL Project Authors. All Rights Reserved.
562 .PP
563 Licensed under the OpenSSL license (the \*(L"License\*(R").  You may not use
564 this file except in compliance with the License.  You can obtain a copy
565 in the file \s-1LICENSE\s0 in the source distribution or at
566 <https://www.openssl.org/source/license.html>.