Message ID | 20221125121630.87793-2-tianjia.zhang@linux.alibaba.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3971039wrr; Fri, 25 Nov 2022 04:17:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf52syfzlR8qVeQPqbh4fAsfyNJnpC3etemIRXfPOOSPnRGHDGpdk7DuBgwy2LX+mFUZMxN6 X-Received: by 2002:a17:902:c7d1:b0:188:5681:4dc8 with SMTP id r17-20020a170902c7d100b0018856814dc8mr18361606pla.23.1669378665548; Fri, 25 Nov 2022 04:17:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669378665; cv=none; d=google.com; s=arc-20160816; b=c4G7hL3RJLJ0lKRJlph1oovx5KLb4YcdkPVD7w+iSHdMgQPqFWEq7x5j3HKSxqDwQK ChZVLz9+BoXMGdVZKyJZHpRP4gneOeNoJu4iqwhqmBiJ0OFbkenoUwHS3JcnuBUDQtuK dq2EsaoxEbgG8MI96X5x41/oQIhrOEwZj6U/IVldZj/+OqAyBWnbbQbdkzrW8GKgdoKe 84+8c07Uy/YrmHQMaxdCS0aTSvXTSWGB6/wX3Dv51s5AGf9UK8xuIAonO2ltmXZwSDNj hKAE191JfSUI5myiy9dlcENveFOnX6rDXPEb9906W7uayNIWhURD2arN0Z1KFNEAU3js jteQ== 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=l0h3ch2bhhEAXGZP9bwX2VjD30wMZImlfDTFskfVrYM=; b=kyuueMYQER/ivWcC7wu1xWS/1kVACpFdnEEunP8p/4p3ob2vGfkmWU85Kd6YLc6X3V vh474fslm5Yx5R2Vi4pfWDC1nLVGytp160NM7VmWEMWOFnK2aFDXoi1eAQ95oG/1tO2s F2bQjQb5G384sJ2TRbfHB9Ndts/UWdd+hJFVxE2QUgF7kf/G1FytFkUzHSiH0rKyyska M1IsVBJ4vellOkuMVIsnL1B/BE6Xrq0MlaUXij7hZ5oXK0FlZt+I7iPKtnW1nW6lZr2t Qk0q5R4AhGVoRtfGkpyTcaRqS6EsICl0785090G8ZAbtCBA/G27r56Shi80am2Yx3FBF Rceg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g25-20020a632019000000b004772bd7e38esi3955122pgg.868.2022.11.25.04.17.32; Fri, 25 Nov 2022 04:17:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229844AbiKYMRI (ORCPT <rfc822;zxc52fgh@gmail.com> + 99 others); Fri, 25 Nov 2022 07:17:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229575AbiKYMRD (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 25 Nov 2022 07:17:03 -0500 Received: from out30-56.freemail.mail.aliyun.com (out30-56.freemail.mail.aliyun.com [115.124.30.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BA184A585; Fri, 25 Nov 2022 04:16:57 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045168;MF=tianjia.zhang@linux.alibaba.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---0VVfHzfl_1669378597; Received: from localhost(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0VVfHzfl_1669378597) by smtp.aliyun-inc.com; Fri, 25 Nov 2022 20:16:38 +0800 From: Tianjia Zhang <tianjia.zhang@linux.alibaba.com> To: Eric Biggers <ebiggers@kernel.org>, "Theodore Y. Ts o" <tytso@mit.edu>, Jaegeuk Kim <jaegeuk@kernel.org>, Jonathan Corbet <corbet@lwn.net>, Jens Axboe <axboe@kernel.dk>, Ard Biesheuvel <ardb@kernel.org>, linux-fscrypt@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org Cc: Tianjia Zhang <tianjia.zhang@linux.alibaba.com> Subject: [PATCH v3 1/2] blk-crypto: Add support for SM4-XTS blk crypto mode Date: Fri, 25 Nov 2022 20:16:29 +0800 Message-Id: <20221125121630.87793-2-tianjia.zhang@linux.alibaba.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20221125121630.87793-1-tianjia.zhang@linux.alibaba.com> References: <20221125121630.87793-1-tianjia.zhang@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750470403914958252?= X-GMAIL-MSGID: =?utf-8?q?1750470403914958252?= |
Series |
Add SM4 XTS symmetric algorithm for blk-crypto and fscrypt
|
|
Commit Message
Tianjia Zhang
Nov. 25, 2022, 12:16 p.m. UTC
SM4 is a symmetric algorithm widely used in China, and SM4-XTS is also
used to encrypt length-preserving data, these algoritms are mandatory
in many scenarios. This patch enables the use of SM4-XTS algorithm in
block inline encryption, and provides support for fscrypt.
Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
---
block/blk-crypto.c | 6 ++++++
include/linux/blk-crypto.h | 1 +
2 files changed, 7 insertions(+)
Comments
On Fri, Nov 25, 2022 at 08:16:29PM +0800, Tianjia Zhang wrote: > SM4 is a symmetric algorithm widely used in China, and SM4-XTS is also > used to encrypt length-preserving data, these algoritms are mandatory > in many scenarios. This patch enables the use of SM4-XTS algorithm in > block inline encryption, and provides support for fscrypt. > > Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com> > --- > block/blk-crypto.c | 6 ++++++ > include/linux/blk-crypto.h | 1 + > 2 files changed, 7 insertions(+) > > diff --git a/block/blk-crypto.c b/block/blk-crypto.c > index a496aaef85ba..e44709fc6a08 100644 > --- a/block/blk-crypto.c > +++ b/block/blk-crypto.c > @@ -36,6 +36,12 @@ const struct blk_crypto_mode blk_crypto_modes[] = { > .keysize = 32, > .ivsize = 32, > }, > + [BLK_ENCRYPTION_MODE_SM4_XTS] = { > + .name = "SM4-XTS", > + .cipher_str = "xts(sm4)", > + .keysize = 32, > + .ivsize = 16, > + }, > }; > > /* > diff --git a/include/linux/blk-crypto.h b/include/linux/blk-crypto.h > index 69b24fe92cbf..26b1b71c3091 100644 > --- a/include/linux/blk-crypto.h > +++ b/include/linux/blk-crypto.h > @@ -13,6 +13,7 @@ enum blk_crypto_mode_num { > BLK_ENCRYPTION_MODE_AES_256_XTS, > BLK_ENCRYPTION_MODE_AES_128_CBC_ESSIV, > BLK_ENCRYPTION_MODE_ADIANTUM, > + BLK_ENCRYPTION_MODE_SM4_XTS, > BLK_ENCRYPTION_MODE_MAX, The commit message should mention that this is needed for the inlinecrypt mount option to be supported via blk-crypto-fallback, as it is for the other fscrypt modes. (Since there's no inline encryption hardware that supports SM4-XTS.) Anyway, if SM4-XTS support is really being added to fscrypt, then this patch looks fine. Jens, are you okay with me taking it through the fscrypt tree? - Eric
On 11/25/22 11:35 AM, Eric Biggers wrote: > On Fri, Nov 25, 2022 at 08:16:29PM +0800, Tianjia Zhang wrote: >> SM4 is a symmetric algorithm widely used in China, and SM4-XTS is also >> used to encrypt length-preserving data, these algoritms are mandatory >> in many scenarios. This patch enables the use of SM4-XTS algorithm in >> block inline encryption, and provides support for fscrypt. >> >> Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com> >> --- >> block/blk-crypto.c | 6 ++++++ >> include/linux/blk-crypto.h | 1 + >> 2 files changed, 7 insertions(+) >> >> diff --git a/block/blk-crypto.c b/block/blk-crypto.c >> index a496aaef85ba..e44709fc6a08 100644 >> --- a/block/blk-crypto.c >> +++ b/block/blk-crypto.c >> @@ -36,6 +36,12 @@ const struct blk_crypto_mode blk_crypto_modes[] = { >> .keysize = 32, >> .ivsize = 32, >> }, >> + [BLK_ENCRYPTION_MODE_SM4_XTS] = { >> + .name = "SM4-XTS", >> + .cipher_str = "xts(sm4)", >> + .keysize = 32, >> + .ivsize = 16, >> + }, >> }; >> >> /* >> diff --git a/include/linux/blk-crypto.h b/include/linux/blk-crypto.h >> index 69b24fe92cbf..26b1b71c3091 100644 >> --- a/include/linux/blk-crypto.h >> +++ b/include/linux/blk-crypto.h >> @@ -13,6 +13,7 @@ enum blk_crypto_mode_num { >> BLK_ENCRYPTION_MODE_AES_256_XTS, >> BLK_ENCRYPTION_MODE_AES_128_CBC_ESSIV, >> BLK_ENCRYPTION_MODE_ADIANTUM, >> + BLK_ENCRYPTION_MODE_SM4_XTS, >> BLK_ENCRYPTION_MODE_MAX, > > The commit message should mention that this is needed for the inlinecrypt mount > option to be supported via blk-crypto-fallback, as it is for the other fscrypt > modes. (Since there's no inline encryption hardware that supports SM4-XTS.) > > Anyway, if SM4-XTS support is really being added to fscrypt, then this patch > looks fine. Jens, are you okay with me taking it through the fscrypt tree? Yes, go ahead.
On 11/25/22 19:16, Tianjia Zhang wrote: > SM4 is a symmetric algorithm widely used in China, and SM4-XTS is also > used to encrypt length-preserving data, these algoritms are mandatory > in many scenarios. This patch enables the use of SM4-XTS algorithm in > block inline encryption, and provides support for fscrypt. > Please reformulate the patch description in imperative mood instead. Also, take care of wording and punctuation - commas should not be used for continuing distinct sentences/clauses where separating them by a full stop is more appropriate. That is, the description should be: ``` SM4 is a symmetric cipher algorithm widely used in China. The SM4-XTS variant is used to encrypt length-preserving data. Enable the algorithm in block inline encryption, as well as enable fscrypt support. ``` Thanks.
diff --git a/block/blk-crypto.c b/block/blk-crypto.c index a496aaef85ba..e44709fc6a08 100644 --- a/block/blk-crypto.c +++ b/block/blk-crypto.c @@ -36,6 +36,12 @@ const struct blk_crypto_mode blk_crypto_modes[] = { .keysize = 32, .ivsize = 32, }, + [BLK_ENCRYPTION_MODE_SM4_XTS] = { + .name = "SM4-XTS", + .cipher_str = "xts(sm4)", + .keysize = 32, + .ivsize = 16, + }, }; /* diff --git a/include/linux/blk-crypto.h b/include/linux/blk-crypto.h index 69b24fe92cbf..26b1b71c3091 100644 --- a/include/linux/blk-crypto.h +++ b/include/linux/blk-crypto.h @@ -13,6 +13,7 @@ enum blk_crypto_mode_num { BLK_ENCRYPTION_MODE_AES_256_XTS, BLK_ENCRYPTION_MODE_AES_128_CBC_ESSIV, BLK_ENCRYPTION_MODE_ADIANTUM, + BLK_ENCRYPTION_MODE_SM4_XTS, BLK_ENCRYPTION_MODE_MAX, };