|
29 | 29 | #define ECRYPTFS_KERNEL_H
|
30 | 30 |
|
31 | 31 | #include <keys/user-type.h>
|
| 32 | +#include <keys/encrypted-type.h> |
32 | 33 | #include <linux/fs.h>
|
33 | 34 | #include <linux/fs_stack.h>
|
34 | 35 | #include <linux/namei.h>
|
@@ -78,11 +79,47 @@ struct ecryptfs_page_crypt_context {
|
78 | 79 | } param;
|
79 | 80 | };
|
80 | 81 |
|
| 82 | +#if defined(CONFIG_ENCRYPTED_KEYS) || defined(CONFIG_ENCRYPTED_KEYS_MODULE) |
| 83 | +static inline struct ecryptfs_auth_tok * |
| 84 | +ecryptfs_get_encrypted_key_payload_data(struct key *key) |
| 85 | +{ |
| 86 | + if (key->type == &key_type_encrypted) |
| 87 | + return (struct ecryptfs_auth_tok *) |
| 88 | + (&((struct encrypted_key_payload *)key->payload.data)->payload_data); |
| 89 | + else |
| 90 | + return NULL; |
| 91 | +} |
| 92 | + |
| 93 | +static inline struct key *ecryptfs_get_encrypted_key(char *sig) |
| 94 | +{ |
| 95 | + return request_key(&key_type_encrypted, sig, NULL); |
| 96 | +} |
| 97 | + |
| 98 | +#else |
| 99 | +static inline struct ecryptfs_auth_tok * |
| 100 | +ecryptfs_get_encrypted_key_payload_data(struct key *key) |
| 101 | +{ |
| 102 | + return NULL; |
| 103 | +} |
| 104 | + |
| 105 | +static inline struct key *ecryptfs_get_encrypted_key(char *sig) |
| 106 | +{ |
| 107 | + return ERR_PTR(-ENOKEY); |
| 108 | +} |
| 109 | + |
| 110 | +#endif /* CONFIG_ENCRYPTED_KEYS */ |
| 111 | + |
81 | 112 | static inline struct ecryptfs_auth_tok *
|
82 | 113 | ecryptfs_get_key_payload_data(struct key *key)
|
83 | 114 | {
|
84 |
| - return (struct ecryptfs_auth_tok *) |
85 |
| - (((struct user_key_payload*)key->payload.data)->data); |
| 115 | + struct ecryptfs_auth_tok *auth_tok; |
| 116 | + |
| 117 | + auth_tok = ecryptfs_get_encrypted_key_payload_data(key); |
| 118 | + if (!auth_tok) |
| 119 | + return (struct ecryptfs_auth_tok *) |
| 120 | + (((struct user_key_payload *)key->payload.data)->data); |
| 121 | + else |
| 122 | + return auth_tok; |
86 | 123 | }
|
87 | 124 |
|
88 | 125 | #define ECRYPTFS_MAX_KEYSET_SIZE 1024
|
|
0 commit comments