+static GOST_cipher magma_template_cipher = {
+ .block_size = 8,
+ .key_len = 32,
+ .flags =
+ EVP_CIPH_RAND_KEY |
+ EVP_CIPH_ALWAYS_CALL_INIT,
+ .cleanup = gost_cipher_cleanup,
+ .ctx_size = sizeof(struct ossl_gost_cipher_ctx),
+ .set_asn1_parameters = magma_set_asn1_parameters,
+ .get_asn1_parameters = magma_get_asn1_parameters,
+ .do_cipher = magma_cipher_do_ctr,
+ .ctrl = magma_cipher_ctl,
+};
+
+GOST_cipher magma_ctr_cipher = {
+ .nid = NID_magma_ctr,
+ .template = &magma_template_cipher,
+ .block_size = 1,
+ .iv_len = 4,
+ .flags = EVP_CIPH_CTR_MODE |
+ EVP_CIPH_CUSTOM_IV |
+ EVP_CIPH_NO_PADDING,
+ .init = magma_cipher_init,
+};
+
+GOST_cipher magma_ctr_acpkm_cipher = {
+ .nid = NID_magma_ctr_acpkm,
+ .template = &magma_template_cipher,
+ .block_size = 1,
+ .iv_len = 4,
+ .flags = EVP_CIPH_CTR_MODE |
+ EVP_CIPH_CUSTOM_IV |
+ EVP_CIPH_NO_PADDING,
+ .init = magma_cipher_init,
+};
+
+GOST_cipher magma_ctr_acpkm_omac_cipher = {
+ .nid = NID_magma_ctr_acpkm_omac,
+ .template = &magma_template_cipher,
+ .block_size = 1,
+ .iv_len = 4,
+ .flags = EVP_CIPH_CTR_MODE |
+ EVP_CIPH_CUSTOM_IV |
+ EVP_CIPH_NO_PADDING |
+ 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,
+ .ctrl = magma_cipher_ctl_acpkm_omac,
+};
+
+GOST_cipher magma_ecb_cipher = {
+ .nid = NID_magma_ecb,
+ .template = &magma_template_cipher,
+ .flags = EVP_CIPH_ECB_MODE,
+ .init = magma_cipher_init,
+ .do_cipher = magma_cipher_do_ecb,
+};
+
+ GOST_cipher magma_mgm_cipher = {
+ .nid = NID_undef,
+ .template = &magma_template_cipher,
+ .block_size = 1,
+ .iv_len = 8,
+ .flags = EVP_CIPH_NO_PADDING |
+ EVP_CIPH_CUSTOM_IV | EVP_CIPH_FLAG_CUSTOM_CIPHER |
+ EVP_CIPH_CTRL_INIT | EVP_CIPH_FLAG_AEAD_CIPHER,
+ .init = gost_magma_cipher_init_mgm,
+ .do_cipher = gost_magma_cipher_do_mgm,
+ .ctrl = gost_magma_mgm_ctrl,
+ .cleanup = gost_magma_mgm_cleanup,
+ .ctx_size = sizeof(gost_mgm_ctx)
+ };
+
+static void magma_NID_callback (int nid)