// SPDX-License-Identifier: GPL-2.0+ OR BSD-2-Clause
/*
* Streebog hash function as specified by GOST R 34.11-2012 and
* described at https://tools.ietf.org/html/rfc6986
*
* Copyright (c) 2013 Alexey Degtyarev <alexey@renatasystems.org>
* Copyright (c) 2018 Vitaly Chikunov <vt@altlinux.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*/
#include <crypto/internal/hash.h>
#include <linux/module.h>
#include <linux/crypto.h>
#include <crypto/streebog.h>
static const struct streebog_uint512 buffer0 = { {
0, 0, 0, 0, 0, 0, 0, 0
} };
static const struct streebog_uint512 buffer512 = { {
cpu_to_le64(0x200), 0, 0, 0, 0, 0, 0, 0
} };
static const struct streebog_uint512 C[12] = {
{ {
cpu_to_le64(0xdd806559f2a64507ULL),
cpu_to_le64(0x05767436cc744d23ULL),
cpu_to_le64(0xa2422a08a460d315ULL),
cpu_to_le64(0x4b7ce09192676901ULL),
cpu_to_le64(0x714eb88d7585c4fcULL),
cpu_to_le64(0x2f6a76432e45d016ULL),
cpu_to_le64(0xebcb2f81c0657c1fULL),
cpu_to_le64(0xb1085bda1ecadae9ULL)
} },
{ {
cpu_to_le64(0xe679047021b19bb7ULL),
cpu_to_le64(0x55dda21bd7cbcd56ULL),
cpu_to_le64(0x5cb561c2db0aa7caULL),
cpu_to_le64(0x9ab5176b12d69958ULL),
cpu_to_le64(0x61d55e0f16b50131ULL),
cpu_to_le64(0xf3feea720a232b98ULL),
cpu_to_le64(0x4fe39d460f70b5d7ULL),
cpu_to_le64(0x6fa3b58aa99d2f1aULL)
} },
{ {
cpu_to_le64(0x991e96f50aba0ab2ULL),
cpu_to_le64(0xc2b6f443867adb31ULL),
cpu_to_le64(0xc1c93a376062db09ULL),
cpu_to_le64(0xd3e20fe490359eb1ULL),
cpu_to_le64(0xf2ea7514b1297b7bULL),
cpu_to_le64(0x06f15e5f529c1f8bULL),
cpu_to_le64(0x0a39fc286a3d8435ULL),
cpu_to_le64(0xf574dcac2bce2fc7ULL)
} },
{ {
cpu_to_le64(0x220cbebc84e3d12eULL),
cpu_to_le64(0x3453eaa193e837f1ULL),
cpu_to_le64(0xd8b71333935203beULL),
cpu_to_le64(0xa9d72c82ed03d675ULL),
cpu_to_le64(0x9d721cad685e353fULL),
cpu_to_le64(0x488e857e335c3c7dULL),
cpu_to_le64(0xf948e1a05d71e4ddULL),
cpu_to_le64(0xef1fdfb3e81566d2ULL)
} },
{ {
cpu_to_le64(0x601758fd7c6cfe57ULL),
cpu_to_le64(0x7a56a27ea9ea63f5ULL),
cpu_to_le64(0xdfff00b723271a16ULL),
cpu_to_le64(0xbfcd1747253af5a3ULL),
cpu_to_le64(0x359e35d7800fffbdULL),
cpu_to_le64(0x7f151c1f1686104aULL),
cpu_to_le64(0x9a3f410c6ca92363ULL),
cpu_to_le64(0x4bea6bacad474799ULL)
} },
{ {
cpu_to_le64(0xfa68407a46647d6eULL),
cpu_to_le64(0xbf71c57236904f35ULL),
cpu_to_le64(0x0af21f66c2bec6b6ULL),
cpu_to_le64(0xcffaa6b71c9ab7b4ULL),
cpu_to_le64(0x187f9ab49af08ec6ULL),
cpu_to_le64(0x2d66c4f95142a46cULL),
cpu_to_le64(0x6fa4c33b7a3039c0ULL),
cpu_to_le64(0xae4faeae1d3ad3d9ULL)
} },
{ {
cpu_to_le64(0x8886564d3a14d493ULL),
cpu_to_le64(0x3517454ca23c4af3ULL),
cpu_to_le64(0x06476983284a0504ULL),
cpu_to_le64(0x0992abc52d822c37ULL),
cpu_to_le64(0xd3473e33197a93c9ULL),
cpu_to_le64(0x399ec6c7e6bf87c9ULL),
cpu_to_le64(0x51ac86febf240954ULL),
cpu_to_le64(0xf4c70e16eeaac5ecULL)
} },
{ {
cpu_to_le64(0xa47f0dd4bf02e71eULL),
cpu_to_le64(0x36acc2355951a8d9ULL),
cpu_to_le64(0x69d18d2bd1a5c42fULL),
cpu_to_le64(0xf4892bcb929b0690ULL),
cpu_to_le64(0x89b4443b4ddbc49aULL),
cpu_to_le64(0x4eb7f8719c36de1eULL),
cpu_to_le64(0x03e7aa020c6e4141ULL),
cpu_to_le64(0x9b1f5b424d93c9a7ULL)
} },
{ {
cpu_to_le64(0x7261445183235adbULL),
cpu_to_le64(0x0e38dc92cb1f2a60ULL),
cpu_to_le64(0x7b2b8a9aa6079c54ULL),
cpu_to_le64(0x800a440bdbb2ceb1ULL),
cpu_to_le64(0x3cd955b7e00d0984ULL),
cpu_to_le64(0x3a7d3a1b25894224ULL),
cpu_to_le64(0x944c9ad8ec165fdeULL),
cpu_to_le64(0x378f5a541631229bULL)
} },
{ {
cpu_to_le64(0x74b4c7fb98459cedULL),
cpu_to_le64(0x3698fad1153bb6c3ULL),
cpu_to_le64(0x7a1e6c303b7652f4ULL),
cpu_to_le64(0x9fe76702af69334bULL),
cpu_to_le64(0x1fffe18a1b336103ULL),
cpu_to_le64(0x8941e71cff8a78dbULL),
cpu_to_le64(0x382ae548b2e4f3f3ULL),
cpu_to_le64(0xabbedea680056f52ULL)
} },
{