]> wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
gost_crypt: Add magma_ctr_acpkm_omac_cipher
authorVitaly Chikunov <vt@altlinux.org>
Mon, 11 May 2020 23:32:00 +0000 (02:32 +0300)
committerDmitry Belyavskiy <beldmit@users.noreply.github.com>
Tue, 12 May 2020 09:55:47 +0000 (12:55 +0300)
gost_crypt.c
gost_eng.c
gost_lcl.h

index 4fac2b7eda5e05a9db0bd6cea7f5ad598a7b6533..c1516d7cc51f1c05284cf13f01a11a70acafca2e 100644 (file)
@@ -213,41 +213,27 @@ GOST_cipher magma_ctr_acpkm_cipher = {
     .ctrl = magma_cipher_ctl,
 };
 
-static EVP_CIPHER *_hidden_magma_ctr_acpkm_omac = NULL;
-const EVP_CIPHER *cipher_magma_ctr_acpkm_omac(void)
-{
-    if (_hidden_magma_ctr_acpkm_omac == NULL
-        && ((_hidden_magma_ctr_acpkm_omac =
-             EVP_CIPHER_meth_new(NID_magma_ctr_acpkm_omac, 1 /* block_size */ ,
-                                 32 /* key_size */ )) == NULL
-            || !EVP_CIPHER_meth_set_iv_length(_hidden_magma_ctr_acpkm_omac, 4)
-            || !EVP_CIPHER_meth_set_flags(_hidden_magma_ctr_acpkm_omac,
-                                          EVP_CIPH_CTR_MODE |
-                                          EVP_CIPH_NO_PADDING |
-                                          EVP_CIPH_CUSTOM_IV |
-                                          EVP_CIPH_RAND_KEY |
-                                          EVP_CIPH_ALWAYS_CALL_INIT |
-                                                                                                                                                                       EVP_CIPH_CUSTOM_COPY |
-                                                                                                                                                                       EVP_CIPH_FLAG_CUSTOM_CIPHER |
-                                                                                                                                                                       EVP_CIPH_FLAG_CIPHER_WITH_MAC)
-            || !EVP_CIPHER_meth_set_init(_hidden_magma_ctr_acpkm_omac, magma_cipher_init_ctr_acpkm_omac)
-            || !EVP_CIPHER_meth_set_do_cipher(_hidden_magma_ctr_acpkm_omac,
-                                              magma_cipher_do_ctr_acpkm_omac)
-            || !EVP_CIPHER_meth_set_cleanup(_hidden_magma_ctr_acpkm_omac,
-                                            gost_cipher_cleanup)
-            || !EVP_CIPHER_meth_set_impl_ctx_size(_hidden_magma_ctr_acpkm_omac,
-                                                  sizeof(struct
-                                                         ossl_gost_cipher_ctx))
-            || !EVP_CIPHER_meth_set_set_asn1_params(_hidden_magma_ctr_acpkm_omac,
-                                                    magma_set_asn1_parameters)
-            || !EVP_CIPHER_meth_set_get_asn1_params(_hidden_magma_ctr_acpkm_omac,
-                                                    magma_get_asn1_parameters)
-            || !EVP_CIPHER_meth_set_ctrl(_hidden_magma_ctr_acpkm_omac, magma_cipher_ctl_acpkm_omac))) {
-        EVP_CIPHER_meth_free(_hidden_magma_ctr_acpkm_omac);
-        _hidden_magma_ctr_acpkm_omac = NULL;
-    }
-    return _hidden_magma_ctr_acpkm_omac;
-}
+GOST_cipher magma_ctr_acpkm_omac_cipher = {
+    .nid = NID_magma_ctr_acpkm_omac,
+    .block_size = 1,
+    .key_len = 32,
+    .iv_len = 4,
+    .flags = EVP_CIPH_CTR_MODE |
+        EVP_CIPH_NO_PADDING |
+        EVP_CIPH_CUSTOM_IV |
+        EVP_CIPH_RAND_KEY |
+        EVP_CIPH_ALWAYS_CALL_INIT |
+        EVP_CIPH_CUSTOM_COPY |
+        EVP_CIPH_FLAG_CUSTOM_CIPHER |
+        EVP_CIPH_FLAG_CIPHER_WITH_MAC,
+    .init = magma_cipher_init_ctr_acpkm_omac,
+    .do_cipher = magma_cipher_do_ctr_acpkm_omac,
+    .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 = magma_cipher_ctl_acpkm_omac,
+};
 
 static EVP_CIPHER *_hidden_magma_cbc = NULL;
 const EVP_CIPHER *cipher_magma_cbc(void)
index d3c0f748f1b2a39165fef69b29a3a81df0bc1643..1154701f5974a6aee5e20a2276850bf402a32140 100644 (file)
@@ -167,7 +167,8 @@ static struct gost_cipher_minfo {
     },
     {
         NID_magma_ctr_acpkm_omac,
-        cipher_magma_ctr_acpkm_omac,
+        NULL,
+       &magma_ctr_acpkm_omac_cipher,
     },
     {
         NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm,
index a271ae28e71b0bfc787c4d7e6e8e06aaf20ddcbd..1591614cb719103f45b8040a6de6259fd6100b9a 100644 (file)
@@ -347,5 +347,6 @@ extern GOST_cipher Gost28147_89_cnt_cipher;
 extern GOST_cipher Gost28147_89_cnt_12_cipher;
 extern GOST_cipher magma_ctr_cipher;
 extern GOST_cipher magma_ctr_acpkm_cipher;
+extern GOST_cipher magma_ctr_acpkm_omac_cipher;
 #endif
 /* vim: set expandtab cinoptions=\:0,l1,t0,g0,(0 sw=4 : */