|
@@ -29,6 +29,7 @@
|
|
|
#define ECRYPTFS_KERNEL_H
|
|
|
|
|
|
#include <keys/user-type.h>
|
|
|
+#include <keys/encrypted-type.h>
|
|
|
#include <linux/fs.h>
|
|
|
#include <linux/fs_stack.h>
|
|
|
#include <linux/namei.h>
|
|
@@ -78,11 +79,47 @@ struct ecryptfs_page_crypt_context {
|
|
|
} param;
|
|
|
};
|
|
|
|
|
|
+#if defined(CONFIG_ENCRYPTED_KEYS) || defined(CONFIG_ENCRYPTED_KEYS_MODULE)
|
|
|
+static inline struct ecryptfs_auth_tok *
|
|
|
+ecryptfs_get_encrypted_key_payload_data(struct key *key)
|
|
|
+{
|
|
|
+ if (key->type == &key_type_encrypted)
|
|
|
+ return (struct ecryptfs_auth_tok *)
|
|
|
+ (&((struct encrypted_key_payload *)key->payload.data)->payload_data);
|
|
|
+ else
|
|
|
+ return NULL;
|
|
|
+}
|
|
|
+
|
|
|
+static inline struct key *ecryptfs_get_encrypted_key(char *sig)
|
|
|
+{
|
|
|
+ return request_key(&key_type_encrypted, sig, NULL);
|
|
|
+}
|
|
|
+
|
|
|
+#else
|
|
|
+static inline struct ecryptfs_auth_tok *
|
|
|
+ecryptfs_get_encrypted_key_payload_data(struct key *key)
|
|
|
+{
|
|
|
+ return NULL;
|
|
|
+}
|
|
|
+
|
|
|
+static inline struct key *ecryptfs_get_encrypted_key(char *sig)
|
|
|
+{
|
|
|
+ return ERR_PTR(-ENOKEY);
|
|
|
+}
|
|
|
+
|
|
|
+#endif /* CONFIG_ENCRYPTED_KEYS */
|
|
|
+
|
|
|
static inline struct ecryptfs_auth_tok *
|
|
|
ecryptfs_get_key_payload_data(struct key *key)
|
|
|
{
|
|
|
- return (struct ecryptfs_auth_tok *)
|
|
|
- (((struct user_key_payload*)key->payload.data)->data);
|
|
|
+ struct ecryptfs_auth_tok *auth_tok;
|
|
|
+
|
|
|
+ auth_tok = ecryptfs_get_encrypted_key_payload_data(key);
|
|
|
+ if (!auth_tok)
|
|
|
+ return (struct ecryptfs_auth_tok *)
|
|
|
+ (((struct user_key_payload *)key->payload.data)->data);
|
|
|
+ else
|
|
|
+ return auth_tok;
|
|
|
}
|
|
|
|
|
|
#define ECRYPTFS_MAX_KEYSET_SIZE 1024
|