diff options
| author | Roberto Sassu <roberto.sassu@polito.it> | 2011-06-27 07:45:42 -0400 |
|---|---|---|
| committer | Mimi Zohar <zohar@linux.vnet.ibm.com> | 2011-06-27 09:10:45 -0400 |
| commit | 4e561d388feff18e4b798cef6a1a84a2cc7f20c2 (patch) | |
| tree | 9208588c7d0e5e75766dd2c98e960840fdc8681e | |
| parent | 7103dff0e598cd634767f17a2958302c515700ca (diff) | |
encrypted-keys: add key format support
This patch introduces a new parameter, called 'format', that defines the
format of data stored by encrypted keys. The 'default' format identifies
encrypted keys containing only the symmetric key, while other formats can
be defined to support additional information. The 'format' parameter is
written in the datablob produced by commands 'keyctl print' or
'keyctl pipe' and is integrity protected by the HMAC.
Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
Acked-by: Gianluca Ramunno <ramunno@polito.it>
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
| -rw-r--r-- | Documentation/security/keys-trusted-encrypted.txt | 48 | ||||
| -rw-r--r-- | include/keys/encrypted-type.h | 13 | ||||
| -rw-r--r-- | security/keys/encrypted.c | 141 |
3 files changed, 142 insertions, 60 deletions
diff --git a/Documentation/security/keys-trusted-encrypted.txt b/Documentation/security/keys-trusted-encrypted.txt index 8fb79bc1ac4b..0afcb5023c75 100644 --- a/Documentation/security/keys-trusted-encrypted.txt +++ b/Documentation/security/keys-trusted-encrypted.txt | |||
| @@ -53,12 +53,19 @@ they are only as secure as the user key encrypting them. The master user key | |||
| 53 | should therefore be loaded in as secure a way as possible, preferably early in | 53 | should therefore be loaded in as secure a way as possible, preferably early in |
| 54 | boot. | 54 | boot. |
| 55 | 55 | ||
| 56 | The decrypted portion of encrypted keys can contain either a simple symmetric | ||
| 57 | key or a more complex structure. The format of the more complex structure is | ||
| 58 | application specific, which is identified by 'format'. | ||
| 59 | |||
| 56 | Usage: | 60 | Usage: |
| 57 | keyctl add encrypted name "new key-type:master-key-name keylen" ring | 61 | keyctl add encrypted name "new [format] key-type:master-key-name keylen" |
| 58 | keyctl add encrypted name "load hex_blob" ring | 62 | ring |
| 59 | keyctl update keyid "update key-type:master-key-name" | 63 | keyctl add encrypted name "load hex_blob" ring |
| 64 | keyctl update keyid "update key-type:master-key-name" | ||
| 65 | |||
| 66 | format:= 'default' | ||
| 67 | key-type:= 'trusted' | 'user' | ||
| 60 | 68 | ||
| 61 | where 'key-type' is either 'trusted' or 'user'. | ||
| 62 | 69 | ||
| 63 | Examples of trusted and encrypted key usage: | 70 | Examples of trusted and encrypted key usage: |
| 64 | 71 | ||
| @@ -114,15 +121,25 @@ Reseal a trusted key under new pcr values: | |||
| 114 | 7ef6a24defe4846104209bf0c3eced7fa1a672ed5b125fc9d8cd88b476a658a4434644ef | 121 | 7ef6a24defe4846104209bf0c3eced7fa1a672ed5b125fc9d8cd88b476a658a4434644ef |
| 115 | df8ae9a178e9f83ba9f08d10fa47e4226b98b0702f06b3b8 | 122 | df8ae9a178e9f83ba9f08d10fa47e4226b98b0702f06b3b8 |
| 116 | 123 | ||
| 117 | Create and save an encrypted key "evm" using the above trusted key "kmk": | 124 | The initial consumer of trusted keys is EVM, which at boot time needs a high |
| 125 | quality symmetric key for HMAC protection of file metadata. The use of a | ||
| 126 | trusted key provides strong guarantees that the EVM key has not been | ||
| 127 | compromised by a user level problem, and when sealed to specific boot PCR | ||
| 128 | values, protects against boot and offline attacks. Create and save an | ||
| 129 | encrypted key "evm" using the above trusted key "kmk": | ||
| 118 | 130 | ||
| 131 | option 1: omitting 'format' | ||
| 119 | $ keyctl add encrypted evm "new trusted:kmk 32" @u | 132 | $ keyctl add encrypted evm "new trusted:kmk 32" @u |
| 120 | 159771175 | 133 | 159771175 |
| 121 | 134 | ||
| 135 | option 2: explicitly defining 'format' as 'default' | ||
| 136 | $ keyctl add encrypted evm "new default trusted:kmk 32" @u | ||
| 137 | 159771175 | ||
| 138 | |||
| 122 | $ keyctl print 159771175 | 139 | $ keyctl print 159771175 |
| 123 | trusted:kmk 32 2375725ad57798846a9bbd240de8906f006e66c03af53b1b382dbbc55 | 140 | default trusted:kmk 32 2375725ad57798846a9bbd240de8906f006e66c03af53b1b3 |
| 124 | be2a44616e4959430436dc4f2a7a9659aa60bb4652aeb2120f149ed197c564e024717c64 | 141 | 82dbbc55be2a44616e4959430436dc4f2a7a9659aa60bb4652aeb2120f149ed197c564e0 |
| 125 | 5972dcb82ab2dde83376d82b2e3c09ffc | 142 | 24717c64 5972dcb82ab2dde83376d82b2e3c09ffc |
| 126 | 143 | ||
| 127 | $ keyctl pipe 159771175 > evm.blob | 144 | $ keyctl pipe 159771175 > evm.blob |
| 128 | 145 | ||
| @@ -132,14 +149,9 @@ Load an encrypted key "evm" from saved blob: | |||
| 132 | 831684262 | 149 | 831684262 |
| 133 | 150 | ||
| 134 | $ keyctl print 831684262 | 151 | $ keyctl print 831684262 |
| 135 | trusted:kmk 32 2375725ad57798846a9bbd240de8906f006e66c03af53b1b382dbbc55 | 152 | default trusted:kmk 32 2375725ad57798846a9bbd240de8906f006e66c03af53b1b3 |
| 136 | be2a44616e4959430436dc4f2a7a9659aa60bb4652aeb2120f149ed197c564e024717c64 | 153 | 82dbbc55be2a44616e4959430436dc4f2a7a9659aa60bb4652aeb2120f149ed197c564e0 |
| 137 | 5972dcb82ab2dde83376d82b2e3c09ffc | 154 | 24717c64 5972dcb82ab2dde83376d82b2e3c09ffc |
| 138 | |||
| 139 | 155 | ||
| 140 | The initial consumer of trusted keys is EVM, which at boot time needs a high | 156 | Other uses for trusted and encrypted keys, such as for disk and file encryption |
| 141 | quality symmetric key for HMAC protection of file metadata. The use of a | 157 | are anticipated. |
| 142 | trusted key provides strong guarantees that the EVM key has not been | ||
| 143 | compromised by a user level problem, and when sealed to specific boot PCR | ||
| 144 | values, protects against boot and offline attacks. Other uses for trusted and | ||
| 145 | encrypted keys, such as for disk and file encryption are anticipated. | ||
diff --git a/include/keys/encrypted-type.h b/include/keys/encrypted-type.h index 95855017a32b..1d4541370a64 100644 --- a/include/keys/encrypted-type.h +++ b/include/keys/encrypted-type.h | |||
| @@ -1,6 +1,11 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2010 IBM Corporation | 2 | * Copyright (C) 2010 IBM Corporation |
| 3 | * Author: Mimi Zohar <zohar@us.ibm.com> | 3 | * Copyright (C) 2010 Politecnico di Torino, Italy |
| 4 | * TORSEC group -- http://security.polito.it | ||
| 5 | * | ||
| 6 | * Authors: | ||
| 7 | * Mimi Zohar <zohar@us.ibm.com> | ||
| 8 | * Roberto Sassu <roberto.sassu@polito.it> | ||
| 4 | * | 9 | * |
| 5 | * This program is free software; you can redistribute it and/or modify | 10 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by | 11 | * it under the terms of the GNU General Public License as published by |
| @@ -15,13 +20,17 @@ | |||
| 15 | 20 | ||
| 16 | struct encrypted_key_payload { | 21 | struct encrypted_key_payload { |
| 17 | struct rcu_head rcu; | 22 | struct rcu_head rcu; |
| 23 | char *format; /* datablob: format */ | ||
| 18 | char *master_desc; /* datablob: master key name */ | 24 | char *master_desc; /* datablob: master key name */ |
| 19 | char *datalen; /* datablob: decrypted key length */ | 25 | char *datalen; /* datablob: decrypted key length */ |
| 20 | u8 *iv; /* datablob: iv */ | 26 | u8 *iv; /* datablob: iv */ |
| 21 | u8 *encrypted_data; /* datablob: encrypted data */ | 27 | u8 *encrypted_data; /* datablob: encrypted data */ |
| 22 | unsigned short datablob_len; /* length of datablob */ | 28 | unsigned short datablob_len; /* length of datablob */ |
| 23 | unsigned short decrypted_datalen; /* decrypted data length */ | 29 | unsigned short decrypted_datalen; /* decrypted data length */ |
| 24 | u8 decrypted_data[0]; /* decrypted data + datablob + hmac */ | 30 | unsigned short payload_datalen; /* payload data length */ |
| 31 | unsigned short encrypted_key_format; /* encrypted key format */ | ||
| 32 | u8 *decrypted_data; /* decrypted data */ | ||
| 33 | u8 payload_data[0]; /* payload data + datablob + hmac */ | ||
| 25 | }; | 34 | }; |
| 26 | 35 | ||
| 27 | extern struct key_type key_type_encrypted; | 36 | extern struct key_type key_type_encrypted; |
diff --git a/security/keys/encrypted.c b/security/keys/encrypted.c index f36a105de791..89981c987ba7 100644 --- a/security/keys/encrypted.c +++ b/security/keys/encrypted.c | |||
| @@ -1,8 +1,11 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2010 IBM Corporation | 2 | * Copyright (C) 2010 IBM Corporation |
| 3 | * Copyright (C) 2010 Politecnico di Torino, Italy | ||
| 4 | * TORSEC group -- http://security.polito.it | ||
| 3 | * | 5 | * |
| 4 | * Author: | 6 | * Authors: |
| 5 | * Mimi Zohar <zohar@us.ibm.com> | 7 | * Mimi Zohar <zohar@us.ibm.com> |
| 8 | * Roberto Sassu <roberto.sassu@polito.it> | ||
| 6 | * | 9 | * |
| 7 | * This program is free software; you can redistribute it and/or modify | 10 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by | 11 | * it under the terms of the GNU General Public License as published by |
| @@ -37,6 +40,7 @@ static const char KEY_USER_PREFIX[] = "user:"; | |||
| 37 | static const char hash_alg[] = "sha256"; | 40 | static const char hash_alg[] = "sha256"; |
| 38 | static const char hmac_alg[] = "hmac(sha256)"; | 41 | static const char hmac_alg[] = "hmac(sha256)"; |
| 39 | static const char blkcipher_alg[] = "cbc(aes)"; | 42 | static const char blkcipher_alg[] = "cbc(aes)"; |
| 43 | static const char key_format_default[] = "default"; | ||
| 40 | static unsigned int ivsize; | 44 | static unsigned int ivsize; |
| 41 | static int blksize; | 45 | static int blksize; |
| 42 | 46 | ||
| @@ -58,6 +62,15 @@ enum { | |||
| 58 | Opt_err = -1, Opt_new, Opt_load, Opt_update | 62 | Opt_err = -1, Opt_new, Opt_load, Opt_update |
| 59 | }; | 63 | }; |
| 60 | 64 | ||
| 65 | enum { | ||
| 66 | Opt_error = -1, Opt_default | ||
| 67 | }; | ||
| 68 | |||
| 69 | static const match_table_t key_format_tokens = { | ||
| 70 | {Opt_default, "default"}, | ||
| 71 | {Opt_error, NULL} | ||
| 72 | }; | ||
| 73 | |||
| 61 | static const match_table_t key_tokens = { | 74 | static const match_table_t key_tokens = { |
| 62 | {Opt_new, "new"}, | 75 | {Opt_new, "new"}, |
| 63 | {Opt_load, "load"}, | 76 | {Opt_load, "load"}, |
| @@ -118,8 +131,9 @@ out: | |||
| 118 | * datablob_parse - parse the keyctl data | 131 | * datablob_parse - parse the keyctl data |
| 119 | * | 132 | * |
| 120 | * datablob format: | 133 | * datablob format: |
| 121 | * new <master-key name> <decrypted data length> | 134 | * new [<format>] <master-key name> <decrypted data length> |
| 122 | * load <master-key name> <decrypted data length> <encrypted iv + data> | 135 | * load [<format>] <master-key name> <decrypted data length> |
| 136 | * <encrypted iv + data> | ||
| 123 | * update <new-master-key name> | ||
