Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1226696ybt; Thu, 9 Jul 2020 01:41:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6WhI4ti4WKeFRm6cr/cEoU38pTEvo4cpOLYyD3uxULoV5Lt+v2Q3ItRcxzZIVPvOApkju X-Received: by 2002:a50:da44:: with SMTP id a4mr66529711edk.379.1594284084888; Thu, 09 Jul 2020 01:41:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594284084; cv=none; d=google.com; s=arc-20160816; b=t6CVl5IwzvN5pDgKMPMEBU35lT8qggIeKkDJ/2CRuO9hLmlmEFMMuM/CPZgrdkecHQ sT3mHMEBy2+VKQovl0jjpKlF4qUSv6dF/DN9BGohZ6bEv4KFayHpVEPc2uila+pM4m3M AER6DvtC+OosibLBuUChswTDC8ZDF6RAtyUhX4bl1reRfwYpSQ3MolABSx8qmxTnawlU aheTain9kimYl5A3Wgq+Qy5OIKRkHGYJY8UFPWH1LHtydJmTbabWt/3ooXh8/hV82xRN pEaEkZNTH1nWJVlRojFkeoGya+uD2Xs6cK2HMmKGDaULF9zyJknQVvQpZ4rxSMkW9qjX vvYw== 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=pB8Ju3XTCizfxJcNiGSLzABNb/tDM4oZ8h/Maz3elCnvuFSrUBb1out34jsI2G0/YW RN2aB0PS6TUvvxnO2hiAazqradnwKB0Ek6I5Xb1X/yhNErDYBIBOVr6QWGNuBbrMrv2G YtHFTBzUYsqJRPIfpPNx3AuKChdy6OGWrJukg1GXiL+rrP6AHDPyBoUF66SX6IeGen5t nOm7BDaG0q2T3aweh6qTLyr5fqpIzNLbUqp1/i5Os0AsKnOjkX3xD+O2mUs4+1FF4gXs D2ReLGIPZvA/VuUXgWrk2XJLxg6KSn8k9WHn2svDlkt8SCLdIzhgiEBLu8axrj2T2VtJ kpAA== 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 q17si1748868edc.298.2020.07.09.01.41.01; Thu, 09 Jul 2020 01:41:24 -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 S1726759AbgGIIk2 (ORCPT + 99 others); Thu, 9 Jul 2020 04:40:28 -0400 Received: from out30-45.freemail.mail.aliyun.com ([115.124.30.45]:36098 "EHLO out30-45.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726734AbgGIIk1 (ORCPT ); Thu, 9 Jul 2020 04:40:27 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04426;MF=tianjia.zhang@linux.alibaba.com;NM=1;PH=DS;RN=22;SR=0;TI=SMTPD_---0U2BK-9F_1594284020; Received: from localhost(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0U2BK-9F_1594284020) by smtp.aliyun-inc.com(127.0.0.1); Thu, 09 Jul 2020 16:40:21 +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, vt@altlinux.org, gilad@benyossef.com, pvanleeuwen@rambus.com, zhang.jia@linux.alibaba.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, tianjia.zhang@linux.alibaba.com Subject: [PATCH v5 5/8] crypto: testmgr - support test with different ciphertext per encryption Date: Thu, 9 Jul 2020 16:40:12 +0800 Message-Id: <20200709084015.21886-6-tianjia.zhang@linux.alibaba.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200709084015.21886-1-tianjia.zhang@linux.alibaba.com> References: <20200709084015.21886-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