Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2170720pxb; Fri, 8 Oct 2021 02:19:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwghLWktagNLkkEJm/eUwKS+nSP9HljUKNFQEkn4OXgy1qbvcul8pEt1zjg+5zx02RKRJqw X-Received: by 2002:a17:90a:de0f:: with SMTP id m15mr10615172pjv.114.1633684747279; Fri, 08 Oct 2021 02:19:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633684747; cv=none; d=google.com; s=arc-20160816; b=uNENZaOCYXCw0ixKuu2EQK6r6+7HjtXjUU3LJJet3lWkAFbYpvjM0petbh7u8Y3W/8 D0Iw0DTZdSY6C1iew9itpiOFr6b49fzuP4Q44CUfz0pJoN7K1Um4Dgqy87nWhP0d923w +ESBQR8vW+8tbfBtYFzsy1h8vDBpdrJ5BGQZVwlMEMwhvbPORQa/EnGcS7Q4Fv6siTyR PrK7rQKauCML0OBpR7XiXUNL1xoueNb7NocoK6AzbsXBgE3eviNkI5ZHxmIzyGWjvx2E D/QftgDK34g+1FhxK1p+Lu6Tt95lHtGG/N37di1SmwZ2bJx0x4AM1M/1SwpYmdF8070L Xl1A== 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 :message-id:date:subject:cc:to:from; bh=d5YkSYznIkW20xKvLeis3aiu5248DFm1LXB5BpHexD0=; b=Cb1UNgb6RCmyvAV9tqEPaE1W7H1F1L+IDB+/bMiArbief9re0CQnqBhBlv+sfyhsfK dN0cHwXCtsampLvg0oZOayee9omfV1wXj2R5Yh2/byVXRXjQcQHN5jB2tnfFPLaFgfZi BKbW/8O3yhEaDR7SfqRMboWQkU0xQTqw9RvJZq00NJ8j51TXNtB5/Ejcxi6wQPHp/QwU 802QQvNL8I8gXr9hQ/0KX5OknPl9Vck2cI9Fny6yos3rXn8r1FcU8IDjUv1eH/ub5iHd J0lrGnxYDGbXvBON9YFPJoA0M4wBBAoH67paqQ9IxN0wxEagxilJyK0FGG+BFzbWxLtQ x9Eg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 d184si2266839pgc.536.2021.10.08.02.18.53; Fri, 08 Oct 2021 02:19:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S236195AbhJHJTo (ORCPT + 99 others); Fri, 8 Oct 2021 05:19:44 -0400 Received: from out30-45.freemail.mail.aliyun.com ([115.124.30.45]:57816 "EHLO out30-45.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229710AbhJHJTn (ORCPT ); Fri, 8 Oct 2021 05:19:43 -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=10;SR=0;TI=SMTPD_---0Ur-Ab74_1633684665; Received: from localhost(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0Ur-Ab74_1633684665) by smtp.aliyun-inc.com(127.0.0.1); Fri, 08 Oct 2021 17:17:45 +0800 From: Tianjia Zhang To: "David S. Miller" , Jakub Kicinski , Shuah Khan , Boris Pismenny , John Fastabend , Daniel Borkmann , netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Tianjia Zhang Subject: [PATCH] selftests/tls: add SM4 GCM/CCM to tls selftests Date: Fri, 8 Oct 2021 17:17:45 +0800 Message-Id: <20211008091745.42917-1-tianjia.zhang@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.3.ge56e4f7 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add new cipher as a variant of standard tls selftests. Signed-off-by: Tianjia Zhang --- tools/testing/selftests/net/tls.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/tls.c b/tools/testing/selftests/net/tls.c index 97fceb9be9ed..d3047e251fe9 100644 --- a/tools/testing/selftests/net/tls.c +++ b/tools/testing/selftests/net/tls.c @@ -29,6 +29,8 @@ struct tls_crypto_info_keys { union { struct tls12_crypto_info_aes_gcm_128 aes128; struct tls12_crypto_info_chacha20_poly1305 chacha20; + struct tls12_crypto_info_sm4_gcm sm4gcm; + struct tls12_crypto_info_sm4_ccm sm4ccm; }; size_t len; }; @@ -49,6 +51,16 @@ static void tls_crypto_info_init(uint16_t tls_version, uint16_t cipher_type, tls12->aes128.info.version = tls_version; tls12->aes128.info.cipher_type = cipher_type; break; + case TLS_CIPHER_SM4_GCM: + tls12->len = sizeof(struct tls12_crypto_info_sm4_gcm); + tls12->sm4gcm.info.version = tls_version; + tls12->sm4gcm.info.cipher_type = cipher_type; + break; + case TLS_CIPHER_SM4_CCM: + tls12->len = sizeof(struct tls12_crypto_info_sm4_ccm); + tls12->sm4ccm.info.version = tls_version; + tls12->sm4ccm.info.cipher_type = cipher_type; + break; default: break; } @@ -148,13 +160,13 @@ FIXTURE_VARIANT(tls) uint16_t cipher_type; }; -FIXTURE_VARIANT_ADD(tls, 12_gcm) +FIXTURE_VARIANT_ADD(tls, 12_aes_gcm) { .tls_version = TLS_1_2_VERSION, .cipher_type = TLS_CIPHER_AES_GCM_128, }; -FIXTURE_VARIANT_ADD(tls, 13_gcm) +FIXTURE_VARIANT_ADD(tls, 13_aes_gcm) { .tls_version = TLS_1_3_VERSION, .cipher_type = TLS_CIPHER_AES_GCM_128, @@ -172,6 +184,18 @@ FIXTURE_VARIANT_ADD(tls, 13_chacha) .cipher_type = TLS_CIPHER_CHACHA20_POLY1305, }; +FIXTURE_VARIANT_ADD(tls, 13_sm4_gcm) +{ + .tls_version = TLS_1_3_VERSION, + .cipher_type = TLS_CIPHER_SM4_GCM, +}; + +FIXTURE_VARIANT_ADD(tls, 13_sm4_ccm) +{ + .tls_version = TLS_1_3_VERSION, + .cipher_type = TLS_CIPHER_SM4_CCM, +}; + FIXTURE_SETUP(tls) { struct tls_crypto_info_keys tls12; -- 2.19.1.3.ge56e4f7