3 * This file is distributed under the same license as OpenSSL
6 #if defined(__cplusplus)
10 #include "gost_grasshopper_cipher.h"
11 #include "gost_grasshopper_defines.h"
12 #include "gost_grasshopper_math.h"
13 #include "gost_grasshopper_core.h"
15 #include <openssl/evp.h>
16 #include <openssl/rand.h>
17 #include <openssl/err.h>
20 #include "e_gost_err.h"
22 enum GRASSHOPPER_CIPHER_TYPE {
23 GRASSHOPPER_CIPHER_ECB = 0,
24 GRASSHOPPER_CIPHER_CBC,
25 GRASSHOPPER_CIPHER_OFB,
26 GRASSHOPPER_CIPHER_CFB,
27 GRASSHOPPER_CIPHER_CTR
30 static EVP_CIPHER* gost_grasshopper_ciphers[5] = {
31 [GRASSHOPPER_CIPHER_ECB] = NULL,
32 [GRASSHOPPER_CIPHER_CBC] = NULL,
33 [GRASSHOPPER_CIPHER_OFB] = NULL,
34 [GRASSHOPPER_CIPHER_CFB] = NULL,
35 [GRASSHOPPER_CIPHER_CTR] = NULL
38 static GRASSHOPPER_INLINE void gost_grasshopper_cipher_destroy_ofb(gost_grasshopper_cipher_ctx* c);
39 static GRASSHOPPER_INLINE void gost_grasshopper_cipher_destroy_ctr(gost_grasshopper_cipher_ctx* c);
41 struct GRASSHOPPER_CIPHER_PARAMS {
43 grasshopper_init_cipher_func init_cipher;
44 grasshopper_do_cipher_func do_cipher;
45 grasshopper_destroy_cipher_func destroy_cipher;
52 static struct GRASSHOPPER_CIPHER_PARAMS gost_cipher_params[5] = {
53 [GRASSHOPPER_CIPHER_ECB] = {
55 gost_grasshopper_cipher_init_ecb,
56 gost_grasshopper_cipher_do_ecb,
59 sizeof(gost_grasshopper_cipher_ctx),
63 [GRASSHOPPER_CIPHER_CBC] = {
65 gost_grasshopper_cipher_init_cbc,
66 gost_grasshopper_cipher_do_cbc,
69 sizeof(gost_grasshopper_cipher_ctx),
73 [GRASSHOPPER_CIPHER_OFB] = {
75 gost_grasshopper_cipher_init_ofb,
76 gost_grasshopper_cipher_do_ofb,
77 gost_grasshopper_cipher_destroy_ofb,
79 sizeof(gost_grasshopper_cipher_ctx_ofb),
83 [GRASSHOPPER_CIPHER_CFB] = {
85 gost_grasshopper_cipher_init_cfb,
86 gost_grasshopper_cipher_do_cfb,
89 sizeof(gost_grasshopper_cipher_ctx),
93 [GRASSHOPPER_CIPHER_CTR] = {
95 gost_grasshopper_cipher_init_ctr,
96 gost_grasshopper_cipher_do_ctr,
97 gost_grasshopper_cipher_destroy_ctr,
99 sizeof(gost_grasshopper_cipher_ctx_ctr),
105 /* Set 256 bit key into context */
106 GRASSHOPPER_INLINE void gost_grasshopper_cipher_key(gost_grasshopper_cipher_ctx* c, const uint8_t* k) {
108 for (i = 0; i < 2; i++) {
109 grasshopper_copy128(&c->key.k.k[i], (const grasshopper_w128_t*) (k + i * 16));
111 grasshopper_set_encrypt_key(&c->encrypt_round_keys, &c->key);
112 grasshopper_set_decrypt_key(&c->decrypt_round_keys, &c->key);
115 /* Cleans up key from context */
116 GRASSHOPPER_INLINE void gost_grasshopper_cipher_destroy(gost_grasshopper_cipher_ctx* c) {
118 for (i = 0; i < 2; i++) {
119 grasshopper_zero128(&c->key.k.k[i]);
121 for (i = 0; i < GRASSHOPPER_ROUND_KEYS_COUNT; i++) {
122 grasshopper_zero128(&c->encrypt_round_keys.k[i]);
124 for (i = 0; i < GRASSHOPPER_ROUND_KEYS_COUNT; i++) {
125 grasshopper_zero128(&c->decrypt_round_keys.k[i]);
127 grasshopper_zero128(&c->buffer);
130 static GRASSHOPPER_INLINE void gost_grasshopper_cipher_destroy_ofb(gost_grasshopper_cipher_ctx* c) {
131 gost_grasshopper_cipher_ctx_ofb* ctx = (gost_grasshopper_cipher_ctx_ofb*) c;
133 grasshopper_zero128(&ctx->buffer1);
136 static GRASSHOPPER_INLINE void gost_grasshopper_cipher_destroy_ctr(gost_grasshopper_cipher_ctx* c) {
137 gost_grasshopper_cipher_ctx_ctr* ctx = (gost_grasshopper_cipher_ctx_ctr*) c;
139 grasshopper_zero128(&ctx->iv_buffer);
140 grasshopper_zero128(&ctx->partial_buffer);
143 int gost_grasshopper_cipher_init(EVP_CIPHER_CTX* ctx, const unsigned char* key,
144 const unsigned char* iv, int enc) {
145 gost_grasshopper_cipher_ctx* c = EVP_CIPHER_CTX_get_cipher_data(ctx);
147 if (EVP_CIPHER_CTX_get_app_data(ctx) == NULL) {
148 EVP_CIPHER_CTX_set_app_data(ctx, EVP_CIPHER_CTX_get_cipher_data(ctx));
152 gost_grasshopper_cipher_key(c, key);
156 memcpy((unsigned char*) EVP_CIPHER_CTX_original_iv(ctx), iv,
157 EVP_CIPHER_CTX_iv_length(ctx));
160 memcpy(EVP_CIPHER_CTX_iv_noconst(ctx),
161 EVP_CIPHER_CTX_original_iv(ctx),
162 EVP_CIPHER_CTX_iv_length(ctx));
164 grasshopper_zero128(&c->buffer);
169 GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_ecb(EVP_CIPHER_CTX* ctx, const unsigned char* key,
170 const unsigned char* iv,
172 gost_grasshopper_cipher_ctx* c = EVP_CIPHER_CTX_get_cipher_data(ctx);
173 c->type = GRASSHOPPER_CIPHER_ECB;
174 return gost_grasshopper_cipher_init(ctx, key, iv, enc);
177 GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_cbc(EVP_CIPHER_CTX* ctx, const unsigned char* key,
178 const unsigned char* iv,
180 gost_grasshopper_cipher_ctx* c = EVP_CIPHER_CTX_get_cipher_data(ctx);
181 c->type = GRASSHOPPER_CIPHER_CBC;
182 return gost_grasshopper_cipher_init(ctx, key, iv, enc);
185 GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_ofb(EVP_CIPHER_CTX* ctx, const unsigned char* key,
186 const unsigned char* iv,
188 gost_grasshopper_cipher_ctx_ofb* c = EVP_CIPHER_CTX_get_cipher_data(ctx);
190 c->c.type = GRASSHOPPER_CIPHER_OFB;
192 grasshopper_zero128(&c->buffer1);
194 return gost_grasshopper_cipher_init(ctx, key, iv, enc);
197 GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_cfb(EVP_CIPHER_CTX* ctx, const unsigned char* key,
198 const unsigned char* iv,
200 gost_grasshopper_cipher_ctx* c = EVP_CIPHER_CTX_get_cipher_data(ctx);
201 c->type = GRASSHOPPER_CIPHER_CFB;
202 return gost_grasshopper_cipher_init(ctx, key, iv, enc);
205 GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_ctr(EVP_CIPHER_CTX* ctx, const unsigned char* key,
206 const unsigned char* iv,
208 gost_grasshopper_cipher_ctx_ctr* c = EVP_CIPHER_CTX_get_cipher_data(ctx);
210 c->c.type = GRASSHOPPER_CIPHER_CTR;
211 EVP_CIPHER_CTX_set_num(ctx, 0);
213 grasshopper_zero128(&c->iv_buffer);
214 grasshopper_zero128(&c->partial_buffer);
216 return gost_grasshopper_cipher_init(ctx, key, iv, enc);
219 GRASSHOPPER_INLINE int gost_grasshopper_cipher_do(EVP_CIPHER_CTX* ctx, unsigned char* out,
220 const unsigned char* in, size_t inl) {
221 gost_grasshopper_cipher_ctx* c = (gost_grasshopper_cipher_ctx*) EVP_CIPHER_CTX_get_cipher_data(ctx);
222 struct GRASSHOPPER_CIPHER_PARAMS* params = &gost_cipher_params[c->type];
224 return params->do_cipher(ctx, out, in, inl);
227 int gost_grasshopper_cipher_do_ecb(EVP_CIPHER_CTX* ctx, unsigned char* out,
228 const unsigned char* in, size_t inl) {
229 gost_grasshopper_cipher_ctx* c = (gost_grasshopper_cipher_ctx*) EVP_CIPHER_CTX_get_cipher_data(ctx);
230 bool encrypting = (bool) EVP_CIPHER_CTX_encrypting(ctx);
231 const unsigned char* current_in = in;
232 unsigned char* current_out = out;
233 size_t blocks = inl / GRASSHOPPER_BLOCK_SIZE;
236 for (i = 0; i < blocks; i++, current_in += GRASSHOPPER_BLOCK_SIZE, current_out += GRASSHOPPER_BLOCK_SIZE) {
238 grasshopper_encrypt_block(&c->encrypt_round_keys, (grasshopper_w128_t*) current_in,
239 (grasshopper_w128_t*) current_out,
242 grasshopper_decrypt_block(&c->decrypt_round_keys, (grasshopper_w128_t*) current_in,
243 (grasshopper_w128_t*) current_out,
251 int gost_grasshopper_cipher_do_cbc(EVP_CIPHER_CTX* ctx, unsigned char* out,
252 const unsigned char* in, size_t inl) {
253 gost_grasshopper_cipher_ctx* c = (gost_grasshopper_cipher_ctx*) EVP_CIPHER_CTX_get_cipher_data(ctx);
254 unsigned char* iv = EVP_CIPHER_CTX_iv_noconst(ctx);
255 bool encrypting = (bool) EVP_CIPHER_CTX_encrypting(ctx);
256 const unsigned char* current_in = in;
257 unsigned char* current_out = out;
258 grasshopper_w128_t* currentInputBlock;
259 grasshopper_w128_t* currentOutputBlock;
260 size_t blocks = inl / GRASSHOPPER_BLOCK_SIZE;
262 grasshopper_w128_t* currentBlock;
264 currentBlock = (grasshopper_w128_t*) iv;
266 for (i = 0; i < blocks; i++, current_in += GRASSHOPPER_BLOCK_SIZE, current_out += GRASSHOPPER_BLOCK_SIZE) {
267 currentInputBlock = (grasshopper_w128_t*) current_in;
268 currentOutputBlock = (grasshopper_w128_t*) current_out;
270 grasshopper_append128(currentBlock, currentInputBlock);
271 grasshopper_encrypt_block(&c->encrypt_round_keys, currentBlock, currentOutputBlock, &c->buffer);
272 grasshopper_copy128(currentBlock, currentOutputBlock);
274 grasshopper_decrypt_block(&c->decrypt_round_keys, currentInputBlock, currentOutputBlock, &c->buffer);
275 grasshopper_append128(currentOutputBlock, currentBlock);
276 grasshopper_copy128(currentBlock, currentInputBlock);
283 /* increment counter (128-bit int) by 1 */
284 static void ctr128_inc(unsigned char *counter)
298 int gost_grasshopper_cipher_do_ctr(EVP_CIPHER_CTX* ctx, unsigned char* out,
299 const unsigned char* in, size_t inl) {
300 gost_grasshopper_cipher_ctx_ctr* c = (gost_grasshopper_cipher_ctx_ctr*) EVP_CIPHER_CTX_get_cipher_data(ctx);
301 unsigned char* iv = EVP_CIPHER_CTX_iv_noconst(ctx);
302 const unsigned char* current_in = in;
303 unsigned char* current_out = out;
304 grasshopper_w128_t* currentInputBlock;
305 grasshopper_w128_t* currentOutputBlock;
306 unsigned int n = EVP_CIPHER_CTX_num(ctx);
311 *(current_out++) = *(current_in++) ^ c->partial_buffer.b[n];
313 n = (n + 1) % GRASSHOPPER_BLOCK_SIZE;
315 EVP_CIPHER_CTX_set_num(ctx, n);
316 size_t blocks = inl / GRASSHOPPER_BLOCK_SIZE;
318 memcpy(&c->iv_buffer, iv, 8);
321 for (i = 0; i < blocks; i++) {
322 currentInputBlock = (grasshopper_w128_t*) current_in;
323 currentOutputBlock = (grasshopper_w128_t*) current_out;
324 grasshopper_encrypt_block(&c->c.encrypt_round_keys, &c->iv_buffer, currentOutputBlock, &c->c.buffer);
325 grasshopper_append128(currentOutputBlock, currentInputBlock);
326 ctr128_inc(c->iv_buffer.b);
327 current_in += GRASSHOPPER_BLOCK_SIZE;
328 current_out += GRASSHOPPER_BLOCK_SIZE;
332 lasted = inl - blocks * GRASSHOPPER_BLOCK_SIZE;
334 currentInputBlock = (grasshopper_w128_t*) current_in;
335 currentOutputBlock = (grasshopper_w128_t*) current_out;
336 grasshopper_encrypt_block(&c->c.encrypt_round_keys, &c->iv_buffer, &c->partial_buffer, &c->c.buffer);
337 for (i = 0; i < lasted; i++) {
338 currentOutputBlock->b[i] = c->partial_buffer.b[i] ^ currentInputBlock->b[i];
340 EVP_CIPHER_CTX_set_num(ctx, i);
341 ctr128_inc(c->iv_buffer.b);
348 * Fixed 128-bit IV implementation make shift regiser redundant.
350 static void gost_grasshopper_cnt_next(gost_grasshopper_cipher_ctx_ofb* ctx, grasshopper_w128_t* iv,
351 grasshopper_w128_t* buf) {
352 memcpy(&ctx->buffer1, iv, 16);
353 grasshopper_encrypt_block(&ctx->c.encrypt_round_keys, &ctx->buffer1, buf, &ctx->c.buffer);
357 int gost_grasshopper_cipher_do_ofb(EVP_CIPHER_CTX* ctx, unsigned char* out,
358 const unsigned char* in, size_t inl) {
359 gost_grasshopper_cipher_ctx_ofb* c = (gost_grasshopper_cipher_ctx_ofb*) EVP_CIPHER_CTX_get_cipher_data(ctx);
360 const unsigned char* in_ptr = in;
361 unsigned char* out_ptr = out;
362 unsigned char* buf = EVP_CIPHER_CTX_buf_noconst(ctx);
363 unsigned char* iv = EVP_CIPHER_CTX_iv_noconst(ctx);
364 int num = EVP_CIPHER_CTX_num(ctx);
368 /* process partial block if any */
370 for (j = (size_t) num, i = 0; j < GRASSHOPPER_BLOCK_SIZE && i < inl;
371 j++, i++, in_ptr++, out_ptr++) {
372 *out_ptr = buf[j] ^ (*in_ptr);
374 if (j == GRASSHOPPER_BLOCK_SIZE) {
375 EVP_CIPHER_CTX_set_num(ctx, 0);
377 EVP_CIPHER_CTX_set_num(ctx, (int) j);
382 for (; i + GRASSHOPPER_BLOCK_SIZE <
383 inl; i += GRASSHOPPER_BLOCK_SIZE, in_ptr += GRASSHOPPER_BLOCK_SIZE, out_ptr += GRASSHOPPER_BLOCK_SIZE) {
385 * block cipher current iv
388 gost_grasshopper_cnt_next(c, (grasshopper_w128_t*) iv, (grasshopper_w128_t*) buf);
391 * xor next block of input text with it and output it
396 for (j = 0; j < GRASSHOPPER_BLOCK_SIZE; j++) {
397 out_ptr[j] = buf[j] ^ in_ptr[j];
401 /* Process rest of buffer */
403 gost_grasshopper_cnt_next(c, (grasshopper_w128_t*) iv, (grasshopper_w128_t*) buf);
404 for (j = 0; i < inl; j++, i++) {
405 out_ptr[j] = buf[j] ^ in_ptr[j];
407 EVP_CIPHER_CTX_set_num(ctx, (int) j);
409 EVP_CIPHER_CTX_set_num(ctx, 0);
415 int gost_grasshopper_cipher_do_cfb(EVP_CIPHER_CTX* ctx, unsigned char* out,
416 const unsigned char* in, size_t inl) {
417 gost_grasshopper_cipher_ctx* c = (gost_grasshopper_cipher_ctx*) EVP_CIPHER_CTX_get_cipher_data(ctx);
418 const unsigned char* in_ptr = in;
419 unsigned char* out_ptr = out;
420 unsigned char* buf = EVP_CIPHER_CTX_buf_noconst(ctx);
421 unsigned char* iv = EVP_CIPHER_CTX_iv_noconst(ctx);
422 bool encrypting = (bool) EVP_CIPHER_CTX_encrypting(ctx);
423 int num = EVP_CIPHER_CTX_num(ctx);
427 /* process partial block if any */
429 for (j = (size_t) num, i = 0; j < GRASSHOPPER_BLOCK_SIZE && i < inl; j++, i++, in_ptr++, out_ptr++) {
431 buf[j + GRASSHOPPER_BLOCK_SIZE] = *in_ptr;
433 *out_ptr = buf[j] ^ (*in_ptr);
435 buf[j + GRASSHOPPER_BLOCK_SIZE] = *out_ptr;
438 if (j == GRASSHOPPER_BLOCK_SIZE) {
439 memcpy(iv, buf + GRASSHOPPER_BLOCK_SIZE, GRASSHOPPER_BLOCK_SIZE);
440 EVP_CIPHER_CTX_set_num(ctx, 0);
442 EVP_CIPHER_CTX_set_num(ctx, (int) j);
447 for (; i + GRASSHOPPER_BLOCK_SIZE <
448 inl; i += GRASSHOPPER_BLOCK_SIZE, in_ptr += GRASSHOPPER_BLOCK_SIZE, out_ptr += GRASSHOPPER_BLOCK_SIZE) {
450 * block cipher current iv
452 grasshopper_encrypt_block(&c->encrypt_round_keys, (grasshopper_w128_t*) iv, (grasshopper_w128_t*) buf,
455 * xor next block of input text with it and output it
461 memcpy(iv, in_ptr, GRASSHOPPER_BLOCK_SIZE);
463 for (j = 0; j < GRASSHOPPER_BLOCK_SIZE; j++) {
464 out_ptr[j] = buf[j] ^ in_ptr[j];
467 /* Next iv is next block of cipher text */
469 memcpy(iv, out_ptr, GRASSHOPPER_BLOCK_SIZE);
473 /* Process rest of buffer */
475 grasshopper_encrypt_block(&c->encrypt_round_keys, (grasshopper_w128_t*) iv, (grasshopper_w128_t*) buf,
478 memcpy(buf + GRASSHOPPER_BLOCK_SIZE, in_ptr, inl - i);
480 for (j = 0; i < inl; j++, i++) {
481 out_ptr[j] = buf[j] ^ in_ptr[j];
483 EVP_CIPHER_CTX_set_num(ctx, (int) j);
485 memcpy(buf + GRASSHOPPER_BLOCK_SIZE, out_ptr, j);
488 EVP_CIPHER_CTX_set_num(ctx, 0);
494 int gost_grasshopper_cipher_cleanup(EVP_CIPHER_CTX* ctx) {
495 gost_grasshopper_cipher_ctx* c = (gost_grasshopper_cipher_ctx*) EVP_CIPHER_CTX_get_cipher_data(ctx);
496 struct GRASSHOPPER_CIPHER_PARAMS* params = &gost_cipher_params[c->type];
498 gost_grasshopper_cipher_destroy(c);
499 if (params->destroy_cipher != NULL) {
500 params->destroy_cipher(c);
503 EVP_CIPHER_CTX_set_app_data(ctx, NULL);
508 int gost_grasshopper_set_asn1_parameters(EVP_CIPHER_CTX* ctx, ASN1_TYPE* params) {
510 unsigned char* buf = NULL;
511 ASN1_OCTET_STRING* os = NULL;
513 os = ASN1_OCTET_STRING_new();
515 if (!os || !ASN1_OCTET_STRING_set(os, buf, len)) {
517 GOSTerr(GOST_F_GOST89_SET_ASN1_PARAMETERS, ERR_R_MALLOC_FAILURE);
522 ASN1_TYPE_set(params, V_ASN1_SEQUENCE, os);
526 GRASSHOPPER_INLINE int gost_grasshopper_get_asn1_parameters(EVP_CIPHER_CTX* ctx, ASN1_TYPE* params) {
529 if (ASN1_TYPE_get(params) != V_ASN1_SEQUENCE) {
536 int gost_grasshopper_cipher_ctl(EVP_CIPHER_CTX* ctx, int type, int arg, void* ptr) {
538 case EVP_CTRL_RAND_KEY: {
539 if (RAND_bytes((unsigned char*) ptr, EVP_CIPHER_CTX_key_length(ctx)) <= 0) {
540 GOSTerr(GOST_F_GOST_CIPHER_CTL, GOST_R_RNG_ERROR);
546 GOSTerr(GOST_F_GOST_CIPHER_CTL, GOST_R_UNSUPPORTED_CIPHER_CTL_COMMAND);
552 GRASSHOPPER_INLINE EVP_CIPHER* cipher_gost_grasshopper_create(int cipher_type, int block_size) {
553 return EVP_CIPHER_meth_new(cipher_type,
554 block_size /* block_size */,
555 GRASSHOPPER_KEY_SIZE /* key_size */);
558 const int cipher_gost_grasshopper_setup(EVP_CIPHER* cipher, uint8_t mode, int iv_size, bool padding) {
559 return EVP_CIPHER_meth_set_iv_length(cipher, iv_size) &&
560 EVP_CIPHER_meth_set_flags(cipher, (unsigned long) (
562 ((!padding) ? EVP_CIPH_NO_PADDING : 0) |
563 ((iv_size > 0) ? EVP_CIPH_CUSTOM_IV : 0) |
565 EVP_CIPH_ALWAYS_CALL_INIT)
567 EVP_CIPHER_meth_set_cleanup(cipher, gost_grasshopper_cipher_cleanup) &&
568 EVP_CIPHER_meth_set_set_asn1_params(cipher, gost_grasshopper_set_asn1_parameters) &&
569 EVP_CIPHER_meth_set_get_asn1_params(cipher, gost_grasshopper_get_asn1_parameters) &&
570 EVP_CIPHER_meth_set_ctrl(cipher, gost_grasshopper_cipher_ctl) &&
571 EVP_CIPHER_meth_set_do_cipher(cipher, gost_grasshopper_cipher_do);
574 const GRASSHOPPER_INLINE EVP_CIPHER* cipher_gost_grasshopper(uint8_t mode, uint8_t num) {
576 struct GRASSHOPPER_CIPHER_PARAMS* params;
578 cipher = &gost_grasshopper_ciphers[num];
580 if (*cipher == NULL) {
581 params = &gost_cipher_params[num];
583 int nid = params->nid;
584 grasshopper_init_cipher_func init_cipher = params->init_cipher;
585 int block_size = params->block_size;
586 int ctx_size = params->ctx_size;
587 int iv_size = params->iv_size;
588 bool padding = params->padding;
590 *cipher = cipher_gost_grasshopper_create(nid, block_size);
591 if (*cipher == NULL) {
595 if (!cipher_gost_grasshopper_setup(*cipher, mode, iv_size, padding) ||
596 !EVP_CIPHER_meth_set_init(*cipher, init_cipher) ||
597 !EVP_CIPHER_meth_set_impl_ctx_size(*cipher, ctx_size)) {
598 EVP_CIPHER_meth_free(*cipher);
606 const GRASSHOPPER_INLINE EVP_CIPHER* cipher_gost_grasshopper_ecb() {
607 return cipher_gost_grasshopper(EVP_CIPH_ECB_MODE, GRASSHOPPER_CIPHER_ECB);
610 const GRASSHOPPER_INLINE EVP_CIPHER* cipher_gost_grasshopper_cbc() {
611 return cipher_gost_grasshopper(EVP_CIPH_CBC_MODE, GRASSHOPPER_CIPHER_CBC);
614 const GRASSHOPPER_INLINE EVP_CIPHER* cipher_gost_grasshopper_ofb() {
615 return cipher_gost_grasshopper(EVP_CIPH_OFB_MODE, GRASSHOPPER_CIPHER_OFB);
618 const GRASSHOPPER_INLINE EVP_CIPHER* cipher_gost_grasshopper_cfb() {
619 return cipher_gost_grasshopper(EVP_CIPH_CFB_MODE, GRASSHOPPER_CIPHER_CFB);
622 const GRASSHOPPER_INLINE EVP_CIPHER* cipher_gost_grasshopper_ctr() {
623 return cipher_gost_grasshopper(EVP_CIPH_CTR_MODE, GRASSHOPPER_CIPHER_CTR);
626 #if defined(__cplusplus)