Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp15852194rwd; Mon, 26 Jun 2023 02:08:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5PXVJnSathoFxeOfQ8jRZdIZOcQV33qUhOOf4VuJGTnZVjFcaY708b/fqmcECfcsL/VYSg X-Received: by 2002:aa7:8556:0:b0:668:728e:64d8 with SMTP id y22-20020aa78556000000b00668728e64d8mr23599631pfn.1.1687770525130; Mon, 26 Jun 2023 02:08:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687770525; cv=none; d=google.com; s=arc-20160816; b=D7TK+srUFt6vkSNNEvsuAYLGalkPsM34WQvQxC4TNQ0UAPLZIKmtC9e723F1zoNUPY Xq9MtBBlV/5PaKTyft+TNZuBuF4qoP1g4lmV61cxtzFlOTmh0Tzimxp5Hm++CBCQCbXa 0v/cpmHB3sQ7F2G0R9h61WqXyV5Xv8faJ1Rc37O91cARPo9+l6s/SvYRz8agGEaxcGXp IF9vlzF+u6+pOGxULyzJKYle3N/TKaRQq6qqTsWIArX+fjgucom5nyf+0VmtdgJQcc0I 4IhGUWGMf82ZvYKBKyoMTCwjf4wjgWsG6XrBET/+mys+PCGidhKrTlXvW0YctaypB5mD sqAQ== 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 :dkim-signature; bh=zuuP2jIe0pZPqoUtxjvL55N6OHfrTkFefMjYKKtwGHs=; fh=BVM8Lk95Ribzx1+wPOAl8bTKP3+yC0sKPvoVd2D5Lf4=; b=xHfAqkzWTwAkBANF2gMgg2DXexYEYfpZFji8iCdbjxQRx+L0q1uLCFnoCRMYr1HM1D DXvYiWA7If46Sv8Ywb+yGyy6zF5ZGGlrixYYh+hZuGluwMvslpz7Ky2uJz1kKVlNMAI2 2L877nMuxQb2BmiL6SPYQkeuc/ecBxkm43LDIMc7p/kU2xpRFunQCPmQNPPnX099Vezw d/aZEqbueu1hKXgebgeBctP5bCz34O4QC4WF5jihItLaoHW0kfmvV+diyPkwT/qPvOdh Kssnjc39rQ6cbvwaZzrjJyely/KXmOk3MqUDkVzuuG1+d/iVM9pyCKINL2CPD8A5xpgM WdRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@nsr.re.kr header.s=LIY0OQ3MUMW6182UNI14 header.b="P/GTSFUj"; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nsr.re.kr Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d6-20020a630e06000000b0055731f11410si4668874pgl.470.2023.06.26.02.08.21; Mon, 26 Jun 2023 02:08:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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; dkim=temperror (no key for signature) header.i=@nsr.re.kr header.s=LIY0OQ3MUMW6182UNI14 header.b="P/GTSFUj"; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nsr.re.kr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229661AbjFZJAU (ORCPT + 99 others); Mon, 26 Jun 2023 05:00:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230359AbjFZI77 (ORCPT ); Mon, 26 Jun 2023 04:59:59 -0400 Received: from mail.nsr.re.kr (unknown [210.104.33.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A59D4EC4 for ; Mon, 26 Jun 2023 01:55:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; s=LIY0OQ3MUMW6182UNI14; d=nsr.re.kr; t=1687769580; c=relaxed/relaxed; h=date:from:message-id:mime-version:subject:to; bh=zuuP2jIe0pZPqoUtxjvL55N6OHfrTkFefMjYKKtwGHs=; b=P/GTSFUjdhT93uRcZ7N5Mf9yKfeZyDvDZoOOoVztHt5bqdnITZyXFbaflivWQnF6QIFzDHXsavJ57MQJugO8IeZvpobCKYgiY/URyNXHEgHYBxiQ/8itIaoISKY3S3T7bYfv5SniSzspsJJMMucbCQFHnUuPMr3v60zCz+RHEyDK5v/GSWyjmZmD3NvtmYCLj0+5RMq2j2NngJIfjanZrGScZux3Hp21GZiTgGHvcDa/bZC6o3A7beodxPw3bVl2zLLK6zK9IgVFWX3UFoBIKB9kDtf8pxZxlMBmNMMsy+ss2owpZBwdPGHct1Z9vWN8NXNjMNo4Zi6JfG6OJk44Ig== Received: from 210.104.33.70 (nsr.re.kr) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128 bits)) by mail.nsr.re.kr with SMTP; Mon, 26 Jun 2023 17:45:39 +0900 Received: from 192.168.155.188 ([192.168.155.188]) by mail.nsr.re.kr (Crinity Message Backbone-7.0.1) with SMTP ID 334; Mon, 26 Jun 2023 17:47:46 +0900 (KST) From: Dongsoo Lee To: Herbert Xu , "David S. Miller" , Jens Axboe , Eric Biggers , "Theodore Y. Ts'o" , Jaegeuk Kim Cc: linux-crypto@vger.kernel.org, linux-block@vger.kernel.org, linux-fscrypt@vger.kernel.org, linux-kernel@vger.kernel.org, Dongsoo Lee Subject: [PATCH v3 4/4] fscrypt: Add LEA-256-XTS, LEA-256-CTS support Date: Mon, 26 Jun 2023 17:47:03 +0900 Message-Id: <20230626084703.907331-5-letrhee@nsr.re.kr> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230626084703.907331-1-letrhee@nsr.re.kr> References: <20230626084703.907331-1-letrhee@nsr.re.kr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=no 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: X-Mailing-List: linux-crypto@vger.kernel.org Add LEA-256-XTS, LEA-256-CTS fscrypt support. LEA is a South Korean 128-bit block cipher (with 128/192/256-bit keys) included in the ISO/IEC 29192-2:2019 standard (Information security - Lightweight cryptography - Part 2: Block ciphers). It shows fast performance and, when SIMD instructions are available, it performs even faster. Particularly, it outperforms AES when the dedicated crypto instructions for AES are unavailable, regardless of the presence of SIMD instructions. However, it is not recommended to use LEA unless there is a clear reason (such as the absence of dedicated crypto instructions for AES or a mandatory requirement) to do so. Also, to enable LEA support, it needs to be enabled in the kernel crypto API. Signed-off-by: Dongsoo Lee --- Documentation/filesystems/fscrypt.rst | 12 ++++++++++++ fs/crypto/fscrypt_private.h | 2 +- fs/crypto/keysetup.c | 15 +++++++++++++++ fs/crypto/policy.c | 4 ++++ include/uapi/linux/fscrypt.h | 4 +++- tools/include/uapi/linux/fscrypt.h | 4 +++- 6 files changed, 38 insertions(+), 3 deletions(-) diff --git a/Documentation/filesystems/fscrypt.rst b/Documentation/filesystems/fscrypt.rst index eccd327e6df5..60fb82c3382e 100644 --- a/Documentation/filesystems/fscrypt.rst +++ b/Documentation/filesystems/fscrypt.rst @@ -339,6 +339,7 @@ Currently, the following pairs of encryption modes are supported: - Adiantum for both contents and filenames - AES-256-XTS for contents and AES-256-HCTR2 for filenames (v2 policies only) - SM4-XTS for contents and SM4-CTS-CBC for filenames (v2 policies only) +- LEA-256-XTS for contents and LEA-256-CTS-CBC for filenames (v2 policies only) If unsure, you should use the (AES-256-XTS, AES-256-CTS-CBC) pair. @@ -376,6 +377,17 @@ size. It may be useful in cases where its use is mandated. Otherwise, it should not be used. For SM4 support to be available, it also needs to be enabled in the kernel crypto API. +LEA is a South Korean 128-bit block cipher (with 128/192/256-bit keys) +included in the ISO/IEC 29192-2:2019 standard (Information security - +Lightweight cryptography - Part 2: Block ciphers). It shows fast +performance and, when SIMD instructions are available, it performs even +faster. Particularly, it outperforms AES when the dedicated crypto +instructions for AES are unavailable, regardless of the presence of SIMD +instructions. However, it is not recommended to use LEA unless there is +a clear reason (such as the absence of dedicated crypto instructions for +AES or a mandatory requirement) to do so. Also, to enable LEA support, +it needs to be enabled in the kernel crypto API. + New encryption modes can be added relatively easily, without changes to individual filesystems. However, authenticated encryption (AE) modes are not currently supported because of the difficulty of dealing diff --git a/fs/crypto/fscrypt_private.h b/fs/crypto/fscrypt_private.h index 7ab5a7b7eef8..400238057219 100644 --- a/fs/crypto/fscrypt_private.h +++ b/fs/crypto/fscrypt_private.h @@ -31,7 +31,7 @@ #define FSCRYPT_CONTEXT_V2 2 /* Keep this in sync with include/uapi/linux/fscrypt.h */ -#define FSCRYPT_MODE_MAX FSCRYPT_MODE_AES_256_HCTR2 +#define FSCRYPT_MODE_MAX FSCRYPT_MODE_LEA_256_CTS struct fscrypt_context_v1 { u8 version; /* FSCRYPT_CONTEXT_V1 */ diff --git a/fs/crypto/keysetup.c b/fs/crypto/keysetup.c index 361f41ef46c7..fa82579e56eb 100644 --- a/fs/crypto/keysetup.c +++ b/fs/crypto/keysetup.c @@ -74,6 +74,21 @@ struct fscrypt_mode fscrypt_modes[] = { .security_strength = 32, .ivsize = 32, }, + [FSCRYPT_MODE_LEA_256_XTS] = { + .friendly_name = "LEA-256-XTS", + .cipher_str = "xts(lea)", + .keysize = 64, + .security_strength = 32, + .ivsize = 16, + .blk_crypto_mode = BLK_ENCRYPTION_MODE_LEA_256_XTS, + }, + [FSCRYPT_MODE_LEA_256_CTS] = { + .friendly_name = "LEA-256-CTS-CBC", + .cipher_str = "cts(cbc(lea))", + .keysize = 32, + .security_strength = 32, + .ivsize = 16, + }, }; static DEFINE_MUTEX(fscrypt_mode_key_setup_mutex); diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c index f4456ecb3f87..9d1e80c43c6d 100644 --- a/fs/crypto/policy.c +++ b/fs/crypto/policy.c @@ -94,6 +94,10 @@ static bool fscrypt_valid_enc_modes_v2(u32 contents_mode, u32 filenames_mode) filenames_mode == FSCRYPT_MODE_SM4_CTS) return true; + if (contents_mode == FSCRYPT_MODE_LEA_256_XTS && + filenames_mode == FSCRYPT_MODE_LEA_256_CTS) + return true; + return fscrypt_valid_enc_modes_v1(contents_mode, filenames_mode); } diff --git a/include/uapi/linux/fscrypt.h b/include/uapi/linux/fscrypt.h index fd1fb0d5389d..df3c8af98210 100644 --- a/include/uapi/linux/fscrypt.h +++ b/include/uapi/linux/fscrypt.h @@ -30,7 +30,9 @@ #define FSCRYPT_MODE_SM4_CTS 8 #define FSCRYPT_MODE_ADIANTUM 9 #define FSCRYPT_MODE_AES_256_HCTR2 10 -/* If adding a mode number > 10, update FSCRYPT_MODE_MAX in fscrypt_private.h */ +#define FSCRYPT_MODE_LEA_256_XTS 11 +#define FSCRYPT_MODE_LEA_256_CTS 12 +/* If adding a mode number > 12, update FSCRYPT_MODE_MAX in fscrypt_private.h */ /* * Legacy policy version; ad-hoc KDF and no key verification. diff --git a/tools/include/uapi/linux/fscrypt.h b/tools/include/uapi/linux/fscrypt.h index fd1fb0d5389d..df3c8af98210 100644 --- a/tools/include/uapi/linux/fscrypt.h +++ b/tools/include/uapi/linux/fscrypt.h @@ -30,7 +30,9 @@ #define FSCRYPT_MODE_SM4_CTS 8 #define FSCRYPT_MODE_ADIANTUM 9 #define FSCRYPT_MODE_AES_256_HCTR2 10 -/* If adding a mode number > 10, update FSCRYPT_MODE_MAX in fscrypt_private.h */ +#define FSCRYPT_MODE_LEA_256_XTS 11 +#define FSCRYPT_MODE_LEA_256_CTS 12 +/* If adding a mode number > 12, update FSCRYPT_MODE_MAX in fscrypt_private.h */ /* * Legacy policy version; ad-hoc KDF and no key verification. -- 2.34.1