diff options
author | Theodore Ts'o <tytso@mit.edu> | 2015-05-01 16:56:50 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2015-05-01 16:56:50 -0400 |
commit | a44cd7a05496d60fd2ba8cca080e3db8f481549b (patch) | |
tree | dd8d05d845817e4a429804d8ffe09dd68b6881e6 /fs/ext4/ext4_crypto.h | |
parent | 5de0b4d0cd153c471640b13aae6ae6d18d0a4603 (diff) |
ext4 crypto: add padding to filenames before encrypting
This obscures the length of the filenames, to decrease the amount of
information leakage. By default, we pad the filenames to the next 4
byte boundaries. This costs nothing, since the directory entries are
aligned to 4 byte boundaries anyway. Filenames can also be padded to
8, 16, or 32 bytes, which will consume more directory space.
Change-Id: Ibb7a0fb76d2c48e2061240a709358ff40b14f322
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/ext4_crypto.h')
-rw-r--r-- | fs/ext4/ext4_crypto.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/ext4/ext4_crypto.h b/fs/ext4/ext4_crypto.h index c2ba35a914b6..d75159c101ce 100644 --- a/fs/ext4/ext4_crypto.h +++ b/fs/ext4/ext4_crypto.h | |||
@@ -20,12 +20,20 @@ struct ext4_encryption_policy { | |||
20 | char version; | 20 | char version; |
21 | char contents_encryption_mode; | 21 | char contents_encryption_mode; |
22 | char filenames_encryption_mode; | 22 | char filenames_encryption_mode; |
23 | char flags; | ||
23 | char master_key_descriptor[EXT4_KEY_DESCRIPTOR_SIZE]; | 24 | char master_key_descriptor[EXT4_KEY_DESCRIPTOR_SIZE]; |
24 | } __attribute__((__packed__)); | 25 | } __attribute__((__packed__)); |
25 | 26 | ||
26 | #define EXT4_ENCRYPTION_CONTEXT_FORMAT_V1 1 | 27 | #define EXT4_ENCRYPTION_CONTEXT_FORMAT_V1 1 |
27 | #define EXT4_KEY_DERIVATION_NONCE_SIZE 16 | 28 | #define EXT4_KEY_DERIVATION_NONCE_SIZE 16 |
28 | 29 | ||
30 | #define EXT4_POLICY_FLAGS_PAD_4 0x00 | ||
31 | #define EXT4_POLICY_FLAGS_PAD_8 0x01 | ||
32 | #define EXT4_POLICY_FLAGS_PAD_16 0x02 | ||
33 | #define EXT4_POLICY_FLAGS_PAD_32 0x03 | ||
34 | #define EXT4_POLICY_FLAGS_PAD_MASK 0x03 | ||
35 | #define EXT4_POLICY_FLAGS_VALID 0x03 | ||
36 | |||
29 | /** | 37 | /** |
30 | * Encryption context for inode | 38 | * Encryption context for inode |
31 | * | 39 | * |
@@ -41,7 +49,7 @@ struct ext4_encryption_context { | |||
41 | char format; | 49 | char format; |
42 | char contents_encryption_mode; | 50 | char contents_encryption_mode; |
43 | char filenames_encryption_mode; | 51 | char filenames_encryption_mode; |
44 | char reserved; | 52 | char flags; |
45 | char master_key_descriptor[EXT4_KEY_DESCRIPTOR_SIZE]; | 53 | char master_key_descriptor[EXT4_KEY_DESCRIPTOR_SIZE]; |
46 | char nonce[EXT4_KEY_DERIVATION_NONCE_SIZE]; | 54 | char nonce[EXT4_KEY_DERIVATION_NONCE_SIZE]; |
47 | } __attribute__((__packed__)); | 55 | } __attribute__((__packed__)); |
@@ -120,6 +128,7 @@ struct ext4_fname_crypto_ctx { | |||
120 | struct crypto_hash *htfm; | 128 | struct crypto_hash *htfm; |
121 | struct page *workpage; | 129 | struct page *workpage; |
122 | struct ext4_encryption_key key; | 130 | struct ext4_encryption_key key; |
131 | unsigned flags : 8; | ||
123 | unsigned has_valid_key : 1; | 132 | unsigned has_valid_key : 1; |
124 | unsigned ctfm_key_is_ready : 1; | 133 | unsigned ctfm_key_is_ready : 1; |
125 | }; | 134 | }; |