encrypted-keys: add ecryptfs format support
[deliverable/linux.git] / fs / ecryptfs / ecryptfs_kernel.h
CommitLineData
237fead6
MH
1/**
2 * eCryptfs: Linux filesystem encryption layer
3 * Kernel declarations.
4 *
5 * Copyright (C) 1997-2003 Erez Zadok
6 * Copyright (C) 2001-2003 Stony Brook University
f66e883e 7 * Copyright (C) 2004-2008 International Business Machines Corp.
237fead6 8 * Author(s): Michael A. Halcrow <mahalcro@us.ibm.com>
88b4a07e
MH
9 * Trevor S. Highland <trevor.highland@gmail.com>
10 * Tyler Hicks <tyhicks@ou.edu>
237fead6
MH
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 * 02111-1307, USA.
26 */
27
28#ifndef ECRYPTFS_KERNEL_H
29#define ECRYPTFS_KERNEL_H
30
31#include <keys/user-type.h>
32#include <linux/fs.h>
0cc72dc7 33#include <linux/fs_stack.h>
b65d34fd 34#include <linux/namei.h>
237fead6 35#include <linux/scatterlist.h>
dddfa461 36#include <linux/hash.h>
6a3fd92e 37#include <linux/nsproxy.h>
9df9c8b9 38#include <linux/backing-dev.h>
f8f85271 39#include <linux/ecryptfs.h>
237fead6 40
237fead6 41#define ECRYPTFS_DEFAULT_IV_BYTES 16
237fead6
MH
42#define ECRYPTFS_DEFAULT_EXTENT_SIZE 4096
43#define ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE 8192
88b4a07e
MH
44#define ECRYPTFS_DEFAULT_MSG_CTX_ELEMS 32
45#define ECRYPTFS_DEFAULT_SEND_TIMEOUT HZ
46#define ECRYPTFS_MAX_MSG_CTX_TTL (HZ*3)
88b4a07e
MH
47#define ECRYPTFS_DEFAULT_NUM_USERS 4
48#define ECRYPTFS_MAX_NUM_USERS 32768
dd2a3b7a 49#define ECRYPTFS_XATTR_NAME "user.ecryptfs"
237fead6 50
237fead6
MH
51void ecryptfs_dump_auth_tok(struct ecryptfs_auth_tok *auth_tok);
52extern void ecryptfs_to_hex(char *dst, char *src, size_t src_size);
53extern void ecryptfs_from_hex(char *dst, char *src, int dst_size);
54
55struct ecryptfs_key_record {
56 unsigned char type;
57 size_t enc_key_size;
58 unsigned char sig[ECRYPTFS_SIG_SIZE];
59 unsigned char enc_key[ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES];
60};
61
62struct ecryptfs_auth_tok_list {
63 struct ecryptfs_auth_tok *auth_tok;
64 struct list_head list;
65};
66
67struct ecryptfs_crypt_stat;
68struct ecryptfs_mount_crypt_stat;
69
70struct ecryptfs_page_crypt_context {
71 struct page *page;
72#define ECRYPTFS_PREPARE_COMMIT_MODE 0
73#define ECRYPTFS_WRITEPAGE_MODE 1
74 unsigned int mode;
75 union {
76 struct file *lower_file;
77 struct writeback_control *wbc;
78 } param;
79};
80
81static inline struct ecryptfs_auth_tok *
82ecryptfs_get_key_payload_data(struct key *key)
83{
84 return (struct ecryptfs_auth_tok *)
85 (((struct user_key_payload*)key->payload.data)->data);
86}
87
237fead6
MH
88#define ECRYPTFS_MAX_KEYSET_SIZE 1024
89#define ECRYPTFS_MAX_CIPHER_NAME_SIZE 32
90#define ECRYPTFS_MAX_NUM_ENC_KEYS 64
237fead6
MH
91#define ECRYPTFS_MAX_IV_BYTES 16 /* 128 bits */
92#define ECRYPTFS_SALT_BYTES 2
93#define MAGIC_ECRYPTFS_MARKER 0x3c81b7f5
94#define MAGIC_ECRYPTFS_MARKER_SIZE_BYTES 8 /* 4*2 */
45eaab79 95#define ECRYPTFS_FILE_SIZE_BYTES (sizeof(u64))
778aeb42
TH
96#define ECRYPTFS_SIZE_AND_MARKER_BYTES (ECRYPTFS_FILE_SIZE_BYTES \
97 + MAGIC_ECRYPTFS_MARKER_SIZE_BYTES)
237fead6
MH
98#define ECRYPTFS_DEFAULT_CIPHER "aes"
99#define ECRYPTFS_DEFAULT_KEY_BYTES 16
565d9724 100#define ECRYPTFS_DEFAULT_HASH "md5"
9c79f34f 101#define ECRYPTFS_TAG_70_DIGEST ECRYPTFS_DEFAULT_HASH
88b4a07e 102#define ECRYPTFS_TAG_1_PACKET_TYPE 0x01
237fead6
MH
103#define ECRYPTFS_TAG_3_PACKET_TYPE 0x8C
104#define ECRYPTFS_TAG_11_PACKET_TYPE 0xED
88b4a07e
MH
105#define ECRYPTFS_TAG_64_PACKET_TYPE 0x40
106#define ECRYPTFS_TAG_65_PACKET_TYPE 0x41
107#define ECRYPTFS_TAG_66_PACKET_TYPE 0x42
108#define ECRYPTFS_TAG_67_PACKET_TYPE 0x43
9c79f34f
MH
109#define ECRYPTFS_TAG_70_PACKET_TYPE 0x46 /* FNEK-encrypted filename
110 * as dentry name */
111#define ECRYPTFS_TAG_71_PACKET_TYPE 0x47 /* FNEK-encrypted filename in
112 * metadata */
113#define ECRYPTFS_TAG_72_PACKET_TYPE 0x48 /* FEK-encrypted filename as
114 * dentry name */
115#define ECRYPTFS_TAG_73_PACKET_TYPE 0x49 /* FEK-encrypted filename as
116 * metadata */
117/* Constraint: ECRYPTFS_FILENAME_MIN_RANDOM_PREPEND_BYTES >=
118 * ECRYPTFS_MAX_IV_BYTES */
119#define ECRYPTFS_FILENAME_MIN_RANDOM_PREPEND_BYTES 16
120#define ECRYPTFS_NON_NULL 0x42 /* A reasonable substitute for NULL */
237fead6 121#define MD5_DIGEST_SIZE 16
9c79f34f
MH
122#define ECRYPTFS_TAG_70_DIGEST_SIZE MD5_DIGEST_SIZE
123#define ECRYPTFS_FEK_ENCRYPTED_FILENAME_PREFIX "ECRYPTFS_FEK_ENCRYPTED."
124#define ECRYPTFS_FEK_ENCRYPTED_FILENAME_PREFIX_SIZE 23
125#define ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX "ECRYPTFS_FNEK_ENCRYPTED."
126#define ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX_SIZE 24
127#define ECRYPTFS_ENCRYPTED_DENTRY_NAME_LEN (18 + 1 + 4 + 1 + 32)
237fead6 128
f4aad16a
MH
129struct ecryptfs_key_sig {
130 struct list_head crypt_stat_list;
7762e230 131 char keysig[ECRYPTFS_SIG_SIZE_HEX + 1];
f4aad16a
MH
132};
133
a34f60f7
MH
134struct ecryptfs_filename {
135 struct list_head crypt_stat_list;
136#define ECRYPTFS_FILENAME_CONTAINS_DECRYPTED 0x00000001
137 u32 flags;
138 u32 seq_no;
139 char *filename;
140 char *encrypted_filename;
141 size_t filename_size;
142 size_t encrypted_filename_size;
143 char fnek_sig[ECRYPTFS_SIG_SIZE_HEX];
144 char dentry_name[ECRYPTFS_ENCRYPTED_DENTRY_NAME_LEN + 1];
145};
146
237fead6
MH
147/**
148 * This is the primary struct associated with each encrypted file.
149 *
150 * TODO: cache align/pack?
151 */
152struct ecryptfs_crypt_stat {
a34f60f7
MH
153#define ECRYPTFS_STRUCT_INITIALIZED 0x00000001
154#define ECRYPTFS_POLICY_APPLIED 0x00000002
fed8859b
TH
155#define ECRYPTFS_ENCRYPTED 0x00000004
156#define ECRYPTFS_SECURITY_WARNING 0x00000008
157#define ECRYPTFS_ENABLE_HMAC 0x00000010
158#define ECRYPTFS_ENCRYPT_IV_PAGES 0x00000020
159#define ECRYPTFS_KEY_VALID 0x00000040
160#define ECRYPTFS_METADATA_IN_XATTR 0x00000080
161#define ECRYPTFS_VIEW_AS_ENCRYPTED 0x00000100
162#define ECRYPTFS_KEY_SET 0x00000200
163#define ECRYPTFS_ENCRYPT_FILENAMES 0x00000400
164#define ECRYPTFS_ENCFN_USE_MOUNT_FNEK 0x00000800
165#define ECRYPTFS_ENCFN_USE_FEK 0x00001000
166#define ECRYPTFS_UNLINK_SIGS 0x00002000
3aeb86ea 167#define ECRYPTFS_I_SIZE_INITIALIZED 0x00004000
237fead6
MH
168 u32 flags;
169 unsigned int file_version;
170 size_t iv_bytes;
fa3ef1cb 171 size_t metadata_size;
237fead6
MH
172 size_t extent_size; /* Data extent size; default is 4096 */
173 size_t key_size;
174 size_t extent_shift;
175 unsigned int extent_mask;
176 struct ecryptfs_mount_crypt_stat *mount_crypt_stat;
8bba066f 177 struct crypto_blkcipher *tfm;
565d9724
MH
178 struct crypto_hash *hash_tfm; /* Crypto context for generating
179 * the initialization vectors */
237fead6
MH
180 unsigned char cipher[ECRYPTFS_MAX_CIPHER_NAME_SIZE];
181 unsigned char key[ECRYPTFS_MAX_KEY_BYTES];
182 unsigned char root_iv[ECRYPTFS_MAX_IV_BYTES];
f4aad16a
MH
183 struct list_head keysig_list;
184 struct mutex keysig_list_mutex;
237fead6 185 struct mutex cs_tfm_mutex;
565d9724 186 struct mutex cs_hash_tfm_mutex;
237fead6
MH
187 struct mutex cs_mutex;
188};
189
190/* inode private data. */
191struct ecryptfs_inode_info {
192 struct inode vfs_inode;
193 struct inode *wii_inode;
332ab16f
TH
194 struct mutex lower_file_mutex;
195 atomic_t lower_file_count;
da0102a1 196 struct file *lower_file;
237fead6
MH
197 struct ecryptfs_crypt_stat crypt_stat;
198};
199
200/* dentry private data. Each dentry must keep track of a lower
201 * vfsmount too. */
202struct ecryptfs_dentry_info {
b65d34fd 203 struct path lower_path;
237fead6
MH
204 struct ecryptfs_crypt_stat *crypt_stat;
205};
206
6c6f57f3 207/**
45eaab79
MH
208 * ecryptfs_global_auth_tok - A key used to encrypt all new files under the mountpoint
209 * @flags: Status flags
210 * @mount_crypt_stat_list: These auth_toks hang off the mount-wide
211 * cryptographic context. Every time a new
212 * inode comes into existence, eCryptfs copies
213 * the auth_toks on that list to the set of
214 * auth_toks on the inode's crypt_stat
215 * @global_auth_tok_key: The key from the user's keyring for the sig
216 * @global_auth_tok: The key contents
217 * @sig: The key identifier
218 *
6c6f57f3
MH
219 * ecryptfs_global_auth_tok structs refer to authentication token keys
220 * in the user keyring that apply to newly created files. A list of
221 * these objects hangs off of the mount_crypt_stat struct for any
222 * given eCryptfs mount. This struct maintains a reference to both the
223 * key contents and the key itself so that the key can be put on
224 * unmount.
225 */
f4aad16a
MH
226struct ecryptfs_global_auth_tok {
227#define ECRYPTFS_AUTH_TOK_INVALID 0x00000001
84814d64 228#define ECRYPTFS_AUTH_TOK_FNEK 0x00000002
f4aad16a 229 u32 flags;
45eaab79
MH
230 struct list_head mount_crypt_stat_list;
231 struct key *global_auth_tok_key;
45eaab79 232 unsigned char sig[ECRYPTFS_SIG_SIZE_HEX + 1];
f4aad16a
MH
233};
234
6c6f57f3 235/**
45eaab79
MH
236 * ecryptfs_key_tfm - Persistent key tfm
237 * @key_tfm: crypto API handle to the key
238 * @key_size: Key size in bytes
239 * @key_tfm_mutex: Mutex to ensure only one operation in eCryptfs is
240 * using the persistent TFM at any point in time
241 * @key_tfm_list: Handle to hang this off the module-wide TFM list
242 * @cipher_name: String name for the cipher for this TFM
243 *
6c6f57f3
MH
244 * Typically, eCryptfs will use the same ciphers repeatedly throughout
245 * the course of its operations. In order to avoid unnecessarily
246 * destroying and initializing the same cipher repeatedly, eCryptfs
247 * keeps a list of crypto API contexts around to use when needed.
248 */
f4aad16a
MH
249struct ecryptfs_key_tfm {
250 struct crypto_blkcipher *key_tfm;
251 size_t key_size;
252 struct mutex key_tfm_mutex;
45eaab79 253 struct list_head key_tfm_list;
f4aad16a
MH
254 unsigned char cipher_name[ECRYPTFS_MAX_CIPHER_NAME_SIZE + 1];
255};
256
af440f52
ES
257extern struct mutex key_tfm_list_mutex;
258
237fead6
MH
259/**
260 * This struct is to enable a mount-wide passphrase/salt combo. This
261 * is more or less a stopgap to provide similar functionality to other
262 * crypto filesystems like EncFS or CFS until full policy support is
263 * implemented in eCryptfs.
264 */
265struct ecryptfs_mount_crypt_stat {
266 /* Pointers to memory we do not own, do not free these */
267#define ECRYPTFS_PLAINTEXT_PASSTHROUGH_ENABLED 0x00000001
17398957
MH
268#define ECRYPTFS_XATTR_METADATA_ENABLED 0x00000002
269#define ECRYPTFS_ENCRYPTED_VIEW_ENABLED 0x00000004
f4aad16a 270#define ECRYPTFS_MOUNT_CRYPT_STAT_INITIALIZED 0x00000008
9c79f34f
MH
271#define ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES 0x00000010
272#define ECRYPTFS_GLOBAL_ENCFN_USE_MOUNT_FNEK 0x00000020
273#define ECRYPTFS_GLOBAL_ENCFN_USE_FEK 0x00000040
f16feb51 274#define ECRYPTFS_GLOBAL_MOUNT_AUTH_TOK_ONLY 0x00000080
237fead6 275 u32 flags;
f4aad16a
MH
276 struct list_head global_auth_tok_list;
277 struct mutex global_auth_tok_list_mutex;
237fead6 278 size_t global_default_cipher_key_size;
9c79f34f 279 size_t global_default_fn_cipher_key_bytes;
237fead6
MH
280 unsigned char global_default_cipher_name[ECRYPTFS_MAX_CIPHER_NAME_SIZE
281 + 1];
9c79f34f
MH
282 unsigned char global_default_fn_cipher_name[
283 ECRYPTFS_MAX_CIPHER_NAME_SIZE + 1];
284 char global_default_fnek_sig[ECRYPTFS_SIG_SIZE_HEX + 1];
237fead6
MH
285};
286
287/* superblock private data. */
288struct ecryptfs_sb_info {
289 struct super_block *wsi_sb;
290 struct ecryptfs_mount_crypt_stat mount_crypt_stat;
9df9c8b9 291 struct backing_dev_info bdi;
237fead6
MH
292};
293
294/* file private data. */
295struct ecryptfs_file_info {
296 struct file *wfi_file;
297 struct ecryptfs_crypt_stat *crypt_stat;
298};
299
300/* auth_tok <=> encrypted_session_key mappings */
301struct ecryptfs_auth_tok_list_item {
302 unsigned char encrypted_session_key[ECRYPTFS_MAX_KEY_BYTES];
303 struct list_head list;
304 struct ecryptfs_auth_tok auth_tok;
305};
306
88b4a07e 307struct ecryptfs_message {
f66e883e
MH
308 /* Can never be greater than ecryptfs_message_buf_len */
309 /* Used to find the parent msg_ctx */
310 /* Inherits from msg_ctx->index */
88b4a07e
MH
311 u32 index;
312 u32 data_len;
313 u8 data[];
314};
315
316struct ecryptfs_msg_ctx {
f66e883e
MH
317#define ECRYPTFS_MSG_CTX_STATE_FREE 0x01
318#define ECRYPTFS_MSG_CTX_STATE_PENDING 0x02
319#define ECRYPTFS_MSG_CTX_STATE_DONE 0x03
320#define ECRYPTFS_MSG_CTX_STATE_NO_REPLY 0x04
321 u8 state;
322#define ECRYPTFS_MSG_HELO 100
323#define ECRYPTFS_MSG_QUIT 101
324#define ECRYPTFS_MSG_REQUEST 102
325#define ECRYPTFS_MSG_RESPONSE 103
326 u8 type;
327 u32 index;
328 /* Counter converts to a sequence number. Each message sent
329 * out for which we expect a response has an associated
330 * sequence number. The response must have the same sequence
331 * number as the counter for the msg_stc for the message to be
332 * valid. */
333 u32 counter;
334 size_t msg_size;
88b4a07e
MH
335 struct ecryptfs_message *msg;
336 struct task_struct *task;
337 struct list_head node;
f66e883e 338 struct list_head daemon_out_list;
88b4a07e
MH
339 struct mutex mux;
340};
341
f66e883e
MH
342struct ecryptfs_daemon;
343
344struct ecryptfs_daemon {
345#define ECRYPTFS_DAEMON_IN_READ 0x00000001
346#define ECRYPTFS_DAEMON_IN_POLL 0x00000002
347#define ECRYPTFS_DAEMON_ZOMBIE 0x00000004
348#define ECRYPTFS_DAEMON_MISCDEV_OPEN 0x00000008
349 u32 flags;
350 u32 num_queued_msg_ctx;
6a3fd92e 351 struct pid *pid;
f66e883e 352 uid_t euid;
6a3fd92e 353 struct user_namespace *user_ns;
f66e883e
MH
354 struct task_struct *task;
355 struct mutex mux;
356 struct list_head msg_ctx_out_queue;
357 wait_queue_head_t wait;
358 struct hlist_node euid_chain;
88b4a07e
MH
359};
360
f66e883e
MH
361extern struct mutex ecryptfs_daemon_hash_mux;
362
157f1071
TH
363static inline size_t
364ecryptfs_lower_header_size(struct ecryptfs_crypt_stat *crypt_stat)
365{
366 if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR)
367 return 0;
fa3ef1cb 368 return crypt_stat->metadata_size;
157f1071
TH
369}
370
237fead6
MH
371static inline struct ecryptfs_file_info *
372ecryptfs_file_to_private(struct file *file)
373{
0c6d7d5d 374 return file->private_data;
237fead6
MH
375}
376
377static inline void
378ecryptfs_set_file_private(struct file *file,
379 struct ecryptfs_file_info *file_info)
380{
381 file->private_data = file_info;
382}
383
384static inline struct file *ecryptfs_file_to_lower(struct file *file)
385{
386 return ((struct ecryptfs_file_info *)file->private_data)->wfi_file;
387}
388
389static inline void
390ecryptfs_set_file_lower(struct file *file, struct file *lower_file)
391{
392 ((struct ecryptfs_file_info *)file->private_data)->wfi_file =
393 lower_file;
394}
395
396static inline struct ecryptfs_inode_info *
397ecryptfs_inode_to_private(struct inode *inode)
398{
399 return container_of(inode, struct ecryptfs_inode_info, vfs_inode);
400}
401
402static inline struct inode *ecryptfs_inode_to_lower(struct inode *inode)
403{
404 return ecryptfs_inode_to_private(inode)->wii_inode;
405}
406
407static inline void
408ecryptfs_set_inode_lower(struct inode *inode, struct inode *lower_inode)
409{
410 ecryptfs_inode_to_private(inode)->wii_inode = lower_inode;
411}
412
413static inline struct ecryptfs_sb_info *
414ecryptfs_superblock_to_private(struct super_block *sb)
415{
416 return (struct ecryptfs_sb_info *)sb->s_fs_info;
417}
418
419static inline void
420ecryptfs_set_superblock_private(struct super_block *sb,
421 struct ecryptfs_sb_info *sb_info)
422{
423 sb->s_fs_info = sb_info;
424}
425
426static inline struct super_block *
427ecryptfs_superblock_to_lower(struct super_block *sb)
428{
429 return ((struct ecryptfs_sb_info *)sb->s_fs_info)->wsi_sb;
430}
431
432static inline void
433ecryptfs_set_superblock_lower(struct super_block *sb,
434 struct super_block *lower_sb)
435{
436 ((struct ecryptfs_sb_info *)sb->s_fs_info)->wsi_sb = lower_sb;
437}
438
439static inline struct ecryptfs_dentry_info *
440ecryptfs_dentry_to_private(struct dentry *dentry)
441{
442 return (struct ecryptfs_dentry_info *)dentry->d_fsdata;
443}
444
445static inline void
446ecryptfs_set_dentry_private(struct dentry *dentry,
447 struct ecryptfs_dentry_info *dentry_info)
448{
449 dentry->d_fsdata = dentry_info;
450}
451
452static inline struct dentry *
453ecryptfs_dentry_to_lower(struct dentry *dentry)
454{
b65d34fd 455 return ((struct ecryptfs_dentry_info *)dentry->d_fsdata)->lower_path.dentry;
237fead6
MH
456}
457
458static inline void
459ecryptfs_set_dentry_lower(struct dentry *dentry, struct dentry *lower_dentry)
460{
b65d34fd 461 ((struct ecryptfs_dentry_info *)dentry->d_fsdata)->lower_path.dentry =
237fead6
MH
462 lower_dentry;
463}
464
465static inline struct vfsmount *
466ecryptfs_dentry_to_lower_mnt(struct dentry *dentry)
467{
b65d34fd 468 return ((struct ecryptfs_dentry_info *)dentry->d_fsdata)->lower_path.mnt;
237fead6
MH
469}
470
471static inline void
472ecryptfs_set_dentry_lower_mnt(struct dentry *dentry, struct vfsmount *lower_mnt)
473{
b65d34fd 474 ((struct ecryptfs_dentry_info *)dentry->d_fsdata)->lower_path.mnt =
237fead6
MH
475 lower_mnt;
476}
477
478#define ecryptfs_printk(type, fmt, arg...) \
18d1dbf1 479 __ecryptfs_printk(type "%s: " fmt, __func__, ## arg);
888d57bb 480__attribute__ ((format(printf, 1, 2)))
237fead6
MH
481void __ecryptfs_printk(const char *fmt, ...);
482
483extern const struct file_operations ecryptfs_main_fops;
484extern const struct file_operations ecryptfs_dir_fops;
754661f1
AV
485extern const struct inode_operations ecryptfs_main_iops;
486extern const struct inode_operations ecryptfs_dir_iops;
487extern const struct inode_operations ecryptfs_symlink_iops;
ee9b6d61 488extern const struct super_operations ecryptfs_sops;
5a3fd05a 489extern const struct dentry_operations ecryptfs_dops;
7f09410b 490extern const struct address_space_operations ecryptfs_aops;
237fead6 491extern int ecryptfs_verbosity;
88b4a07e
MH
492extern unsigned int ecryptfs_message_buf_len;
493extern signed long ecryptfs_message_wait_timeout;
494extern unsigned int ecryptfs_number_of_users;
237fead6
MH
495
496extern struct kmem_cache *ecryptfs_auth_tok_list_item_cache;
497extern struct kmem_cache *ecryptfs_file_info_cache;
498extern struct kmem_cache *ecryptfs_dentry_info_cache;
499extern struct kmem_cache *ecryptfs_inode_info_cache;
500extern struct kmem_cache *ecryptfs_sb_info_cache;
30632870 501extern struct kmem_cache *ecryptfs_header_cache;
dd2a3b7a 502extern struct kmem_cache *ecryptfs_xattr_cache;
eb95e7ff 503extern struct kmem_cache *ecryptfs_key_record_cache;
f4aad16a
MH
504extern struct kmem_cache *ecryptfs_key_sig_cache;
505extern struct kmem_cache *ecryptfs_global_auth_tok_cache;
506extern struct kmem_cache *ecryptfs_key_tfm_cache;
746f1e55
MH
507extern struct kmem_cache *ecryptfs_open_req_cache;
508
509struct ecryptfs_open_req {
510#define ECRYPTFS_REQ_PROCESSED 0x00000001
511#define ECRYPTFS_REQ_DROPPED 0x00000002
512#define ECRYPTFS_REQ_ZOMBIE 0x00000004
513 u32 flags;
514 struct file **lower_file;
515 struct dentry *lower_dentry;
516 struct vfsmount *lower_mnt;
517 wait_queue_head_t wait;
518 struct mutex mux;
519 struct list_head kthread_ctl_list;
520};
237fead6 521
c4f79073
TH
522struct inode *ecryptfs_get_inode(struct inode *lower_inode,
523 struct super_block *sb);
3aeb86ea 524void ecryptfs_i_size_init(const char *page_virt, struct inode *inode);
a34f60f7
MH
525int ecryptfs_decode_and_decrypt_filename(char **decrypted_name,
526 size_t *decrypted_name_size,
527 struct dentry *ecryptfs_dentry,
528 const char *name, size_t name_size);
237fead6 529int ecryptfs_fill_zeros(struct file *file, loff_t new_length);
a34f60f7
MH
530int ecryptfs_encrypt_and_encode_filename(
531 char **encoded_name,
532 size_t *encoded_name_size,
533 struct ecryptfs_crypt_stat *crypt_stat,
534 struct ecryptfs_mount_crypt_stat *mount_crypt_stat,
535 const char *name, size_t name_size);
237fead6 536struct dentry *ecryptfs_lower_dentry(struct dentry *this_dentry);
237fead6
MH
537void ecryptfs_dump_hex(char *data, int bytes);
538int virt_to_scatterlist(const void *addr, int size, struct scatterlist *sg,
539 int sg_size);
540int ecryptfs_compute_root_iv(struct ecryptfs_crypt_stat *crypt_stat);
541void ecryptfs_rotate_iv(unsigned char *iv);
542void ecryptfs_init_crypt_stat(struct ecryptfs_crypt_stat *crypt_stat);
fcd12835
MH
543void ecryptfs_destroy_crypt_stat(struct ecryptfs_crypt_stat *crypt_stat);
544void ecryptfs_destroy_mount_crypt_stat(
237fead6
MH
545 struct ecryptfs_mount_crypt_stat *mount_crypt_stat);
546int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat);
b6c1d8fc 547int ecryptfs_write_inode_size_to_metadata(struct inode *ecryptfs_inode);
0216f7f7
MH
548int ecryptfs_encrypt_page(struct page *page);
549int ecryptfs_decrypt_page(struct page *page);
d7cdc5fe
MH
550int ecryptfs_write_metadata(struct dentry *ecryptfs_dentry);
551int ecryptfs_read_metadata(struct dentry *ecryptfs_dentry);
237fead6 552int ecryptfs_new_file_context(struct dentry *ecryptfs_dentry);
f4e60e6b
TH
553void ecryptfs_write_crypt_stat_flags(char *page_virt,
554 struct ecryptfs_crypt_stat *crypt_stat,
555 size_t *written);
778aeb42
TH
556int ecryptfs_read_and_validate_header_region(struct inode *inode);
557int ecryptfs_read_and_validate_xattr_region(struct dentry *dentry,
3b06b3eb 558 struct inode *inode);
9c79f34f 559u8 ecryptfs_code_for_cipher_string(char *cipher_name, size_t key_bytes);
19e66a67 560int ecryptfs_cipher_code_to_string(char *str, u8 cipher_code);
237fead6
MH
561void ecryptfs_set_default_sizes(struct ecryptfs_crypt_stat *crypt_stat);
562int ecryptfs_generate_key_packet_set(char *dest_base,
563 struct ecryptfs_crypt_stat *crypt_stat,
564 struct dentry *ecryptfs_dentry,
565 size_t *len, size_t max);
237fead6
MH
566int
567ecryptfs_parse_packet_set(struct ecryptfs_crypt_stat *crypt_stat,
568 unsigned char *src, struct dentry *ecryptfs_dentry);
569int ecryptfs_truncate(struct dentry *dentry, loff_t new_length);
d7cdc5fe
MH
570ssize_t
571ecryptfs_getxattr_lower(struct dentry *lower_dentry, const char *name,
572 void *value, size_t size);
dd2a3b7a
MH
573int
574ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value,
575 size_t size, int flags);
d7cdc5fe 576int ecryptfs_read_xattr_region(char *page_virt, struct inode *ecryptfs_inode);
624ae528
TH
577int ecryptfs_process_helo(uid_t euid, struct user_namespace *user_ns,
578 struct pid *pid);
6a3fd92e
MH
579int ecryptfs_process_quit(uid_t euid, struct user_namespace *user_ns,
580 struct pid *pid);
581int ecryptfs_process_response(struct ecryptfs_message *msg, uid_t euid,
582 struct user_namespace *user_ns, struct pid *pid,
583 u32 seq);
624ae528 584int ecryptfs_send_message(char *data, int data_len,
88b4a07e
MH
585 struct ecryptfs_msg_ctx **msg_ctx);
586int ecryptfs_wait_for_response(struct ecryptfs_msg_ctx *msg_ctx,
587 struct ecryptfs_message **emsg);
624ae528
TH
588int ecryptfs_init_messaging(void);
589void ecryptfs_release_messaging(void);
590
e77a56dd
MH
591void
592ecryptfs_write_header_metadata(char *virt,
593 struct ecryptfs_crypt_stat *crypt_stat,
594 size_t *written);
f4aad16a
MH
595int ecryptfs_add_keysig(struct ecryptfs_crypt_stat *crypt_stat, char *sig);
596int
597ecryptfs_add_global_auth_tok(struct ecryptfs_mount_crypt_stat *mount_crypt_stat,
84814d64 598 char *sig, u32 global_auth_tok_flags);
f4aad16a
MH
599int ecryptfs_get_global_auth_tok_for_sig(
600 struct ecryptfs_global_auth_tok **global_auth_tok,
601 struct ecryptfs_mount_crypt_stat *mount_crypt_stat, char *sig);
602int
603ecryptfs_add_new_key_tfm(struct ecryptfs_key_tfm **key_tfm, char *cipher_name,
604 size_t key_size);
605int ecryptfs_init_crypto(void);
fcd12835 606int ecryptfs_destroy_crypto(void);
af440f52 607int ecryptfs_tfm_exists(char *cipher_name, struct ecryptfs_key_tfm **key_tfm);
f4aad16a
MH
608int ecryptfs_get_tfm_and_mutex_for_cipher_name(struct crypto_blkcipher **tfm,
609 struct mutex **tfm_mutex,
610 char *cipher_name);
611int ecryptfs_keyring_auth_tok_for_sig(struct key **auth_tok_key,
612 struct ecryptfs_auth_tok **auth_tok,
613 char *sig);
da0102a1
MH
614int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data,
615 loff_t offset, size_t size);
616int ecryptfs_write_lower_page_segment(struct inode *ecryptfs_inode,
617 struct page *page_for_lower,
618 size_t offset_in_page, size_t size);
48c1e44a 619int ecryptfs_write(struct inode *inode, char *data, loff_t offset, size_t size);
da0102a1
MH
620int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
621 struct inode *ecryptfs_inode);
622int ecryptfs_read_lower_page_segment(struct page *page_for_ecryptfs,
623 pgoff_t page_index,
624 size_t offset_in_page, size_t size,
625 struct inode *ecryptfs_inode);
02bd9799 626struct page *ecryptfs_get_locked_page(struct inode *inode, loff_t index);
f66e883e 627int ecryptfs_exorcise_daemon(struct ecryptfs_daemon *daemon);
6a3fd92e
MH
628int ecryptfs_find_daemon_by_euid(struct ecryptfs_daemon **daemon, uid_t euid,
629 struct user_namespace *user_ns);
f66e883e
MH
630int ecryptfs_parse_packet_length(unsigned char *data, size_t *size,
631 size_t *length_size);
632int ecryptfs_write_packet_length(char *dest, size_t size,
633 size_t *packet_size_length);
634int ecryptfs_init_ecryptfs_miscdev(void);
635void ecryptfs_destroy_ecryptfs_miscdev(void);
636int ecryptfs_send_miscdev(char *data, size_t data_size,
637 struct ecryptfs_msg_ctx *msg_ctx, u8 msg_type,
638 u16 msg_flags, struct ecryptfs_daemon *daemon);
639void ecryptfs_msg_ctx_alloc_to_free(struct ecryptfs_msg_ctx *msg_ctx);
640int
6a3fd92e
MH
641ecryptfs_spawn_daemon(struct ecryptfs_daemon **daemon, uid_t euid,
642 struct user_namespace *user_ns, struct pid *pid);
746f1e55
MH
643int ecryptfs_init_kthread(void);
644void ecryptfs_destroy_kthread(void);
645int ecryptfs_privileged_open(struct file **lower_file,
646 struct dentry *lower_dentry,
745ca247
DH
647 struct vfsmount *lower_mnt,
648 const struct cred *cred);
3b06b3eb 649int ecryptfs_get_lower_file(struct dentry *dentry, struct inode *inode);
332ab16f 650void ecryptfs_put_lower_file(struct inode *inode);
9c79f34f
MH
651int
652ecryptfs_write_tag_70_packet(char *dest, size_t *remaining_bytes,
653 size_t *packet_size,
654 struct ecryptfs_mount_crypt_stat *mount_crypt_stat,
655 char *filename, size_t filename_size);
656int
657ecryptfs_parse_tag_70_packet(char **filename, size_t *filename_size,
658 size_t *packet_size,
659 struct ecryptfs_mount_crypt_stat *mount_crypt_stat,
660 char *data, size_t max_packet_size);
a34f60f7
MH
661int ecryptfs_derive_iv(char *iv, struct ecryptfs_crypt_stat *crypt_stat,
662 loff_t offset);
88b4a07e 663
237fead6 664#endif /* #ifndef ECRYPTFS_KERNEL_H */
This page took 0.405107 seconds and 5 git commands to generate.