Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1#ifndef __ENCRYPTED_KEY_H
2#define __ENCRYPTED_KEY_H
3
4#define ENCRYPTED_DEBUG 0
5#ifdef CONFIG_TRUSTED_KEYS
6extern struct key *request_trusted_key(const char *trusted_desc,
7 u8 **master_key, size_t *master_keylen);
8#else
9static inline struct key *request_trusted_key(const char *trusted_desc,
10 u8 **master_key,
11 size_t *master_keylen)
12{
13 return ERR_PTR(-EOPNOTSUPP);
14}
15#endif
16
17#if ENCRYPTED_DEBUG
18static inline void dump_master_key(const u8 *master_key, size_t master_keylen)
19{
20 print_hex_dump(KERN_ERR, "master key: ", DUMP_PREFIX_NONE, 32, 1,
21 master_key, master_keylen, 0);
22}
23
24static inline void dump_decrypted_data(struct encrypted_key_payload *epayload)
25{
26 print_hex_dump(KERN_ERR, "decrypted data: ", DUMP_PREFIX_NONE, 32, 1,
27 epayload->decrypted_data,
28 epayload->decrypted_datalen, 0);
29}
30
31static inline void dump_encrypted_data(struct encrypted_key_payload *epayload,
32 unsigned int encrypted_datalen)
33{
34 print_hex_dump(KERN_ERR, "encrypted data: ", DUMP_PREFIX_NONE, 32, 1,
35 epayload->encrypted_data, encrypted_datalen, 0);
36}
37
38static inline void dump_hmac(const char *str, const u8 *digest,
39 unsigned int hmac_size)
40{
41 if (str)
42 pr_info("encrypted_key: %s", str);
43 print_hex_dump(KERN_ERR, "hmac: ", DUMP_PREFIX_NONE, 32, 1, digest,
44 hmac_size, 0);
45}
46#else
47static inline void dump_master_key(const u8 *master_key, size_t master_keylen)
48{
49}
50
51static inline void dump_decrypted_data(struct encrypted_key_payload *epayload)
52{
53}
54
55static inline void dump_encrypted_data(struct encrypted_key_payload *epayload,
56 unsigned int encrypted_datalen)
57{
58}
59
60static inline void dump_hmac(const char *str, const u8 *digest,
61 unsigned int hmac_size)
62{
63}
64#endif
65#endif