]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - secure/lib/libcrypto/man/EVP_PKEY_meth_new.3
MFC: r352191
[FreeBSD/FreeBSD.git] / secure / lib / libcrypto / man / EVP_PKEY_meth_new.3
1 .\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.39)
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-09-10" "1.1.1d" "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_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
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_check(EVP_PKEY_METHOD *pmeth,
236 \&                              int (*check) (EVP_PKEY *pkey));
237 \& void EVP_PKEY_meth_set_public_check(EVP_PKEY_METHOD *pmeth,
238 \&                                     int (*check) (EVP_PKEY *pkey));
239 \& void EVP_PKEY_meth_set_param_check(EVP_PKEY_METHOD *pmeth,
240 \&                                    int (*check) (EVP_PKEY *pkey));
241 \& void EVP_PKEY_meth_set_digest_custom(EVP_PKEY_METHOD *pmeth,
242 \&                                     int (*digest_custom) (EVP_PKEY_CTX *ctx,
243 \&                                                           EVP_MD_CTX *mctx));
244 \&
245 \& void EVP_PKEY_meth_get_init(const EVP_PKEY_METHOD *pmeth,
246 \&                             int (**pinit) (EVP_PKEY_CTX *ctx));
247 \& void EVP_PKEY_meth_get_copy(const EVP_PKEY_METHOD *pmeth,
248 \&                             int (**pcopy) (EVP_PKEY_CTX *dst,
249 \&                                            EVP_PKEY_CTX *src));
250 \& void EVP_PKEY_meth_get_cleanup(const EVP_PKEY_METHOD *pmeth,
251 \&                                void (**pcleanup) (EVP_PKEY_CTX *ctx));
252 \& void EVP_PKEY_meth_get_paramgen(const EVP_PKEY_METHOD *pmeth,
253 \&                                 int (**pparamgen_init) (EVP_PKEY_CTX *ctx),
254 \&                                 int (**pparamgen) (EVP_PKEY_CTX *ctx,
255 \&                                                    EVP_PKEY *pkey));
256 \& void EVP_PKEY_meth_get_keygen(const EVP_PKEY_METHOD *pmeth,
257 \&                               int (**pkeygen_init) (EVP_PKEY_CTX *ctx),
258 \&                               int (**pkeygen) (EVP_PKEY_CTX *ctx,
259 \&                                                EVP_PKEY *pkey));
260 \& void EVP_PKEY_meth_get_sign(const EVP_PKEY_METHOD *pmeth,
261 \&                             int (**psign_init) (EVP_PKEY_CTX *ctx),
262 \&                             int (**psign) (EVP_PKEY_CTX *ctx,
263 \&                                            unsigned char *sig, size_t *siglen,
264 \&                                            const unsigned char *tbs,
265 \&                                            size_t tbslen));
266 \& void EVP_PKEY_meth_get_verify(const EVP_PKEY_METHOD *pmeth,
267 \&                               int (**pverify_init) (EVP_PKEY_CTX *ctx),
268 \&                               int (**pverify) (EVP_PKEY_CTX *ctx,
269 \&                                                const unsigned char *sig,
270 \&                                                size_t siglen,
271 \&                                                const unsigned char *tbs,
272 \&                                                size_t tbslen));
273 \& void EVP_PKEY_meth_get_verify_recover(const EVP_PKEY_METHOD *pmeth,
274 \&                                       int (**pverify_recover_init) (EVP_PKEY_CTX
275 \&                                                                     *ctx),
276 \&                                       int (**pverify_recover) (EVP_PKEY_CTX
277 \&                                                                *ctx,
278 \&                                                                unsigned char
279 \&                                                                *sig,
280 \&                                                                size_t *siglen,
281 \&                                                                const unsigned
282 \&                                                                char *tbs,
283 \&                                                                size_t tbslen));
284 \& void EVP_PKEY_meth_get_signctx(const EVP_PKEY_METHOD *pmeth,
285 \&                                int (**psignctx_init) (EVP_PKEY_CTX *ctx,
286 \&                                                       EVP_MD_CTX *mctx),
287 \&                                int (**psignctx) (EVP_PKEY_CTX *ctx,
288 \&                                                  unsigned char *sig,
289 \&                                                  size_t *siglen,
290 \&                                                  EVP_MD_CTX *mctx));
291 \& void EVP_PKEY_meth_get_verifyctx(const EVP_PKEY_METHOD *pmeth,
292 \&                                  int (**pverifyctx_init) (EVP_PKEY_CTX *ctx,
293 \&                                                           EVP_MD_CTX *mctx),
294 \&                                  int (**pverifyctx) (EVP_PKEY_CTX *ctx,
295 \&                                                      const unsigned char *sig,
296 \&                                                      int siglen,
297 \&                                                      EVP_MD_CTX *mctx));
298 \& void EVP_PKEY_meth_get_encrypt(const EVP_PKEY_METHOD *pmeth,
299 \&                                int (**pencrypt_init) (EVP_PKEY_CTX *ctx),
300 \&                                int (**pencryptfn) (EVP_PKEY_CTX *ctx,
301 \&                                                    unsigned char *out,
302 \&                                                    size_t *outlen,
303 \&                                                    const unsigned char *in,
304 \&                                                    size_t inlen));
305 \& void EVP_PKEY_meth_get_decrypt(const EVP_PKEY_METHOD *pmeth,
306 \&                                int (**pdecrypt_init) (EVP_PKEY_CTX *ctx),
307 \&                                int (**pdecrypt) (EVP_PKEY_CTX *ctx,
308 \&                                                  unsigned char *out,
309 \&                                                  size_t *outlen,
310 \&                                                  const unsigned char *in,
311 \&                                                  size_t inlen));
312 \& void EVP_PKEY_meth_get_derive(const EVP_PKEY_METHOD *pmeth,
313 \&                               int (**pderive_init) (EVP_PKEY_CTX *ctx),
314 \&                               int (**pderive) (EVP_PKEY_CTX *ctx,
315 \&                                                unsigned char *key,
316 \&                                                size_t *keylen));
317 \& void EVP_PKEY_meth_get_ctrl(const EVP_PKEY_METHOD *pmeth,
318 \&                             int (**pctrl) (EVP_PKEY_CTX *ctx, int type, int p1,
319 \&                                            void *p2),
320 \&                             int (**pctrl_str) (EVP_PKEY_CTX *ctx,
321 \&                                                const char *type,
322 \&                                                const char *value));
323 \& void EVP_PKEY_meth_get_check(const EVP_PKEY_METHOD *pmeth,
324 \&                              int (**pcheck) (EVP_PKEY *pkey));
325 \& void EVP_PKEY_meth_get_public_check(const EVP_PKEY_METHOD *pmeth,
326 \&                                     int (**pcheck) (EVP_PKEY *pkey));
327 \& void EVP_PKEY_meth_get_param_check(const EVP_PKEY_METHOD *pmeth,
328 \&                                    int (**pcheck) (EVP_PKEY *pkey));
329 \& void EVP_PKEY_meth_get_digest_custom(EVP_PKEY_METHOD *pmeth,
330 \&                                     int (**pdigest_custom) (EVP_PKEY_CTX *ctx,
331 \&                                                             EVP_MD_CTX *mctx));
332 .Ve
333 .SH "DESCRIPTION"
334 .IX Header "DESCRIPTION"
335 \&\fB\s-1EVP_PKEY_METHOD\s0\fR is a structure which holds a set of methods for a
336 specific public key cryptographic algorithm. Those methods are usually
337 used to perform different jobs, such as generating a key, signing or
338 verifying, encrypting or decrypting, etc.
339 .PP
340 There are two places where the \fB\s-1EVP_PKEY_METHOD\s0\fR objects are stored: one
341 is a built-in static array representing the standard methods for different
342 algorithms, and the other one is a stack of user-defined application-specific
343 methods, which can be manipulated by using \fBEVP_PKEY_meth_add0\fR\|(3).
344 .PP
345 The \fB\s-1EVP_PKEY_METHOD\s0\fR objects are usually referenced by \fB\s-1EVP_PKEY_CTX\s0\fR
346 objects.
347 .SS "Methods"
348 .IX Subsection "Methods"
349 The methods are the underlying implementations of a particular public key
350 algorithm present by the \fB\s-1EVP_PKEY_CTX\s0\fR object.
351 .PP
352 .Vb 3
353 \& int (*init) (EVP_PKEY_CTX *ctx);
354 \& int (*copy) (EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src);
355 \& void (*cleanup) (EVP_PKEY_CTX *ctx);
356 .Ve
357 .PP
358 The \fBinit()\fR method is called to initialize algorithm-specific data when a new
359 \&\fB\s-1EVP_PKEY_CTX\s0\fR is created. As opposed to \fBinit()\fR, the \fBcleanup()\fR method is called
360 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
361 is being duplicated. Refer to \fBEVP_PKEY_CTX_new\fR\|(3), \fBEVP_PKEY_CTX_new_id\fR\|(3),
362 \&\fBEVP_PKEY_CTX_free\fR\|(3) and \fBEVP_PKEY_CTX_dup\fR\|(3).
363 .PP
364 .Vb 2
365 \& int (*paramgen_init) (EVP_PKEY_CTX *ctx);
366 \& int (*paramgen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
367 .Ve
368 .PP
369 The \fBparamgen_init()\fR and \fBparamgen()\fR methods deal with key parameter generation.
370 They are called by \fBEVP_PKEY_paramgen_init\fR\|(3) and \fBEVP_PKEY_paramgen\fR\|(3) to
371 handle the parameter generation process.
372 .PP
373 .Vb 2
374 \& int (*keygen_init) (EVP_PKEY_CTX *ctx);
375 \& int (*keygen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
376 .Ve
377 .PP
378 The \fBkeygen_init()\fR and \fBkeygen()\fR methods are used to generate the actual key for
379 the specified algorithm. They are called by \fBEVP_PKEY_keygen_init\fR\|(3) and
380 \&\fBEVP_PKEY_keygen\fR\|(3).
381 .PP
382 .Vb 3
383 \& int (*sign_init) (EVP_PKEY_CTX *ctx);
384 \& int (*sign) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
385 \&              const unsigned char *tbs, size_t tbslen);
386 .Ve
387 .PP
388 The \fBsign_init()\fR and \fBsign()\fR methods are used to generate the signature of a
389 piece of data using a private key. They are called by \fBEVP_PKEY_sign_init\fR\|(3)
390 and \fBEVP_PKEY_sign\fR\|(3).
391 .PP
392 .Vb 4
393 \& int (*verify_init) (EVP_PKEY_CTX *ctx);
394 \& int (*verify) (EVP_PKEY_CTX *ctx,
395 \&                const unsigned char *sig, size_t siglen,
396 \&                const unsigned char *tbs, size_t tbslen);
397 .Ve
398 .PP
399 The \fBverify_init()\fR and \fBverify()\fR methods are used to verify whether a signature is
400 valid. They are called by \fBEVP_PKEY_verify_init\fR\|(3) and \fBEVP_PKEY_verify\fR\|(3).
401 .PP
402 .Vb 4
403 \& int (*verify_recover_init) (EVP_PKEY_CTX *ctx);
404 \& int (*verify_recover) (EVP_PKEY_CTX *ctx,
405 \&                        unsigned char *rout, size_t *routlen,
406 \&                        const unsigned char *sig, size_t siglen);
407 .Ve
408 .PP
409 The \fBverify_recover_init()\fR and \fBverify_recover()\fR methods are used to verify a
410 signature and then recover the digest from the signature (for instance, a
411 signature that was generated by \s-1RSA\s0 signing algorithm). They are called by
412 \&\fBEVP_PKEY_verify_recover_init\fR\|(3) and \fBEVP_PKEY_verify_recover\fR\|(3).
413 .PP
414 .Vb 3
415 \& int (*signctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
416 \& int (*signctx) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
417 \&                 EVP_MD_CTX *mctx);
418 .Ve
419 .PP
420 The \fBsignctx_init()\fR and \fBsignctx()\fR methods are used to sign a digest present by
421 a \fB\s-1EVP_MD_CTX\s0\fR object. They are called by the EVP_DigestSign functions. See
422 \&\fBEVP_DigestSignInit\fR\|(3) for details.
423 .PP
424 .Vb 3
425 \& int (*verifyctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
426 \& int (*verifyctx) (EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen,
427 \&                   EVP_MD_CTX *mctx);
428 .Ve
429 .PP
430 The \fBverifyctx_init()\fR and \fBverifyctx()\fR methods are used to verify a signature
431 against the data in a \fB\s-1EVP_MD_CTX\s0\fR object. They are called by the various
432 EVP_DigestVerify functions. See \fBEVP_DigestVerifyInit\fR\|(3) for details.
433 .PP
434 .Vb 3
435 \& int (*encrypt_init) (EVP_PKEY_CTX *ctx);
436 \& int (*encrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
437 \&                 const unsigned char *in, size_t inlen);
438 .Ve
439 .PP
440 The \fBencrypt_init()\fR and \fBencrypt()\fR methods are used to encrypt a piece of data.
441 They are called by \fBEVP_PKEY_encrypt_init\fR\|(3) and \fBEVP_PKEY_encrypt\fR\|(3).
442 .PP
443 .Vb 3
444 \& int (*decrypt_init) (EVP_PKEY_CTX *ctx);
445 \& int (*decrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
446 \&                 const unsigned char *in, size_t inlen);
447 .Ve
448 .PP
449 The \fBdecrypt_init()\fR and \fBdecrypt()\fR methods are used to decrypt a piece of data.
450 They are called by \fBEVP_PKEY_decrypt_init\fR\|(3) and \fBEVP_PKEY_decrypt\fR\|(3).
451 .PP
452 .Vb 2
453 \& int (*derive_init) (EVP_PKEY_CTX *ctx);
454 \& int (*derive) (EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);
455 .Ve
456 .PP
457 The \fBderive_init()\fR and \fBderive()\fR methods are used to derive the shared secret
458 from a public key algorithm (for instance, the \s-1DH\s0 algorithm). They are called by
459 \&\fBEVP_PKEY_derive_init\fR\|(3) and \fBEVP_PKEY_derive\fR\|(3).
460 .PP
461 .Vb 2
462 \& int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1, void *p2);
463 \& int (*ctrl_str) (EVP_PKEY_CTX *ctx, const char *type, const char *value);
464 .Ve
465 .PP
466 The \fBctrl()\fR and \fBctrl_str()\fR methods are used to adjust algorithm-specific
467 settings. See \fBEVP_PKEY_CTX_ctrl\fR\|(3) and related functions for details.
468 .PP
469 .Vb 5
470 \& int (*digestsign) (EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen,
471 \&                    const unsigned char *tbs, size_t tbslen);
472 \& int (*digestverify) (EVP_MD_CTX *ctx, const unsigned char *sig,
473 \&                      size_t siglen, const unsigned char *tbs,
474 \&                      size_t tbslen);
475 .Ve
476 .PP
477 The \fBdigestsign()\fR and \fBdigestverify()\fR methods are used to generate or verify
478 a signature in a one-shot mode. They could be called by \fBEVP_DigestSign\fR\|(3)
479 and \fBEVP_DigestVerify\fR\|(3).
480 .PP
481 .Vb 3
482 \& int (*check) (EVP_PKEY *pkey);
483 \& int (*public_check) (EVP_PKEY *pkey);
484 \& int (*param_check) (EVP_PKEY *pkey);
485 .Ve
486 .PP
487 The \fBcheck()\fR, \fBpublic_check()\fR and \fBparam_check()\fR methods are used to validate a
488 key-pair, the public component and parameters respectively for a given \fBpkey\fR.
489 They could be called by \fBEVP_PKEY_check\fR\|(3), \fBEVP_PKEY_public_check\fR\|(3) and
490 \&\fBEVP_PKEY_param_check\fR\|(3) respectively.
491 .PP
492 .Vb 1
493 \& int (*digest_custom) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
494 .Ve
495 .PP
496 The \fBdigest_custom()\fR method is used to generate customized digest content before
497 the real message is passed to functions like \fBEVP_DigestSignUpdate\fR\|(3) or
498 \&\fBEVP_DigestVerifyInit\fR\|(3). This is usually required by some public key
499 signature algorithms like \s-1SM2\s0 which requires a hashed prefix to the message to
500 be signed. The \fBdigest_custom()\fR function will be called by \fBEVP_DigestSignInit\fR\|(3)
501 and \fBEVP_DigestVerifyInit\fR\|(3).
502 .SS "Functions"
503 .IX Subsection "Functions"
504 \&\fBEVP_PKEY_meth_new()\fR creates and returns a new \fB\s-1EVP_PKEY_METHOD\s0\fR object,
505 and associates the given \fBid\fR and \fBflags\fR. The following flags are
506 supported:
507 .PP
508 .Vb 2
509 \& EVP_PKEY_FLAG_AUTOARGLEN
510 \& EVP_PKEY_FLAG_SIGCTX_CUSTOM
511 .Ve
512 .PP
513 If an \fB\s-1EVP_PKEY_METHOD\s0\fR is set with the \fB\s-1EVP_PKEY_FLAG_AUTOARGLEN\s0\fR flag, the
514 maximum size of the output buffer will be automatically calculated or checked
515 in corresponding \s-1EVP\s0 methods by the \s-1EVP\s0 framework. Thus the implementations of
516 these methods don't need to care about handling the case of returning output
517 buffer size by themselves. For details on the output buffer size, refer to
518 \&\fBEVP_PKEY_sign\fR\|(3).
519 .PP
520 The \fB\s-1EVP_PKEY_FLAG_SIGCTX_CUSTOM\s0\fR is used to indicate the \fBsignctx()\fR method
521 of an \fB\s-1EVP_PKEY_METHOD\s0\fR is always called by the \s-1EVP\s0 framework while doing a
522 digest signing operation by calling \fBEVP_DigestSignFinal\fR\|(3).
523 .PP
524 \&\fBEVP_PKEY_meth_free()\fR frees an existing \fB\s-1EVP_PKEY_METHOD\s0\fR pointed by
525 \&\fBpmeth\fR.
526 .PP
527 \&\fBEVP_PKEY_meth_copy()\fR copies an \fB\s-1EVP_PKEY_METHOD\s0\fR object from \fBsrc\fR
528 to \fBdst\fR.
529 .PP
530 \&\fBEVP_PKEY_meth_find()\fR finds an \fB\s-1EVP_PKEY_METHOD\s0\fR object with the \fBid\fR.
531 This function first searches through the user-defined method objects and
532 then the built-in objects.
533 .PP
534 \&\fBEVP_PKEY_meth_add0()\fR adds \fBpmeth\fR to the user defined stack of methods.
535 .PP
536 \&\fBEVP_PKEY_meth_remove()\fR removes an \fB\s-1EVP_PKEY_METHOD\s0\fR object added by
537 \&\fBEVP_PKEY_meth_add0()\fR.
538 .PP
539 The EVP_PKEY_meth_set functions set the corresponding fields of
540 \&\fB\s-1EVP_PKEY_METHOD\s0\fR structure with the arguments passed.
541 .PP
542 The EVP_PKEY_meth_get functions get the corresponding fields of
543 \&\fB\s-1EVP_PKEY_METHOD\s0\fR structure to the arguments provided.
544 .SH "RETURN VALUES"
545 .IX Header "RETURN VALUES"
546 \&\fBEVP_PKEY_meth_new()\fR returns a pointer to a new \fB\s-1EVP_PKEY_METHOD\s0\fR
547 object or returns \s-1NULL\s0 on error.
548 .PP
549 \&\fBEVP_PKEY_meth_free()\fR and \fBEVP_PKEY_meth_copy()\fR do not return values.
550 .PP
551 \&\fBEVP_PKEY_meth_find()\fR returns a pointer to the found \fB\s-1EVP_PKEY_METHOD\s0\fR
552 object or returns \s-1NULL\s0 if not found.
553 .PP
554 \&\fBEVP_PKEY_meth_add0()\fR returns 1 if method is added successfully or 0
555 if an error occurred.
556 .PP
557 \&\fBEVP_PKEY_meth_remove()\fR returns 1 if method is removed successfully or
558 0 if an error occurred.
559 .PP
560 All EVP_PKEY_meth_set and EVP_PKEY_meth_get functions have no return
561 values. For the 'get' functions, function pointers are returned by
562 arguments.
563 .SH "COPYRIGHT"
564 .IX Header "COPYRIGHT"
565 Copyright 2017\-2019 The OpenSSL Project Authors. All Rights Reserved.
566 .PP
567 Licensed under the OpenSSL license (the \*(L"License\*(R").  You may not use
568 this file except in compliance with the License.  You can obtain a copy
569 in the file \s-1LICENSE\s0 in the source distribution or at
570 <https://www.openssl.org/source/license.html>.