aboutsummaryrefslogtreecommitdiffstats
path: root/security/keys/encrypted_defined.h
diff options
context:
space:
mode:
authorMimi Zohar <zohar@linux.vnet.ibm.com>2010-11-23 18:55:35 -0500
committerJames Morris <jmorris@namei.org>2010-11-28 16:55:29 -0500
commit7e70cb4978507cf31d76b90e4cfb4c28cad87f0c (patch)
treec5df493eef8d30dcb40d647b0528970eb4a391c6 /security/keys/encrypted_defined.h
parentd00a1c72f7f4661212299e6cb132dfa58030bcdb (diff)
keys: add new key-type encrypted
Define a new kernel key-type called 'encrypted'. Encrypted keys are kernel generated random numbers, which are encrypted/decrypted with a 'trusted' symmetric key. Encrypted keys are created/encrypted/decrypted in the kernel. Userspace only ever sees/stores encrypted blobs. Changelog: - bug fix: replaced master-key rcu based locking with semaphore (reported by David Howells) - Removed memset of crypto_shash_digest() digest output - Replaced verification of 'key-type:key-desc' using strcspn(), with one based on string constants. - Moved documentation to Documentation/keys-trusted-encrypted.txt - Replace hash with shash (based on comments by David Howells) - Make lengths/counts size_t where possible (based on comments by David Howells) Could not convert most lengths, as crypto expects 'unsigned int' (size_t: on 32 bit is defined as unsigned int, but on 64 bit is unsigned long) - Add 'const' where possible (based on comments by David Howells) - allocate derived_buf dynamically to support arbitrary length master key (fixed by Roberto Sassu) - wait until late_initcall for crypto libraries to be registered - cleanup security/Kconfig - Add missing 'update' keyword (reported/fixed by Roberto Sassu) - Free epayload on failure to create key (reported/fixed by Roberto Sassu) - Increase the data size limit (requested by Roberto Sassu) - Crypto return codes are always 0 on success and negative on failure, remove unnecessary tests. - Replaced kzalloc() with kmalloc() Signed-off-by: Mimi Zohar <zohar@us.ibm.com> Signed-off-by: David Safford <safford@watson.ibm.com> Reviewed-by: Roberto Sassu <roberto.sassu@polito.it> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security/keys/encrypted_defined.h')
-rw-r--r--security/keys/encrypted_defined.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/security/keys/encrypted_defined.h b/security/keys/encrypted_defined.h
new file mode 100644
index 000000000000..c298a3f1cf70
--- /dev/null
+++ b/security/keys/encrypted_defined.h
@@ -0,0 +1,56 @@
1#ifndef __ENCRYPTED_KEY_H
2#define __ENCRYPTED_KEY_H
3
4#define ENCRYPTED_DEBUG 0
5
6#if ENCRYPTED_DEBUG
7static inline void dump_master_key(const u8 *master_key,
8 unsigned int master_keylen)
9{
10 print_hex_dump(KERN_ERR, "master key: ", DUMP_PREFIX_NONE, 32, 1,
11 master_key, master_keylen, 0);
12}
13
14static inline void dump_decrypted_data(struct encrypted_key_payload *epayload)
15{
16 print_hex_dump(KERN_ERR, "decrypted data: ", DUMP_PREFIX_NONE, 32, 1,
17 epayload->decrypted_data,
18 epayload->decrypted_datalen, 0);
19}
20
21static inline void dump_encrypted_data(struct encrypted_key_payload *epayload,
22 unsigned int encrypted_datalen)
23{
24 print_hex_dump(KERN_ERR, "encrypted data: ", DUMP_PREFIX_NONE, 32, 1,
25 epayload->encrypted_data, encrypted_datalen, 0);
26}
27
28static inline void dump_hmac(const char *str, const u8 *digest,
29 unsigned int hmac_size)
30{
31 if (str)
32 pr_info("encrypted_key: %s", str);
33 print_hex_dump(KERN_ERR, "hmac: ", DUMP_PREFIX_NONE, 32, 1, digest,
34 hmac_size, 0);
35}
36#else
37static inline void dump_master_key(const u8 *master_key,
38 unsigned int master_keylen)
39{
40}
41
42static inline void dump_decrypted_data(struct encrypted_key_payload *epayload)
43{
44}
45
46static inline void dump_encrypted_data(struct encrypted_key_payload *epayload,
47 unsigned int encrypted_datalen)
48{
49}
50
51static inline void dump_hmac(const char *str, const u8 *digest,
52 unsigned int hmac_size)
53{
54}
55#endif
56#endif