-static struct GRASSHOPPER_CIPHER_PARAMS gost_cipher_params[6] = {
- {
- NID_grasshopper_ecb,
- gost_grasshopper_cipher_init_ecb,
- gost_grasshopper_cipher_do_ecb,
- NULL,
- 16,
- sizeof(gost_grasshopper_cipher_ctx),
- 0,
- true}
- ,
- {
- NID_grasshopper_cbc,
- gost_grasshopper_cipher_init_cbc,
- gost_grasshopper_cipher_do_cbc,
- NULL,
- 16,
- sizeof(gost_grasshopper_cipher_ctx),
- 16,
- true}
- ,
- {
- NID_grasshopper_ofb,
- gost_grasshopper_cipher_init_ofb,
- gost_grasshopper_cipher_do_ofb,
- gost_grasshopper_cipher_destroy_ofb,
- 1,
- sizeof(gost_grasshopper_cipher_ctx_ofb),
- 16,
- false}
- ,
- {
- NID_grasshopper_cfb,
- gost_grasshopper_cipher_init_cfb,
- gost_grasshopper_cipher_do_cfb,
- NULL,
- 1,
- sizeof(gost_grasshopper_cipher_ctx),
- 16,
- false}
- ,
- {
- NID_grasshopper_ctr,
- gost_grasshopper_cipher_init_ctr,
- gost_grasshopper_cipher_do_ctr,
- gost_grasshopper_cipher_destroy_ctr,
- 1,
- sizeof(gost_grasshopper_cipher_ctx_ctr),
- /* IV size is set to match full block, to make it responsibility of
- * user to assign correct values (IV || 0), and to make naive context
- * copy possible (for software such as openssh) */
- 16,
- false}
- ,
- {
- NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm,
- gost_grasshopper_cipher_init_ctracpkm,
- gost_grasshopper_cipher_do_ctracpkm,
- gost_grasshopper_cipher_destroy_ctr,
- 1,
- sizeof(gost_grasshopper_cipher_ctx_ctr),
- 16,
- false}
- ,
+GOST_cipher grasshopper_cbc_cipher = {
+ .nid = NID_grasshopper_cbc,
+ .template = &grasshopper_template_cipher,
+ .iv_len = 16,
+ .flags = EVP_CIPH_CBC_MODE |
+ EVP_CIPH_CUSTOM_IV,
+ .init = gost_grasshopper_cipher_init_cbc,
+ .do_cipher = gost_grasshopper_cipher_do_cbc,
+};
+
+GOST_cipher grasshopper_ofb_cipher = {
+ .nid = NID_grasshopper_ofb,
+ .template = &grasshopper_template_cipher,
+ .block_size = 1,
+ .iv_len = 16,
+ .flags = EVP_CIPH_OFB_MODE |
+ EVP_CIPH_NO_PADDING |
+ EVP_CIPH_CUSTOM_IV,
+ .init = gost_grasshopper_cipher_init_ofb,
+ .do_cipher = gost_grasshopper_cipher_do_ofb,
+};
+
+GOST_cipher grasshopper_cfb_cipher = {
+ .nid = NID_grasshopper_cfb,
+ .template = &grasshopper_template_cipher,
+ .block_size = 1,
+ .iv_len = 16,
+ .flags = EVP_CIPH_CFB_MODE |
+ EVP_CIPH_NO_PADDING |
+ EVP_CIPH_CUSTOM_IV,
+ .init = gost_grasshopper_cipher_init_cfb,
+ .do_cipher = gost_grasshopper_cipher_do_cfb,
+};
+
+GOST_cipher grasshopper_ctr_cipher = {
+ .nid = NID_grasshopper_ctr,
+ .template = &grasshopper_template_cipher,
+ .block_size = 1,
+ .iv_len = 8,
+ .flags = EVP_CIPH_CTR_MODE |
+ EVP_CIPH_NO_PADDING |
+ EVP_CIPH_CUSTOM_IV,
+ .init = gost_grasshopper_cipher_init_ctr,
+ .do_cipher = gost_grasshopper_cipher_do_ctr,
+ .ctx_size = sizeof(gost_grasshopper_cipher_ctx_ctr),
+};
+
+GOST_cipher grasshopper_ctr_acpkm_cipher = {
+ .nid = NID_kuznyechik_ctr_acpkm,
+ .template = &grasshopper_template_cipher,
+ .block_size = 1,
+ .iv_len = 8,
+ .flags = EVP_CIPH_CTR_MODE |
+ EVP_CIPH_NO_PADDING |
+ EVP_CIPH_CUSTOM_IV,
+ .init = gost_grasshopper_cipher_init_ctracpkm,
+ .do_cipher = gost_grasshopper_cipher_do_ctracpkm,
+ .ctx_size = sizeof(gost_grasshopper_cipher_ctx_ctr),
+};
+
+GOST_cipher grasshopper_ctr_acpkm_omac_cipher = {
+ .nid = NID_kuznyechik_ctr_acpkm_omac,
+ .template = &grasshopper_template_cipher,
+ .block_size = 1,
+ .iv_len = 8,
+ .flags = EVP_CIPH_CTR_MODE |
+ EVP_CIPH_NO_PADDING |
+ EVP_CIPH_CUSTOM_IV |
+ EVP_CIPH_FLAG_CUSTOM_CIPHER |
+ EVP_CIPH_FLAG_CIPHER_WITH_MAC |
+ EVP_CIPH_CUSTOM_COPY,
+ .init = gost_grasshopper_cipher_init_ctracpkm_omac,
+ .do_cipher = gost_grasshopper_cipher_do_ctracpkm_omac,
+ .ctx_size = sizeof(gost_grasshopper_cipher_ctx_ctr),
+};
+
+GOST_cipher grasshopper_mgm_cipher = {
+ .nid = NID_undef,
+ .template = &grasshopper_template_cipher,
+ .block_size = 1,
+ .iv_len = 16,
+ .flags = EVP_CIPH_NO_PADDING |
+ EVP_CIPH_CUSTOM_IV | EVP_CIPH_FLAG_CUSTOM_CIPHER |
+ EVP_CIPH_CTRL_INIT | EVP_CIPH_FLAG_AEAD_CIPHER,
+ .cleanup = gost_grasshopper_mgm_cleanup,
+ .ctrl = gost_grasshopper_mgm_ctrl,
+ .init = gost_grasshopper_cipher_init_mgm,
+ .do_cipher = gost_grasshopper_cipher_do_mgm,
+ .ctx_size = sizeof(gost_mgm_ctx)
+};
+
+static void kuznyechik_NID_callback (int nid)
+{
+ grasshopper_mgm_cipher.nid = nid;
+}
+
+GOST_NID_JOB kuznyechik_mgm_NID = {
+ .sn = SN_kuznyechik_mgm,
+ .ln = SN_kuznyechik_mgm,
+ .callback = kuznyechik_NID_callback,