2 * Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
12 #include "internal/cryptlib.h"
13 #include <openssl/engine.h>
14 #include <openssl/evp.h>
15 #include <openssl/x509v3.h>
16 #include "internal/asn1_int.h"
17 #include "internal/evp_int.h"
18 #include "internal/numbers.h"
20 typedef int sk_cmp_fn_type(const char *const *a
, const char *const *b
);
22 static STACK_OF(EVP_PKEY_METHOD
) *app_pkey_methods
= NULL
;
24 /* This array needs to be in order of NIDs */
25 static const EVP_PKEY_METHOD
*standard_methods
[] = {
26 #ifndef OPENSSL_NO_RSA
32 #ifndef OPENSSL_NO_DSA
39 #ifndef OPENSSL_NO_CMAC
42 #ifndef OPENSSL_NO_RSA
48 #ifndef OPENSSL_NO_SCRYPT
57 #ifndef OPENSSL_NO_POLY1305
60 #ifndef OPENSSL_NO_SIPHASH
67 #ifndef OPENSSL_NO_SM2
72 DECLARE_OBJ_BSEARCH_CMP_FN(const EVP_PKEY_METHOD
*, const EVP_PKEY_METHOD
*,
75 static int pmeth_cmp(const EVP_PKEY_METHOD
*const *a
,
76 const EVP_PKEY_METHOD
*const *b
)
78 return ((*a
)->pkey_id
- (*b
)->pkey_id
);
81 IMPLEMENT_OBJ_BSEARCH_CMP_FN(const EVP_PKEY_METHOD
*, const EVP_PKEY_METHOD
*,
84 const EVP_PKEY_METHOD
*EVP_PKEY_meth_find(int type
)
87 const EVP_PKEY_METHOD
*t
= &tmp
, **ret
;
89 if (app_pkey_methods
) {
91 idx
= sk_EVP_PKEY_METHOD_find(app_pkey_methods
, &tmp
);
93 return sk_EVP_PKEY_METHOD_value(app_pkey_methods
, idx
);
95 ret
= OBJ_bsearch_pmeth(&t
, standard_methods
,
96 sizeof(standard_methods
) /
97 sizeof(EVP_PKEY_METHOD
*));
103 static EVP_PKEY_CTX
*int_ctx_new(EVP_PKEY
*pkey
, ENGINE
*e
, int id
)
106 const EVP_PKEY_METHOD
*pmeth
;
113 #ifndef OPENSSL_NO_ENGINE
114 if (e
== NULL
&& pkey
!= NULL
)
115 e
= pkey
->pmeth_engine
!= NULL
? pkey
->pmeth_engine
: pkey
->engine
;
116 /* Try to find an ENGINE which implements this method */
118 if (!ENGINE_init(e
)) {
119 EVPerr(EVP_F_INT_CTX_NEW
, ERR_R_ENGINE_LIB
);
123 e
= ENGINE_get_pkey_meth_engine(id
);
127 * If an ENGINE handled this method look it up. Otherwise use internal
131 pmeth
= ENGINE_get_pkey_meth(e
, id
);
134 pmeth
= EVP_PKEY_meth_find(id
);
137 #ifndef OPENSSL_NO_ENGINE
140 EVPerr(EVP_F_INT_CTX_NEW
, EVP_R_UNSUPPORTED_ALGORITHM
);
144 ret
= OPENSSL_zalloc(sizeof(*ret
));
146 #ifndef OPENSSL_NO_ENGINE
149 EVPerr(EVP_F_INT_CTX_NEW
, ERR_R_MALLOC_FAILURE
);
154 ret
->operation
= EVP_PKEY_OP_UNDEFINED
;
157 EVP_PKEY_up_ref(pkey
);
160 if (pmeth
->init(ret
) <= 0) {
162 EVP_PKEY_CTX_free(ret
);
170 EVP_PKEY_METHOD
*EVP_PKEY_meth_new(int id
, int flags
)
172 EVP_PKEY_METHOD
*pmeth
;
174 pmeth
= OPENSSL_zalloc(sizeof(*pmeth
));
176 EVPerr(EVP_F_EVP_PKEY_METH_NEW
, ERR_R_MALLOC_FAILURE
);
181 pmeth
->flags
= flags
| EVP_PKEY_FLAG_DYNAMIC
;
185 void EVP_PKEY_meth_get0_info(int *ppkey_id
, int *pflags
,
186 const EVP_PKEY_METHOD
*meth
)
189 *ppkey_id
= meth
->pkey_id
;
191 *pflags
= meth
->flags
;
194 void EVP_PKEY_meth_copy(EVP_PKEY_METHOD
*dst
, const EVP_PKEY_METHOD
*src
)
197 dst
->init
= src
->init
;
198 dst
->copy
= src
->copy
;
199 dst
->cleanup
= src
->cleanup
;
201 dst
->paramgen_init
= src
->paramgen_init
;
202 dst
->paramgen
= src
->paramgen
;
204 dst
->keygen_init
= src
->keygen_init
;
205 dst
->keygen
= src
->keygen
;
207 dst
->sign_init
= src
->sign_init
;
208 dst
->sign
= src
->sign
;
210 dst
->verify_init
= src
->verify_init
;
211 dst
->verify
= src
->verify
;
213 dst
->verify_recover_init
= src
->verify_recover_init
;
214 dst
->verify_recover
= src
->verify_recover
;
216 dst
->signctx_init
= src
->signctx_init
;
217 dst
->signctx
= src
->signctx
;
219 dst
->verifyctx_init
= src
->verifyctx_init
;
220 dst
->verifyctx
= src
->verifyctx
;
222 dst
->encrypt_init
= src
->encrypt_init
;
223 dst
->encrypt
= src
->encrypt
;
225 dst
->decrypt_init
= src
->decrypt_init
;
226 dst
->decrypt
= src
->decrypt
;
228 dst
->derive_init
= src
->derive_init
;
229 dst
->derive
= src
->derive
;
231 dst
->ctrl
= src
->ctrl
;
232 dst
->ctrl_str
= src
->ctrl_str
;
234 dst
->check
= src
->check
;
237 void EVP_PKEY_meth_free(EVP_PKEY_METHOD
*pmeth
)
239 if (pmeth
&& (pmeth
->flags
& EVP_PKEY_FLAG_DYNAMIC
))
243 EVP_PKEY_CTX
*EVP_PKEY_CTX_new(EVP_PKEY
*pkey
, ENGINE
*e
)
245 return int_ctx_new(pkey
, e
, -1);
248 EVP_PKEY_CTX
*EVP_PKEY_CTX_new_id(int id
, ENGINE
*e
)
250 return int_ctx_new(NULL
, e
, id
);
253 EVP_PKEY_CTX
*EVP_PKEY_CTX_dup(EVP_PKEY_CTX
*pctx
)
256 if (!pctx
->pmeth
|| !pctx
->pmeth
->copy
)
258 #ifndef OPENSSL_NO_ENGINE
259 /* Make sure it's safe to copy a pkey context using an ENGINE */
260 if (pctx
->engine
&& !ENGINE_init(pctx
->engine
)) {
261 EVPerr(EVP_F_EVP_PKEY_CTX_DUP
, ERR_R_ENGINE_LIB
);
265 rctx
= OPENSSL_malloc(sizeof(*rctx
));
267 EVPerr(EVP_F_EVP_PKEY_CTX_DUP
, ERR_R_MALLOC_FAILURE
);
271 rctx
->pmeth
= pctx
->pmeth
;
272 #ifndef OPENSSL_NO_ENGINE
273 rctx
->engine
= pctx
->engine
;
277 EVP_PKEY_up_ref(pctx
->pkey
);
279 rctx
->pkey
= pctx
->pkey
;
282 EVP_PKEY_up_ref(pctx
->peerkey
);
284 rctx
->peerkey
= pctx
->peerkey
;
287 rctx
->app_data
= NULL
;
288 rctx
->operation
= pctx
->operation
;
290 if (pctx
->pmeth
->copy(rctx
, pctx
) > 0)
294 EVP_PKEY_CTX_free(rctx
);
299 int EVP_PKEY_meth_add0(const EVP_PKEY_METHOD
*pmeth
)
301 if (app_pkey_methods
== NULL
) {
302 app_pkey_methods
= sk_EVP_PKEY_METHOD_new(pmeth_cmp
);
303 if (app_pkey_methods
== NULL
){
304 EVPerr(EVP_F_EVP_PKEY_METH_ADD0
, ERR_R_MALLOC_FAILURE
);
308 if (!sk_EVP_PKEY_METHOD_push(app_pkey_methods
, pmeth
)) {
309 EVPerr(EVP_F_EVP_PKEY_METH_ADD0
, ERR_R_MALLOC_FAILURE
);
312 sk_EVP_PKEY_METHOD_sort(app_pkey_methods
);
316 void evp_app_cleanup_int(void)
318 if (app_pkey_methods
!= NULL
)
319 sk_EVP_PKEY_METHOD_pop_free(app_pkey_methods
, EVP_PKEY_meth_free
);
322 int EVP_PKEY_meth_remove(const EVP_PKEY_METHOD
*pmeth
)
324 const EVP_PKEY_METHOD
*ret
;
326 ret
= sk_EVP_PKEY_METHOD_delete_ptr(app_pkey_methods
, pmeth
);
328 return ret
== NULL
? 0 : 1;
331 size_t EVP_PKEY_meth_get_count(void)
333 size_t rv
= OSSL_NELEM(standard_methods
);
335 if (app_pkey_methods
)
336 rv
+= sk_EVP_PKEY_METHOD_num(app_pkey_methods
);
340 const EVP_PKEY_METHOD
*EVP_PKEY_meth_get0(size_t idx
)
342 if (idx
< OSSL_NELEM(standard_methods
))
343 return standard_methods
[idx
];
344 if (app_pkey_methods
== NULL
)
346 idx
-= OSSL_NELEM(standard_methods
);
347 if (idx
>= (size_t)sk_EVP_PKEY_METHOD_num(app_pkey_methods
))
349 return sk_EVP_PKEY_METHOD_value(app_pkey_methods
, idx
);
352 void EVP_PKEY_CTX_free(EVP_PKEY_CTX
*ctx
)
356 if (ctx
->pmeth
&& ctx
->pmeth
->cleanup
)
357 ctx
->pmeth
->cleanup(ctx
);
358 EVP_PKEY_free(ctx
->pkey
);
359 EVP_PKEY_free(ctx
->peerkey
);
360 #ifndef OPENSSL_NO_ENGINE
361 ENGINE_finish(ctx
->engine
);
366 int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX
*ctx
, int keytype
, int optype
,
367 int cmd
, int p1
, void *p2
)
370 if (!ctx
|| !ctx
->pmeth
|| !ctx
->pmeth
->ctrl
) {
371 EVPerr(EVP_F_EVP_PKEY_CTX_CTRL
, EVP_R_COMMAND_NOT_SUPPORTED
);
374 if ((keytype
!= -1) && (ctx
->pmeth
->pkey_id
!= keytype
))
377 if (ctx
->operation
== EVP_PKEY_OP_UNDEFINED
) {
378 EVPerr(EVP_F_EVP_PKEY_CTX_CTRL
, EVP_R_NO_OPERATION_SET
);
382 if ((optype
!= -1) && !(ctx
->operation
& optype
)) {
383 EVPerr(EVP_F_EVP_PKEY_CTX_CTRL
, EVP_R_INVALID_OPERATION
);
387 ret
= ctx
->pmeth
->ctrl(ctx
, cmd
, p1
, p2
);
390 EVPerr(EVP_F_EVP_PKEY_CTX_CTRL
, EVP_R_COMMAND_NOT_SUPPORTED
);
396 int EVP_PKEY_CTX_ctrl_uint64(EVP_PKEY_CTX
*ctx
, int keytype
, int optype
,
397 int cmd
, uint64_t value
)
399 return EVP_PKEY_CTX_ctrl(ctx
, keytype
, optype
, cmd
, 0, &value
);
402 int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX
*ctx
,
403 const char *name
, const char *value
)
405 if (!ctx
|| !ctx
->pmeth
|| !ctx
->pmeth
->ctrl_str
) {
406 EVPerr(EVP_F_EVP_PKEY_CTX_CTRL_STR
, EVP_R_COMMAND_NOT_SUPPORTED
);
409 if (strcmp(name
, "digest") == 0)
410 return EVP_PKEY_CTX_md(ctx
, EVP_PKEY_OP_TYPE_SIG
, EVP_PKEY_CTRL_MD
,
412 return ctx
->pmeth
->ctrl_str(ctx
, name
, value
);
415 /* Utility functions to send a string of hex string to a ctrl */
417 int EVP_PKEY_CTX_str2ctrl(EVP_PKEY_CTX
*ctx
, int cmd
, const char *str
)
424 return ctx
->pmeth
->ctrl(ctx
, cmd
, len
, (void *)str
);
427 int EVP_PKEY_CTX_hex2ctrl(EVP_PKEY_CTX
*ctx
, int cmd
, const char *hex
)
433 bin
= OPENSSL_hexstr2buf(hex
, &binlen
);
436 if (binlen
<= INT_MAX
)
437 rv
= ctx
->pmeth
->ctrl(ctx
, cmd
, binlen
, bin
);
442 /* Pass a message digest to a ctrl */
443 int EVP_PKEY_CTX_md(EVP_PKEY_CTX
*ctx
, int optype
, int cmd
, const char *md
)
447 if (md
== NULL
|| (m
= EVP_get_digestbyname(md
)) == NULL
) {
448 EVPerr(EVP_F_EVP_PKEY_CTX_MD
, EVP_R_INVALID_DIGEST
);
451 return EVP_PKEY_CTX_ctrl(ctx
, -1, optype
, cmd
, 0, (void *)m
);
454 int EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX
*ctx
)
456 return ctx
->operation
;
459 void EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX
*ctx
, int *dat
, int datlen
)
461 ctx
->keygen_info
= dat
;
462 ctx
->keygen_info_count
= datlen
;
465 void EVP_PKEY_CTX_set_data(EVP_PKEY_CTX
*ctx
, void *data
)
470 void *EVP_PKEY_CTX_get_data(EVP_PKEY_CTX
*ctx
)
475 EVP_PKEY
*EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX
*ctx
)
480 EVP_PKEY
*EVP_PKEY_CTX_get0_peerkey(EVP_PKEY_CTX
*ctx
)
485 void EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX
*ctx
, void *data
)
487 ctx
->app_data
= data
;
490 void *EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX
*ctx
)
492 return ctx
->app_data
;
495 void EVP_PKEY_meth_set_init(EVP_PKEY_METHOD
*pmeth
,
496 int (*init
) (EVP_PKEY_CTX
*ctx
))
501 void EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD
*pmeth
,
502 int (*copy
) (EVP_PKEY_CTX
*dst
,
508 void EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD
*pmeth
,
509 void (*cleanup
) (EVP_PKEY_CTX
*ctx
))
511 pmeth
->cleanup
= cleanup
;
514 void EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD
*pmeth
,
515 int (*paramgen_init
) (EVP_PKEY_CTX
*ctx
),
516 int (*paramgen
) (EVP_PKEY_CTX
*ctx
,
519 pmeth
->paramgen_init
= paramgen_init
;
520 pmeth
->paramgen
= paramgen
;
523 void EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD
*pmeth
,
524 int (*keygen_init
) (EVP_PKEY_CTX
*ctx
),
525 int (*keygen
) (EVP_PKEY_CTX
*ctx
,
528 pmeth
->keygen_init
= keygen_init
;
529 pmeth
->keygen
= keygen
;
532 void EVP_PKEY_meth_set_sign(EVP_PKEY_METHOD
*pmeth
,
533 int (*sign_init
) (EVP_PKEY_CTX
*ctx
),
534 int (*sign
) (EVP_PKEY_CTX
*ctx
,
535 unsigned char *sig
, size_t *siglen
,
536 const unsigned char *tbs
,
539 pmeth
->sign_init
= sign_init
;
543 void EVP_PKEY_meth_set_verify(EVP_PKEY_METHOD
*pmeth
,
544 int (*verify_init
) (EVP_PKEY_CTX
*ctx
),
545 int (*verify
) (EVP_PKEY_CTX
*ctx
,
546 const unsigned char *sig
,
548 const unsigned char *tbs
,
551 pmeth
->verify_init
= verify_init
;
552 pmeth
->verify
= verify
;
555 void EVP_PKEY_meth_set_verify_recover(EVP_PKEY_METHOD
*pmeth
,
556 int (*verify_recover_init
) (EVP_PKEY_CTX
558 int (*verify_recover
) (EVP_PKEY_CTX
567 pmeth
->verify_recover_init
= verify_recover_init
;
568 pmeth
->verify_recover
= verify_recover
;
571 void EVP_PKEY_meth_set_signctx(EVP_PKEY_METHOD
*pmeth
,
572 int (*signctx_init
) (EVP_PKEY_CTX
*ctx
,
574 int (*signctx
) (EVP_PKEY_CTX
*ctx
,
579 pmeth
->signctx_init
= signctx_init
;
580 pmeth
->signctx
= signctx
;
583 void EVP_PKEY_meth_set_verifyctx(EVP_PKEY_METHOD
*pmeth
,
584 int (*verifyctx_init
) (EVP_PKEY_CTX
*ctx
,
586 int (*verifyctx
) (EVP_PKEY_CTX
*ctx
,
587 const unsigned char *sig
,
591 pmeth
->verifyctx_init
= verifyctx_init
;
592 pmeth
->verifyctx
= verifyctx
;
595 void EVP_PKEY_meth_set_encrypt(EVP_PKEY_METHOD
*pmeth
,
596 int (*encrypt_init
) (EVP_PKEY_CTX
*ctx
),
597 int (*encryptfn
) (EVP_PKEY_CTX
*ctx
,
600 const unsigned char *in
,
603 pmeth
->encrypt_init
= encrypt_init
;
604 pmeth
->encrypt
= encryptfn
;
607 void EVP_PKEY_meth_set_decrypt(EVP_PKEY_METHOD
*pmeth
,
608 int (*decrypt_init
) (EVP_PKEY_CTX
*ctx
),
609 int (*decrypt
) (EVP_PKEY_CTX
*ctx
,
612 const unsigned char *in
,
615 pmeth
->decrypt_init
= decrypt_init
;
616 pmeth
->decrypt
= decrypt
;
619 void EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD
*pmeth
,
620 int (*derive_init
) (EVP_PKEY_CTX
*ctx
),
621 int (*derive
) (EVP_PKEY_CTX
*ctx
,
625 pmeth
->derive_init
= derive_init
;
626 pmeth
->derive
= derive
;
629 void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD
*pmeth
,
630 int (*ctrl
) (EVP_PKEY_CTX
*ctx
, int type
, int p1
,
632 int (*ctrl_str
) (EVP_PKEY_CTX
*ctx
,
637 pmeth
->ctrl_str
= ctrl_str
;
640 void EVP_PKEY_meth_set_check(EVP_PKEY_METHOD
*pmeth
,
641 int (*check
) (EVP_PKEY
*pkey
))
643 pmeth
->check
= check
;
646 void EVP_PKEY_meth_set_public_check(EVP_PKEY_METHOD
*pmeth
,
647 int (*check
) (EVP_PKEY
*pkey
))
649 pmeth
->public_check
= check
;
652 void EVP_PKEY_meth_set_param_check(EVP_PKEY_METHOD
*pmeth
,
653 int (*check
) (EVP_PKEY
*pkey
))
655 pmeth
->param_check
= check
;
658 void EVP_PKEY_meth_set_digest_custom(EVP_PKEY_METHOD
*pmeth
,
659 int (*digest_custom
) (EVP_PKEY_CTX
*ctx
,
662 pmeth
->digest_custom
= digest_custom
;
665 void EVP_PKEY_meth_get_init(const EVP_PKEY_METHOD
*pmeth
,
666 int (**pinit
) (EVP_PKEY_CTX
*ctx
))
668 *pinit
= pmeth
->init
;
671 void EVP_PKEY_meth_get_copy(const EVP_PKEY_METHOD
*pmeth
,
672 int (**pcopy
) (EVP_PKEY_CTX
*dst
,
675 *pcopy
= pmeth
->copy
;
678 void EVP_PKEY_meth_get_cleanup(const EVP_PKEY_METHOD
*pmeth
,
679 void (**pcleanup
) (EVP_PKEY_CTX
*ctx
))
681 *pcleanup
= pmeth
->cleanup
;
684 void EVP_PKEY_meth_get_paramgen(const EVP_PKEY_METHOD
*pmeth
,
685 int (**pparamgen_init
) (EVP_PKEY_CTX
*ctx
),
686 int (**pparamgen
) (EVP_PKEY_CTX
*ctx
,
690 *pparamgen_init
= pmeth
->paramgen_init
;
692 *pparamgen
= pmeth
->paramgen
;
695 void EVP_PKEY_meth_get_keygen(const EVP_PKEY_METHOD
*pmeth
,
696 int (**pkeygen_init
) (EVP_PKEY_CTX
*ctx
),
697 int (**pkeygen
) (EVP_PKEY_CTX
*ctx
,
701 *pkeygen_init
= pmeth
->keygen_init
;
703 *pkeygen
= pmeth
->keygen
;
706 void EVP_PKEY_meth_get_sign(const EVP_PKEY_METHOD
*pmeth
,
707 int (**psign_init
) (EVP_PKEY_CTX
*ctx
),
708 int (**psign
) (EVP_PKEY_CTX
*ctx
,
709 unsigned char *sig
, size_t *siglen
,
710 const unsigned char *tbs
,
714 *psign_init
= pmeth
->sign_init
;
716 *psign
= pmeth
->sign
;
719 void EVP_PKEY_meth_get_verify(const EVP_PKEY_METHOD
*pmeth
,
720 int (**pverify_init
) (EVP_PKEY_CTX
*ctx
),
721 int (**pverify
) (EVP_PKEY_CTX
*ctx
,
722 const unsigned char *sig
,
724 const unsigned char *tbs
,
728 *pverify_init
= pmeth
->verify_init
;
730 *pverify
= pmeth
->verify
;
733 void EVP_PKEY_meth_get_verify_recover(const EVP_PKEY_METHOD
*pmeth
,
734 int (**pverify_recover_init
) (EVP_PKEY_CTX
736 int (**pverify_recover
) (EVP_PKEY_CTX
745 if (pverify_recover_init
)
746 *pverify_recover_init
= pmeth
->verify_recover_init
;
748 *pverify_recover
= pmeth
->verify_recover
;
751 void EVP_PKEY_meth_get_signctx(const EVP_PKEY_METHOD
*pmeth
,
752 int (**psignctx_init
) (EVP_PKEY_CTX
*ctx
,
754 int (**psignctx
) (EVP_PKEY_CTX
*ctx
,
760 *psignctx_init
= pmeth
->signctx_init
;
762 *psignctx
= pmeth
->signctx
;
765 void EVP_PKEY_meth_get_verifyctx(const EVP_PKEY_METHOD
*pmeth
,
766 int (**pverifyctx_init
) (EVP_PKEY_CTX
*ctx
,
768 int (**pverifyctx
) (EVP_PKEY_CTX
*ctx
,
769 const unsigned char *sig
,
774 *pverifyctx_init
= pmeth
->verifyctx_init
;
776 *pverifyctx
= pmeth
->verifyctx
;
779 void EVP_PKEY_meth_get_encrypt(const EVP_PKEY_METHOD
*pmeth
,
780 int (**pencrypt_init
) (EVP_PKEY_CTX
*ctx
),
781 int (**pencryptfn
) (EVP_PKEY_CTX
*ctx
,
784 const unsigned char *in
,
788 *pencrypt_init
= pmeth
->encrypt_init
;
790 *pencryptfn
= pmeth
->encrypt
;
793 void EVP_PKEY_meth_get_decrypt(const EVP_PKEY_METHOD
*pmeth
,
794 int (**pdecrypt_init
) (EVP_PKEY_CTX
*ctx
),
795 int (**pdecrypt
) (EVP_PKEY_CTX
*ctx
,
798 const unsigned char *in
,
802 *pdecrypt_init
= pmeth
->decrypt_init
;
804 *pdecrypt
= pmeth
->decrypt
;
807 void EVP_PKEY_meth_get_derive(const EVP_PKEY_METHOD
*pmeth
,
808 int (**pderive_init
) (EVP_PKEY_CTX
*ctx
),
809 int (**pderive
) (EVP_PKEY_CTX
*ctx
,
814 *pderive_init
= pmeth
->derive_init
;
816 *pderive
= pmeth
->derive
;
819 void EVP_PKEY_meth_get_ctrl(const EVP_PKEY_METHOD
*pmeth
,
820 int (**pctrl
) (EVP_PKEY_CTX
*ctx
, int type
, int p1
,
822 int (**pctrl_str
) (EVP_PKEY_CTX
*ctx
,
827 *pctrl
= pmeth
->ctrl
;
829 *pctrl_str
= pmeth
->ctrl_str
;
832 void EVP_PKEY_meth_get_check(const EVP_PKEY_METHOD
*pmeth
,
833 int (**pcheck
) (EVP_PKEY
*pkey
))
836 *pcheck
= pmeth
->check
;
839 void EVP_PKEY_meth_get_public_check(const EVP_PKEY_METHOD
*pmeth
,
840 int (**pcheck
) (EVP_PKEY
*pkey
))
843 *pcheck
= pmeth
->public_check
;
846 void EVP_PKEY_meth_get_param_check(const EVP_PKEY_METHOD
*pmeth
,
847 int (**pcheck
) (EVP_PKEY
*pkey
))
850 *pcheck
= pmeth
->param_check
;
853 void EVP_PKEY_meth_get_digest_custom(EVP_PKEY_METHOD
*pmeth
,
854 int (**pdigest_custom
) (EVP_PKEY_CTX
*ctx
,
858 *pdigest_custom
= pmeth
->digest_custom
;