1 /**********************************************************************
3 * Copyright (c) 2005-2013 Cryptocom LTD *
4 * This file is distributed under the same license as OpenSSL *
6 * Implementation of RFC 4357 (GOST R 34.10) Publick key method *
8 * Requires OpenSSL 1.0.0+ for compilation *
9 **********************************************************************/
10 #include <openssl/evp.h>
11 #include <openssl/objects.h>
12 #include <openssl/ec.h>
13 #include <openssl/err.h>
14 #include <openssl/x509v3.h> /* For string_to_hex */
19 #include "e_gost_err.h"
21 /* -----init, cleanup, copy - uniform for all algs --------------*/
22 /* Allocates new gost_pmeth_data structure and assigns it as data */
23 static int pkey_gost_init(EVP_PKEY_CTX *ctx)
25 struct gost_pmeth_data *data;
26 EVP_PKEY *pkey = EVP_PKEY_CTX_get0_pkey(ctx);
28 data = OPENSSL_malloc(sizeof(*data));
31 memset(data, 0, sizeof(*data));
32 if (pkey && EVP_PKEY_get0(pkey)) {
33 int id = (EVP_PKEY_base_id(pkey));
34 if (id == NID_id_GostR3410_2001 ||
35 id == NID_gost2012_256 ||
36 id == NID_gost2012_512)
38 const EC_GROUP *group =
39 EC_KEY_get0_group(EVP_PKEY_get0((EVP_PKEY *)pkey));
41 data->sign_param_nid = EC_GROUP_get_curve_name(group);
50 EVP_PKEY_CTX_set_data(ctx, data);
54 /* Copies contents of gost_pmeth_data structure */
55 static int pkey_gost_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
57 struct gost_pmeth_data *dst_data, *src_data;
58 if (!pkey_gost_init(dst)) {
61 src_data = EVP_PKEY_CTX_get_data(src);
62 dst_data = EVP_PKEY_CTX_get_data(dst);
63 if (!src_data || !dst_data)
66 *dst_data = *src_data;
67 if (src_data->shared_ukm) {
68 dst_data->shared_ukm = NULL;
73 /* Frees up gost_pmeth_data structure */
74 static void pkey_gost_cleanup(EVP_PKEY_CTX *ctx)
76 struct gost_pmeth_data *data = EVP_PKEY_CTX_get_data(ctx);
79 OPENSSL_free(data->shared_ukm);
83 /* --------------------- control functions ------------------------------*/
84 static int pkey_gost_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
86 struct gost_pmeth_data *pctx =
87 (struct gost_pmeth_data *)EVP_PKEY_CTX_get_data(ctx);
92 case EVP_PKEY_CTRL_MD:
94 EVP_PKEY *key = EVP_PKEY_CTX_get0_pkey(ctx);
95 int pkey_nid = (key == NULL) ? NID_undef : EVP_PKEY_base_id(key);
97 OPENSSL_assert(p2 != NULL);
99 int md_type = EVP_MD_type((const EVP_MD *)p2);
100 if (md_type == NID_id_GostR3411_94) {
101 if (pkey_nid == NID_id_GostR3410_2001
102 || pkey_nid == NID_id_GostR3410_94) {
103 pctx->md = (EVP_MD *)p2;
106 } else if (md_type == NID_md_gost12_256) {
107 if (pkey_nid == NID_gost2012_256) {
108 pctx->md = (EVP_MD *)p2;
111 } else if ( md_type == NID_md_gost12_512) {
112 if (pkey_nid == NID_gost2012_512) {
113 pctx->md = (EVP_MD *)p2;
118 GOSTerr(GOST_F_PKEY_GOST_CTRL, GOST_R_INVALID_DIGEST_TYPE);
121 #ifdef EVP_PKEY_CTRL_GET_MD
122 case EVP_PKEY_CTRL_GET_MD:
123 *(const EVP_MD **)p2 = pctx->md;
126 case EVP_PKEY_CTRL_PKCS7_ENCRYPT:
127 case EVP_PKEY_CTRL_PKCS7_DECRYPT:
128 case EVP_PKEY_CTRL_PKCS7_SIGN:
129 case EVP_PKEY_CTRL_DIGESTINIT:
130 #ifndef OPENSSL_NO_CMS
131 case EVP_PKEY_CTRL_CMS_ENCRYPT:
132 case EVP_PKEY_CTRL_CMS_DECRYPT:
133 case EVP_PKEY_CTRL_CMS_SIGN:
137 case EVP_PKEY_CTRL_GOST_PARAMSET:
138 pctx->sign_param_nid = (int)p1;
140 case EVP_PKEY_CTRL_SET_IV:
141 OPENSSL_assert(p2 != NULL);
142 pctx->shared_ukm = OPENSSL_malloc((int)p1);
143 if (!pctx->shared_ukm)
145 memcpy(pctx->shared_ukm, p2, (int)p1);
147 case EVP_PKEY_CTRL_PEER_KEY:
148 if (p1 == 0 || p1 == 1) /* call from EVP_PKEY_derive_set_peer */
150 if (p1 == 2) /* TLS: peer key used? */
151 return pctx->peer_key_used;
152 if (p1 == 3) /* TLS: peer key used! */
153 return (pctx->peer_key_used = 1);
157 GOSTerr(GOST_F_PKEY_GOST_CTRL, GOST_R_CTRL_CALL_FAILED);
161 static int pkey_gost_ec_ctrl_str_256(EVP_PKEY_CTX *ctx,
162 const char *type, const char *value)
166 if (strcmp(type, param_ctrl_string) == 0) {
170 if (strlen(value) == 1) {
171 switch (toupper((unsigned char)value[0])) {
173 param_nid = NID_id_GostR3410_2001_CryptoPro_A_ParamSet;
176 param_nid = NID_id_GostR3410_2001_CryptoPro_B_ParamSet;
179 param_nid = NID_id_GostR3410_2001_CryptoPro_C_ParamSet;
182 param_nid = NID_id_GostR3410_2001_TestParamSet;
187 } else if ((strlen(value) == 2)
188 && (toupper((unsigned char)value[0]) == 'X')) {
189 switch (toupper((unsigned char)value[1])) {
191 param_nid = NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet;
194 param_nid = NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet;
200 R3410_ec_params *p = R3410_2001_paramset;
201 param_nid = OBJ_txt2nid(value);
202 if (param_nid == NID_undef) {
205 for (; p->nid != NID_undef; p++) {
206 if (p->nid == param_nid)
209 if (p->nid == NID_undef) {
210 GOSTerr(GOST_F_PKEY_GOST_EC_CTRL_STR_256,
211 GOST_R_INVALID_PARAMSET);
216 return pkey_gost_ctrl(ctx, EVP_PKEY_CTRL_GOST_PARAMSET,
222 static int pkey_gost_ec_ctrl_str_512(EVP_PKEY_CTX *ctx,
223 const char *type, const char *value)
225 int param_nid = NID_undef;
227 if (strcmp(type, param_ctrl_string))
233 if (strlen(value) == 1) {
234 switch (toupper((unsigned char)value[0])) {
236 param_nid = NID_id_tc26_gost_3410_2012_512_paramSetA;
240 param_nid = NID_id_tc26_gost_3410_2012_512_paramSetB;
247 R3410_ec_params *p = R3410_2012_512_paramset;
248 param_nid = OBJ_txt2nid(value);
249 if (param_nid == NID_undef)
252 while (p->nid != NID_undef && p->nid != param_nid)
255 if (p->nid == NID_undef) {
256 GOSTerr(GOST_F_PKEY_GOST_EC_CTRL_STR_512,
257 GOST_R_INVALID_PARAMSET);
262 return pkey_gost_ctrl(ctx, EVP_PKEY_CTRL_GOST_PARAMSET, param_nid, NULL);
265 /* --------------------- key generation --------------------------------*/
267 static int pkey_gost_paramgen_init(EVP_PKEY_CTX *ctx)
272 static int pkey_gost2001_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
274 struct gost_pmeth_data *data = EVP_PKEY_CTX_get_data(ctx);
277 if (!data || data->sign_param_nid == NID_undef) {
278 GOSTerr(GOST_F_PKEY_GOST01_PARAMGEN, GOST_R_NO_PARAMETERS_SET);
283 if (!fill_GOST_EC_params(ec, data->sign_param_nid)
284 || !EVP_PKEY_assign(pkey, NID_id_GostR3410_2001, ec)) {
291 static int pkey_gost2012_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
293 struct gost_pmeth_data *data = EVP_PKEY_CTX_get_data(ctx);
297 if (!data || data->sign_param_nid == NID_undef) {
298 GOSTerr(GOST_F_PKEY_GOST12_PARAMGEN, GOST_R_NO_PARAMETERS_SET);
303 if (!fill_GOST_EC_params(ec, data->sign_param_nid)) {
308 if (data->sign_param_nid == NID_id_tc26_gost_3410_2012_512_paramSetA ||
309 data->sign_param_nid == NID_id_tc26_gost_3410_2012_512_paramSetB) {
311 (EVP_PKEY_assign(pkey, NID_gost2012_512, ec)) ? 1 : 0;
313 if (data->sign_param_nid == NID_id_GostR3410_2001_CryptoPro_A_ParamSet ||
314 data->sign_param_nid == NID_id_GostR3410_2001_CryptoPro_B_ParamSet ||
315 data->sign_param_nid == NID_id_GostR3410_2001_CryptoPro_C_ParamSet ||
316 data->sign_param_nid == NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet ||
317 data->sign_param_nid == NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet ||
318 data->sign_param_nid == NID_id_GostR3410_2001_TestParamSet) {
320 (EVP_PKEY_assign(pkey, NID_gost2012_256, ec)) ? 1 : 0;
329 /* ----------- keygen callbacks --------------------------------------*/
330 /* Generates GOST_R3410 2001 key and assigns it using specified type */
331 static int pkey_gost2001cp_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
334 if (!pkey_gost2001_paramgen(ctx, pkey))
336 ec = EVP_PKEY_get0(pkey);
341 /* Generates GOST_R3410 2012 key and assigns it using specified type */
342 static int pkey_gost2012cp_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
344 if (!pkey_gost2012_paramgen(ctx, pkey))
347 gost_ec_keygen(EVP_PKEY_get0(pkey));
351 /* ----------- sign callbacks --------------------------------------*/
353 * Packs signature according to Cryptopro rules
354 * and frees up DSA_SIG structure
356 int pack_sign_cp(DSA_SIG *s, int order, unsigned char *sig, size_t *siglen)
359 memset(sig, 0, *siglen);
360 store_bignum(s->s, sig, order);
361 store_bignum(s->r, sig + order, order);
366 static int pkey_gost_ec_cp_sign(EVP_PKEY_CTX *ctx, unsigned char *sig,
367 size_t *siglen, const unsigned char *tbs,
370 DSA_SIG *unpacked_sig = NULL;
371 EVP_PKEY *pkey = EVP_PKEY_CTX_get0_pkey(ctx);
373 int id = EVP_PKEY_base_id(pkey);
379 if (id == NID_id_GostR3410_2001 ||
380 id == NID_gost2012_256) {
382 } else if (id == NID_gost2012_512) {
392 unpacked_sig = gost_ec_sign(tbs, tbs_len, EVP_PKEY_get0(pkey));
396 return pack_sign_cp(unpacked_sig, order / 2, sig, siglen);
399 /* ------------------- verify callbacks ---------------------------*/
400 /* Unpack signature according to cryptopro rules */
401 DSA_SIG *unpack_cp_signature(const unsigned char *sig, size_t siglen)
407 GOSTerr(GOST_F_UNPACK_CP_SIGNATURE, ERR_R_MALLOC_FAILURE);
410 s->s = BN_bin2bn(sig, siglen / 2, NULL);
411 s->r = BN_bin2bn(sig + siglen / 2, siglen / 2, NULL);
415 static int pkey_gost_ec_cp_verify(EVP_PKEY_CTX *ctx, const unsigned char *sig,
416 size_t siglen, const unsigned char *tbs,
420 EVP_PKEY *pub_key = EVP_PKEY_CTX_get0_pkey(ctx);
421 DSA_SIG *s = (sig) ? unpack_cp_signature(sig, siglen) : NULL;
425 fprintf(stderr, "R=");
426 BN_print_fp(stderr, s->r);
427 fprintf(stderr, "\nS=");
428 BN_print_fp(stderr, s->s);
429 fprintf(stderr, "\n");
432 ok = gost_ec_verify(tbs, tbs_len, s, EVP_PKEY_get0(pub_key));
437 /* ------------- encrypt init -------------------------------------*/
438 /* Generates ephermeral key */
439 static int pkey_gost_encrypt_init(EVP_PKEY_CTX *ctx)
444 /* --------------- Derive init ------------------------------------*/
445 static int pkey_gost_derive_init(EVP_PKEY_CTX *ctx)
450 /* -------- PKEY_METHOD for GOST MAC algorithm --------------------*/
451 static int pkey_gost_mac_init(EVP_PKEY_CTX *ctx)
453 struct gost_mac_pmeth_data *data = OPENSSL_malloc(sizeof(*data));
457 memset(data, 0, sizeof(*data));
459 EVP_PKEY_CTX_set_data(ctx, data);
463 static void pkey_gost_mac_cleanup(EVP_PKEY_CTX *ctx)
465 struct gost_mac_pmeth_data *data = EVP_PKEY_CTX_get_data(ctx);
470 static int pkey_gost_mac_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
472 struct gost_mac_pmeth_data *dst_data, *src_data;
473 if (!pkey_gost_mac_init(dst)) {
476 src_data = EVP_PKEY_CTX_get_data(src);
477 dst_data = EVP_PKEY_CTX_get_data(dst);
478 if (!src_data || !dst_data)
481 *dst_data = *src_data;
485 static int pkey_gost_mac_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
487 struct gost_mac_pmeth_data *data =
488 (struct gost_mac_pmeth_data *)EVP_PKEY_CTX_get_data(ctx);
491 case EVP_PKEY_CTRL_MD:
493 int nid = EVP_MD_type((const EVP_MD *)p2);
494 if (nid != NID_id_Gost28147_89_MAC && nid != NID_gost_mac_12) {
495 GOSTerr(GOST_F_PKEY_GOST_MAC_CTRL,
496 GOST_R_INVALID_DIGEST_TYPE);
499 data->md = (EVP_MD *)p2;
502 #ifdef EVP_PKEY_CTRL_GET_MD
503 case EVP_PKEY_CTRL_GET_MD:
504 *(const EVP_MD **)p2 = data->md;
507 case EVP_PKEY_CTRL_PKCS7_ENCRYPT:
508 case EVP_PKEY_CTRL_PKCS7_DECRYPT:
509 case EVP_PKEY_CTRL_PKCS7_SIGN:
511 case EVP_PKEY_CTRL_SET_MAC_KEY:
513 GOSTerr(GOST_F_PKEY_GOST_MAC_CTRL, GOST_R_INVALID_MAC_KEY_LENGTH);
517 memcpy(data->key, p2, 32);
520 case EVP_PKEY_CTRL_DIGESTINIT:
522 EVP_MD_CTX *mctx = p2;
524 if (!data->key_set) {
525 EVP_PKEY *pkey = EVP_PKEY_CTX_get0_pkey(ctx);
527 GOSTerr(GOST_F_PKEY_GOST_MAC_CTRL,
528 GOST_R_MAC_KEY_NOT_SET);
531 key = EVP_PKEY_get0(pkey);
533 GOSTerr(GOST_F_PKEY_GOST_MAC_CTRL,
534 GOST_R_MAC_KEY_NOT_SET);
540 return mctx->digest->md_ctrl(mctx, EVP_MD_CTRL_SET_KEY, 32, key);
542 case EVP_PKEY_CTRL_MAC_LEN:
547 GOSTerr(GOST_F_PKEY_GOST_MAC_CTRL,GOST_R_INVALID_MAC_SIZE);
557 static int pkey_gost_mac_ctrl_str(EVP_PKEY_CTX *ctx,
558 const char *type, const char *value)
560 if (strcmp(type, key_ctrl_string) == 0) {
561 if (strlen(value) != 32) {
562 GOSTerr(GOST_F_PKEY_GOST_MAC_CTRL_STR,
563 GOST_R_INVALID_MAC_KEY_LENGTH);
566 return pkey_gost_mac_ctrl(ctx, EVP_PKEY_CTRL_SET_MAC_KEY,
569 if (strcmp(type, hexkey_ctrl_string) == 0) {
572 unsigned char *keybuf = string_to_hex(value, &keylen);
573 if (!keybuf || keylen != 32) {
574 GOSTerr(GOST_F_PKEY_GOST_MAC_CTRL_STR,
575 GOST_R_INVALID_MAC_KEY_LENGTH);
576 OPENSSL_free(keybuf);
579 ret = pkey_gost_mac_ctrl(ctx, EVP_PKEY_CTRL_SET_MAC_KEY, 32, keybuf);
580 OPENSSL_free(keybuf);
584 if (!strcmp(type,maclen_ctrl_string)) {
586 long size=strtol(value,&endptr,10);
588 GOSTerr(GOST_F_PKEY_GOST_MAC_CTRL_STR,
589 GOST_R_INVALID_MAC_SIZE);
592 return pkey_gost_mac_ctrl(ctx, EVP_PKEY_CTRL_MAC_LEN,size,NULL);
597 static int pkey_gost_mac_keygen_base(EVP_PKEY_CTX *ctx,
598 EVP_PKEY *pkey, int mac_nid)
600 struct gost_mac_pmeth_data *data = EVP_PKEY_CTX_get_data(ctx);
601 unsigned char *keydata;
602 if (!data || !data->key_set) {
603 GOSTerr(GOST_F_PKEY_GOST_MAC_KEYGEN, GOST_R_MAC_KEY_NOT_SET);
606 keydata = OPENSSL_malloc(32);
609 memcpy(keydata, data->key, 32);
610 EVP_PKEY_assign(pkey, mac_nid, keydata);
614 static int pkey_gost_mac_keygen_12(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
616 return pkey_gost_mac_keygen_base(ctx, pkey, NID_gost_mac_12);
619 static int pkey_gost_mac_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
621 return pkey_gost_mac_keygen_base(ctx, pkey, NID_id_Gost28147_89_MAC);
624 static int pkey_gost_mac_signctx_init(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx)
629 static int pkey_gost_mac_signctx(EVP_PKEY_CTX *ctx, unsigned char *sig,
630 size_t *siglen, EVP_MD_CTX *mctx)
632 unsigned int tmpsiglen;
634 struct gost_mac_pmeth_data *data = EVP_PKEY_CTX_get_data(ctx);
638 tmpsiglen = *siglen; /* for platforms where sizeof(int) !=
642 *siglen = data->mac_size;
646 mctx->digest->md_ctrl(mctx, EVP_MD_CTRL_MAC_LEN, data->mac_size, NULL);
647 ret = EVP_DigestFinal_ex(mctx, sig, &tmpsiglen);
648 *siglen = data->mac_size;
652 /* ----------------------------------------------------------------*/
653 int register_pmeth_gost(int id, EVP_PKEY_METHOD **pmeth, int flags)
655 *pmeth = EVP_PKEY_meth_new(id, flags);
659 if (id == NID_id_GostR3410_2001) {
660 EVP_PKEY_meth_set_ctrl(*pmeth,
661 pkey_gost_ctrl, pkey_gost_ec_ctrl_str_256);
662 EVP_PKEY_meth_set_sign(*pmeth, NULL, pkey_gost_ec_cp_sign);
663 EVP_PKEY_meth_set_verify(*pmeth, NULL, pkey_gost_ec_cp_verify);
665 EVP_PKEY_meth_set_keygen(*pmeth, NULL, pkey_gost2001cp_keygen);
667 EVP_PKEY_meth_set_encrypt(*pmeth,
668 pkey_gost_encrypt_init,
669 pkey_GOST_ECcp_encrypt);
670 EVP_PKEY_meth_set_decrypt(*pmeth, NULL, pkey_GOST_ECcp_decrypt);
671 EVP_PKEY_meth_set_derive(*pmeth,
672 pkey_gost_derive_init, pkey_gost_ec_derive);
673 EVP_PKEY_meth_set_paramgen(*pmeth, pkey_gost_paramgen_init,
674 pkey_gost2001_paramgen);
675 } else if (id == NID_gost2012_256) {
676 EVP_PKEY_meth_set_ctrl(*pmeth,
677 pkey_gost_ctrl, pkey_gost_ec_ctrl_str_256);
678 EVP_PKEY_meth_set_sign(*pmeth, NULL, pkey_gost_ec_cp_sign);
679 EVP_PKEY_meth_set_verify(*pmeth, NULL, pkey_gost_ec_cp_verify);
681 EVP_PKEY_meth_set_keygen(*pmeth, NULL, pkey_gost2012cp_keygen);
683 EVP_PKEY_meth_set_encrypt(*pmeth,
684 pkey_gost_encrypt_init,
685 pkey_GOST_ECcp_encrypt);
686 EVP_PKEY_meth_set_decrypt(*pmeth, NULL, pkey_GOST_ECcp_decrypt);
687 EVP_PKEY_meth_set_derive(*pmeth,
688 pkey_gost_derive_init, pkey_gost_ec_derive);
689 EVP_PKEY_meth_set_paramgen(*pmeth,
690 pkey_gost_paramgen_init,
691 pkey_gost2012_paramgen);
692 } else if (id == NID_gost2012_512 ) {
693 EVP_PKEY_meth_set_ctrl(*pmeth,
694 pkey_gost_ctrl, pkey_gost_ec_ctrl_str_512);
695 EVP_PKEY_meth_set_sign(*pmeth, NULL, pkey_gost_ec_cp_sign);
696 EVP_PKEY_meth_set_verify(*pmeth, NULL, pkey_gost_ec_cp_verify);
698 EVP_PKEY_meth_set_keygen(*pmeth, NULL, pkey_gost2012cp_keygen);
700 EVP_PKEY_meth_set_encrypt(*pmeth,
701 pkey_gost_encrypt_init,
702 pkey_GOST_ECcp_encrypt);
703 EVP_PKEY_meth_set_decrypt(*pmeth, NULL, pkey_GOST_ECcp_decrypt);
704 EVP_PKEY_meth_set_derive(*pmeth,
705 pkey_gost_derive_init, pkey_gost_ec_derive);
706 EVP_PKEY_meth_set_paramgen(*pmeth,
707 pkey_gost_paramgen_init,
708 pkey_gost2012_paramgen);
709 } else if (id == NID_id_Gost28147_89_MAC) {
710 EVP_PKEY_meth_set_ctrl(*pmeth, pkey_gost_mac_ctrl,
711 pkey_gost_mac_ctrl_str);
712 EVP_PKEY_meth_set_signctx(*pmeth, pkey_gost_mac_signctx_init,
713 pkey_gost_mac_signctx);
714 EVP_PKEY_meth_set_keygen(*pmeth, NULL, pkey_gost_mac_keygen);
715 EVP_PKEY_meth_set_init(*pmeth, pkey_gost_mac_init);
716 EVP_PKEY_meth_set_cleanup(*pmeth, pkey_gost_mac_cleanup);
717 EVP_PKEY_meth_set_copy(*pmeth, pkey_gost_mac_copy);
719 } else if (id == NID_gost_mac_12) {
720 EVP_PKEY_meth_set_ctrl(*pmeth, pkey_gost_mac_ctrl,
721 pkey_gost_mac_ctrl_str);
722 EVP_PKEY_meth_set_signctx(*pmeth, pkey_gost_mac_signctx_init,
723 pkey_gost_mac_signctx);
724 EVP_PKEY_meth_set_keygen(*pmeth, NULL, pkey_gost_mac_keygen_12);
725 EVP_PKEY_meth_set_init(*pmeth, pkey_gost_mac_init);
726 EVP_PKEY_meth_set_cleanup(*pmeth, pkey_gost_mac_cleanup);
727 EVP_PKEY_meth_set_copy(*pmeth, pkey_gost_mac_copy);
730 /* Unsupported method */
733 EVP_PKEY_meth_set_init(*pmeth, pkey_gost_init);
734 EVP_PKEY_meth_set_cleanup(*pmeth, pkey_gost_cleanup);
736 EVP_PKEY_meth_set_copy(*pmeth, pkey_gost_copy);
738 * FIXME derive etc...