Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp563525pxb; Fri, 13 Aug 2021 00:57:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQZUkLEP7EUcmuxG0bQ3zTHUA77AurfSW2clXfquft+HJRopKhbNsMnk9+s8KZhgfuz0/3 X-Received: by 2002:a05:6402:3496:: with SMTP id v22mr1498960edc.223.1628841448053; Fri, 13 Aug 2021 00:57:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628841448; cv=none; d=google.com; s=arc-20160816; b=0adneHFTHsDRBX/BLX1ZskshWF5PQa7b+SeQdLimhd++m0Pe0xx6u3D7/rvFWXgE7r IQHef1ulxdHRjU0Z0PPItmLZcsjQIl3JNSSNI0sLSdtEwDANZiTZEcALcaA+vFWsEFP1 RC8fS9jjADmhL6Tr1eO7MgTn6qHP7Q7bH2+FHEBWxlpBM3LOH93s3J/V9o91WsKCcYVz WgXd3Fm4zOq9P7hIVNSaCP0zBZBYOi4wXOJDficbNg2/J1ZsNm3XAI9SyYl5CQfcAjF9 4MB3WR4FIa+Zt1tvc6hqcavr+1hFH8CAqfDQPPQfTEIJkbZVtF1lBa/LmpCtNXG/dtK0 sBDA== 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=LeMzCzfXbDRnOT78spvSEkDl5Bxp2skvJ3Veb4tqSTw=; b=Qzqv0XauU5KIDHp25zbJkYnLzvIWX7LjJyINeqrPcIG5bfKpp1/wnkjpKOWYukOJO2 EI8/jfKU1k1ukRmLXtF+GwBlcaFlTXmwnF4cYhZQDWyZWA2O8A+aFIBuaOIYQ6p5pkS9 wyI1MKmbIkDevPaoed/9e1iu7iW8g63KwOttm4cY+86i+Y4++VzAzORujmzpQlT+k3YE AC0xV2zbotz8GExG/egsPm7d+ZfRrFdWIJtGQJgjRyfIUvrYuhOLyERnFyKs1h8+h2Rq 1HCZ3plf1HdXGCK3ybsN8j6frvpER/uPvdHAOaTS2Wu5ZRLGW9FtsQPwWPH/5AoRna5R 0uXQ== 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 c26si841338ejx.235.2021.08.13.00.57.04; Fri, 13 Aug 2021 00:57:28 -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 S239594AbhHMHzj (ORCPT + 99 others); Fri, 13 Aug 2021 03:55:39 -0400 Received: from out30-44.freemail.mail.aliyun.com ([115.124.30.44]:55105 "EHLO out30-44.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239042AbhHMHzi (ORCPT ); Fri, 13 Aug 2021 03:55:38 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R901e4;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=11;SR=0;TI=SMTPD_---0Uis59gQ_1628841310; Received: from localhost(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0Uis59gQ_1628841310) by smtp.aliyun-inc.com(127.0.0.1); Fri, 13 Aug 2021 15:55:10 +0800 From: Tianjia Zhang To: Herbert Xu , "David S. Miller" , Eric Biggers , Eric Biggers , Gilad Ben-Yossef , Ard Biesheuvel , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Jia Zhang , "YiLin . Li" Cc: Tianjia Zhang Subject: [PATCH v2 3/3] crypto: tcrypt: add GCM/CCM mode test for SM4 algorithm Date: Fri, 13 Aug 2021 15:55:08 +0800 Message-Id: <20210813075508.98854-4-tianjia.zhang@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.3.ge56e4f7 In-Reply-To: <20210813075508.98854-1-tianjia.zhang@linux.alibaba.com> References: <20210813075508.98854-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 tcrypt supports GCM/CCM mode, CMAC, CBCMAC, and speed test of SM4 algorithm. Signed-off-by: Tianjia Zhang --- crypto/tcrypt.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index 170102e92f7d..82b0400985a5 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c @@ -1916,6 +1916,14 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb) ret += tcrypt_test("streebog512"); break; + case 55: + ret += tcrypt_test("gcm(sm4)"); + break; + + case 56: + ret += tcrypt_test("ccm(sm4)"); + break; + case 100: ret += tcrypt_test("hmac(md5)"); break; @@ -2007,6 +2015,15 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb) case 157: ret += tcrypt_test("authenc(hmac(sha1),ecb(cipher_null))"); break; + + case 158: + ret += tcrypt_test("cbcmac(sm4)"); + break; + + case 159: + ret += tcrypt_test("cmac(sm4)"); + break; + case 181: ret += tcrypt_test("authenc(hmac(sha1),cbc(des))"); break; @@ -2336,6 +2353,34 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb) NULL, 0, 16, 8, speed_template_16); break; + case 222: + test_aead_speed("gcm(sm4)", ENCRYPT, sec, + NULL, 0, 16, 8, speed_template_16); + test_aead_speed("gcm(sm4)", DECRYPT, sec, + NULL, 0, 16, 8, speed_template_16); + break; + + case 223: + test_aead_speed("rfc4309(ccm(sm4))", ENCRYPT, sec, + NULL, 0, 16, 16, aead_speed_template_19); + test_aead_speed("rfc4309(ccm(sm4))", DECRYPT, sec, + NULL, 0, 16, 16, aead_speed_template_19); + break; + + case 224: + test_mb_aead_speed("gcm(sm4)", ENCRYPT, sec, NULL, 0, 16, 8, + speed_template_16, num_mb); + test_mb_aead_speed("gcm(sm4)", DECRYPT, sec, NULL, 0, 16, 8, + speed_template_16, num_mb); + break; + + case 225: + test_mb_aead_speed("rfc4309(ccm(sm4))", ENCRYPT, sec, NULL, 0, + 16, 16, aead_speed_template_19, num_mb); + test_mb_aead_speed("rfc4309(ccm(sm4))", DECRYPT, sec, NULL, 0, + 16, 16, aead_speed_template_19, num_mb); + break; + case 300: if (alg) { test_hash_speed(alg, sec, generic_hash_speed_template); -- 2.19.1.3.ge56e4f7