#include "gost_lcl.h"
#include "e_gost_err.h"
+#include <internal/evp_int.h>
+
/*
* Pack bignum into byte buffer of given size, filling all leading bytes by
* zeros
int gost_cipher_do_cbc(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, size_t inl)
{
- OPENSSL_assert(inl % 8 == 0);
unsigned char b[8];
const unsigned char *in_ptr = in;
unsigned char *out_ptr = out;
int i;
struct ossl_gost_cipher_ctx *c = EVP_CIPHER_CTX_get_cipher_data(ctx);
unsigned char *iv = EVP_CIPHER_CTX_iv_noconst(ctx);
+ OPENSSL_assert(inl % 8 == 0);
if (EVP_CIPHER_CTX_encrypting(ctx)) {
while (inl > 0) {
gost_grasshopper_cipher_do_ctr,
gost_grasshopper_cipher_destroy_ctr,
1,
- sizeof(gost_grasshopper_cipher_ctx),
+ sizeof(gost_grasshopper_cipher_ctx_ctr),
8,
false
},
grasshopper_w128_t* currentInputBlock;
grasshopper_w128_t* currentOutputBlock;
size_t lasted;
- size_t i;
+ size_t i;
memcpy(&c->iv_buffer, iv, 8);
// full parts
- for (i = 0; i < blocks; i++, current_in += GRASSHOPPER_BLOCK_SIZE, current_out += GRASSHOPPER_BLOCK_SIZE) {
+ for (i = 0; i < blocks; i++) {
currentInputBlock = (grasshopper_w128_t*) current_in;
currentOutputBlock = (grasshopper_w128_t*) current_out;
memcpy(c->iv_buffer.b + 8, &c->counter, 8);
grasshopper_encrypt_block(&c->c.encrypt_round_keys, &c->iv_buffer, currentOutputBlock, &c->c.buffer);
grasshopper_append128(currentOutputBlock, currentInputBlock);
c->counter += 1;
+ current_in += GRASSHOPPER_BLOCK_SIZE;
+ current_out += GRASSHOPPER_BLOCK_SIZE;
}
// last part
--- /dev/null
+diff --git a/crypto/objects/objects.txt b/crypto/objects/objects.txt
+index 645591b..b8e2467 100644
+--- a/crypto/objects/objects.txt
++++ b/crypto/objects/objects.txt
+@@ -1297,12 +1297,12 @@ member-body 643 100 111 : subjectSignTool : Signing Tool of Subject
+ member-body 643 100 112 : issuerSignTool : Signing Tool of Issuer
+
+ #GOST R34.13-2015 Grasshopper "Kuznechik"
+- : grasshopper-ecb
+- : grasshopper-ctr
+- : grasshopper-ofb
+- : grasshopper-cbc
+- : grasshopper-cfb
+- : grasshopper-mac
++cryptopro 37 1 : GRASSHOPPER-ECB : grasshopper-ecb
++cryptopro 37 2 : GRASSHOPPER-CTR : grasshopper-ctr
++cryptopro 37 3 : GRASSHOPPER-OFB : grasshopper-ofb
++cryptopro 37 4 : GRASSHOPPER-CBC : grasshopper-cbc
++cryptopro 37 5 : GRASSHOPPER-CFB : grasshopper-cfb
++#grasshopper-mac
+
+ # Definitions for Camellia cipher - CBC MODE