Re: [PATCH 1/2] crypto: streebog - add Streebog hash function

From: Vitaly Chikunov
Date: Tue Oct 09 2018 - 02:57:25 EST


On Sun, Oct 07, 2018 at 12:41:10PM +0300, Vitaly Chikunov wrote:
> Add GOST/IETF Streebog hash function (GOST R 34.11-2012, RFC 6986)
> generic hash transformation.
>
> Signed-off-by: Vitaly Chikunov <vt@xxxxxxxxxxxx>
> ---
> crypto/Kconfig | 12 +
> crypto/Makefile | 1 +
> crypto/streebog_generic.c | 1142 +++++++++++++++++++++++++++++++++++++++++++++
> include/crypto/streebog.h | 34 ++
> 4 files changed, 1189 insertions(+)
> create mode 100644 crypto/streebog_generic.c
> create mode 100644 include/crypto/streebog.h
>
> diff --git a/crypto/streebog_generic.c b/crypto/streebog_generic.c
> --- /dev/null
> +++ b/crypto/streebog_generic.c
> @@ -0,0 +1,1142 @@
>> ...
> +static inline void add512(const struct streebog_uint512 *x,
> + const struct streebog_uint512 *y,
> + struct streebog_uint512 *r)
> +{
> + u64 carry = 0;
> + int i;
> +
> + for (i = 0; i < 8; i++) {
> + const u64 left = le64_to_cpu(x->qword[i]);
> + u64 sum;
> +
> + sum = left + le64_to_cpu(y->qword[i]) + carry;
> + if (sum != left)
> + carry = (sum < left);
> + r->qword[i] = sum;

Last assignment should be: r->qword[i] = cpu_to_le64(sum).