aboutsummaryrefslogtreecommitdiff
path: root/fs/ext4/ext4_crypto.h
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@google.com>2015-04-14 20:56:49 -0400
committerMister Oyster <oysterized@gmail.com>2017-05-27 19:39:59 +0200
commit5ab04b9c148fbab30697b9e95ec2cc5e16bfe072 (patch)
tree095689573eea9dbd3e7574a5166206919d858fbd /fs/ext4/ext4_crypto.h
parentbdd646de97d8dd589282161c175e23e62fc5fa9c (diff)
ext4 crypto: Add symlink encryption
Change-Id: Iea4299ef61fb5493db679115d75534474785bb78 Signed-off-by: Uday Savagaonkar <savagaon@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Theodore Ts'o <tytso@google.com>
Diffstat (limited to 'fs/ext4/ext4_crypto.h')
-rw-r--r--fs/ext4/ext4_crypto.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/fs/ext4/ext4_crypto.h b/fs/ext4/ext4_crypto.h
index f7d46e8dc..c2ba35a91 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 */