X-Git-Url: http://www.wagner.pp.ru/gitweb/?p=openssl-gost%2Fengine.git;a=blobdiff_plain;f=gosthash2012.c;h=91c2c9462518681df33e7536dba0b06e24dc73de;hp=60fa43696b6bd2efd0c7198d836b183c00a38d11;hb=HEAD;hpb=053ecb0a582e2dbfba5ddd6dc8dafb5698051ac4 diff --git a/gosthash2012.c b/gosthash2012.c index 60fa436..91c2c94 100644 --- a/gosthash2012.c +++ b/gosthash2012.c @@ -69,28 +69,28 @@ static INLINE void add512(union uint512_u * RESTRICT x, # ifdef HAVE_ADDCARRY_U64 for (i = 0; i < 8; i++) - CF = _addcarry_u64(CF, x->QWORD[i] , y->QWORD[i], &(x->QWORD[i])); + CF = _addcarry_u64(CF, x->QWORD[i] , y->QWORD[i], &(x->QWORD[i])); # else for (i = 0; i < 8; i++) { - const unsigned long long left = x->QWORD[i]; - unsigned long long sum; - - sum = left + y->QWORD[i] + CF; - /* - * (sum == left): is noop, because it's possible only - * when `left' is added with `0 + 0' or with `ULLONG_MAX + 1', - * in that case `CF' (carry) retain previous value, which is correct, - * because when `left + 0 + 0' there was no overflow (thus no carry), - * and when `left + ULLONG_MAX + 1' value is wrapped back to - * itself with overflow, thus creating carry. - * - * (sum != left): - * if `sum' is not wrapped (sum > left) there should not be carry, - * if `sum' is wrapped (sum < left) there should be carry. - */ - if (sum != left) - CF = (sum < left); - x->QWORD[i] = sum; + const unsigned long long left = x->QWORD[i]; + unsigned long long sum; + + sum = left + y->QWORD[i] + CF; + /* + * (sum == left): is noop, because it's possible only + * when `left' is added with `0 + 0' or with `ULLONG_MAX + 1', + * in that case `CF' (carry) retain previous value, which is correct, + * because when `left + 0 + 0' there was no overflow (thus no carry), + * and when `left + ULLONG_MAX + 1' value is wrapped back to + * itself with overflow, thus creating carry. + * + * (sum != left): + * if `sum' is not wrapped (sum > left) there should not be carry, + * if `sum' is wrapped (sum < left) there should be carry. + */ + if (sum != left) + CF = (sum < left); + x->QWORD[i] = sum; } # endif /* !__x86_64__ */ #else /* __GOST3411_BIG_ENDIAN__ */ @@ -195,7 +195,6 @@ static INLINE void stage3(gost2012_hash_ctx * CTX) void gost2012_hash_block(gost2012_hash_ctx * CTX, const unsigned char *data, size_t len) { - register size_t chunksize; register size_t bufsize = CTX->bufsize; if (bufsize == 0) { @@ -208,7 +207,7 @@ void gost2012_hash_block(gost2012_hash_ctx * CTX, } while (len) { - chunksize = 64 - bufsize; + register size_t chunksize = 64 - bufsize; if (chunksize > len) chunksize = len;