]> www.wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
Remove unset local buffer meshing. This removes valgrind errors.
authorNikolay Morozov <nmorozoff77@yandex.ru>
Thu, 26 Dec 2019 06:17:06 +0000 (09:17 +0300)
committerDmitry Belyavskiy <beldmit@users.noreply.github.com>
Sat, 1 Feb 2020 19:27:33 +0000 (22:27 +0300)
gost89.c
gost_crypt.c

index c670bb61cb6bf8eefdc7fda790882db55cc28de0..593bc237257cd568594a4a5a03a69bce3d2382e2 100644 (file)
--- a/gost89.c
+++ b/gost89.c
@@ -621,15 +621,18 @@ int gost_mac_iv(gost_ctx * ctx, int mac_len, const unsigned char *iv,
 /* Implements key meshing algorithm by modifing ctx and IV in place */
 void cryptopro_key_meshing(gost_ctx * ctx, unsigned char *iv)
 {
-    unsigned char newkey[32], newiv[8];
+    unsigned char newkey[32];
     /* Set static keymeshing key */
     /* "Decrypt" key with keymeshing key */
     gost_dec(ctx, CryptoProKeyMeshingKey, newkey, 4);
     /* set new key */
     gost_key(ctx, newkey);
     /* Encrypt iv with new key */
-    gostcrypt(ctx, iv, newiv);
-    memcpy(iv, newiv, 8);
+    if (iv != NULL ) {
+        unsigned char newiv[8];
+        gostcrypt(ctx, iv, newiv);
+        memcpy(iv, newiv, 8);
+    }
 }
 
 void acpkm_magma_key_meshing(gost_ctx * ctx)
index 16fb6610682a31cab052c615e7c433753aa1629c..7e733df7e581168ef2fd57cc9d78a0d2f333b509 100644 (file)
@@ -1071,15 +1071,14 @@ static int gost_imit_init_cp_12(EVP_MD_CTX *ctx)
 static void mac_block_mesh(struct ossl_gost_imit_ctx *c,
                            const unsigned char *data)
 {
-    unsigned char buffer[8];
     /*
-     * We are using local buffer for iv because CryptoPro doesn't interpret
+     * We are using NULL for iv because CryptoPro doesn't interpret
      * internal state of MAC algorithm as iv during keymeshing (but does
      * initialize internal state from iv in key transport
      */
     assert(c->count % 8 == 0 && c->count <= 1024);
     if (c->key_meshing && c->count == 1024) {
-        cryptopro_key_meshing(&(c->cctx), buffer);
+        cryptopro_key_meshing(&(c->cctx), NULL);
     }
     mac_block(&(c->cctx), c->buffer, data);
     c->count = c->count % 1024 + 8;