Skip to content

Commit be1eb7f

Browse files
Ard Biesheuvelsnitm
authored andcommitted
crypto: essiv - create wrapper template for ESSIV generation
Implement a template that wraps a (skcipher,shash) or (aead,shash) tuple so that we can consolidate the ESSIV handling in fscrypt and dm-crypt and move it into the crypto API. This will result in better test coverage, and will allow future changes to make the bare cipher interface internal to the crypto subsystem, in order to increase robustness of the API against misuse. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Acked-by: Herbert Xu <herbert@gondor.apana.org.au> Tested-by: Milan Broz <gmazyland@gmail.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
1 parent c1499a0 commit be1eb7f

File tree

3 files changed

+692
-0
lines changed

3 files changed

+692
-0
lines changed

crypto/Kconfig

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,34 @@ config CRYPTO_ADIANTUM
568568

569569
If unsure, say N.
570570

571+
config CRYPTO_ESSIV
572+
tristate "ESSIV support for block encryption"
573+
select CRYPTO_AUTHENC
574+
help
575+
Encrypted salt-sector initialization vector (ESSIV) is an IV
576+
generation method that is used in some cases by fscrypt and/or
577+
dm-crypt. It uses the hash of the block encryption key as the
578+
symmetric key for a block encryption pass applied to the input
579+
IV, making low entropy IV sources more suitable for block
580+
encryption.
581+
582+
This driver implements a crypto API template that can be
583+
instantiated either as a skcipher or as a aead (depending on the
584+
type of the first template argument), and which defers encryption
585+
and decryption requests to the encapsulated cipher after applying
586+
ESSIV to the input IV. Note that in the aead case, it is assumed
587+
that the keys are presented in the same format used by the authenc
588+
template, and that the IV appears at the end of the authenticated
589+
associated data (AAD) region (which is how dm-crypt uses it.)
590+
591+
Note that the use of ESSIV is not recommended for new deployments,
592+
and so this only needs to be enabled when interoperability with
593+
existing encrypted volumes of filesystems is required, or when
594+
building for a particular system that requires it (e.g., when
595+
the SoC in question has accelerated CBC but not XTS, making CBC
596+
combined with ESSIV the only feasible mode for h/w accelerated
597+
block encryption)
598+
571599
comment "Hash modes"
572600

573601
config CRYPTO_CMAC

crypto/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ obj-$(CONFIG_CRYPTO_USER_API_AEAD) += algif_aead.o
147147
obj-$(CONFIG_CRYPTO_ZSTD) += zstd.o
148148
obj-$(CONFIG_CRYPTO_OFB) += ofb.o
149149
obj-$(CONFIG_CRYPTO_ECC) += ecc.o
150+
obj-$(CONFIG_CRYPTO_ESSIV) += essiv.o
150151

151152
ecdh_generic-y += ecdh.o
152153
ecdh_generic-y += ecdh_helper.o

0 commit comments

Comments
 (0)