linux/fs/crypto
Eric Biggers b103fb7653 fscrypt: add support for IV_INO_LBLK_64 policies
Inline encryption hardware compliant with the UFS v2.1 standard or with
the upcoming version of the eMMC standard has the following properties:

(1) Per I/O request, the encryption key is specified by a previously
    loaded keyslot.  There might be only a small number of keyslots.

(2) Per I/O request, the starting IV is specified by a 64-bit "data unit
    number" (DUN).  IV bits 64-127 are assumed to be 0.  The hardware
    automatically increments the DUN for each "data unit" of
    configurable size in the request, e.g. for each filesystem block.

Property (1) makes it inefficient to use the traditional fscrypt
per-file keys.  Property (2) precludes the use of the existing
DIRECT_KEY fscrypt policy flag, which needs at least 192 IV bits.

Therefore, add a new fscrypt policy flag IV_INO_LBLK_64 which causes the
encryption to modified as follows:

- The encryption keys are derived from the master key, encryption mode
  number, and filesystem UUID.

- The IVs are chosen as (inode_number << 32) | file_logical_block_num.
  For filenames encryption, file_logical_block_num is 0.

Since the file nonces aren't used in the key derivation, many files may
share the same encryption key.  This is much more efficient on the
target hardware.  Including the inode number in the IVs and mixing the
filesystem UUID into the keys ensures that data in different files is
nevertheless still encrypted differently.

Additionally, limiting the inode and block numbers to 32 bits and
placing the block number in the low bits maintains compatibility with
the 64-bit DUN convention (property (2) above).

Since this scheme assumes that inode numbers are stable (which may
preclude filesystem shrinking) and that inode and file logical block
numbers are at most 32-bit, IV_INO_LBLK_64 will only be allowed on
filesystems that meet these constraints.  These are acceptable
limitations for the cases where this format would actually be used.

Note that IV_INO_LBLK_64 is an on-disk format, not an implementation.
This patch just adds support for it using the existing filesystem layer
encryption.  A later patch will add support for inline encryption.

Reviewed-by: Paul Crowley <paulcrowley@google.com>
Co-developed-by: Satya Tangirala <satyat@google.com>
Signed-off-by: Satya Tangirala <satyat@google.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
2019-11-06 12:34:36 -08:00
..
bio.c fscrypt: remove struct fscrypt_ctx 2019-10-21 13:22:08 -07:00
crypto.c fscrypt: add support for IV_INO_LBLK_64 policies 2019-11-06 12:34:36 -08:00
fname.c fscrypt: v2 encryption policy support 2019-08-12 19:18:50 -07:00
fscrypt_private.h fscrypt: add support for IV_INO_LBLK_64 policies 2019-11-06 12:34:36 -08:00
hkdf.c fscrypt: add an HKDF-SHA512 implementation 2019-08-12 19:18:50 -07:00
hooks.c fscrypt: make fscrypt_msg() take inode instead of super_block 2019-08-12 19:04:44 -07:00
Kconfig fscrypt: add an HKDF-SHA512 implementation 2019-08-12 19:18:50 -07:00
keyring.c fscrypt: add support for IV_INO_LBLK_64 policies 2019-11-06 12:34:36 -08:00
keysetup_v1.c fscrypt: invoke crypto API for ESSIV handling 2019-10-21 13:22:08 -07:00
keysetup.c fscrypt: add support for IV_INO_LBLK_64 policies 2019-11-06 12:34:36 -08:00
Makefile fscrypt: add an HKDF-SHA512 implementation 2019-08-12 19:18:50 -07:00
policy.c fscrypt: add support for IV_INO_LBLK_64 policies 2019-11-06 12:34:36 -08:00