From patchwork Tue Apr 1 16:18:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 27552 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f198.google.com (mail-ig0-f198.google.com [209.85.213.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D33C820553 for ; Tue, 1 Apr 2014 16:18:44 +0000 (UTC) Received: by mail-ig0-f198.google.com with SMTP id ur14sf13720977igb.1 for ; Tue, 01 Apr 2014 09:18:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=pTYZ5EbHo3FBWcd5I+pDfEKCEunW+lgjcq4WIZEXxIA=; b=RcOYd+xY9Y/n3fj0s9+67S5GML9K5rktEH9J8Je2MBrTtHcMJQfEHJ3Mn9SrZaaNVu nqIlrnI6+tT9x0vW4rocyTwxKdv3YVDQbwA3DdcnuLg2dZ9b1Xjo6flG67Gar9vEbOEU T92S2kqTVbsWcoXavvATa/8/UleWN/m3YF+WYlY6chygsLrsIcGgZ3RC2Xyx/lspZxVF Bq6ljVNmMZOOZVZJU8iUyo04nOE0gukBqZEcMc3sgWpntrIAn/Tj44C50iVbDthVnOew tjgY6KoaprnikapJDKt3gWKLlQLE+JwiIe1jwBVzbrsYg6acx0B02ipNI+wpNfeMjvwU f4Ag== X-Gm-Message-State: ALoCoQkStfniTU+3sThdLG8O19UcM1oFfEbv0eIB0Q+Cu9jTtTmb9rw7fdEh0WVz5Q3dfpVHUVfw X-Received: by 10.182.19.164 with SMTP id g4mr13723188obe.21.1396369124289; Tue, 01 Apr 2014 09:18:44 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.28.137 with SMTP id 9ls52411qgz.14.gmail; Tue, 01 Apr 2014 09:18:44 -0700 (PDT) X-Received: by 10.220.92.135 with SMTP id r7mr29068396vcm.11.1396369124193; Tue, 01 Apr 2014 09:18:44 -0700 (PDT) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) by mx.google.com with ESMTPS id fn10si3731281vdc.207.2014.04.01.09.18.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 01 Apr 2014 09:18:44 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.172; Received: by mail-vc0-f172.google.com with SMTP id la4so9993963vcb.17 for ; Tue, 01 Apr 2014 09:18:44 -0700 (PDT) X-Received: by 10.220.68.83 with SMTP id u19mr58967vci.52.1396369124111; Tue, 01 Apr 2014 09:18:44 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.12.8 with SMTP id v8csp250847vcv; Tue, 1 Apr 2014 09:18:43 -0700 (PDT) X-Received: by 10.68.194.97 with SMTP id hv1mr2866597pbc.162.1396369123360; Tue, 01 Apr 2014 09:18:43 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id iw3si11518653pac.465.2014.04.01.09.18.43; Tue, 01 Apr 2014 09:18:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752620AbaDAQSj (ORCPT + 1 other); Tue, 1 Apr 2014 12:18:39 -0400 Received: from mail-we0-f175.google.com ([74.125.82.175]:35330 "EHLO mail-we0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752470AbaDAQSf (ORCPT ); Tue, 1 Apr 2014 12:18:35 -0400 Received: by mail-we0-f175.google.com with SMTP id q58so6598126wes.34 for ; Tue, 01 Apr 2014 09:18:34 -0700 (PDT) X-Received: by 10.194.157.41 with SMTP id wj9mr24131355wjb.34.1396369114017; Tue, 01 Apr 2014 09:18:34 -0700 (PDT) Received: from ards-macbook-pro.local ([95.129.121.210]) by mx.google.com with ESMTPSA id p8sm41535059eef.26.2014.04.01.09.18.33 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 01 Apr 2014 09:18:33 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au Cc: Ard Biesheuvel Subject: [PATCH] crypto: add test cases for SHA-1, SHA-224 and SHA-256 Date: Tue, 1 Apr 2014 18:18:21 +0200 Message-Id: <1396369101-2302-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 Sender: linux-crypto-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This adds a test case for each of SHA-1, SHA-224 and SHA-256 with a plaintext size of 64 bytes, which is exactly the block size. The reason is that some implementations may use a different code path for inputs that are an exact multiple of the block size. --- Just some trivial test vectors I have been using locally for my work on arm64, but may be useful to send upstream. If not, that's also fine. Regards, diff --git a/crypto/testmgr.h b/crypto/testmgr.h index 7d44aa3d6b44..af00e3abd7f5 100644 --- a/crypto/testmgr.h +++ b/crypto/testmgr.h @@ -487,7 +487,7 @@ static struct hash_testvec crct10dif_tv_template[] = { * SHA1 test vectors from from FIPS PUB 180-1 * Long vector from CAVS 5.0 */ -#define SHA1_TEST_VECTORS 3 +#define SHA1_TEST_VECTORS 4 static struct hash_testvec sha1_tv_template[] = { { @@ -529,6 +529,11 @@ static struct hash_testvec sha1_tv_template[] = { "\x45\x9c\x02\xb6\x9b\x4a\xa8\xf5\x82\x17", .np = 4, .tap = { 63, 64, 31, 5 } + }, { + .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-", + .psize = 64, + .digest = "\xc8\x71\xf6\x9a\x63\xcc\xa9\x84\x84\x82" + "\x64\xe7\x79\x95\x5d\xd7\x19\x41\x7c\x91", } }; @@ -536,7 +541,7 @@ static struct hash_testvec sha1_tv_template[] = { /* * SHA224 test vectors from from FIPS PUB 180-2 */ -#define SHA224_TEST_VECTORS 2 +#define SHA224_TEST_VECTORS 3 static struct hash_testvec sha224_tv_template[] = { { @@ -556,13 +561,20 @@ static struct hash_testvec sha224_tv_template[] = { "\x52\x52\x25\x25", .np = 2, .tap = { 28, 28 } + }, { + .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-", + .psize = 64, + .digest = "\xc4\xdb\x2b\x3a\x58\xc3\x99\x01" + "\x42\xfd\x10\x92\xaa\x4e\x04\x08" + "\x58\xbb\xbb\xe8\xf8\x14\xa7\x0c" + "\xef\x3b\xcb\x0e", } }; /* * SHA256 test vectors from from NIST */ -#define SHA256_TEST_VECTORS 2 +#define SHA256_TEST_VECTORS 3 static struct hash_testvec sha256_tv_template[] = { { @@ -581,7 +593,14 @@ static struct hash_testvec sha256_tv_template[] = { "\xf6\xec\xed\xd4\x19\xdb\x06\xc1", .np = 2, .tap = { 28, 28 } - }, + }, { + .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-", + .psize = 64, + .digest = "\xb5\xfe\xad\x56\x7d\xff\xcb\xa4" + "\x2c\x32\x29\x32\x19\xbb\xfb\xfa" + "\xd6\xff\x94\xa3\x72\x91\x85\x66" + "\x3b\xa7\x87\x77\x58\xa3\x40\x3a", + } }; /*