X-Git-Url: http://www.wagner.pp.ru/gitweb/?p=openssl-gost%2Fengine.git;a=blobdiff_plain;f=gosthash.c;h=7fd3cb058b6abf27ddd49c00552708e19825a1c1;hp=72faa24ed5605fafc8db7316396f957e875a8fb1;hb=HEAD;hpb=c98ba9d03213d0c63d6874539d59f7b55fbc3fae diff --git a/gosthash.c b/gosthash.c index 72faa24..7fd3cb0 100644 --- a/gosthash.c +++ b/gosthash.c @@ -65,9 +65,8 @@ static int add_blocks(int n, byte * left, const byte * right) { int i; int carry = 0; - int sum; for (i = 0; i < n; i++) { - sum = (int)left[i] + (int)right[i] + carry; + int sum = (int)left[i] + (int)right[i] + carry; left[i] = sum & 0xff; carry = sum >> 8; } @@ -154,7 +153,7 @@ static int hash_step(gost_ctx * c, byte * H, const byte * M) int init_gost_hash_ctx(gost_hash_ctx * ctx, const gost_subst_block * subst_block) { - memset(ctx, 0, sizeof(gost_hash_ctx)); + memset(ctx, 0, sizeof(*ctx)); ctx->cipher_ctx = (gost_ctx *) MYALLOC(sizeof(gost_ctx)); if (!ctx->cipher_ctx) { return 0; @@ -255,6 +254,8 @@ int finish_hash(gost_hash_ctx * ctx, byte * hashval) fin_len += ctx->left; } memset(buf, 0, 32); + if (fin_len == 0) + hash_step(ctx->cipher_ctx, H, buf); bptr = buf; fin_len <<= 3; /* Hash length in BITS!! */ while (fin_len > 0) {