- enum GRASSHOPPER_CIPHER_TYPE {
- GRASSHOPPER_CIPHER_ECB = 0,
- GRASSHOPPER_CIPHER_CBC,
- GRASSHOPPER_CIPHER_OFB,
- GRASSHOPPER_CIPHER_CFB,
- GRASSHOPPER_CIPHER_CTR,
- GRASSHOPPER_CIPHER_CTRACPKM,
- };
-
- static EVP_CIPHER *gost_grasshopper_ciphers[6] = {
- [GRASSHOPPER_CIPHER_ECB] = NULL,
- [GRASSHOPPER_CIPHER_CBC] = NULL,
- [GRASSHOPPER_CIPHER_OFB] = NULL,
- [GRASSHOPPER_CIPHER_CFB] = NULL,
- [GRASSHOPPER_CIPHER_CTR] = NULL,
- [GRASSHOPPER_CIPHER_CTRACPKM] = NULL,
- };
-
- static GRASSHOPPER_INLINE void
- gost_grasshopper_cipher_destroy_ofb(gost_grasshopper_cipher_ctx * c);
- static GRASSHOPPER_INLINE void
- gost_grasshopper_cipher_destroy_ctr(gost_grasshopper_cipher_ctx * c);
-
- struct GRASSHOPPER_CIPHER_PARAMS {
- int nid;
- grasshopper_init_cipher_func init_cipher;
- grasshopper_do_cipher_func do_cipher;
- grasshopper_destroy_cipher_func destroy_cipher;
- int block_size;
- int ctx_size;
- int iv_size;
- bool padding;
- };
-
- static struct GRASSHOPPER_CIPHER_PARAMS gost_cipher_params[6] = {
- [GRASSHOPPER_CIPHER_ECB] = {
- NID_grasshopper_ecb,
- gost_grasshopper_cipher_init_ecb,
- gost_grasshopper_cipher_do_ecb,
- NULL,
- 16,
- sizeof(gost_grasshopper_cipher_ctx),
- 0,
- true}
- ,
- [GRASSHOPPER_CIPHER_CBC] = {
- NID_grasshopper_cbc,
- gost_grasshopper_cipher_init_cbc,
- gost_grasshopper_cipher_do_cbc,
- NULL,
- 16,
- sizeof(gost_grasshopper_cipher_ctx),
- 16,
- true}
- ,
- [GRASSHOPPER_CIPHER_OFB] = {
- 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}
- ,
- [GRASSHOPPER_CIPHER_CFB] = {
- NID_grasshopper_cfb,
- gost_grasshopper_cipher_init_cfb,
- gost_grasshopper_cipher_do_cfb,
- NULL,
- 1,
- sizeof(gost_grasshopper_cipher_ctx),
- 16,
- false}
- ,
- [GRASSHOPPER_CIPHER_CTR] = {
- 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}
- ,
- [GRASSHOPPER_CIPHER_CTRACPKM] = {
- 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}
- ,
- };
+enum GRASSHOPPER_CIPHER_TYPE {
+ GRASSHOPPER_CIPHER_ECB = 0,
+ GRASSHOPPER_CIPHER_CBC,
+ GRASSHOPPER_CIPHER_OFB,
+ GRASSHOPPER_CIPHER_CFB,
+ GRASSHOPPER_CIPHER_CTR,
+ GRASSHOPPER_CIPHER_CTRACPKM,
+};
+
+static EVP_CIPHER *gost_grasshopper_ciphers[6] = {
+ [GRASSHOPPER_CIPHER_ECB] = NULL,
+ [GRASSHOPPER_CIPHER_CBC] = NULL,
+ [GRASSHOPPER_CIPHER_OFB] = NULL,
+ [GRASSHOPPER_CIPHER_CFB] = NULL,
+ [GRASSHOPPER_CIPHER_CTR] = NULL,
+ [GRASSHOPPER_CIPHER_CTRACPKM] = NULL,
+};
+
+static GRASSHOPPER_INLINE void
+gost_grasshopper_cipher_destroy_ofb(gost_grasshopper_cipher_ctx * c);
+static GRASSHOPPER_INLINE void
+gost_grasshopper_cipher_destroy_ctr(gost_grasshopper_cipher_ctx * c);
+
+struct GRASSHOPPER_CIPHER_PARAMS {
+ int nid;
+ grasshopper_init_cipher_func init_cipher;
+ grasshopper_do_cipher_func do_cipher;
+ grasshopper_destroy_cipher_func destroy_cipher;
+ int block_size;
+ int ctx_size;
+ int iv_size;
+ bool padding;
+};
+
+static struct GRASSHOPPER_CIPHER_PARAMS gost_cipher_params[6] = {
+ [GRASSHOPPER_CIPHER_ECB] = {
+ NID_grasshopper_ecb,
+ gost_grasshopper_cipher_init_ecb,
+ gost_grasshopper_cipher_do_ecb,
+ NULL,
+ 16,
+ sizeof(gost_grasshopper_cipher_ctx),
+ 0,
+ true}
+ ,
+ [GRASSHOPPER_CIPHER_CBC] = {
+ NID_grasshopper_cbc,
+ gost_grasshopper_cipher_init_cbc,
+ gost_grasshopper_cipher_do_cbc,
+ NULL,
+ 16,
+ sizeof(gost_grasshopper_cipher_ctx),
+ 16,
+ true}
+ ,
+ [GRASSHOPPER_CIPHER_OFB] = {
+ 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}
+ ,
+ [GRASSHOPPER_CIPHER_CFB] = {
+ NID_grasshopper_cfb,
+ gost_grasshopper_cipher_init_cfb,
+ gost_grasshopper_cipher_do_cfb,
+ NULL,
+ 1,
+ sizeof(gost_grasshopper_cipher_ctx),
+ 16,
+ false}
+ ,
+ [GRASSHOPPER_CIPHER_CTR] = {
+ 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}
+ ,
+ [GRASSHOPPER_CIPHER_CTRACPKM] = {
+ 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}
+ ,
+};