X-Git-Url: http://wagner.pp.ru/gitweb/?a=blobdiff_plain;f=gost_grasshopper_cipher.c;h=e7c8dd6299de4e93001e53b08370dda259ee1c3d;hb=5186d798730c1ecec7ed40126beaf493804fcf45;hp=20c04b0d7f5e12de1925ac6cc219851ed5e23a0f;hpb=586ebd520657eaed361968c55c1ef3e268cf5053;p=openssl-gost%2Fengine.git diff --git a/gost_grasshopper_cipher.c b/gost_grasshopper_cipher.c index 20c04b0..e7c8dd6 100644 --- a/gost_grasshopper_cipher.c +++ b/gost_grasshopper_cipher.c @@ -17,6 +17,7 @@ extern "C" { #include #include +#include "gost_lcl.h" #include "e_gost_err.h" enum GRASSHOPPER_CIPHER_TYPE { @@ -279,11 +280,10 @@ int gost_grasshopper_cipher_do_cbc(EVP_CIPHER_CTX* ctx, unsigned char* out, return 1; } -/* increment counter (128-bit int) by 1 */ -static void ctr128_inc(unsigned char *counter) +void inc_counter(unsigned char* counter, size_t counter_bytes) { - unsigned int n = 16; unsigned char c; + unsigned int n = counter_bytes; do { --n; @@ -294,6 +294,12 @@ static void ctr128_inc(unsigned char *counter) } while (n); } +/* increment counter (128-bit int) by 1 */ +static void ctr128_inc(unsigned char *counter) +{ + inc_counter(counter, 16); +} + int gost_grasshopper_cipher_do_ctr(EVP_CIPHER_CTX* ctx, unsigned char* out, const unsigned char* in, size_t inl) { gost_grasshopper_cipher_ctx_ctr* c = (gost_grasshopper_cipher_ctx_ctr*) EVP_CIPHER_CTX_get_cipher_data(ctx);