From: Dmitry Belyavskiy Date: Thu, 27 Dec 2018 23:34:46 +0000 (+0300) Subject: Bugfix of seq decrement X-Git-Tag: v3.0.0~319 X-Git-Url: http://www.wagner.pp.ru/gitweb/?a=commitdiff_plain;h=2b79bbba6aed4e69b1d2d0c04da00f121c69799d;p=openssl-gost%2Fengine.git Bugfix of seq decrement --- diff --git a/gost_grasshopper_cipher.c b/gost_grasshopper_cipher.c index 050ec7a..b6d044f 100644 --- a/gost_grasshopper_cipher.c +++ b/gost_grasshopper_cipher.c @@ -785,7 +785,7 @@ int gost_grasshopper_cipher_ctl(EVP_CIPHER_CTX *ctx, int type, int arg, memcpy(seq, ptr, 8); if (EVP_CIPHER_CTX_encrypting(ctx)) { /* - * OpenSSL increments seq on after mac calculation + * OpenSSL increments seq after mac calculation. * As we have Mac-Then-Encrypt, we need decrement it here on encryption * to derive the key correctly. * */ @@ -793,7 +793,8 @@ int gost_grasshopper_cipher_ctl(EVP_CIPHER_CTX *ctx, int type, int arg, { for(j=7; j>=0; j--) { - if (seq[j] != 0) {seq[j]--; break;}; + if (seq[j] != 0) {seq[j]--; break;} + else seq[j] = 0xFF; } } }