Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp357507ybt; Wed, 8 Jul 2020 01:30:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzF8KKGdC5BQtkBIHpX5uwOX9KNGkyAnZNI7x++clWdca7WqdO9Sd8FOLrF4scnGuFzUHbE X-Received: by 2002:a05:6402:1c8f:: with SMTP id cy15mr66122230edb.308.1594197047131; Wed, 08 Jul 2020 01:30:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594197047; cv=none; d=google.com; s=arc-20160816; b=bHcDh8CPQThfLIPYJmb8ouylVNXfPYWMoxRGu5F/9xbJAlh6MMI2Tps+5FydKJoXNL zQs3ZwIXIEBG07iihI2ie5Cshkmp5vqOMrFbMjfr2ggNxg027agEyh9ttiMd8K2djJpM aFshfdGSMFYE25yvhWLKcsLXbWbpVvu9W0IiAniOBbRbrHQVTS8Gc4PesF4zc2JZxNpO Ho3XW5Tce2aoq/6QUGAQWb1DMskUKWLdYO8LWWDYW9u7e2ueEyeJF0mqbe97YoGRa8D3 7EcyF0A/tX/KTyBkkLdjZrDyOM7VlihrVpI1dYkkpfzUvRjIHG/szg51GQQ3qenmXgOL vbSA== 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; bh=tPCi21zhw5W6PxS6GgEgVLX/bpuBYGDLKwjv/2KmvTw=; b=nC06IG9NwnsdaEivlPsiEUO2BDNNd6fn7/pKoFpB8PxGD3r1KE5Q8mXx+JRBuUpUAt Qt0CFCNvNXzf2C0X/nLxhuxDdAyEvzoFYfGrjJ1MzS0wS1xyKBFpi1THVyC8dTI3xKze DWl8QOd77H8K3i2cxZEygpMC6Rn4WneHce0hRalj+FcrwCJkp7Uy9G4Orijy6E50hkp3 oku82Np90v4ewg/Np4N48pjOLCipKvApupvb7iGujPKiCsx109TvBWHOjUZ58LluSW26 W4DrjEM9oc16kApVGLXAQ5rUvqp+5o+uDTB4Fh0g+Ym7ocRE5iv0JZYNyxjJnX5rcHU+ k4IQ== 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 bi27si19619870edb.232.2020.07.08.01.30.24; Wed, 08 Jul 2020 01:30:47 -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 S1728158AbgGHI23 (ORCPT + 99 others); Wed, 8 Jul 2020 04:28:29 -0400 Received: from out30-42.freemail.mail.aliyun.com ([115.124.30.42]:57823 "EHLO out30-42.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727119AbgGHI23 (ORCPT ); Wed, 8 Jul 2020 04:28:29 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04427;MF=tianjia.zhang@linux.alibaba.com;NM=1;PH=DS;RN=21;SR=0;TI=SMTPD_---0U262FR._1594196902; Received: from localhost(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0U262FR._1594196902) by smtp.aliyun-inc.com(127.0.0.1); Wed, 08 Jul 2020 16:28:22 +0800 From: Tianjia Zhang To: herbert@gondor.apana.org.au, davem@davemloft.net, dhowells@redhat.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, jmorris@namei.org, serge@hallyn.com, nramas@linux.microsoft.com, tusharsu@linux.microsoft.com, zohar@linux.ibm.com, gilad@benyossef.com, pvanleeuwen@rambus.com Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-security-module@vger.kernel.org, linux-integrity@vger.kernel.org, zhang.jia@linux.alibaba.com, tianjia.zhang@linux.alibaba.com Subject: [PATCH v4 5/8] crypto: testmgr - support test with different ciphertext per encryption Date: Wed, 8 Jul 2020 16:28:15 +0800 Message-Id: <20200708082818.5511-6-tianjia.zhang@linux.alibaba.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200708082818.5511-1-tianjia.zhang@linux.alibaba.com> References: <20200708082818.5511-1-tianjia.zhang@linux.alibaba.com> Sender: linux-crypto-owner@vger.kernel.org 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 --- crypto/testmgr.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 6863f911fcee..0dc94461c437 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.17.1