From patchwork Sun Dec 17 08:29:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 122175 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1514623qgn; Sun, 17 Dec 2017 00:30:16 -0800 (PST) X-Google-Smtp-Source: ACJfBotG9N5mD1hQRmPPHlo4GEUfylXK3Yt48zYFD+mka4QXCMTolmImSOxH2FI/RuO04xo3bKoa X-Received: by 10.84.149.102 with SMTP id b35mr14384792plh.240.1513499416527; Sun, 17 Dec 2017 00:30:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513499416; cv=none; d=google.com; s=arc-20160816; b=Hq6neC6Sweckcl14daFjYqqRDmZKUrSZlOVMPPbyh29zJtZwL64ihZttZTJTRqGc1Q 7HHudNejdHC/ZWDY1JDlDwClK+jcYGqcemfPpF0px+nrs6/ae9ykZscRqJsiP559TRwr hZo7qopTUs9mFR4iDh66nGIWemicrQ+UUqmzMaSiFzdN21aY2LL7lIg+mEWiCSBU2sSV ea8gf7YUsXznApUJif88fR9Qau5yVmK/7CCFWCVSxdr4x3xtKrSl6dTdgLL6YH5v8nCI zLQFpVOlLGUcWCyskKojGfqyYDiC8FObDtuVtikwtNiCFyheb3yAM/V5x5ABIkfD6LYa cRKA== 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:arc-authentication-results; bh=L8KjKlO1ZfH+ivRDQaBMbef9fN+P6ooeJ4Rmom6/Tlk=; b=TP17bgb83q9pfv0s+NGAo7e9vjm1m8sWRu5Y7jU28dFOPgok0+IK3oxz5cIyEjZVdZ GQmEm7FBT4OMLLXieDY7MmCf+Ju4m8TNVlsNiMkVEPO+mDu0Z7toSps846RbsSMN2QMM HjTAMT+HbX6HbjxiuUMWbJOkoIqCwNJXFEo91fDkHnNkDDOSL8wUSqcV4fl4r3X/vSRS aMV6kkO2e8ahzNgwidtEHQHOIAIJHp64X1U8Wd1ja6WNSjIFIfkjO9tK330r4/kHjivs WdBIQjH5BPu4PucQBkZrraFueJZf6XHW2DB81jBRu3E86mgPWTxUcq6H8o14YdtUW41h xu0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-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 w7si7550038plp.574.2017.12.17.00.30.16; Sun, 17 Dec 2017 00:30:16 -0800 (PST) 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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751650AbdLQIaN (ORCPT + 1 other); Sun, 17 Dec 2017 03:30:13 -0500 Received: from foss.arm.com ([217.140.101.70]:40914 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751005AbdLQIaI (ORCPT ); Sun, 17 Dec 2017 03:30:08 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2963D1435; Sun, 17 Dec 2017 00:30:08 -0800 (PST) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 56C793F24A; Sun, 17 Dec 2017 00:30:06 -0800 (PST) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" Cc: Ofir Drang , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/6] crypto: tcrypt: fix AEAD decryption speed test Date: Sun, 17 Dec 2017 08:29:01 +0000 Message-Id: <1513499346-9047-3-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513499346-9047-1-git-send-email-gilad@benyossef.com> References: <1513499346-9047-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The AEAD speed test pretended to support decryption, however that support was broken as decryption requires a valid auth field which the test did not provide. Fix this by running the encryption path once with inout/output sgls switched to calculate the auth field prior to performing decryption speed tests. Signed-off-by: Gilad Ben-Yossef --- crypto/tcrypt.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index a0c4e0d..69c8e63 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c @@ -329,10 +329,30 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, *b_size + (enc ? authsize : 0), assoc, aad_size); + aead_request_set_ad(req, aad_size); + + if (!enc) { + + /* + * For decryption we need a proper auth so + * we do the encryption path once with buffers + * reversed (input <-> output) to calculate it + */ + aead_request_set_crypt(req, sgout, sg, + *b_size, iv); + ret = do_one_aead_op(req, + crypto_aead_encrypt(req)); + + if (ret) { + pr_err("calculating auth failed failed (%d)\n", + ret); + break; + } + } + aead_request_set_crypt(req, sg, sgout, *b_size + (enc ? 0 : authsize), iv); - aead_request_set_ad(req, aad_size); if (secs) ret = test_aead_jiffies(req, enc, *b_size, @@ -1566,16 +1586,24 @@ static int do_test(const char *alg, u32 type, u32 mask, int m) NULL, 0, 16, 16, aead_speed_template_20); test_aead_speed("gcm(aes)", ENCRYPT, sec, NULL, 0, 16, 8, speed_template_16_24_32); + test_aead_speed("rfc4106(gcm(aes))", DECRYPT, sec, + NULL, 0, 16, 16, aead_speed_template_20); + test_aead_speed("gcm(aes)", DECRYPT, sec, + NULL, 0, 16, 8, speed_template_16_24_32); break; case 212: test_aead_speed("rfc4309(ccm(aes))", ENCRYPT, sec, NULL, 0, 16, 16, aead_speed_template_19); + test_aead_speed("rfc4309(ccm(aes))", DECRYPT, sec, + NULL, 0, 16, 16, aead_speed_template_19); break; case 213: test_aead_speed("rfc7539esp(chacha20,poly1305)", ENCRYPT, sec, NULL, 0, 16, 8, aead_speed_template_36); + test_aead_speed("rfc7539esp(chacha20,poly1305)", DECRYPT, sec, + NULL, 0, 16, 8, aead_speed_template_36); break; case 214: