]> wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
Fix in-place decryption for CBC mode
authorVitaly Chikunov <vt@altlinux.org>
Thu, 13 Sep 2018 00:26:19 +0000 (03:26 +0300)
committerVitaly Chikunov <vt@altlinux.org>
Thu, 13 Sep 2018 00:27:44 +0000 (03:27 +0300)
gost_grasshopper_cipher.c

index 0d0eacb7623f89280b44218fd3c16eaaba1892e3..a045a92d754eb780692150649aed8beea50bacdc 100644 (file)
@@ -365,11 +365,14 @@ int gost_grasshopper_cipher_do_cbc(EVP_CIPHER_CTX *ctx, unsigned char *out,
                                       currentOutputBlock, &c->buffer);
             grasshopper_copy128(currentBlock, currentOutputBlock);
         } else {
+            grasshopper_w128_t tmp;
+
+            grasshopper_copy128(&tmp, currentInputBlock);
             grasshopper_decrypt_block(&c->decrypt_round_keys,
                                       currentInputBlock, currentOutputBlock,
                                       &c->buffer);
             grasshopper_append128(currentOutputBlock, currentBlock);
-            grasshopper_copy128(currentBlock, currentInputBlock);
+            grasshopper_copy128(currentBlock, &tmp);
         }
     }