From: Vitaly Chikunov Date: Mon, 11 May 2020 23:19:45 +0000 (+0300) Subject: gost_crypt: Add Gost28147_89_cnt_12_cipher X-Git-Tag: v3.0.0~113 X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=ac616531eb3a22e7926fe0f01c11e1631923b261;p=openssl-gost%2Fengine.git gost_crypt: Add Gost28147_89_cnt_12_cipher --- diff --git a/gost_crypt.c b/gost_crypt.c index d35be33..ab5197e 100644 --- a/gost_crypt.c +++ b/gost_crypt.c @@ -156,40 +156,24 @@ GOST_cipher Gost28147_89_cnt_cipher = { .ctrl = gost_cipher_ctl, }; -static EVP_CIPHER *_hidden_gost89_cnt_12 = NULL; -const EVP_CIPHER *cipher_gost_cpcnt_12(void) -{ - if (_hidden_gost89_cnt_12 == NULL - && ((_hidden_gost89_cnt_12 = - EVP_CIPHER_meth_new(NID_gost89_cnt_12, 1 /* block_size */ , - 32 /* key_size */ )) == NULL - || !EVP_CIPHER_meth_set_iv_length(_hidden_gost89_cnt_12, 8) - || !EVP_CIPHER_meth_set_flags(_hidden_gost89_cnt_12, - EVP_CIPH_OFB_MODE | - EVP_CIPH_NO_PADDING | - EVP_CIPH_CUSTOM_IV | - EVP_CIPH_RAND_KEY | - EVP_CIPH_ALWAYS_CALL_INIT) - || !EVP_CIPHER_meth_set_init(_hidden_gost89_cnt_12, - gost_cipher_init_cp_12) - || !EVP_CIPHER_meth_set_do_cipher(_hidden_gost89_cnt_12, - gost_cipher_do_cnt) - || !EVP_CIPHER_meth_set_cleanup(_hidden_gost89_cnt_12, - gost_cipher_cleanup) - || !EVP_CIPHER_meth_set_impl_ctx_size(_hidden_gost89_cnt_12, - sizeof(struct - ossl_gost_cipher_ctx)) - || !EVP_CIPHER_meth_set_set_asn1_params(_hidden_gost89_cnt_12, - gost89_set_asn1_parameters) - || !EVP_CIPHER_meth_set_get_asn1_params(_hidden_gost89_cnt_12, - gost89_get_asn1_parameters) - || !EVP_CIPHER_meth_set_ctrl(_hidden_gost89_cnt_12, - gost_cipher_ctl))) { - EVP_CIPHER_meth_free(_hidden_gost89_cnt_12); - _hidden_gost89_cnt_12 = NULL; - } - return _hidden_gost89_cnt_12; -} +GOST_cipher Gost28147_89_cnt_12_cipher = { + .nid = NID_gost89_cnt_12, + .block_size = 1, + .key_len = 32, + .iv_len = 8, + .flags = EVP_CIPH_OFB_MODE | + EVP_CIPH_NO_PADDING | + EVP_CIPH_CUSTOM_IV | + EVP_CIPH_RAND_KEY | + EVP_CIPH_ALWAYS_CALL_INIT, + .init = gost_cipher_init_cp_12, + .do_cipher = gost_cipher_do_cnt, + .cleanup = gost_cipher_cleanup, + .ctx_size = sizeof(struct ossl_gost_cipher_ctx), + .set_asn1_parameters = gost89_set_asn1_parameters, + .get_asn1_parameters = gost89_get_asn1_parameters, + .ctrl = gost_cipher_ctl, +}; static EVP_CIPHER *_hidden_magma_ctr = NULL; const EVP_CIPHER *cipher_magma_ctr(void) diff --git a/gost_eng.c b/gost_eng.c index 2363239..fb71d3b 100644 --- a/gost_eng.c +++ b/gost_eng.c @@ -123,7 +123,8 @@ static struct gost_cipher_minfo { }, { NID_gost89_cnt_12, - cipher_gost_cpcnt_12, + NULL, + &Gost28147_89_cnt_12_cipher, }, { NID_gost89_cbc, diff --git a/gost_lcl.h b/gost_lcl.h index e117f9f..0369f82 100644 --- a/gost_lcl.h +++ b/gost_lcl.h @@ -344,5 +344,6 @@ void GOST_deinit_cipher(GOST_cipher *c); extern GOST_cipher Gost28147_89_cipher; extern GOST_cipher Gost28147_89_cbc_cipher; extern GOST_cipher Gost28147_89_cnt_cipher; +extern GOST_cipher Gost28147_89_cnt_12_cipher; #endif /* vim: set expandtab cinoptions=\:0,l1,t0,g0,(0 sw=4 : */