]> www.wagner.pp.ru Git - openssl-gost/engine.git/blobdiff - gost89.c
Remove unset local buffer meshing. This removes valgrind errors.
[openssl-gost/engine.git] / gost89.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)