From: Vitaly Chikunov Date: Thu, 13 Sep 2018 00:26:19 +0000 (+0300) Subject: Fix in-place decryption for CBC mode X-Git-Tag: v3.0.0~344^2~1 X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;ds=inline;h=ff6364a8907b15684e685e8d7984088cfb4c74b4;p=openssl-gost%2Fengine.git Fix in-place decryption for CBC mode --- diff --git a/gost_grasshopper_cipher.c b/gost_grasshopper_cipher.c index 0d0eacb..a045a92 100644 --- a/gost_grasshopper_cipher.c +++ b/gost_grasshopper_cipher.c @@ -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); } }