Revert "BACKPORT, FROMLIST: fscrypt: add Speck128/256 support"

This reverts commit eafbcb2354.

Resolves conflicts with a later CL, e7724207f7 "fscrypt: log the
crypto algorithm implementations".

[astrachan: This is an update to 7977ade69d which reverted only
            the fscrypt changes, not the ext4 changes, due to a
            historical bad merge.]
Bug: 116008047
Change-Id: I772d78d6e4bd126dcd2b25049c719f8522a1c157
Signed-off-by: Alistair Strachan <astrachan@google.com>
[AmitP: Updated commit message for correct SHA1 hash]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
This commit is contained in:
Alistair Strachan
2018-10-23 12:37:23 -07:00
committed by Amit Pundir
parent 00428ff5a2
commit f111b61338
6 changed files with 19 additions and 28 deletions

View File

@@ -457,17 +457,9 @@ errout:
return err;
}
bool ext4_valid_enc_modes(uint32_t contents_mode, uint32_t filenames_mode)
bool ext4_valid_contents_enc_mode(uint32_t mode)
{
if (contents_mode == EXT4_ENCRYPTION_MODE_AES_256_XTS) {
return (filenames_mode == EXT4_ENCRYPTION_MODE_AES_256_CTS ||
filenames_mode == EXT4_ENCRYPTION_MODE_AES_256_HEH);
}
if (contents_mode == EXT4_ENCRYPTION_MODE_SPECK128_256_XTS)
return filenames_mode == EXT4_ENCRYPTION_MODE_SPECK128_256_CTS;
return false;
return (mode == EXT4_ENCRYPTION_MODE_AES_256_XTS);
}
/**

View File

@@ -42,6 +42,12 @@ static void ext4_dir_crypt_complete(struct crypto_async_request *req, int res)
complete(&ecr->completion);
}
bool ext4_valid_filenames_enc_mode(uint32_t mode)
{
return (mode == EXT4_ENCRYPTION_MODE_AES_256_CTS ||
mode == EXT4_ENCRYPTION_MODE_AES_256_HEH);
}
static unsigned max_name_len(struct inode *inode)
{
return S_ISLNK(inode->i_mode) ? inode->i_sb->s_blocksize :

View File

@@ -258,12 +258,6 @@ int ext4_get_encryption_info(struct inode *inode)
case EXT4_ENCRYPTION_MODE_AES_256_HEH:
cipher_str = "heh(aes)";
break;
case EXT4_ENCRYPTION_MODE_SPECK128_256_XTS:
cipher_str = "xts(speck128)";
break;
case EXT4_ENCRYPTION_MODE_SPECK128_256_CTS:
cipher_str = "cts(cbc(speck128))";
break;
default:
printk_once(KERN_WARNING
"ext4: unsupported key mode %d (ino %u)\n",

View File

@@ -60,12 +60,16 @@ static int ext4_create_encryption_context_from_policy(
ctx.format = EXT4_ENCRYPTION_CONTEXT_FORMAT_V1;
memcpy(ctx.master_key_descriptor, policy->master_key_descriptor,
EXT4_KEY_DESCRIPTOR_SIZE);
if (!ext4_valid_enc_modes(policy->contents_encryption_mode,
policy->filenames_encryption_mode)) {
if (!ext4_valid_contents_enc_mode(policy->contents_encryption_mode)) {
printk(KERN_WARNING
"%s: Invalid encryption modes (contents %d, filenames %d)\n",
__func__, policy->contents_encryption_mode,
policy->filenames_encryption_mode);
"%s: Invalid contents encryption mode %d\n", __func__,
policy->contents_encryption_mode);
return -EINVAL;
}
if (!ext4_valid_filenames_enc_mode(policy->filenames_encryption_mode)) {
printk(KERN_WARNING
"%s: Invalid filenames encryption mode %d\n", __func__,
policy->filenames_encryption_mode);
return -EINVAL;
}
if (policy->flags & ~EXT4_POLICY_FLAGS_VALID)

View File

@@ -589,8 +589,6 @@ 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_SPECK128_256_XTS 7
#define EXT4_ENCRYPTION_MODE_SPECK128_256_CTS 8
#define EXT4_ENCRYPTION_MODE_AES_256_HEH 126
#include "ext4_crypto.h"
@@ -2256,7 +2254,7 @@ int ext4_get_policy(struct inode *inode,
/* crypto.c */
extern struct kmem_cache *ext4_crypt_info_cachep;
bool ext4_valid_enc_modes(uint32_t contents_mode, uint32_t filenames_mode);
bool ext4_valid_contents_enc_mode(uint32_t mode);
uint32_t ext4_validate_encryption_key_size(uint32_t mode, uint32_t size);
extern struct workqueue_struct *ext4_read_workqueue;
struct ext4_crypto_ctx *ext4_get_crypto_ctx(struct inode *inode,
@@ -2287,6 +2285,7 @@ static inline int ext4_sb_has_crypto(struct super_block *sb)
#endif
/* crypto_fname.c */
bool ext4_valid_filenames_enc_mode(uint32_t mode);
u32 ext4_fname_crypto_round_up(u32 size, u32 blksize);
unsigned ext4_fname_encrypted_size(struct inode *inode, u32 ilen);
int ext4_fname_crypto_alloc_buffer(struct inode *inode,

View File

@@ -124,10 +124,6 @@ static inline int ext4_encryption_key_size(int mode)
return EXT4_AES_256_CTS_KEY_SIZE;
case EXT4_ENCRYPTION_MODE_AES_256_HEH:
return EXT4_AES_256_HEH_KEY_SIZE;
case EXT4_ENCRYPTION_MODE_SPECK128_256_XTS:
return 64;
case EXT4_ENCRYPTION_MODE_SPECK128_256_CTS:
return 32;
default:
BUG();
}