]> www.wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
merge upstream
authorMax <maxamar@mail.ru>
Thu, 8 Sep 2016 08:49:08 +0000 (11:49 +0300)
committerMax <maxamar@mail.ru>
Thu, 8 Sep 2016 08:49:08 +0000 (11:49 +0300)
gost_ameth.c
gost_crypt.c
gost_grasshopper_cipher.c
patches/1.1.0-grasshopper/oids.diff [new file with mode: 0644]

index 8dc47f141c5f9e3ad5b1576014b0ad7fc5d8de1a..27217a827c533ac048fac63355efc5f215cb9078 100644 (file)
@@ -19,6 +19,8 @@
 #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
index f9ed2cf22b0c8125252ef354b653e096476b0251..d375a3dc89dd1b237900acf719f1fd371b72afd7 100644 (file)
@@ -487,13 +487,13 @@ static void gost_cnt_next(void *ctx, unsigned char *iv, unsigned char *buf)
 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) {
 
index 24e389a6cee3c9cf9174a8ba7d09c56558d7c3f8..b3aa4b9aa9009184dae6b9cc20b30f9ba9b4deba 100644 (file)
@@ -96,7 +96,7 @@ static struct GRASSHOPPER_CIPHER_PARAMS gost_cipher_params[5] = {
                 gost_grasshopper_cipher_do_ctr,
                 gost_grasshopper_cipher_destroy_ctr,
                 1,
-                sizeof(gost_grasshopper_cipher_ctx),
+                sizeof(gost_grasshopper_cipher_ctx_ctr),
                 8,
                 false
         },
@@ -293,18 +293,20 @@ static int gost_grasshopper_cipher_do_ctr(EVP_CIPHER_CTX* ctx, unsigned char* ou
     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
diff --git a/patches/1.1.0-grasshopper/oids.diff b/patches/1.1.0-grasshopper/oids.diff
new file mode 100644 (file)
index 0000000..3464122
--- /dev/null
@@ -0,0 +1,22 @@
+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