From f348c252320b98e11176074fe04223f22bddaf0d Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Thu, 16 Apr 2015 01:55:00 -0400 Subject: ext4 crypto: add symlink encryption Signed-off-by: Uday Savagaonkar Signed-off-by: Theodore Ts'o --- fs/ext4/ext4_crypto.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'fs/ext4/ext4_crypto.h') diff --git a/fs/ext4/ext4_crypto.h b/fs/ext4/ext4_crypto.h index f7d46e8dc9d3..c2ba35a914b6 100644 --- a/fs/ext4/ext4_crypto.h +++ b/fs/ext4/ext4_crypto.h @@ -124,4 +124,24 @@ struct ext4_fname_crypto_ctx { unsigned ctfm_key_is_ready : 1; }; +/** + * For encrypted symlinks, the ciphertext length is stored at the beginning + * of the string in little-endian format. + */ +struct ext4_encrypted_symlink_data { + __le16 len; + char encrypted_path[1]; +} __attribute__((__packed__)); + +/** + * This function is used to calculate the disk space required to + * store a filename of length l in encrypted symlink format. + */ +static inline u32 encrypted_symlink_data_len(u32 l) +{ + if (l < EXT4_CRYPTO_BLOCK_SIZE) + l = EXT4_CRYPTO_BLOCK_SIZE; + return (l + sizeof(struct ext4_encrypted_symlink_data) - 1); +} + #endif /* _EXT4_CRYPTO_H */ -- cgit v1.2.3