X-Git-Url: http://wagner.pp.ru/gitweb/?a=blobdiff_plain;f=gost_grasshopper_cipher.c;h=32af154b2bea8175f691d7fe9119ffa1c45791b4;hb=cf43fbf26194688bc1823e9a8ab13762d69b23b7;hp=9cef0c5f02fa1a596177385d32531c230e98e46a;hpb=a6df1e0ca7c7b34c468d2d1c0fc50029f6ec711b;p=openssl-gost%2Fengine.git diff --git a/gost_grasshopper_cipher.c b/gost_grasshopper_cipher.c index 9cef0c5..32af154 100644 --- a/gost_grasshopper_cipher.c +++ b/gost_grasshopper_cipher.c @@ -528,15 +528,15 @@ int gost_grasshopper_cipher_do_ctracpkm(EVP_CIPHER_CTX *ctx, gost_grasshopper_cipher_ctx_ctr *c = EVP_CIPHER_CTX_get_cipher_data(ctx); unsigned char *iv = EVP_CIPHER_CTX_iv_noconst(ctx); unsigned int num = EVP_CIPHER_CTX_num(ctx); - size_t blocks, i, lasted; + size_t blocks, i, lasted = inl; grasshopper_w128_t tmp; - while ((num & GRASSHOPPER_BLOCK_MASK) && inl) { + while ((num & GRASSHOPPER_BLOCK_MASK) && lasted) { *out++ = *in++ ^ c->partial_buffer.b[num & GRASSHOPPER_BLOCK_MASK]; - --inl; + --lasted; num++; } - blocks = inl / GRASSHOPPER_BLOCK_SIZE; + blocks = lasted / GRASSHOPPER_BLOCK_SIZE; // full parts for (i = 0; i < blocks; i++) { @@ -552,10 +552,10 @@ int gost_grasshopper_cipher_do_ctracpkm(EVP_CIPHER_CTX *ctx, in += GRASSHOPPER_BLOCK_SIZE; out += GRASSHOPPER_BLOCK_SIZE; num += GRASSHOPPER_BLOCK_SIZE; + lasted -= GRASSHOPPER_BLOCK_SIZE; } // last part - lasted = inl - blocks * GRASSHOPPER_BLOCK_SIZE; if (lasted > 0) { apply_acpkm_grasshopper(c, &num); grasshopper_encrypt_block(&c->c.encrypt_round_keys,