28 #ifndef ECRYPTFS_KERNEL_H
29 #define ECRYPTFS_KERNEL_H
37 #include <linux/hash.h>
42 #define ECRYPTFS_DEFAULT_IV_BYTES 16
43 #define ECRYPTFS_DEFAULT_EXTENT_SIZE 4096
44 #define ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE 8192
45 #define ECRYPTFS_DEFAULT_MSG_CTX_ELEMS 32
46 #define ECRYPTFS_DEFAULT_SEND_TIMEOUT HZ
47 #define ECRYPTFS_MAX_MSG_CTX_TTL (HZ*3)
48 #define ECRYPTFS_DEFAULT_NUM_USERS 4
49 #define ECRYPTFS_MAX_NUM_USERS 32768
50 #define ECRYPTFS_XATTR_NAME "user.ecryptfs"
73 #define ECRYPTFS_PREPARE_COMMIT_MODE 0
74 #define ECRYPTFS_WRITEPAGE_MODE 1
82 #if defined(CONFIG_ENCRYPTED_KEYS) || defined(CONFIG_ENCRYPTED_KEYS_MODULE)
84 ecryptfs_get_encrypted_key_payload_data(
struct key *
key)
93 static inline struct key *ecryptfs_get_encrypted_key(
char *
sig)
100 ecryptfs_get_encrypted_key_payload_data(
struct key *
key)
105 static inline struct key *ecryptfs_get_encrypted_key(
char *
sig)
113 ecryptfs_get_key_payload_data(
struct key *
key)
117 auth_tok = ecryptfs_get_encrypted_key_payload_data(key);
125 #define ECRYPTFS_MAX_KEYSET_SIZE 1024
126 #define ECRYPTFS_MAX_CIPHER_NAME_SIZE 32
127 #define ECRYPTFS_MAX_NUM_ENC_KEYS 64
128 #define ECRYPTFS_MAX_IV_BYTES 16
129 #define ECRYPTFS_SALT_BYTES 2
130 #define MAGIC_ECRYPTFS_MARKER 0x3c81b7f5
131 #define MAGIC_ECRYPTFS_MARKER_SIZE_BYTES 8
132 #define ECRYPTFS_FILE_SIZE_BYTES (sizeof(u64))
133 #define ECRYPTFS_SIZE_AND_MARKER_BYTES (ECRYPTFS_FILE_SIZE_BYTES \
134 + MAGIC_ECRYPTFS_MARKER_SIZE_BYTES)
135 #define ECRYPTFS_DEFAULT_CIPHER "aes"
136 #define ECRYPTFS_DEFAULT_KEY_BYTES 16
137 #define ECRYPTFS_DEFAULT_HASH "md5"
138 #define ECRYPTFS_TAG_70_DIGEST ECRYPTFS_DEFAULT_HASH
139 #define ECRYPTFS_TAG_1_PACKET_TYPE 0x01
140 #define ECRYPTFS_TAG_3_PACKET_TYPE 0x8C
141 #define ECRYPTFS_TAG_11_PACKET_TYPE 0xED
142 #define ECRYPTFS_TAG_64_PACKET_TYPE 0x40
143 #define ECRYPTFS_TAG_65_PACKET_TYPE 0x41
144 #define ECRYPTFS_TAG_66_PACKET_TYPE 0x42
145 #define ECRYPTFS_TAG_67_PACKET_TYPE 0x43
146 #define ECRYPTFS_TAG_70_PACKET_TYPE 0x46
148 #define ECRYPTFS_TAG_71_PACKET_TYPE 0x47
150 #define ECRYPTFS_TAG_72_PACKET_TYPE 0x48
152 #define ECRYPTFS_TAG_73_PACKET_TYPE 0x49
154 #define ECRYPTFS_MIN_PKT_LEN_SIZE 1
155 #define ECRYPTFS_MAX_PKT_LEN_SIZE 2
161 #define ECRYPTFS_FILENAME_MIN_RANDOM_PREPEND_BYTES 16
162 #define ECRYPTFS_NON_NULL 0x42
163 #define MD5_DIGEST_SIZE 16
164 #define ECRYPTFS_TAG_70_DIGEST_SIZE MD5_DIGEST_SIZE
165 #define ECRYPTFS_TAG_70_MIN_METADATA_SIZE (1 + ECRYPTFS_MIN_PKT_LEN_SIZE \
166 + ECRYPTFS_SIG_SIZE + 1 + 1)
167 #define ECRYPTFS_TAG_70_MAX_METADATA_SIZE (1 + ECRYPTFS_MAX_PKT_LEN_SIZE \
168 + ECRYPTFS_SIG_SIZE + 1 + 1)
169 #define ECRYPTFS_FEK_ENCRYPTED_FILENAME_PREFIX "ECRYPTFS_FEK_ENCRYPTED."
170 #define ECRYPTFS_FEK_ENCRYPTED_FILENAME_PREFIX_SIZE 23
171 #define ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX "ECRYPTFS_FNEK_ENCRYPTED."
172 #define ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX_SIZE 24
173 #define ECRYPTFS_ENCRYPTED_DENTRY_NAME_LEN (18 + 1 + 4 + 1 + 32)
182 #define ECRYPTFS_FILENAME_CONTAINS_DECRYPTED 0x00000001
199 #define ECRYPTFS_STRUCT_INITIALIZED 0x00000001
200 #define ECRYPTFS_POLICY_APPLIED 0x00000002
201 #define ECRYPTFS_ENCRYPTED 0x00000004
202 #define ECRYPTFS_SECURITY_WARNING 0x00000008
203 #define ECRYPTFS_ENABLE_HMAC 0x00000010
204 #define ECRYPTFS_ENCRYPT_IV_PAGES 0x00000020
205 #define ECRYPTFS_KEY_VALID 0x00000040
206 #define ECRYPTFS_METADATA_IN_XATTR 0x00000080
207 #define ECRYPTFS_VIEW_AS_ENCRYPTED 0x00000100
208 #define ECRYPTFS_KEY_SET 0x00000200
209 #define ECRYPTFS_ENCRYPT_FILENAMES 0x00000400
210 #define ECRYPTFS_ENCFN_USE_MOUNT_FNEK 0x00000800
211 #define ECRYPTFS_ENCFN_USE_FEK 0x00001000
212 #define ECRYPTFS_UNLINK_SIGS 0x00002000
213 #define ECRYPTFS_I_SIZE_INITIALIZED 0x00004000
238 struct inode vfs_inode;
240 struct mutex lower_file_mutex;
273 #define ECRYPTFS_AUTH_TOK_INVALID 0x00000001
274 #define ECRYPTFS_AUTH_TOK_FNEK 0x00000002
313 #define ECRYPTFS_PLAINTEXT_PASSTHROUGH_ENABLED 0x00000001
314 #define ECRYPTFS_XATTR_METADATA_ENABLED 0x00000002
315 #define ECRYPTFS_ENCRYPTED_VIEW_ENABLED 0x00000004
316 #define ECRYPTFS_MOUNT_CRYPT_STAT_INITIALIZED 0x00000008
317 #define ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES 0x00000010
318 #define ECRYPTFS_GLOBAL_ENCFN_USE_MOUNT_FNEK 0x00000020
319 #define ECRYPTFS_GLOBAL_ENCFN_USE_FEK 0x00000040
320 #define ECRYPTFS_GLOBAL_MOUNT_AUTH_TOK_ONLY 0x00000080
363 #define ECRYPTFS_MSG_CTX_STATE_FREE 0x01
364 #define ECRYPTFS_MSG_CTX_STATE_PENDING 0x02
365 #define ECRYPTFS_MSG_CTX_STATE_DONE 0x03
366 #define ECRYPTFS_MSG_CTX_STATE_NO_REPLY 0x04
368 #define ECRYPTFS_MSG_HELO 100
369 #define ECRYPTFS_MSG_QUIT 101
370 #define ECRYPTFS_MSG_REQUEST 102
371 #define ECRYPTFS_MSG_RESPONSE 103
389 #define ECRYPTFS_DAEMON_IN_READ 0x00000001
390 #define ECRYPTFS_DAEMON_IN_POLL 0x00000002
391 #define ECRYPTFS_DAEMON_ZOMBIE 0x00000004
392 #define ECRYPTFS_DAEMON_MISCDEV_OPEN 0x00000008
413 ecryptfs_file_to_private(
struct file *
file)
419 ecryptfs_set_file_private(
struct file *
file,
425 static inline struct file *ecryptfs_file_to_lower(
struct file *
file)
431 ecryptfs_set_file_lower(
struct file *file,
struct file *lower_file)
438 ecryptfs_inode_to_private(
struct inode *
inode)
443 static inline struct inode *ecryptfs_inode_to_lower(
struct inode *
inode)
445 return ecryptfs_inode_to_private(inode)->wii_inode;
449 ecryptfs_set_inode_lower(
struct inode *
inode,
struct inode *lower_inode)
451 ecryptfs_inode_to_private(inode)->wii_inode = lower_inode;
461 ecryptfs_set_superblock_private(
struct super_block *sb,
468 ecryptfs_superblock_to_lower(
struct super_block *sb)
474 ecryptfs_set_superblock_lower(
struct super_block *sb,
487 ecryptfs_set_dentry_private(
struct dentry *dentry,
493 static inline struct dentry *
494 ecryptfs_dentry_to_lower(
struct dentry *dentry)
500 ecryptfs_set_dentry_lower(
struct dentry *dentry,
struct dentry *lower_dentry)
507 ecryptfs_dentry_to_lower_mnt(
struct dentry *dentry)
513 ecryptfs_set_dentry_lower_mnt(
struct dentry *dentry,
struct vfsmount *lower_mnt)
519 #define ecryptfs_printk(type, fmt, arg...) \
520 __ecryptfs_printk(type "%s: " fmt, __func__, ## arg);
553 struct inode *ecryptfs_inode);
555 size_t *decrypted_name_size,
556 struct dentry *ecryptfs_dentry,
561 size_t *encoded_name_size,
564 const char *name,
size_t name_size);
580 struct inode *ecryptfs_inode);
594 struct dentry *ecryptfs_dentry,
595 size_t *len,
size_t max);
598 unsigned char *
src,
struct dentry *ecryptfs_dentry);
602 void *
value,
size_t size);
605 size_t size,
int flags);
623 char *sig,
u32 global_auth_tok_flags);
640 loff_t
offset,
size_t size);
642 struct page *page_for_lower,
646 struct inode *ecryptfs_inode);
649 size_t offset_in_page,
size_t size,
650 struct inode *ecryptfs_inode);
655 size_t *length_size);
657 size_t *packet_size_length);
669 struct dentry *lower_dentry,
678 char *
filename,
size_t filename_size);
683 char *data,
size_t max_packet_size);