Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2587974pxk; Sun, 20 Sep 2020 09:22:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDrnamfnbuIn5w4zknqMiWfVLKijfoe0m0vCDBFHyyPl1S2H8FT9y0r4aBgsR3mVlsHJHa X-Received: by 2002:a05:6402:13d3:: with SMTP id a19mr47488548edx.255.1600618969721; Sun, 20 Sep 2020 09:22:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600618969; cv=none; d=google.com; s=arc-20160816; b=iK3Z1z6w+jyYnDJT1avtus1EgFgT6G4hOaDMb28ci79iP0dPm4fWNmY+WWex191I3z 1fUaaTZrHaYRbEwnxIgJEvAhTGM75joGeCzAnk8bF9mE4BdyT5vwjebhh5u9U08Ezehg UDxVHifAQQ1aQTuEoaxRTlu0M3EXmzHadxSZLr+oG8xNaTB8DvsJMp4q5+Cz2Lzeltaf QRnzmUvXXYg5DWOVYVGjAHn8/qS+NPrg254zKvlWbOj9ka+6l1jKNwBdcXR1/boBH48l bkr5+qf4ZOdx5crpmbXTTwz0ZUIsfcUMiucD+soOyabL86FZZlR1hB7w3x2Al/wgspSW ds9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=SiAjCeIemu1fq0YPzRjB2g+0LMCCY6s6idJf6vUyRHo=; b=ZG4Vk/bRaBn5XkFbyWb2+U3AIM6u8+qtfvvzrFW/fhniZQMsF74t+FHCsLYbIvBBLR Db3/hE0Bf/dUptHyZlG0dg3nPPYqwYNNCTQwHAWPfrpYxq6ywArqDZSqHlIUpUvlc57k 2qdEBohwQy6EljTkgDD7K1X9hJ5fH9SUIkcxoqLV109+4awdOx0jc9vA3JJ9E2tkEC+d /LOxLLlmQaNCXxdyLzbMnsG7GF4cShoYh9e7NoYdJNoxZTWsU+BYBQFcN/P17aix86ms 4hgGO1O5ouHtTJsch/xmF5NW1z7Ud3GF5q9zAewEx3XuLj2ykswBRpRShL/Hf6qz3nUp A64A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r11si6724047ejs.214.2020.09.20.09.22.25; Sun, 20 Sep 2020 09:22:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726486AbgITQVY (ORCPT + 99 others); Sun, 20 Sep 2020 12:21:24 -0400 Received: from out30-56.freemail.mail.aliyun.com ([115.124.30.56]:51221 "EHLO out30-56.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726392AbgITQVS (ORCPT ); Sun, 20 Sep 2020 12:21:18 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01424;MF=tianjia.zhang@linux.alibaba.com;NM=1;PH=DS;RN=34;SR=0;TI=SMTPD_---0U9VME2i_1600618866; Received: from localhost(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0U9VME2i_1600618866) by smtp.aliyun-inc.com(127.0.0.1); Mon, 21 Sep 2020 00:21:07 +0800 From: Tianjia Zhang To: Herbert Xu , "David S. Miller" , David Howells , Eric Biggers , Jarkko Sakkinen , Maxime Coquelin , Alexandre Torgue , James Morris , "Serge E. Hallyn" , Stephan Mueller , Marcelo Henrique Cerri , "Steven Rostedt (VMware)" , Masahiro Yamada , Brendan Higgins , Andrew Morton , Johannes Weiner , Waiman Long , Mimi Zohar , Lakshmi Ramasubramanian , Colin Ian King , Tushar Sugandhi , Vitaly Chikunov , "Gilad Ben-Yossef" , Pascal van Leeuwen , linux-crypto@vger.kernel.org, keyrings@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Xufeng Zhang , Jia Zhang , Tianjia Zhang Subject: [PATCH v7 05/10] crypto: testmgr - support test with different ciphertext per encryption Date: Mon, 21 Sep 2020 00:20:58 +0800 Message-Id: <20200920162103.83197-6-tianjia.zhang@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.3.ge56e4f7 In-Reply-To: <20200920162103.83197-1-tianjia.zhang@linux.alibaba.com> References: <20200920162103.83197-1-tianjia.zhang@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Some asymmetric algorithms will get different ciphertext after each encryption, such as SM2, and let testmgr support the testing of such algorithms. In struct akcipher_testvec, set c and c_size to be empty, skip the comparison of the ciphertext, and compare the decrypted plaintext with m to achieve the test purpose. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang --- crypto/testmgr.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 23c27fc96394..cd002a030af5 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c @@ -4025,7 +4025,7 @@ static int test_akcipher_one(struct crypto_akcipher *tfm, pr_err("alg: akcipher: %s test failed. err %d\n", op, err); goto free_all; } - if (!vecs->siggen_sigver_test) { + if (!vecs->siggen_sigver_test && c) { if (req->dst_len != c_size) { pr_err("alg: akcipher: %s test failed. Invalid output len\n", op); @@ -4056,6 +4056,11 @@ static int test_akcipher_one(struct crypto_akcipher *tfm, goto free_all; } + if (!vecs->siggen_sigver_test && !c) { + c = outbuf_enc; + c_size = req->dst_len; + } + op = vecs->siggen_sigver_test ? "sign" : "decrypt"; if (WARN_ON(c_size > PAGE_SIZE)) goto free_all; -- 2.19.1.3.ge56e4f7