mirror of
https://github.com/armbian/linux-cix.git
synced 2026-01-06 12:30:45 -08:00
crypto: hctr2 - Add HCTR2 support
Add support for HCTR2 as a template. HCTR2 is a length-preserving encryption mode that is efficient on processors with instructions to accelerate AES and carryless multiplication, e.g. x86 processors with AES-NI and CLMUL, and ARM processors with the ARMv8 Crypto Extensions. As a length-preserving encryption mode, HCTR2 is suitable for applications such as storage encryption where ciphertext expansion is not possible, and thus authenticated encryption cannot be used. Currently, such applications usually use XTS, or in some cases Adiantum. XTS has the disadvantage that it is a narrow-block mode: a bitflip will only change 16 bytes in the resulting ciphertext or plaintext. This reveals more information to an attacker than necessary. HCTR2 is a wide-block mode, so it provides a stronger security property: a bitflip will change the entire message. HCTR2 is somewhat similar to Adiantum, which is also a wide-block mode. However, HCTR2 is designed to take advantage of existing crypto instructions, while Adiantum targets devices without such hardware support. Adiantum is also designed with longer messages in mind, while HCTR2 is designed to be efficient even on short messages. HCTR2 requires POLYVAL and XCTR as components. More information on HCTR2 can be found here: "Length-preserving encryption with HCTR2": https://eprint.iacr.org/2021/1441.pdf Signed-off-by: Nathan Huckleberry <nhuck@google.com> Reviewed-by: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
committed by
Herbert Xu
parent
f3c923a09c
commit
7ff554ced7
@@ -532,6 +532,17 @@ config CRYPTO_ADIANTUM
|
||||
|
||||
If unsure, say N.
|
||||
|
||||
config CRYPTO_HCTR2
|
||||
tristate "HCTR2 support"
|
||||
select CRYPTO_XCTR
|
||||
select CRYPTO_POLYVAL
|
||||
select CRYPTO_MANAGER
|
||||
help
|
||||
HCTR2 is a length-preserving encryption mode for storage encryption that
|
||||
is efficient on processors with instructions to accelerate AES and
|
||||
carryless multiplication, e.g. x86 processors with AES-NI and CLMUL, and
|
||||
ARM processors with the ARMv8 crypto extensions.
|
||||
|
||||
config CRYPTO_ESSIV
|
||||
tristate "ESSIV support for block encryption"
|
||||
select CRYPTO_AUTHENC
|
||||
|
||||
@@ -95,6 +95,7 @@ obj-$(CONFIG_CRYPTO_LRW) += lrw.o
|
||||
obj-$(CONFIG_CRYPTO_XTS) += xts.o
|
||||
obj-$(CONFIG_CRYPTO_CTR) += ctr.o
|
||||
obj-$(CONFIG_CRYPTO_XCTR) += xctr.o
|
||||
obj-$(CONFIG_CRYPTO_HCTR2) += hctr2.o
|
||||
obj-$(CONFIG_CRYPTO_KEYWRAP) += keywrap.o
|
||||
obj-$(CONFIG_CRYPTO_ADIANTUM) += adiantum.o
|
||||
obj-$(CONFIG_CRYPTO_NHPOLY1305) += nhpoly1305.o
|
||||
|
||||
581
crypto/hctr2.c
Normal file
581
crypto/hctr2.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -2191,6 +2191,11 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb)
|
||||
16, 16, aead_speed_template_19, num_mb);
|
||||
break;
|
||||
|
||||
case 226:
|
||||
test_cipher_speed("hctr2(aes)", ENCRYPT, sec, NULL,
|
||||
0, speed_template_32);
|
||||
break;
|
||||
|
||||
case 300:
|
||||
if (alg) {
|
||||
test_hash_speed(alg, sec, generic_hash_speed_template);
|
||||
|
||||
@@ -5088,6 +5088,14 @@ static const struct alg_test_desc alg_test_descs[] = {
|
||||
.suite = {
|
||||
.hash = __VECS(ghash_tv_template)
|
||||
}
|
||||
}, {
|
||||
.alg = "hctr2(aes)",
|
||||
.generic_driver =
|
||||
"hctr2_base(xctr(aes-generic),polyval-generic)",
|
||||
.test = alg_test_skcipher,
|
||||
.suite = {
|
||||
.cipher = __VECS(aes_hctr2_tv_template)
|
||||
}
|
||||
}, {
|
||||
.alg = "hmac(md5)",
|
||||
.test = alg_test_hash,
|
||||
|
||||
672
crypto/testmgr.h
672
crypto/testmgr.h
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user