generic: test HCTR2 filename encryption
v2 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 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 reference implementation
generic: add tests for fscrypt policies with HCTR2
common/encrypt | 2 + src/fscrypt-crypt-util.c | 338 ++++++++++++++++++++++++++++++++------- tests/generic/900 | 24 +++ tests/generic/900.out | 6 + tests/generic/901 | 26 +++ tests/generic/901.out | 6 + tests/generic/902 | 26 +++ tests/generic/902.out | 6 + 8 files changed, 377 insertions(+), 57 deletions(-) create mode 100755 tests/generic/900 create mode 100644 tests/generic/900.out create mode 100755 tests/generic/901 create mode 100644 tests/generic/901.out create mode 100755 tests/generic/902 create mode 100644 tests/generic/902.out
Signature · 1 line
2.36.0.512.ge40c2bad7a-goog
RFC PATCH v2 1/2 fscrypt-crypt-util: add HCTR2 reference implementation
This patch adds a reference 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 | 338 ++++++++++++++++++++++++++++++++------- 2 files changed, 283 insertions(+), 57 deletions(-)
common/encrypt +2 -0
@@ -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 +281 -57
404 lines not on this page · raw message
Signature · 1 line
2.36.0.512.ge40c2bad7a-goog
RFC PATCH v2 2/2 generic: add tests for fscrypt policies with HCTR2
In reply to Nathan HuckleberryThis 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 | 24 ++++++++++++++++++++++++ tests/generic/900.out | 6 ++++++ tests/generic/901 | 26 ++++++++++++++++++++++++++ tests/generic/901.out | 6 ++++++ tests/generic/902 | 26 ++++++++++++++++++++++++++ tests/generic/902.out | 6 ++++++ 6 files changed, 94 insertions(+) create mode 100755 tests/generic/900 create mode 100644 tests/generic/900.out create mode 100755 tests/generic/901 create mode 100644 tests/generic/901.out create mode 100755 tests/generic/902 create mode 100644 tests/generic/902.out
tests/generic/900 new file +24 -0
@@ -0,0 +1,24 @@ +#! /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. +# +. ./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 + +# success, all done +status=0 +exit
tests/generic/900.out new file +6 -0
@@ -0,0 +1,6 @@ +QA output created by 900 + +Verifying ciphertext with parameters: + contents_encryption_mode: AES-256-XTS + filenames_encryption_mode: AES-256-HCTR2 + options: v2
tests/generic/901 new file +26 -0
@@ -0,0 +1,26 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright 2022 Google LLC +# +# FS QA Test No. 901 +# +# Verify ciphertext for v2 encryption policies that use the IV_INO_LBLK_32 flag +# and use AES-256-XTS to encrypt file contents and AES-256-HCTR2 to encrypt +# file names. +# +. ./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 iv_ino_lblk_32 + +# success, all done +status=0 +exit
tests/generic/901.out new file +6 -0
@@ -0,0 +1,6 @@ +QA output created by 901 + +Verifying ciphertext with parameters: + contents_encryption_mode: AES-256-XTS + filenames_encryption_mode: AES-256-HCTR2 + options: v2 iv_ino_lblk_32
tests/generic/902 new file +26 -0
@@ -0,0 +1,26 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright 2022 Google LLC +# +# FS QA Test No. 902 +# +# Verify ciphertext for v2 encryption policies that use the IV_INO_LBLK_64 flag +# and use AES-256-XTS to encrypt file contents and AES-256-HCTR2 to encrypt +# file names. +# +. ./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 iv_ino_lblk_64 + +# success, all done +status=0 +exit
tests/generic/902.out new file +6 -0
@@ -0,0 +1,6 @@ +QA output created by 902 + +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.36.0.512.ge40c2bad7a-goog
Re: [RFC PATCH v2 2/2] generic: add tests for fscrypt policies with HCTR2
Quoted 5 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
One test for all three verifications would be better - less tests to run, less tests to maintain. Especially as these are effectively one-line tests with a clear golden output which tells us exactly which verification failed...
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]