diff options
author | Vitaly Chikunov <vt@altlinux.org> | 2020-05-12 02:16:25 +0300 |
---|---|---|
committer | Dmitry Belyavskiy <beldmit@users.noreply.github.com> | 2020-05-12 12:55:47 +0300 |
commit | 96c69fa1d20a9d7b9c025364239b77ca0fa6763e (patch) | |
tree | 03d30a289a996a14d22da2b478a7057bf6d8a63f | |
parent | 499aa8754cf2200d7c83dfea16e7602c9c60d673 (diff) | |
download | gost-engine-96c69fa1d20a9d7b9c025364239b77ca0fa6763e.zip gost-engine-96c69fa1d20a9d7b9c025364239b77ca0fa6763e.tar.gz gost-engine-96c69fa1d20a9d7b9c025364239b77ca0fa6763e.tar.bz2 |
gost_crypt: Add Gost28147_89_cnt_cipher
-rw-r--r-- | gost_crypt.c | 51 | ||||
-rw-r--r-- | gost_eng.c | 3 | ||||
-rw-r--r-- | gost_lcl.h | 1 |
3 files changed, 21 insertions, 34 deletions
diff --git a/gost_crypt.c b/gost_crypt.c index 943d873..d35be33 100644 --- a/gost_crypt.c +++ b/gost_crypt.c @@ -137,39 +137,24 @@ GOST_cipher Gost28147_89_cbc_cipher = { .ctrl = gost_cipher_ctl, }; -static EVP_CIPHER *_hidden_gost89_cnt = NULL; -const EVP_CIPHER *cipher_gost_cpacnt(void) -{ - if (_hidden_gost89_cnt == NULL - && ((_hidden_gost89_cnt = - EVP_CIPHER_meth_new(NID_gost89_cnt, 1 /* block_size */ , - 32 /* key_size */ )) == NULL - || !EVP_CIPHER_meth_set_iv_length(_hidden_gost89_cnt, 8) - || !EVP_CIPHER_meth_set_flags(_hidden_gost89_cnt, - 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, - gost_cipher_init_cpa) - || !EVP_CIPHER_meth_set_do_cipher(_hidden_gost89_cnt, - gost_cipher_do_cnt) - || !EVP_CIPHER_meth_set_cleanup(_hidden_gost89_cnt, - gost_cipher_cleanup) - || !EVP_CIPHER_meth_set_impl_ctx_size(_hidden_gost89_cnt, - sizeof(struct - ossl_gost_cipher_ctx)) - || !EVP_CIPHER_meth_set_set_asn1_params(_hidden_gost89_cnt, - gost89_set_asn1_parameters) - || !EVP_CIPHER_meth_set_get_asn1_params(_hidden_gost89_cnt, - gost89_get_asn1_parameters) - || !EVP_CIPHER_meth_set_ctrl(_hidden_gost89_cnt, gost_cipher_ctl))) { - EVP_CIPHER_meth_free(_hidden_gost89_cnt); - _hidden_gost89_cnt = NULL; - } - return _hidden_gost89_cnt; -} +GOST_cipher Gost28147_89_cnt_cipher = { + .nid = NID_gost89_cnt, + .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_cpa, + .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_gost89_cnt_12 = NULL; const EVP_CIPHER *cipher_gost_cpcnt_12(void) @@ -118,7 +118,8 @@ static struct gost_cipher_minfo { }, { NID_gost89_cnt, - cipher_gost_cpacnt, + NULL, + &Gost28147_89_cnt_cipher, }, { NID_gost89_cnt_12, @@ -343,5 +343,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; #endif /* vim: set expandtab cinoptions=\:0,l1,t0,g0,(0 sw=4 : */ |