X-Git-Url: http://wagner.pp.ru/gitweb/?a=blobdiff_plain;f=gost_grasshopper_cipher.c;h=b6d044f3ef0b0d02a6a922b76b7b8436a460e64e;hb=0046678ed37edff837ed07b78f3e8e99550ea40e;hp=050ec7a1838a53ae7bc498e77ae02616eabca55f;hpb=a334763bff413affb0fac3220512d97339099330;p=openssl-gost%2Fengine.git 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; } } }