2 * Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (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"
21 typedef int sk_cmp_fn_type(const char *const *a
, const char *const *b
);
23 static STACK_OF(EVP_PKEY_METHOD
) *app_pkey_methods
= NULL
;
25 /* This array needs to be in order of NIDs */
26 static const EVP_PKEY_METHOD
*standard_methods
[] = {
27 #ifndef OPENSSL_NO_RSA
33 #ifndef OPENSSL_NO_DSA
40 #ifndef OPENSSL_NO_CMAC
43 #ifndef OPENSSL_NO_RSA
49 #ifndef OPENSSL_NO_SCRYPT
58 #ifndef OPENSSL_NO_POLY1305
61 #ifndef OPENSSL_NO_SIPHASH
68 #ifndef OPENSSL_NO_SM2
73 DECLARE_OBJ_BSEARCH_CMP_FN(const EVP_PKEY_METHOD
*, const EVP_PKEY_METHOD
*,
76 static int pmeth_cmp(const EVP_PKEY_METHOD
*const *a
,
77 const EVP_PKEY_METHOD
*const *b
)
79 return ((*a
)->pkey_id
- (*b
)->pkey_id
);
82 IMPLEMENT_OBJ_BSEARCH_CMP_FN(const EVP_PKEY_METHOD
*, const EVP_PKEY_METHOD
*,
85 const EVP_PKEY_METHOD
*EVP_PKEY_meth_find(int type
)
88 const EVP_PKEY_METHOD
*t
= &tmp
, **ret
;
90 if (app_pkey_methods
) {
92 idx
= sk_EVP_PKEY_METHOD_find(app_pkey_methods
, &tmp
);
94 return sk_EVP_PKEY_METHOD_value(app_pkey_methods
, idx
);
96 ret
= OBJ_bsearch_pmeth(&t
, standard_methods
,
97 sizeof(standard_methods
) /
98 sizeof(EVP_PKEY_METHOD
*));
104 static EVP_PKEY_CTX
*int_ctx_new(EVP_PKEY
*pkey
, ENGINE
*e
, int id
)
107 const EVP_PKEY_METHOD
*pmeth
;
114 #ifndef OPENSSL_NO_ENGINE
115 if (e
== NULL
&& pkey
!= NULL
)
116 e
= pkey
->pmeth_engine
!= NULL
? pkey
->pmeth_engine
: pkey
->engine
;
117 /* Try to find an ENGINE which implements this method */
119 if (!ENGINE_init(e
)) {
120 EVPerr(EVP_F_INT_CTX_NEW
, ERR_R_ENGINE_LIB
);
124 e
= ENGINE_get_pkey_meth_engine(id
);
128 * If an ENGINE handled this method look it up. Otherwise use internal
132 pmeth
= ENGINE_get_pkey_meth(e
, id
);
135 pmeth
= EVP_PKEY_meth_find(id
);
138 #ifndef OPENSSL_NO_ENGINE
141 EVPerr(EVP_F_INT_CTX_NEW
, EVP_R_UNSUPPORTED_ALGORITHM
);
145 ret
= OPENSSL_zalloc(sizeof(*ret
));
147 #ifndef OPENSSL_NO_ENGINE
150 EVPerr(EVP_F_INT_CTX_NEW
, ERR_R_MALLOC_FAILURE
);
155 ret
->operation
= EVP_PKEY_OP_UNDEFINED
;
158 EVP_PKEY_up_ref(pkey
);
161 if (pmeth
->init(ret
) <= 0) {
163 EVP_PKEY_CTX_free(ret
);
171 EVP_PKEY_METHOD
*EVP_PKEY_meth_new(int id
, int flags
)
173 EVP_PKEY_METHOD
*pmeth
;
175 pmeth
= OPENSSL_zalloc(sizeof(*pmeth
));
177 EVPerr(EVP_F_EVP_PKEY_METH_NEW
, ERR_R_MALLOC_FAILURE
);
182 pmeth
->flags
= flags
| EVP_PKEY_FLAG_DYNAMIC
;
186 void EVP_PKEY_meth_get0_info(int *ppkey_id
, int *pflags
,
187 const EVP_PKEY_METHOD
*meth
)
190 *ppkey_id
= meth
->pkey_id
;
192 *pflags
= meth
->flags
;
195 void EVP_PKEY_meth_copy(EVP_PKEY_METHOD
*dst
, const EVP_PKEY_METHOD
*src
)
198 dst
->init
= src
->init
;
199 dst
->copy
= src
->copy
;
200 dst
->cleanup
= src
->cleanup
;
202 dst
->paramgen_init
= src
->paramgen_init
;
203 dst
->paramgen
= src
->paramgen
;
205 dst
->keygen_init
= src
->keygen_init
;
206 dst
->keygen
= src
->keygen
;
208 dst
->sign_init
= src
->sign_init
;
209 dst
->sign
= src
->sign
;
211 dst
->verify_init
= src
->verify_init
;
212 dst
->verify
= src
->verify
;
214 dst
->verify_recover_init
= src
->verify_recover_init
;
215 dst
->verify_recover
= src
->verify_recover
;
217 dst
->signctx_init
= src
->signctx_init
;
218 dst
->signctx
= src
->signctx
;
220 dst
->verifyctx_init
= src
->verifyctx_init
;
221 dst
->verifyctx
= src
->verifyctx
;
223 dst
->encrypt_init
= src
->encrypt_init
;
224 dst
->encrypt
= src
->encrypt
;
226 dst
->decrypt_init
= src
->decrypt_init
;
227 dst
->decrypt
= src
->decrypt
;
229 dst
->derive_init
= src
->derive_init
;
230 dst
->derive
= src
->derive
;
232 dst
->ctrl
= src
->ctrl
;
233 dst
->ctrl_str
= src
->ctrl_str
;
235 dst
->check
= src
->check
;
238 void EVP_PKEY_meth_free(EVP_PKEY_METHOD
*pmeth
)
240 if (pmeth
&& (pmeth
->flags
& EVP_PKEY_FLAG_DYNAMIC
))
244 EVP_PKEY_CTX
*EVP_PKEY_CTX_new(EVP_PKEY
*pkey
, ENGINE
*e
)
246 return int_ctx_new(pkey
, e
, -1);
249 EVP_PKEY_CTX
*EVP_PKEY_CTX_new_id(int id
, ENGINE
*e
)
251 return int_ctx_new(NULL
, e
, id
);
254 EVP_PKEY_CTX
*EVP_PKEY_CTX_dup(const EVP_PKEY_CTX
*pctx
)
258 if (((pctx
->pmeth
== NULL
) || (pctx
->pmeth
->copy
== NULL
))
259 && pctx
->exchprovctx
== NULL
)
261 #ifndef OPENSSL_NO_ENGINE
262 /* Make sure it's safe to copy a pkey context using an ENGINE */
263 if (pctx
->engine
&& !ENGINE_init(pctx
->engine
)) {
264 EVPerr(EVP_F_EVP_PKEY_CTX_DUP
, ERR_R_ENGINE_LIB
);
268 rctx
= OPENSSL_zalloc(sizeof(*rctx
));
270 EVPerr(EVP_F_EVP_PKEY_CTX_DUP
, ERR_R_MALLOC_FAILURE
);
274 if (pctx
->pkey
!= NULL
)
275 EVP_PKEY_up_ref(pctx
->pkey
);
276 rctx
->pkey
= pctx
->pkey
;
277 rctx
->operation
= pctx
->operation
;
279 if (pctx
->exchprovctx
!= NULL
) {
280 if (!ossl_assert(pctx
->exchange
!= NULL
))
282 rctx
->exchange
= pctx
->exchange
;
283 if (!EVP_KEYEXCH_up_ref(rctx
->exchange
)) {
287 rctx
->exchprovctx
= pctx
->exchange
->dupctx(pctx
->exchprovctx
);
288 if (rctx
->exchprovctx
== NULL
) {
289 EVP_KEYEXCH_free(rctx
->exchange
);
296 rctx
->pmeth
= pctx
->pmeth
;
297 #ifndef OPENSSL_NO_ENGINE
298 rctx
->engine
= pctx
->engine
;
302 EVP_PKEY_up_ref(pctx
->peerkey
);
303 rctx
->peerkey
= pctx
->peerkey
;
305 if (pctx
->pmeth
->copy(rctx
, pctx
) > 0)
309 EVP_PKEY_CTX_free(rctx
);
314 int EVP_PKEY_meth_add0(const EVP_PKEY_METHOD
*pmeth
)
316 if (app_pkey_methods
== NULL
) {
317 app_pkey_methods
= sk_EVP_PKEY_METHOD_new(pmeth_cmp
);
318 if (app_pkey_methods
== NULL
){
319 EVPerr(EVP_F_EVP_PKEY_METH_ADD0
, ERR_R_MALLOC_FAILURE
);
323 if (!sk_EVP_PKEY_METHOD_push(app_pkey_methods
, pmeth
)) {
324 EVPerr(EVP_F_EVP_PKEY_METH_ADD0
, ERR_R_MALLOC_FAILURE
);
327 sk_EVP_PKEY_METHOD_sort(app_pkey_methods
);
331 void evp_app_cleanup_int(void)
333 if (app_pkey_methods
!= NULL
)
334 sk_EVP_PKEY_METHOD_pop_free(app_pkey_methods
, EVP_PKEY_meth_free
);
337 int EVP_PKEY_meth_remove(const EVP_PKEY_METHOD
*pmeth
)
339 const EVP_PKEY_METHOD
*ret
;
341 ret
= sk_EVP_PKEY_METHOD_delete_ptr(app_pkey_methods
, pmeth
);
343 return ret
== NULL
? 0 : 1;
346 size_t EVP_PKEY_meth_get_count(void)
348 size_t rv
= OSSL_NELEM(standard_methods
);
350 if (app_pkey_methods
)
351 rv
+= sk_EVP_PKEY_METHOD_num(app_pkey_methods
);
355 const EVP_PKEY_METHOD
*EVP_PKEY_meth_get0(size_t idx
)
357 if (idx
< OSSL_NELEM(standard_methods
))
358 return standard_methods
[idx
];
359 if (app_pkey_methods
== NULL
)
361 idx
-= OSSL_NELEM(standard_methods
);
362 if (idx
>= (size_t)sk_EVP_PKEY_METHOD_num(app_pkey_methods
))
364 return sk_EVP_PKEY_METHOD_value(app_pkey_methods
, idx
);
367 void EVP_PKEY_CTX_free(EVP_PKEY_CTX
*ctx
)
371 if (ctx
->pmeth
&& ctx
->pmeth
->cleanup
)
372 ctx
->pmeth
->cleanup(ctx
);
374 if (ctx
->exchprovctx
!= NULL
&& ctx
->exchange
!= NULL
)
375 ctx
->exchange
->freectx(ctx
->exchprovctx
);
377 EVP_KEYEXCH_free(ctx
->exchange
);
379 EVP_PKEY_free(ctx
->pkey
);
380 EVP_PKEY_free(ctx
->peerkey
);
381 #ifndef OPENSSL_NO_ENGINE
382 ENGINE_finish(ctx
->engine
);
387 int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX
*ctx
, int keytype
, int optype
,
388 int cmd
, int p1
, void *p2
)
392 if (!ctx
|| !ctx
->pmeth
|| !ctx
->pmeth
->ctrl
) {
393 EVPerr(EVP_F_EVP_PKEY_CTX_CTRL
, EVP_R_COMMAND_NOT_SUPPORTED
);
396 if ((keytype
!= -1) && (ctx
->pmeth
->pkey_id
!= keytype
))
399 /* Skip the operation checks since this is called in a very early stage */
400 if (ctx
->pmeth
->digest_custom
!= NULL
)
403 if (ctx
->operation
== EVP_PKEY_OP_UNDEFINED
) {
404 EVPerr(EVP_F_EVP_PKEY_CTX_CTRL
, EVP_R_NO_OPERATION_SET
);
408 if ((optype
!= -1) && !(ctx
->operation
& optype
)) {
409 EVPerr(EVP_F_EVP_PKEY_CTX_CTRL
, EVP_R_INVALID_OPERATION
);
414 ret
= ctx
->pmeth
->ctrl(ctx
, cmd
, p1
, p2
);
417 EVPerr(EVP_F_EVP_PKEY_CTX_CTRL
, EVP_R_COMMAND_NOT_SUPPORTED
);
422 int EVP_PKEY_CTX_ctrl_uint64(EVP_PKEY_CTX
*ctx
, int keytype
, int optype
,
423 int cmd
, uint64_t value
)
425 return EVP_PKEY_CTX_ctrl(ctx
, keytype
, optype
, cmd
, 0, &value
);
428 int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX
*ctx
,
429 const char *name
, const char *value
)
431 if (!ctx
|| !ctx
->pmeth
|| !ctx
->pmeth
->ctrl_str
) {
432 EVPerr(EVP_F_EVP_PKEY_CTX_CTRL_STR
, EVP_R_COMMAND_NOT_SUPPORTED
);
435 if (strcmp(name
, "digest") == 0)
436 return EVP_PKEY_CTX_md(ctx
, EVP_PKEY_OP_TYPE_SIG
, EVP_PKEY_CTRL_MD
,
438 return ctx
->pmeth
->ctrl_str(ctx
, name
, value
);
441 /* Utility functions to send a string of hex string to a ctrl */
443 int EVP_PKEY_CTX_str2ctrl(EVP_PKEY_CTX
*ctx
, int cmd
, const char *str
)
450 return ctx
->pmeth
->ctrl(ctx
, cmd
, len
, (void *)str
);
453 int EVP_PKEY_CTX_hex2ctrl(EVP_PKEY_CTX
*ctx
, int cmd
, const char *hex
)
459 bin
= OPENSSL_hexstr2buf(hex
, &binlen
);
462 if (binlen
<= INT_MAX
)
463 rv
= ctx
->pmeth
->ctrl(ctx
, cmd
, binlen
, bin
);
468 /* Pass a message digest to a ctrl */
469 int EVP_PKEY_CTX_md(EVP_PKEY_CTX
*ctx
, int optype
, int cmd
, const char *md
)
473 if (md
== NULL
|| (m
= EVP_get_digestbyname(md
)) == NULL
) {
474 EVPerr(EVP_F_EVP_PKEY_CTX_MD
, EVP_R_INVALID_DIGEST
);
477 return EVP_PKEY_CTX_ctrl(ctx
, -1, optype
, cmd
, 0, (void *)m
);
480 int EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX
*ctx
)
482 return ctx
->operation
;
485 void EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX
*ctx
, int *dat
, int datlen
)
487 ctx
->keygen_info
= dat
;
488 ctx
->keygen_info_count
= datlen
;
491 void EVP_PKEY_CTX_set_data(EVP_PKEY_CTX
*ctx
, void *data
)
496 void *EVP_PKEY_CTX_get_data(const EVP_PKEY_CTX
*ctx
)
501 EVP_PKEY
*EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX
*ctx
)
506 EVP_PKEY
*EVP_PKEY_CTX_get0_peerkey(EVP_PKEY_CTX
*ctx
)
511 void EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX
*ctx
, void *data
)
513 ctx
->app_data
= data
;
516 void *EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX
*ctx
)
518 return ctx
->app_data
;
521 void EVP_PKEY_meth_set_init(EVP_PKEY_METHOD
*pmeth
,
522 int (*init
) (EVP_PKEY_CTX
*ctx
))
527 void EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD
*pmeth
,
528 int (*copy
) (EVP_PKEY_CTX
*dst
,
529 const EVP_PKEY_CTX
*src
))
534 void EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD
*pmeth
,
535 void (*cleanup
) (EVP_PKEY_CTX
*ctx
))
537 pmeth
->cleanup
= cleanup
;
540 void EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD
*pmeth
,
541 int (*paramgen_init
) (EVP_PKEY_CTX
*ctx
),
542 int (*paramgen
) (EVP_PKEY_CTX
*ctx
,
545 pmeth
->paramgen_init
= paramgen_init
;
546 pmeth
->paramgen
= paramgen
;
549 void EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD
*pmeth
,
550 int (*keygen_init
) (EVP_PKEY_CTX
*ctx
),
551 int (*keygen
) (EVP_PKEY_CTX
*ctx
,
554 pmeth
->keygen_init
= keygen_init
;
555 pmeth
->keygen
= keygen
;
558 void EVP_PKEY_meth_set_sign(EVP_PKEY_METHOD
*pmeth
,
559 int (*sign_init
) (EVP_PKEY_CTX
*ctx
),
560 int (*sign
) (EVP_PKEY_CTX
*ctx
,
561 unsigned char *sig
, size_t *siglen
,
562 const unsigned char *tbs
,
565 pmeth
->sign_init
= sign_init
;
569 void EVP_PKEY_meth_set_verify(EVP_PKEY_METHOD
*pmeth
,
570 int (*verify_init
) (EVP_PKEY_CTX
*ctx
),
571 int (*verify
) (EVP_PKEY_CTX
*ctx
,
572 const unsigned char *sig
,
574 const unsigned char *tbs
,
577 pmeth
->verify_init
= verify_init
;
578 pmeth
->verify
= verify
;
581 void EVP_PKEY_meth_set_verify_recover(EVP_PKEY_METHOD
*pmeth
,
582 int (*verify_recover_init
) (EVP_PKEY_CTX
584 int (*verify_recover
) (EVP_PKEY_CTX
593 pmeth
->verify_recover_init
= verify_recover_init
;
594 pmeth
->verify_recover
= verify_recover
;
597 void EVP_PKEY_meth_set_signctx(EVP_PKEY_METHOD
*pmeth
,
598 int (*signctx_init
) (EVP_PKEY_CTX
*ctx
,
600 int (*signctx
) (EVP_PKEY_CTX
*ctx
,
605 pmeth
->signctx_init
= signctx_init
;
606 pmeth
->signctx
= signctx
;
609 void EVP_PKEY_meth_set_verifyctx(EVP_PKEY_METHOD
*pmeth
,
610 int (*verifyctx_init
) (EVP_PKEY_CTX
*ctx
,
612 int (*verifyctx
) (EVP_PKEY_CTX
*ctx
,
613 const unsigned char *sig
,
617 pmeth
->verifyctx_init
= verifyctx_init
;
618 pmeth
->verifyctx
= verifyctx
;
621 void EVP_PKEY_meth_set_encrypt(EVP_PKEY_METHOD
*pmeth
,
622 int (*encrypt_init
) (EVP_PKEY_CTX
*ctx
),
623 int (*encryptfn
) (EVP_PKEY_CTX
*ctx
,
626 const unsigned char *in
,
629 pmeth
->encrypt_init
= encrypt_init
;
630 pmeth
->encrypt
= encryptfn
;
633 void EVP_PKEY_meth_set_decrypt(EVP_PKEY_METHOD
*pmeth
,
634 int (*decrypt_init
) (EVP_PKEY_CTX
*ctx
),
635 int (*decrypt
) (EVP_PKEY_CTX
*ctx
,
638 const unsigned char *in
,
641 pmeth
->decrypt_init
= decrypt_init
;
642 pmeth
->decrypt
= decrypt
;
645 void EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD
*pmeth
,
646 int (*derive_init
) (EVP_PKEY_CTX
*ctx
),
647 int (*derive
) (EVP_PKEY_CTX
*ctx
,
651 pmeth
->derive_init
= derive_init
;
652 pmeth
->derive
= derive
;
655 void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD
*pmeth
,
656 int (*ctrl
) (EVP_PKEY_CTX
*ctx
, int type
, int p1
,
658 int (*ctrl_str
) (EVP_PKEY_CTX
*ctx
,
663 pmeth
->ctrl_str
= ctrl_str
;
666 void EVP_PKEY_meth_set_check(EVP_PKEY_METHOD
*pmeth
,
667 int (*check
) (EVP_PKEY
*pkey
))
669 pmeth
->check
= check
;
672 void EVP_PKEY_meth_set_public_check(EVP_PKEY_METHOD
*pmeth
,
673 int (*check
) (EVP_PKEY
*pkey
))
675 pmeth
->public_check
= check
;
678 void EVP_PKEY_meth_set_param_check(EVP_PKEY_METHOD
*pmeth
,
679 int (*check
) (EVP_PKEY
*pkey
))
681 pmeth
->param_check
= check
;
684 void EVP_PKEY_meth_set_digest_custom(EVP_PKEY_METHOD
*pmeth
,
685 int (*digest_custom
) (EVP_PKEY_CTX
*ctx
,
688 pmeth
->digest_custom
= digest_custom
;
691 void EVP_PKEY_meth_get_init(const EVP_PKEY_METHOD
*pmeth
,
692 int (**pinit
) (EVP_PKEY_CTX
*ctx
))
694 *pinit
= pmeth
->init
;
697 void EVP_PKEY_meth_get_copy(const EVP_PKEY_METHOD
*pmeth
,
698 int (**pcopy
) (EVP_PKEY_CTX
*dst
,
699 const EVP_PKEY_CTX
*src
))
701 *pcopy
= pmeth
->copy
;
704 void EVP_PKEY_meth_get_cleanup(const EVP_PKEY_METHOD
*pmeth
,
705 void (**pcleanup
) (EVP_PKEY_CTX
*ctx
))
707 *pcleanup
= pmeth
->cleanup
;
710 void EVP_PKEY_meth_get_paramgen(const EVP_PKEY_METHOD
*pmeth
,
711 int (**pparamgen_init
) (EVP_PKEY_CTX
*ctx
),
712 int (**pparamgen
) (EVP_PKEY_CTX
*ctx
,
716 *pparamgen_init
= pmeth
->paramgen_init
;
718 *pparamgen
= pmeth
->paramgen
;
721 void EVP_PKEY_meth_get_keygen(const EVP_PKEY_METHOD
*pmeth
,
722 int (**pkeygen_init
) (EVP_PKEY_CTX
*ctx
),
723 int (**pkeygen
) (EVP_PKEY_CTX
*ctx
,
727 *pkeygen_init
= pmeth
->keygen_init
;
729 *pkeygen
= pmeth
->keygen
;
732 void EVP_PKEY_meth_get_sign(const EVP_PKEY_METHOD
*pmeth
,
733 int (**psign_init
) (EVP_PKEY_CTX
*ctx
),
734 int (**psign
) (EVP_PKEY_CTX
*ctx
,
735 unsigned char *sig
, size_t *siglen
,
736 const unsigned char *tbs
,
740 *psign_init
= pmeth
->sign_init
;
742 *psign
= pmeth
->sign
;
745 void EVP_PKEY_meth_get_verify(const EVP_PKEY_METHOD
*pmeth
,
746 int (**pverify_init
) (EVP_PKEY_CTX
*ctx
),
747 int (**pverify
) (EVP_PKEY_CTX
*ctx
,
748 const unsigned char *sig
,
750 const unsigned char *tbs
,
754 *pverify_init
= pmeth
->verify_init
;
756 *pverify
= pmeth
->verify
;
759 void EVP_PKEY_meth_get_verify_recover(const EVP_PKEY_METHOD
*pmeth
,
760 int (**pverify_recover_init
) (EVP_PKEY_CTX
762 int (**pverify_recover
) (EVP_PKEY_CTX
771 if (pverify_recover_init
)
772 *pverify_recover_init
= pmeth
->verify_recover_init
;
774 *pverify_recover
= pmeth
->verify_recover
;
777 void EVP_PKEY_meth_get_signctx(const EVP_PKEY_METHOD
*pmeth
,
778 int (**psignctx_init
) (EVP_PKEY_CTX
*ctx
,
780 int (**psignctx
) (EVP_PKEY_CTX
*ctx
,
786 *psignctx_init
= pmeth
->signctx_init
;
788 *psignctx
= pmeth
->signctx
;
791 void EVP_PKEY_meth_get_verifyctx(const EVP_PKEY_METHOD
*pmeth
,
792 int (**pverifyctx_init
) (EVP_PKEY_CTX
*ctx
,
794 int (**pverifyctx
) (EVP_PKEY_CTX
*ctx
,
795 const unsigned char *sig
,
800 *pverifyctx_init
= pmeth
->verifyctx_init
;
802 *pverifyctx
= pmeth
->verifyctx
;
805 void EVP_PKEY_meth_get_encrypt(const EVP_PKEY_METHOD
*pmeth
,
806 int (**pencrypt_init
) (EVP_PKEY_CTX
*ctx
),
807 int (**pencryptfn
) (EVP_PKEY_CTX
*ctx
,
810 const unsigned char *in
,
814 *pencrypt_init
= pmeth
->encrypt_init
;
816 *pencryptfn
= pmeth
->encrypt
;
819 void EVP_PKEY_meth_get_decrypt(const EVP_PKEY_METHOD
*pmeth
,
820 int (**pdecrypt_init
) (EVP_PKEY_CTX
*ctx
),
821 int (**pdecrypt
) (EVP_PKEY_CTX
*ctx
,
824 const unsigned char *in
,
828 *pdecrypt_init
= pmeth
->decrypt_init
;
830 *pdecrypt
= pmeth
->decrypt
;
833 void EVP_PKEY_meth_get_derive(const EVP_PKEY_METHOD
*pmeth
,
834 int (**pderive_init
) (EVP_PKEY_CTX
*ctx
),
835 int (**pderive
) (EVP_PKEY_CTX
*ctx
,
840 *pderive_init
= pmeth
->derive_init
;
842 *pderive
= pmeth
->derive
;
845 void EVP_PKEY_meth_get_ctrl(const EVP_PKEY_METHOD
*pmeth
,
846 int (**pctrl
) (EVP_PKEY_CTX
*ctx
, int type
, int p1
,
848 int (**pctrl_str
) (EVP_PKEY_CTX
*ctx
,
853 *pctrl
= pmeth
->ctrl
;
855 *pctrl_str
= pmeth
->ctrl_str
;
858 void EVP_PKEY_meth_get_check(const EVP_PKEY_METHOD
*pmeth
,
859 int (**pcheck
) (EVP_PKEY
*pkey
))
862 *pcheck
= pmeth
->check
;
865 void EVP_PKEY_meth_get_public_check(const EVP_PKEY_METHOD
*pmeth
,
866 int (**pcheck
) (EVP_PKEY
*pkey
))
869 *pcheck
= pmeth
->public_check
;
872 void EVP_PKEY_meth_get_param_check(const EVP_PKEY_METHOD
*pmeth
,
873 int (**pcheck
) (EVP_PKEY
*pkey
))
876 *pcheck
= pmeth
->param_check
;
879 void EVP_PKEY_meth_get_digest_custom(EVP_PKEY_METHOD
*pmeth
,
880 int (**pdigest_custom
) (EVP_PKEY_CTX
*ctx
,
883 if (pdigest_custom
!= NULL
)
884 *pdigest_custom
= pmeth
->digest_custom
;