]> wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
Bugfix of seq decrement
authorDmitry Belyavskiy <beldmit@gmail.com>
Thu, 27 Dec 2018 23:34:46 +0000 (02:34 +0300)
committerDmitry Belyavskiy <beldmit@gmail.com>
Thu, 27 Dec 2018 23:34:46 +0000 (02:34 +0300)
gost_grasshopper_cipher.c

index 050ec7a1838a53ae7bc498e77ae02616eabca55f..b6d044f3ef0b0d02a6a922b76b7b8436a460e64e 100644 (file)
@@ -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;
                   }
                 }
               }