X-Git-Url: http://wagner.pp.ru/gitweb/?a=blobdiff_plain;f=gost_eng.c;h=69f99757c2ae704a324930297ee71eef0502963e;hb=refs%2Fheads%2Fgost_provider;hp=ba67fda6181854d427a341546e9e2e62b0136a69;hpb=37e242a6a246cbf51d0e7f16f11f122a8c2051eb;p=openssl-gost%2Fengine.git diff --git a/gost_eng.c b/gost_eng.c index ba67fda..69f9975 100644 --- a/gost_eng.c +++ b/gost_eng.c @@ -48,11 +48,13 @@ static int gost_cipher_nids[] = { NID_grasshopper_ofb, NID_grasshopper_ctr, NID_magma_cbc, + NID_magma_ctr, + NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm, 0 }; static int gost_digest_nids(const int** nids) { - static int digest_nids[8] = {0, 0, 0, 0, 0, 0, 0, 0}; + static int digest_nids[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; static int pos = 0; static int init = 0; @@ -72,7 +74,10 @@ static int gost_digest_nids(const int** nids) { digest_nids[pos++] = EVP_MD_type(md); if ((md = grasshopper_omac()) != NULL) digest_nids[pos++] = EVP_MD_type(md); - +/* if ((md = magma_omac_acpkm()) != NULL) + digest_nids[pos++] = EVP_MD_type(md);*/ + if ((md = grasshopper_omac_acpkm()) != NULL) + digest_nids[pos++] = EVP_MD_type(md); digest_nids[pos] = 0; init = 1; @@ -89,6 +94,8 @@ static int gost_pkey_meth_nids[] = { NID_gost_mac_12, NID_magma_mac, NID_grasshopper_mac, + NID_id_tc26_cipher_gostr3412_2015_magma_ctracpkm_omac, + NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac, 0 }; @@ -96,13 +103,15 @@ static EVP_PKEY_METHOD* pmeth_GostR3410_2001 = NULL, * pmeth_GostR3410_2012_256 = NULL, * pmeth_GostR3410_2012_512 = NULL, * pmeth_Gost28147_MAC = NULL, * pmeth_Gost28147_MAC_12 = NULL, - * pmeth_magma_mac = NULL, * pmeth_grasshopper_mac = NULL; + * pmeth_magma_mac = NULL, * pmeth_grasshopper_mac = NULL, + * pmeth_magma_mac_acpkm = NULL, * pmeth_grasshopper_mac_acpkm = NULL; static EVP_PKEY_ASN1_METHOD* ameth_GostR3410_2001 = NULL, * ameth_GostR3410_2012_256 = NULL, * ameth_GostR3410_2012_512 = NULL, * ameth_Gost28147_MAC = NULL, * ameth_Gost28147_MAC_12 = NULL, - * ameth_magma_mac = NULL, * ameth_grasshopper_mac = NULL; + * ameth_magma_mac = NULL, * ameth_grasshopper_mac = NULL, + * ameth_magma_mac_acpkm = NULL, * ameth_grasshopper_mac_acpkm = NULL; static int gost_engine_init(ENGINE* e) { return 1; @@ -113,38 +122,46 @@ static int gost_engine_finish(ENGINE* e) { } static int gost_engine_destroy(ENGINE* e) { - digest_gost_destroy(); - digest_gost2012_256_destroy(); - digest_gost2012_512_destroy(); - - imit_gost_cpa_destroy(); - imit_gost_cp_12_destroy(); - magma_omac_destroy(); - grasshopper_omac_destroy(); - - cipher_gost_destroy(); - - gost_param_free(); - - pmeth_GostR3410_2001 = NULL; - pmeth_Gost28147_MAC = NULL; - pmeth_GostR3410_2012_256 = NULL; - pmeth_GostR3410_2012_512 = NULL; - pmeth_Gost28147_MAC_12 = NULL; - pmeth_magma_mac = NULL; - pmeth_grasshopper_mac = NULL; - - ameth_GostR3410_2001 = NULL; - ameth_Gost28147_MAC = NULL; - ameth_GostR3410_2012_256 = NULL; - ameth_GostR3410_2012_512 = NULL; - ameth_Gost28147_MAC_12 = NULL; - ameth_magma_mac = NULL; - ameth_grasshopper_mac = NULL; - - ERR_unload_GOST_strings(); - - return 1; + EVP_delete_digest_alias("streebog256"); + EVP_delete_digest_alias("streebog512"); + digest_gost_destroy(); + digest_gost2012_256_destroy(); + digest_gost2012_512_destroy(); + + imit_gost_cpa_destroy(); + imit_gost_cp_12_destroy(); + magma_omac_destroy(); + grasshopper_omac_destroy(); + grasshopper_omac_acpkm_destroy(); + + cipher_gost_destroy(); + cipher_gost_grasshopper_destroy(); + + gost_param_free(); + + pmeth_GostR3410_2001 = NULL; + pmeth_Gost28147_MAC = NULL; + pmeth_GostR3410_2012_256 = NULL; + pmeth_GostR3410_2012_512 = NULL; + pmeth_Gost28147_MAC_12 = NULL; + pmeth_magma_mac = NULL; + pmeth_grasshopper_mac = NULL; + pmeth_magma_mac_acpkm = NULL; + pmeth_grasshopper_mac_acpkm = NULL; + + ameth_GostR3410_2001 = NULL; + ameth_Gost28147_MAC = NULL; + ameth_GostR3410_2012_256 = NULL; + ameth_GostR3410_2012_512 = NULL; + ameth_Gost28147_MAC_12 = NULL; + ameth_magma_mac = NULL; + ameth_grasshopper_mac = NULL; + ameth_magma_mac_acpkm = NULL; + ameth_grasshopper_mac_acpkm = NULL; + + ERR_unload_GOST_strings(); + + return 1; } static int bind_gost(ENGINE* e, const char* id) { @@ -219,6 +236,13 @@ static int bind_gost(ENGINE* e, const char* id) { if (!register_ameth_gost(NID_grasshopper_mac, &ameth_grasshopper_mac, "GRASSHOPPER-MAC", "GOST R 34.13-2015 Grasshopper MAC")) goto end; +/* if (!register_ameth_gost(NID_id_tc26_cipher_gostr3412_2015_magma_ctracpkm_omac, &ameth_magma_mac_acpkm, + "ID-TC26-CIPHER-GOSTR3412-2015-MAGMA-CTRACPKM-OMAC", "GOST R 34.13-2015 Magma MAC ACPKM")) + goto end;*/ + if (!register_ameth_gost(NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac, &ameth_grasshopper_mac_acpkm, + "ID-TC26-CIPHER-GOSTR3412-2015-KUZNYECHIK-CTRACPKM-OMAC", "GOST R 34.13-2015 Grasshopper MAC ACPKM")) + goto end; + if (!register_pmeth_gost(NID_id_GostR3410_2001, &pmeth_GostR3410_2001, 0)) goto end; @@ -238,6 +262,10 @@ static int bind_gost(ENGINE* e, const char* id) { goto end; if (!register_pmeth_gost(NID_grasshopper_mac, &pmeth_grasshopper_mac, 0)) goto end; +/* if (!register_pmeth_gost(NID_magma_mac_acpkm, &pmeth_magma_mac_acpkm, 0)) + goto end;*/ + if (!register_pmeth_gost(NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac, &pmeth_grasshopper_mac_acpkm, 0)) + goto end; if (!ENGINE_register_ciphers(e) || !ENGINE_register_digests(e) || !ENGINE_register_pkey_meths(e) @@ -251,16 +279,27 @@ static int bind_gost(ENGINE* e, const char* id) { || !EVP_add_cipher(cipher_gost_grasshopper_cfb()) || !EVP_add_cipher(cipher_gost_grasshopper_ofb()) || !EVP_add_cipher(cipher_gost_grasshopper_ctr()) + || !EVP_add_cipher(cipher_gost_grasshopper_ctracpkm()) || !EVP_add_cipher(cipher_magma_cbc()) + || !EVP_add_cipher(cipher_magma_ctr()) || !EVP_add_digest(digest_gost()) || !EVP_add_digest(digest_gost2012_512()) || !EVP_add_digest(digest_gost2012_256()) || !EVP_add_digest(imit_gost_cpa()) || !EVP_add_digest(imit_gost_cp_12()) + || !EVP_add_digest(magma_omac()) + || !EVP_add_digest(grasshopper_omac()) +/* || !EVP_add_digest(magma_omac_acpkm()) */ + || !EVP_add_digest(grasshopper_omac_acpkm()) ) { goto end; } + if(!EVP_add_digest_alias(SN_id_GostR3411_2012_256, "streebog256") + || !EVP_add_digest_alias(SN_id_GostR3411_2012_512, "streebog512")) { + goto end; + } + ENGINE_register_all_complete(); ERR_load_GOST_strings(); @@ -294,6 +333,8 @@ static int gost_digests(ENGINE* e, const EVP_MD** digest, *digest = magma_omac(); } else if (nid == NID_grasshopper_mac) { *digest = grasshopper_omac(); + } else if (nid == NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac) { + *digest = grasshopper_omac_acpkm(); } else { ok = 0; *digest = NULL; @@ -327,8 +368,12 @@ static int gost_ciphers(ENGINE* e, const EVP_CIPHER** cipher, *cipher = cipher_gost_grasshopper_ofb(); } else if (nid == NID_grasshopper_ctr) { *cipher = cipher_gost_grasshopper_ctr(); + } else if (nid == NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm) { + *cipher = cipher_gost_grasshopper_ctracpkm(); } else if (nid == NID_magma_cbc) { *cipher = cipher_magma_cbc(); + } else if (nid == NID_magma_ctr) { + *cipher = cipher_magma_ctr(); } else { ok = 0; *cipher = NULL; @@ -365,6 +410,12 @@ static int gost_pkey_meths(ENGINE* e, EVP_PKEY_METHOD** pmeth, case NID_grasshopper_mac: *pmeth = pmeth_grasshopper_mac; return 1; + case NID_id_tc26_cipher_gostr3412_2015_magma_ctracpkm_omac: + *pmeth = pmeth_magma_mac_acpkm; + return 1; + case NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac: + *pmeth = pmeth_grasshopper_mac_acpkm; + return 1; default:; } @@ -402,6 +453,13 @@ static int gost_pkey_asn1_meths(ENGINE* e, EVP_PKEY_ASN1_METHOD** ameth, case NID_grasshopper_mac: *ameth = ameth_grasshopper_mac; return 1; + case NID_id_tc26_cipher_gostr3412_2015_magma_ctracpkm_omac: + *ameth = ameth_magma_mac_acpkm; + return 1; + case NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac: + *ameth = ameth_grasshopper_mac_acpkm; + return 1; + default:; }