Skip to contentSkip to conversation

generic: test HCTR2 filename encryption

PATCH Superseded Nathan Huckleberry 2 participants 6 messages Aug 3, 2022 – Aug 5, 2022 fscrypt: file system level encryption support

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v5 cover generic: test HCTR2 filename encryption

This patchset is not intended to be accepted yet. It is reliant on HCTR2 support in the kernel which has not yet been accepted. See the HCTR2 patchset
here: https://lore.kernel.org/all/[email protected]/

HCTR2 is a new wide-block encryption mode that can used for filename encryption in fscrypt. This patchset adds a reference implementation of HCTR2 to the fscrypt testing utility and adds tests for filename encryption with HCTR2.

More information on HCTR2 can be found here: "Length-preserving encryption with HCTR2": https://ia.cr/2021/1441

Changes in v5:
* Added links to relevant references for POLYVAL and HCTR2
* Removed POLYVAL partial block handling
* Referenced HCTR2 commit in test

Changes in v4:
* Add helper functions for HCTR2 hashing
* Fix accumulator alignment bug
* Small style fixes

Changes in v3:
* Consolidate tests into one file

Changes in v2:
* Use POLYVAL multiplication directly instead of using GHASH trick
* Split reference implementation and tests into two patches
* Remove v1 policy tests
* Various small style fixes

Nathan Huckleberry (2):
fscrypt-crypt-util: add HCTR2 implementation
generic: add tests for fscrypt policies with HCTR2

 common/encrypt           |   2 +
 src/fscrypt-crypt-util.c | 358 ++++++++++++++++++++++++++++++++-------
 tests/generic/900        |  31 ++++
 tests/generic/900.out    |  16 ++
 4 files changed, 350 insertions(+), 57 deletions(-)
 create mode 100755 tests/generic/900
 create mode 100644 tests/generic/900.out
Signature · 1 line
2.37.1.455.g008518b4e5-goog
#1 lore raw

PATCH v5 1/2 fscrypt-crypt-util: add HCTR2 implementation

This patch adds an implementation of HCTR2 to the fscrypt testing utility.

More information on HCTR2 can be found here: "Length-preserving encryption with HCTR2": https://ia.cr/2021/1441

---
 common/encrypt           |   2 +
 src/fscrypt-crypt-util.c | 358 ++++++++++++++++++++++++++++++++-------
 2 files changed, 303 insertions(+), 57 deletions(-)
common/encrypt +2 -0
index f90c4ef0..937bb914 100644
@@ -767,6 +767,7 @@ FSCRYPT_MODE_AES_256_CTS=4
 FSCRYPT_MODE_AES_128_CBC=5
 FSCRYPT_MODE_AES_128_CTS=6
 FSCRYPT_MODE_ADIANTUM=9
+FSCRYPT_MODE_AES_256_HCTR2=10
 
 FSCRYPT_POLICY_FLAG_DIRECT_KEY=0x04
 FSCRYPT_POLICY_FLAG_IV_INO_LBLK_64=0x08
@@ -785,6 +786,7 @@ _fscrypt_mode_name_to_num()
 	AES-128-CBC-ESSIV)	echo $FSCRYPT_MODE_AES_128_CBC ;;
 	AES-128-CTS-CBC)	echo $FSCRYPT_MODE_AES_128_CTS ;;
 	Adiantum)		echo $FSCRYPT_MODE_ADIANTUM ;;
+	AES-256-HCTR2)		echo $FSCRYPT_MODE_AES_256_HCTR2 ;;
 	*)			_fail "Unknown fscrypt mode: $name" ;;
 	esac
 }
src/fscrypt-crypt-util.c +301 -57

424 lines not on this page · raw message

Signature · 1 line
2.37.1.455.g008518b4e5-goog
maintainer Reviewed-by Tested-by on v5 1/2
#2 lore raw

Re: [PATCH v5 1/2] fscrypt-crypt-util: add HCTR2 implementation

src/fscrypt-crypt-util.c static void test_hkdf_sha512(void) · line 1008

Quoted 7 lines · Nathan Huckleberry
src/fscrypt-crypt-util.c +7 -0
+static void polyval_update(const u8 key[POLYVAL_KEY_SIZE],
+			   const u8 *msg, size_t msglen,
+			   u8 accumulator[POLYVAL_BLOCK_SIZE])
+{
+	ble128 h;
+	ble128 aligned_accumulator;
+	size_t chunk_size;

chunk_size is an unused variable.

Otherwise this looks good:

- Eric

#3 lore raw

PATCH v5 2/2 generic: add tests for fscrypt policies with HCTR2

In reply to Nathan Huckleberry

This patch adds fscrypt policy tests for filename encryption using HCTR2.

More information on HCTR2 can be found here: "Length-preserving encryption with HCTR2" https://ia.cr/2021/1441

---
 tests/generic/900     | 31 +++++++++++++++++++++++++++++++
 tests/generic/900.out | 16 ++++++++++++++++
 2 files changed, 47 insertions(+)
 create mode 100755 tests/generic/900
 create mode 100644 tests/generic/900.out
tests/generic/900 new file +31 -0
new file mode 100755
index 00000000..1ff7c512
@@ -0,0 +1,31 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright 2022 Google LLC
+#
+# FS QA Test No. generic/900
+#
+# Verify ciphertext for v2 encryption policies that use AES-256-XTS to encrypt
+# file contents and AES-256-HCTR2 to encrypt file names.
+#
+# HCTR2 was introduced in kernel commit 6b2a51ff03bf ("fscrypt: Add HCTR2
+# support for filename encryption")
+#
+. ./common/preamble
+_begin_fstest auto quick encrypt
+
+# Import common functions.
+. ./common/filter
+. ./common/encrypt
+
+# real QA test starts here
+_supported_fs generic
+
+_verify_ciphertext_for_encryption_policy AES-256-XTS AES-256-HCTR2 v2
+_verify_ciphertext_for_encryption_policy AES-256-XTS AES-256-HCTR2 \
+	v2 iv_ino_lblk_32
+_verify_ciphertext_for_encryption_policy AES-256-XTS AES-256-HCTR2 \
+	v2 iv_ino_lblk_64
+
+# success, all done
+status=0
+exit
tests/generic/900.out new file +16 -0
new file mode 100644
index 00000000..a87c80b3
@@ -0,0 +1,16 @@
+QA output created by 900
+
+Verifying ciphertext with parameters:
+	contents_encryption_mode: AES-256-XTS
+	filenames_encryption_mode: AES-256-HCTR2
+	options: v2
+
+Verifying ciphertext with parameters:
+	contents_encryption_mode: AES-256-XTS
+	filenames_encryption_mode: AES-256-HCTR2
+	options: v2 iv_ino_lblk_32
+
+Verifying ciphertext with parameters:
+	contents_encryption_mode: AES-256-XTS
+	filenames_encryption_mode: AES-256-HCTR2
+	options: v2 iv_ino_lblk_64
Signature · 1 line
2.37.1.455.g008518b4e5-goog
maintainer Reviewed-by Tested-by on v5 2/2
#4 lore raw

Re: [PATCH v5 2/2] generic: add tests for fscrypt policies with HCTR2

Quoted 7 lines · Nathan Huckleberry

This patch adds fscrypt policy tests for filename encryption using HCTR2.

More information on HCTR2 can be found here: "Length-preserving encryption with HCTR2" https://ia.cr/2021/1441

Looks good,

- Eric

#5 lore raw
In reply to Nathan Huckleberry
Quoted 4 lines · Nathan Huckleberry

This patchset is not intended to be accepted yet. It is reliant on HCTR2 support in the kernel which has not yet been accepted. See the HCTR2 patchset
here: https://lore.kernel.org/all/[email protected]/

Oops, I need to remove this.

Quoted 42 lines

HCTR2 is a new wide-block encryption mode that can used for filename encryption in fscrypt. This patchset adds a reference implementation of HCTR2 to the fscrypt testing utility and adds tests for filename encryption with HCTR2.

More information on HCTR2 can be found here: "Length-preserving encryption with HCTR2": https://ia.cr/2021/1441

Changes in v5:
* Added links to relevant references for POLYVAL and HCTR2
* Removed POLYVAL partial block handling
* Referenced HCTR2 commit in test

Changes in v4:
* Add helper functions for HCTR2 hashing
* Fix accumulator alignment bug
* Small style fixes

Changes in v3:
* Consolidate tests into one file

Changes in v2:
* Use POLYVAL multiplication directly instead of using GHASH trick
* Split reference implementation and tests into two patches
* Remove v1 policy tests
* Various small style fixes

Nathan Huckleberry (2):
fscrypt-crypt-util: add HCTR2 implementation
generic: add tests for fscrypt policies with HCTR2

 common/encrypt           |   2 +
 src/fscrypt-crypt-util.c | 358 ++++++++++++++++++++++++++++++++-------
 tests/generic/900        |  31 ++++
 tests/generic/900.out    |  16 ++
 4 files changed, 350 insertions(+), 57 deletions(-)
 create mode 100755 tests/generic/900
 create mode 100644 tests/generic/900.out

--
2.37.1.455.g008518b4e5-goog