From patchwork Wed Jan 28 09:03:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Stoica X-Patchwork-Id: 5729801 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 871A5BF440 for ; Wed, 28 Jan 2015 20:36:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B228C20221 for ; Wed, 28 Jan 2015 20:36:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B20592013A for ; Wed, 28 Jan 2015 20:36:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760851AbbA1UgH (ORCPT ); Wed, 28 Jan 2015 15:36:07 -0500 Received: from mail-bn1bon0143.outbound.protection.outlook.com ([157.56.111.143]:64934 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756518AbbA1UgE (ORCPT ); Wed, 28 Jan 2015 15:36:04 -0500 Received: from CY1PR0301MB0620.namprd03.prod.outlook.com (25.160.142.27) by CY1PR0301MB0764.namprd03.prod.outlook.com (25.160.160.12) with Microsoft SMTP Server (TLS) id 15.1.65.19; Wed, 28 Jan 2015 09:03:28 +0000 Received: from BN3PR0301CA0034.namprd03.prod.outlook.com (25.160.180.172) by CY1PR0301MB0620.namprd03.prod.outlook.com (25.160.142.27) with Microsoft SMTP Server (TLS) id 15.1.75.20; Wed, 28 Jan 2015 09:03:26 +0000 Received: from BY2FFO11FD011.protection.gbl (2a01:111:f400:7c0c::138) by BN3PR0301CA0034.outlook.office365.com (2a01:111:e400:4000::44) with Microsoft SMTP Server (TLS) id 15.1.75.20 via Frontend Transport; Wed, 28 Jan 2015 09:03:26 +0000 Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11FD011.mail.protection.outlook.com (10.1.14.129) with Microsoft SMTP Server (TLS) id 15.1.75.11 via Frontend Transport; Wed, 28 Jan 2015 09:03:25 +0000 Received: from enigma.ea.freescale.net (enigma.ea.freescale.net [10.171.77.120]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id t0S93MUP005114; Wed, 28 Jan 2015 02:03:23 -0700 From: Cristian Stoica To: , CC: , Cristian Stoica Subject: [PATCH] crypto: testmgr: limit IV copy length in aead tests Date: Wed, 28 Jan 2015 11:03:05 +0200 Message-ID: <1422435785-31259-1-git-send-email-cristian.stoica@freescale.com> X-Mailer: git-send-email 2.2.0 X-EOPAttributedMessage: 0 Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=cristian.stoica@freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; freescale.mail.onmicrosoft.com; dmarc=permerror action=none header.from=freescale.com; X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(50986999)(19580395003)(19580405001)(36756003)(50226001)(6806004)(229853001)(47776003)(85426001)(46102003)(105606002)(87936001)(33646002)(92566002)(50466002)(48376002)(77156002)(62966003)(77096005)(104016003); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR0301MB0620; H:tx30smr01.am.freescale.net; FPR:; SPF:None; MLV:sfv; LANG:en; MIME-Version: 1.0 X-DmarcAction-Test: None X-Microsoft-Antispam: UriScan:;UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(3005004);SRVR:CY1PR0301MB0620; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004); SRVR:CY1PR0301MB0620; X-Forefront-PRVS: 047001DADA X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:; SRVR:CY1PR0301MB0620; X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2015 09:03:25.8401 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.168.50] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB0620 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB0764; X-OriginatorOrg: freescale.com Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The working copy of IV is the same size as the transformation's IV. It is not necessary to copy more than that from the template since iv_len is usually less than MAX_IVLEN and the rest of the copied data is garbage. Signed-off-by: Cristian Stoica --- crypto/testmgr.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 758d028..f4ed6d4 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c @@ -429,7 +429,7 @@ static int __test_aead(struct crypto_aead *tfm, int enc, struct scatterlist *sgout; const char *e, *d; struct tcrypt_result result; - unsigned int authsize; + unsigned int authsize, iv_len; void *input; void *output; void *assoc; @@ -500,10 +500,11 @@ static int __test_aead(struct crypto_aead *tfm, int enc, memcpy(input, template[i].input, template[i].ilen); memcpy(assoc, template[i].assoc, template[i].alen); + iv_len = crypto_aead_ivsize(tfm); if (template[i].iv) - memcpy(iv, template[i].iv, MAX_IVLEN); + memcpy(iv, template[i].iv, iv_len); else - memset(iv, 0, MAX_IVLEN); + memset(iv, 0, iv_len); crypto_aead_clear_flags(tfm, ~0); if (template[i].wk)