aboutsummaryrefslogtreecommitdiff
path: root/security/keys/encrypted-keys/encrypted.h
blob: b6ade8945250c0b3f13913c56ee5b9686a3f39d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef __ENCRYPTED_KEY_H
#define __ENCRYPTED_KEY_H

#define ENCRYPTED_DEBUG 0
#ifdef CONFIG_TRUSTED_KEYS
extern struct key *request_trusted_key(const char *trusted_desc,
				       u8 **master_key, size_t *master_keylen);
#else
static inline struct key *request_trusted_key(const char *trusted_desc,
					      u8 **master_key,
					      size_t *master_keylen)
{
	return ERR_PTR(-EOPNOTSUPP);
}
#endif

#if ENCRYPTED_DEBUG
static inline void dump_master_key(const u8 *master_key, size_t master_keylen)
{
	print_hex_dump(KERN_ERR, "master key: ", DUMP_PREFIX_NONE, 32, 1,
		       master_key, master_keylen, 0);
}

static inline void dump_decrypted_data(struct encrypted_key_payload *epayload)
{
	print_hex_dump(KERN_ERR, "decrypted data: ", DUMP_PREFIX_NONE, 32, 1,
		       epayload->decrypted_data,
		       epayload->decrypted_datalen, 0);
}

static inline void dump_encrypted_data(struct encrypted_key_payload *epayload,
				       unsigned int encrypted_datalen)
{
	print_hex_dump(KERN_ERR, "encrypted data: ", DUMP_PREFIX_NONE, 32, 1,
		       epayload->encrypted_data, encrypted_datalen, 0);
}

static inline void dump_hmac(const char *str, const u8 *digest,
			     unsigned int hmac_size)
{
	if (str)
		pr_info("encrypted_key: %s", str);
	print_hex_dump(KERN_ERR, "hmac: ", DUMP_PREFIX_NONE, 32, 1, digest,
		       hmac_size, 0);
}
#else
static inline void dump_master_key(const u8 *master_key, size_t master_keylen)
{
}

static inline void dump_decrypted_data(struct encrypted_key_payload *epayload)
{
}

static inline void dump_encrypted_data(struct encrypted_key_payload *epayload,
				       unsigned int encrypted_datalen)
{
}

static inline void dump_hmac(const char *str, const u8 *digest,
			     unsigned int hmac_size)
{
}
#endif
#endif