Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp586427pxk; Thu, 3 Sep 2020 07:38:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTxphAHn4hreJOjGeCD6A0jC3JcKqUD5/ln79mQbDEJK4nZXJLDc+lnclQ/vSMtu1gwtxz X-Received: by 2002:a50:bb26:: with SMTP id y35mr3586980ede.234.1599143902489; Thu, 03 Sep 2020 07:38:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599143902; cv=none; d=google.com; s=arc-20160816; b=lkmFRKXmNm+Axl1l0+C9ew2GB8+OBFsKDy5YFmgIoaqiRQz0+Aqjnr49s1XVc8v/9e XSku9QrJX/1nPhtU2ySNJQ9Gio+mucQ6dPR5us21J3tLFW16Mye/ACWwkPoxFxOSsobS qI1c9rm7pTcdgPxBM9vXQ3+KNBum6Mo5TY5CB+IJaUA+z+3iWNh8Yh+ibgx4rW+vzNeI Dy92j8tLqqb4COgCOXy1zmsA1RHkMg97dTLIqHQRsdb7y0fn/QUJ3GjRCgQs8rTK6UsQ PAMLgcA8+tztp12ZS+r2kboRnctJUeccqY5lZgv5gxKTNZI4gxnhdzR2Vt09CMAkNpdp /khA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=SiAjCeIemu1fq0YPzRjB2g+0LMCCY6s6idJf6vUyRHo=; b=zK56xDWmkugajZe9e9QidWIpS6f5imh4xt/tL8bWq/C0wVkQZBj+f/BrXxYeFi7DTH 3gCOhgoKwoJkLEOeJNZSiE2rGXf4IvfFYMlGKhDmMUVw80YNfWZ3GajHmwFeeDyj810C KuBXpLKdEEdfqfllZZ8240DWx/VUk4TDRieBayUaeibEf4yP6uhWZVndfwr6et15rwf1 0fd93sI06Au9g8LgNajixUaUdarnFd8mJU323x20J4rbnSkFVW74DfS0C7OthvB4suOU e4mGtmvjoi5fg02LJP9N/fLtWCRxWzvlGcVNlw3Ip+IawKMluFDXvetDsHtQiRcpyjnO Vs3g== 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 f12si1841754edv.593.2020.09.03.07.37.58; Thu, 03 Sep 2020 07:38:22 -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 S1729309AbgICOgy (ORCPT + 99 others); Thu, 3 Sep 2020 10:36:54 -0400 Received: from out30-45.freemail.mail.aliyun.com ([115.124.30.45]:46127 "EHLO out30-45.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729369AbgICOgS (ORCPT ); Thu, 3 Sep 2020 10:36:18 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R211e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07488;MF=tianjia.zhang@linux.alibaba.com;NM=1;PH=DS;RN=31;SR=0;TI=SMTPD_---0U7p3k-0_1599138765; Received: from localhost(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0U7p3k-0_1599138765) by smtp.aliyun-inc.com(127.0.0.1); Thu, 03 Sep 2020 21:12:45 +0800 From: Tianjia Zhang To: Herbert Xu , "David S. Miller" , David Howells , 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, 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 Cc: Xufeng Zhang , Jia Zhang , Tianjia Zhang Subject: [PATCH v6 5/8] crypto: testmgr - support test with different ciphertext per encryption Date: Thu, 3 Sep 2020 21:12:39 +0800 Message-Id: <20200903131242.128665-6-tianjia.zhang@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.3.ge56e4f7 In-Reply-To: <20200903131242.128665-1-tianjia.zhang@linux.alibaba.com> References: <20200903131242.128665-1-tianjia.zhang@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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