ANDROID: ext4: allow encrypting filenames using HEH algorithm
Update ext4 encryption to allow filenames to be encrypted using the Hash-Encrypt-Hash (HEH) block cipher mode of operation, which is believed to be more secure than CBC, particularly within the constant initialization vector (IV) constraint of filename encryption. Notably, HEH avoids the "common prefix" problem of CBC. Both algorithms use AES-256 as the underlying block cipher and take a 256-bit key. We assign mode number 126 to HEH, just below 127 (EXT4_ENCRYPTION_MODE_PRIVATE) which in some kernels is reserved for inline encryption on MSM chipsets. Note that these modes are not yet upstream, which is why these numbers are being used; it's preferable to avoid collisions with modes that may be added upstream. Also, although HEH is not hardware-specific, we aren't currently reserving mode number 5 for HEH upstream, since for now we are tying HEH to the new key derivation method which might become an independent flag upstream, and there's also a chance that details of HEH will change after it gets wider review. Bug: 32975945 Signed-off-by: Eric Biggers <ebiggers@google.com> Change-Id: I81418709d47da0e0ac607ae3f91088063c2d5dd4
This commit is contained in:
parent
0223de3a24
commit
3e0dd6ec69
5 changed files with 10 additions and 1 deletions
|
@ -106,6 +106,7 @@ config EXT4_ENCRYPTION
|
|||
select CRYPTO_ECB
|
||||
select CRYPTO_XTS
|
||||
select CRYPTO_CTS
|
||||
select CRYPTO_HEH
|
||||
select CRYPTO_CTR
|
||||
select CRYPTO_SHA256
|
||||
select KEYS
|
||||
|
|
|
@ -44,7 +44,8 @@ static void ext4_dir_crypt_complete(struct crypto_async_request *req, int res)
|
|||
|
||||
bool ext4_valid_filenames_enc_mode(uint32_t mode)
|
||||
{
|
||||
return (mode == EXT4_ENCRYPTION_MODE_AES_256_CTS);
|
||||
return (mode == EXT4_ENCRYPTION_MODE_AES_256_CTS ||
|
||||
mode == EXT4_ENCRYPTION_MODE_AES_256_HEH);
|
||||
}
|
||||
|
||||
static unsigned max_name_len(struct inode *inode)
|
||||
|
|
|
@ -182,6 +182,9 @@ retry:
|
|||
case EXT4_ENCRYPTION_MODE_AES_256_CTS:
|
||||
cipher_str = "cts(cbc(aes))";
|
||||
break;
|
||||
case EXT4_ENCRYPTION_MODE_AES_256_HEH:
|
||||
cipher_str = "heh(aes)";
|
||||
break;
|
||||
default:
|
||||
printk_once(KERN_WARNING
|
||||
"ext4: unsupported key mode %d (ino %u)\n",
|
||||
|
|
|
@ -588,6 +588,7 @@ enum {
|
|||
#define EXT4_ENCRYPTION_MODE_AES_256_GCM 2
|
||||
#define EXT4_ENCRYPTION_MODE_AES_256_CBC 3
|
||||
#define EXT4_ENCRYPTION_MODE_AES_256_CTS 4
|
||||
#define EXT4_ENCRYPTION_MODE_AES_256_HEH 126
|
||||
|
||||
#include "ext4_crypto.h"
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ struct ext4_encryption_context {
|
|||
#define EXT4_AES_256_GCM_KEY_SIZE 32
|
||||
#define EXT4_AES_256_CBC_KEY_SIZE 32
|
||||
#define EXT4_AES_256_CTS_KEY_SIZE 32
|
||||
#define EXT4_AES_256_HEH_KEY_SIZE 32
|
||||
#define EXT4_AES_256_XTS_KEY_SIZE 64
|
||||
#define EXT4_MAX_KEY_SIZE 64
|
||||
|
||||
|
@ -121,6 +122,8 @@ static inline int ext4_encryption_key_size(int mode)
|
|||
return EXT4_AES_256_CBC_KEY_SIZE;
|
||||
case EXT4_ENCRYPTION_MODE_AES_256_CTS:
|
||||
return EXT4_AES_256_CTS_KEY_SIZE;
|
||||
case EXT4_ENCRYPTION_MODE_AES_256_HEH:
|
||||
return EXT4_AES_256_HEH_KEY_SIZE;
|
||||
default:
|
||||
BUG();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue