Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp837851imm; Wed, 10 Oct 2018 05:13:55 -0700 (PDT) X-Google-Smtp-Source: ACcGV62BKcSmRrkiYov2XqMTerB5PJRmyIejwv3SJSNX0l4A292GR4xZNnlrOkT982w8BkV6/wfU X-Received: by 2002:a65:62d5:: with SMTP id m21-v6mr30122533pgv.243.1539173635862; Wed, 10 Oct 2018 05:13:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539173635; cv=none; d=google.com; s=arc-20160816; b=igBwCCsai9RokzgNf6AHpm57XMbKCMrpim5DMgZ5eroAWDGbmQh1zQHLa0kztLkFio a0iD+SDegTtvJ5ENz5dD9H70RKBcdhN8lW05mdvIMpwBnRwywi6lblVjePWk4u46srBc FK/g56nmbko0p6WqQ/xgFiLZfPsG/X9TLCIrweC9CxkWLAC2LuwyiItjzBGCQM7D1J13 2f/1otRAhsfvVq2IN3NZdZuAQZ4NHQzFqANLSjzL3Y22BisJ9VABgD3bnmv4YiFOSryD lrmUaB5OAnCra7udp/+TKVeWw1C8GhssYdfEQ90PvM58dbSC02jv/W0CIeZ1QJYKDxcN rUbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=rddgT6A0FGeLfV+yLvgM1N5XsSVHajflEChd6hBuyHU=; b=LJWMFbY/8970vgnJRNHTrySr+7pVHg+6LtQt3i5rjhROvKOk3/OqFVG/gPxfJtJGdL lKiWFzwctjdPw0oQVBQ1HJ7nOxlLJVxCRsk/eaTt7p3gnv4g9VgCkCbAktaxNNjvh+ny rpMxDkNF7hl8POjCluokV5fyby9buo2wtS9H2UzDXwvNnQ/DWzxSG2ZVmeTQAKnhAUMM bZSv9OJ5qYvW+o0y3eIC0Ai7i9ri9KhwdwvU1pmqPmEboxE879CH+40D6D8CzYnmV7Bn ZM+zP+04k3I/oi7YoZAJZKLaA0r27NmQt4pFvbHAa8txfyonfUg9naQ7Js1UuZf21pUZ oKRg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t10-v6si18553867pgm.374.2018.10.10.05.13.41; Wed, 10 Oct 2018 05:13:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727051AbeJJTfH (ORCPT + 99 others); Wed, 10 Oct 2018 15:35:07 -0400 Received: from vmicros1.altlinux.org ([194.107.17.57]:42814 "EHLO vmicros1.altlinux.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726206AbeJJTfG (ORCPT ); Wed, 10 Oct 2018 15:35:06 -0400 Received: from imap.altlinux.org (imap.altlinux.org [194.107.17.38]) by vmicros1.altlinux.org (Postfix) with ESMTP id CCE7972CC5B; Wed, 10 Oct 2018 15:13:10 +0300 (MSK) Received: from beacon.altlinux.org (unknown [185.6.174.98]) by imap.altlinux.org (Postfix) with ESMTPSA id 9A6694A4A29; Wed, 10 Oct 2018 15:13:10 +0300 (MSK) From: Vitaly Chikunov To: Herbert Xu , "David S. Miller" , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vitaly Chikunov Subject: [PATCH v2 2/2] crypto: streebog - add Streebog test vectors Date: Wed, 10 Oct 2018 15:12:52 +0300 Message-Id: <20181010121254.12220-3-vt@altlinux.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181010121254.12220-1-vt@altlinux.org> References: <20181010121254.12220-1-vt@altlinux.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add testmgr and tcrypt tests and vectors for Streebog hash function from RFC 6986 and GOST R 34.11-2012. Signed-off-by: Vitaly Chikunov --- crypto/tcrypt.c | 27 +++++++++++++++++++++ crypto/testmgr.c | 12 ++++++++++ crypto/testmgr.h | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 110 insertions(+) diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index bdde95e8d369..d66cb167daa2 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c @@ -77,6 +77,7 @@ static char *check[] = { "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt", "camellia", "seed", "salsa20", "rmd128", "rmd160", "rmd256", "rmd320", "lzo", "cts", "zlib", "sha3-224", "sha3-256", "sha3-384", "sha3-512", + "sb256", "sb512", NULL }; @@ -1914,6 +1915,14 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb) ret += tcrypt_test("sm3"); break; + case 53: + ret += tcrypt_test("sb256"); + break; + + case 54: + ret += tcrypt_test("sb512"); + break; + case 100: ret += tcrypt_test("hmac(md5)"); break; @@ -2392,6 +2401,14 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb) test_hash_speed("sm3", sec, generic_hash_speed_template); if (mode > 300 && mode < 400) break; /* fall through */ + case 327: + test_hash_speed("sb256", sec, generic_hash_speed_template); + if (mode > 300 && mode < 400) break; + /* fall through */ + case 328: + test_hash_speed("sb512", sec, generic_hash_speed_template); + if (mode > 300 && mode < 400) break; + /* fall through */ case 399: break; @@ -2505,6 +2522,16 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb) num_mb); if (mode > 400 && mode < 500) break; /* fall through */ + case 426: + test_mb_ahash_speed("sb256", sec, generic_hash_speed_template, + num_mb); + if (mode > 400 && mode < 500) break; + /* fall through */ + case 427: + test_mb_ahash_speed("sb512", sec, generic_hash_speed_template, + num_mb); + if (mode > 400 && mode < 500) break; + /* fall through */ case 499: break; diff --git a/crypto/testmgr.c b/crypto/testmgr.c index a1d42245082a..6efb0a218b41 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c @@ -3428,6 +3428,18 @@ static const struct alg_test_desc alg_test_descs[] = { .cipher = __VECS(salsa20_stream_tv_template) } }, { + .alg = "sb256", + .test = alg_test_hash, + .suite = { + .hash = __VECS(sb256_tv_template) + } + }, { + .alg = "sb512", + .test = alg_test_hash, + .suite = { + .hash = __VECS(sb512_tv_template) + } + }, { .alg = "sha1", .test = alg_test_hash, .fips_allowed = 1, diff --git a/crypto/testmgr.h b/crypto/testmgr.h index 173111c70746..9f9b7d6e4072 100644 --- a/crypto/testmgr.h +++ b/crypto/testmgr.h @@ -2309,6 +2309,77 @@ static const struct hash_testvec crct10dif_tv_template[] = { } }; +/* + * Streebog test vectors from RFC 6986 and GOST R 34.11-2012 + */ +static const struct hash_testvec sb256_tv_template[] = { + { /* M1 */ + .plaintext = "012345678901234567890123456789012345678901234567890123456789012", + .psize = 63, + .digest = + "\x9d\x15\x1e\xef\xd8\x59\x0b\x89" + "\xda\xa6\xba\x6c\xb7\x4a\xf9\x27" + "\x5d\xd0\x51\x02\x6b\xb1\x49\xa4" + "\x52\xfd\x84\xe5\xe5\x7b\x55\x00", + }, + { /* M2 */ + .plaintext = + "\xd1\xe5\x20\xe2\xe5\xf2\xf0\xe8" + "\x2c\x20\xd1\xf2\xf0\xe8\xe1\xee" + "\xe6\xe8\x20\xe2\xed\xf3\xf6\xe8" + "\x2c\x20\xe2\xe5\xfe\xf2\xfa\x20" + "\xf1\x20\xec\xee\xf0\xff\x20\xf1" + "\xf2\xf0\xe5\xeb\xe0\xec\xe8\x20" + "\xed\xe0\x20\xf5\xf0\xe0\xe1\xf0" + "\xfb\xff\x20\xef\xeb\xfa\xea\xfb" + "\x20\xc8\xe3\xee\xf0\xe5\xe2\xfb", + .psize = 72, + .digest = + "\x9d\xd2\xfe\x4e\x90\x40\x9e\x5d" + "\xa8\x7f\x53\x97\x6d\x74\x05\xb0" + "\xc0\xca\xc6\x28\xfc\x66\x9a\x74" + "\x1d\x50\x06\x3c\x55\x7e\x8f\x50", + }, +}; + +static const struct hash_testvec sb512_tv_template[] = { + { /* M1 */ + .plaintext = "012345678901234567890123456789012345678901234567890123456789012", + .psize = 63, + .digest = + "\x1b\x54\xd0\x1a\x4a\xf5\xb9\xd5" + "\xcc\x3d\x86\xd6\x8d\x28\x54\x62" + "\xb1\x9a\xbc\x24\x75\x22\x2f\x35" + "\xc0\x85\x12\x2b\xe4\xba\x1f\xfa" + "\x00\xad\x30\xf8\x76\x7b\x3a\x82" + "\x38\x4c\x65\x74\xf0\x24\xc3\x11" + "\xe2\xa4\x81\x33\x2b\x08\xef\x7f" + "\x41\x79\x78\x91\xc1\x64\x6f\x48", + }, + { /* M2 */ + .plaintext = + "\xd1\xe5\x20\xe2\xe5\xf2\xf0\xe8" + "\x2c\x20\xd1\xf2\xf0\xe8\xe1\xee" + "\xe6\xe8\x20\xe2\xed\xf3\xf6\xe8" + "\x2c\x20\xe2\xe5\xfe\xf2\xfa\x20" + "\xf1\x20\xec\xee\xf0\xff\x20\xf1" + "\xf2\xf0\xe5\xeb\xe0\xec\xe8\x20" + "\xed\xe0\x20\xf5\xf0\xe0\xe1\xf0" + "\xfb\xff\x20\xef\xeb\xfa\xea\xfb" + "\x20\xc8\xe3\xee\xf0\xe5\xe2\xfb", + .psize = 72, + .digest = + "\x1e\x88\xe6\x22\x26\xbf\xca\x6f" + "\x99\x94\xf1\xf2\xd5\x15\x69\xe0" + "\xda\xf8\x47\x5a\x3b\x0f\xe6\x1a" + "\x53\x00\xee\xe4\x6d\x96\x13\x76" + "\x03\x5f\xe8\x35\x49\xad\xa2\xb8" + "\x62\x0f\xcd\x7c\x49\x6c\xe5\xb3" + "\x3f\x0c\xb9\xdd\xdc\x2b\x64\x60" + "\x14\x3b\x03\xda\xba\xc9\xfb\x28", + }, +}; + /* Example vectors below taken from * http://www.oscca.gov.cn/UpFile/20101222141857786.pdf * -- 2.11.0