]> wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
gost_crypt: Fix Magma CBC in-place decryption
authorVitaly Chikunov <vt@altlinux.org>
Sat, 9 May 2020 22:20:40 +0000 (01:20 +0300)
committerDmitry Belyavskiy <beldmit@users.noreply.github.com>
Sun, 10 May 2020 14:11:21 +0000 (17:11 +0300)
Simplest fix not concerned with performance, still should not impact it
too much.

gost_crypt.c

index ffb577db84dbae00eee4d700dc1b11c336faf8ed..33dc668cba088cbf88fa1053d432bf835f7390a5 100644 (file)
@@ -774,10 +774,11 @@ int magma_cipher_do_cbc(EVP_CIPHER_CTX *ctx, unsigned char *out,
                 d[7 - i] = in_ptr[i];
             }
             gostdecrypt(&(c->cctx), d, b);
+            memcpy(d, in_ptr, 8);
             for (i = 0; i < 8; i++) {
                 out_ptr[i] = iv[i] ^ b[7 - i];
             }
-            memcpy(iv, in_ptr, 8);
+            memcpy(iv, d, 8);
             out_ptr += 8;
             in_ptr += 8;
             inl -= 8;