From patchwork Thu Apr 10 17:16:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 28238 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f198.google.com (mail-vc0-f198.google.com [209.85.220.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 24DAF212DC for ; Thu, 10 Apr 2014 17:17:02 +0000 (UTC) Received: by mail-vc0-f198.google.com with SMTP id il7sf12423634vcb.9 for ; Thu, 10 Apr 2014 10:17:01 -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=wSfoHVuFG4mxG9XzFC3Sb60fZiD/+8+6svlWE0h2Xak=; b=gTcKdCHdrvRENN3RLjlD1SFRTZnZLxgiFF9dSVE6eozFq6G1hK/SnMn78qIVLnuu7g KsqOibp2Ivkj09IsZ1bthlqucBzK3Iw+tXa6v74SxyDn132Vw21HT23tSdtgcFSRPmB2 SDEClSC668MmR3Zqakt4Vz5+3WGq1qORy8XBu/0YfDcb4ECwisNvOl7SKQ10QXXJXSB2 THAQ8/mDSKW4cZsf9Pvvkf7Szjr2L85kc2YH5CP0P6g6kx22JPIMal138OOc0X9hJFbO bdA5IyC0aFF8W3YsyqchSlHqN8usLYLnS15tFENfaSBwjdEhK0Yv00Ntozv5uHXxglNV MLIg== X-Gm-Message-State: ALoCoQmP1Y9MO5GfOhgxtQT2rASHjkofpjbHsc8f5m3/x2uT5JNtmSkKaVgNRBkIlOxzFq+c9Wc2 X-Received: by 10.236.181.74 with SMTP id k50mr7313193yhm.46.1397150221891; Thu, 10 Apr 2014 10:17:01 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.92.163 with SMTP id b32ls1278575qge.22.gmail; Thu, 10 Apr 2014 10:17:01 -0700 (PDT) X-Received: by 10.220.159.4 with SMTP id h4mr15472412vcx.1.1397150221723; Thu, 10 Apr 2014 10:17:01 -0700 (PDT) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by mx.google.com with ESMTPS id rw10si806495vec.80.2014.04.10.10.17.01 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 10 Apr 2014 10:17:01 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.169; Received: by mail-ve0-f169.google.com with SMTP id pa12so3829830veb.0 for ; Thu, 10 Apr 2014 10:17:01 -0700 (PDT) X-Received: by 10.52.251.199 with SMTP id zm7mr12912250vdc.21.1397150221638; Thu, 10 Apr 2014 10:17:01 -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.221.72 with SMTP id ib8csp76933vcb; Thu, 10 Apr 2014 10:17:01 -0700 (PDT) X-Received: by 10.68.139.71 with SMTP id qw7mr21159201pbb.68.1397150220926; Thu, 10 Apr 2014 10:17:00 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sr9si2570074pab.202.2014.04.10.10.17.00; Thu, 10 Apr 2014 10:17:00 -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 S1758794AbaDJRQ4 (ORCPT ); Thu, 10 Apr 2014 13:16:56 -0400 Received: from mail-ee0-f48.google.com ([74.125.83.48]:61141 "EHLO mail-ee0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758758AbaDJRQx (ORCPT ); Thu, 10 Apr 2014 13:16:53 -0400 Received: by mail-ee0-f48.google.com with SMTP id b57so3234069eek.21 for ; Thu, 10 Apr 2014 10:16:52 -0700 (PDT) X-Received: by 10.14.94.5 with SMTP id m5mr22297894eef.23.1397150212191; Thu, 10 Apr 2014 10:16:52 -0700 (PDT) Received: from ards-macbook-pro.local ([188.207.99.109]) by mx.google.com with ESMTPSA id m44sm11306895eep.14.2014.04.10.10.16.50 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 10 Apr 2014 10:16:51 -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, SHA-256 and AES-CCM Date: Thu, 10 Apr 2014 19:16:43 +0200 Message-Id: <1397150203-12654-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.128.169 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 test cases for SHA-1, SHA-224, SHA-256 and AES-CCM with an input size that is an exact multiple of the block size. The reason is that some implementations use a different code path for these cases. Signed-off-by: Ard Biesheuvel --- This is the same patch as I posted last week, but this time with the S-o-b line, and I also added another test case that I used to test my Arm64 AES in CCM mode. crypto/testmgr.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/crypto/testmgr.h b/crypto/testmgr.h index 3db83dbba1d9..c5d911dd8039 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", + } }; /* @@ -12844,7 +12863,7 @@ static struct cipher_testvec cast6_xts_dec_tv_template[] = { #define AES_GCM_4106_DEC_TEST_VECTORS 7 #define AES_GCM_4543_ENC_TEST_VECTORS 1 #define AES_GCM_4543_DEC_TEST_VECTORS 2 -#define AES_CCM_ENC_TEST_VECTORS 7 +#define AES_CCM_ENC_TEST_VECTORS 8 #define AES_CCM_DEC_TEST_VECTORS 7 #define AES_CCM_4309_ENC_TEST_VECTORS 7 #define AES_CCM_4309_DEC_TEST_VECTORS 10 @@ -18746,7 +18765,29 @@ static struct aead_testvec aes_ccm_enc_tv_template[] = { "\x7c\xf9\xbe\xc2\x40\x88\x97\xc6" "\xba", .rlen = 33, - }, + }, { + /* + * This is the same vector as aes_ccm_rfc4309_enc_tv_template[0] + * below but rewritten to use the ccm algorithm directly. + */ + .key = "\x83\xac\x54\x66\xc2\xeb\xe5\x05" + "\x2e\x01\xd1\xfc\x5d\x82\x66\x2e", + .klen = 16, + .iv = "\x03\x96\xac\x59\x30\x07\xa1\xe2\xa2\xc7\x55\x24\0\0\0\0", + .alen = 0, + .input = "\x19\xc8\x81\xf6\xe9\x86\xff\x93" + "\x0b\x78\x67\xe5\xbb\xb7\xfc\x6e" + "\x83\x77\xb3\xa6\x0c\x8c\x9f\x9c" + "\x35\x2e\xad\xe0\x62\xf9\x91\xa1", + .ilen = 32, + .result = "\xab\x6f\xe1\x69\x1d\x19\x99\xa8" + "\x92\xa0\xc4\x6f\x7e\xe2\x8b\xb1" + "\x70\xbb\x8c\xa6\x4c\x6e\x97\x8a" + "\x57\x2b\xbe\x5d\x98\xa6\xb1\x32" + "\xda\x24\xea\xd9\xa1\x39\x98\xfd" + "\xa4\xbe\xd9\xf2\x1a\x6d\x22\xa8", + .rlen = 48, + } }; static struct aead_testvec aes_ccm_dec_tv_template[] = {