Skip to contentSkip to conversation

generic: test HCTR2 filename encryption

PATCH In review Nathan Huckleberry 3 participants 5 messages Aug 9, 2022 – Aug 11, 2022 fscrypt: file system level encryption support

lore
Share & tools
lore
#0 lore raw

v6 cover generic: test HCTR2 filename encryption

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

The patchset introducing HCTR2 to the kernel can be found here:
https://lore.kernel.org/linux-crypto/[email protected]/

Changes in v6:
* Remove unused variable
* Rework cover letter

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 | 357 ++++++++++++++++++++++++++++++++-------
 tests/generic/900        |  31 ++++
 tests/generic/900.out    |  16 ++
 4 files changed, 349 insertions(+), 57 deletions(-)
 create mode 100755 tests/generic/900
 create mode 100644 tests/generic/900.out
Signature · 1 line
2.37.1.559.g78731f0fdb-goog
#1 lore raw

PATCH v6 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 | 357 ++++++++++++++++++++++++++++++++-------
 2 files changed, 302 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 +300 -57

423 lines not on this page · raw message

Signature · 1 line
2.37.1.559.g78731f0fdb-goog
#2 lore raw

PATCH v6 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.559.g78731f0fdb-goog
maintainer
#3 lore raw
In reply to Nathan Huckleberry
Quoted 9 lines · Nathan Huckleberry

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

The patchset introducing HCTR2 to the kernel can be found here:
https://lore.kernel.org/linux-crypto/[email protected]/

Thanks Huck. Zorro already applied v5 to the for-next branch, with the chunk_size variable removed (which is the only code you changed in v6), and with generic/900 renamed to its final name of generic/693. See
https://lore.kernel.org/fstests/[email protected]/T/#u

So I think everything is good to go already.

- Eric

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

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

Quoted 6 lines

The patchset introducing HCTR2 to the kernel can be found here:
https://lore.kernel.org/linux-crypto/[email protected]/

Changes in v6:
* Remove unused variable
* Rework cover letter

I've merged your v5 patchset. So feel free to send bug fix patches if you found more issues.

Thanks,
Zorro

Quoted 38 lines

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 | 357 ++++++++++++++++++++++++++++++++-------
 tests/generic/900        |  31 ++++
 tests/generic/900.out    |  16 ++
 4 files changed, 349 insertions(+), 57 deletions(-)
 create mode 100755 tests/generic/900
 create mode 100644 tests/generic/900.out
Signature · 1 line
2.37.1.559.g78731f0fdb-goog