Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux...
[deliverable/linux.git] / security / keys / encrypted-keys / encrypted.h
CommitLineData
7e70cb49
MZ
1#ifndef __ENCRYPTED_KEY_H
2#define __ENCRYPTED_KEY_H
3
4#define ENCRYPTED_DEBUG 0
9c698987
MZ
5#if defined(CONFIG_TRUSTED_KEYS) || \
6 (defined(CONFIG_TRUSTED_KEYS_MODULE) && defined(CONFIG_ENCRYPTED_KEYS_MODULE))
982e617a 7extern struct key *request_trusted_key(const char *trusted_desc,
146aa8b1 8 const u8 **master_key, size_t *master_keylen);
982e617a
MZ
9#else
10static inline struct key *request_trusted_key(const char *trusted_desc,
146aa8b1 11 const u8 **master_key,
982e617a
MZ
12 size_t *master_keylen)
13{
14 return ERR_PTR(-EOPNOTSUPP);
15}
16#endif
7e70cb49
MZ
17
18#if ENCRYPTED_DEBUG
3b1826ce 19static inline void dump_master_key(const u8 *master_key, size_t master_keylen)
7e70cb49
MZ
20{
21 print_hex_dump(KERN_ERR, "master key: ", DUMP_PREFIX_NONE, 32, 1,
22 master_key, master_keylen, 0);
23}
24
25static inline void dump_decrypted_data(struct encrypted_key_payload *epayload)
26{
27 print_hex_dump(KERN_ERR, "decrypted data: ", DUMP_PREFIX_NONE, 32, 1,
28 epayload->decrypted_data,
29 epayload->decrypted_datalen, 0);
30}
31
32static inline void dump_encrypted_data(struct encrypted_key_payload *epayload,
33 unsigned int encrypted_datalen)
34{
35 print_hex_dump(KERN_ERR, "encrypted data: ", DUMP_PREFIX_NONE, 32, 1,
36 epayload->encrypted_data, encrypted_datalen, 0);
37}
38
39static inline void dump_hmac(const char *str, const u8 *digest,
40 unsigned int hmac_size)
41{
42 if (str)
43 pr_info("encrypted_key: %s", str);
44 print_hex_dump(KERN_ERR, "hmac: ", DUMP_PREFIX_NONE, 32, 1, digest,
45 hmac_size, 0);
46}
47#else
3b1826ce 48static inline void dump_master_key(const u8 *master_key, size_t master_keylen)
7e70cb49
MZ
49{
50}
51
52static inline void dump_decrypted_data(struct encrypted_key_payload *epayload)
53{
54}
55
56static inline void dump_encrypted_data(struct encrypted_key_payload *epayload,
57 unsigned int encrypted_datalen)
58{
59}
60
61static inline void dump_hmac(const char *str, const u8 *digest,
62 unsigned int hmac_size)
63{
64}
65#endif
66#endif
This page took 0.298813 seconds and 5 git commands to generate.