Skip to content

Commit 4e561d3

Browse files
Roberto SassuMimi Zohar
authored andcommitted
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>
1 parent 7103dff commit 4e561d3

3 files changed

Lines changed: 142 additions & 60 deletions

File tree

‎Documentation/security/keys-trusted-encrypted.txt‎

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,19 @@ they are only as secure as the user key encrypting them. The master user key
5353
should therefore be loaded in as secure a way as possible, preferably early in
5454
boot.
5555

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+
5660
Usage:
57-
keyctl add encrypted name "new key-type:master-key-name keylen" ring
58-
keyctl add encrypted name "load hex_blob" ring
59-
keyctl update keyid "update key-type:master-key-name"
61+
keyctl add encrypted name "new [format] key-type:master-key-name keylen"
62+
ring
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'
6068

61-
where 'key-type' is either 'trusted' or 'user'.
6269

6370
Examples of trusted and encrypted key usage:
6471

@@ -114,15 +121,25 @@ Reseal a trusted key under new pcr values:
114121
7ef6a24defe4846104209bf0c3eced7fa1a672ed5b125fc9d8cd88b476a658a4434644ef
115122
df8ae9a178e9f83ba9f08d10fa47e4226b98b0702f06b3b8
116123

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":
118130

131+
option 1: omitting 'format'
119132
$ keyctl add encrypted evm "new trusted:kmk 32" @u
120133
159771175
121134

135+
option 2: explicitly defining 'format' as 'default'
136+
$ keyctl add encrypted evm "new default trusted:kmk 32" @u
137+
159771175
138+
122139
$ keyctl print 159771175
123-
trusted:kmk 32 2375725ad57798846a9bbd240de8906f006e66c03af53b1b382dbbc55
124-
be2a44616e4959430436dc4f2a7a9659aa60bb4652aeb2120f149ed197c564e024717c64
125-
5972dcb82ab2dde83376d82b2e3c09ffc
140+
default trusted:kmk 32 2375725ad57798846a9bbd240de8906f006e66c03af53b1b3
141+
82dbbc55be2a44616e4959430436dc4f2a7a9659aa60bb4652aeb2120f149ed197c564e0
142+
24717c64 5972dcb82ab2dde83376d82b2e3c09ffc
126143

127144
$ keyctl pipe 159771175 > evm.blob
128145

@@ -132,14 +149,9 @@ Load an encrypted key "evm" from saved blob:
132149
831684262
133150

134151
$ keyctl print 831684262
135-
trusted:kmk 32 2375725ad57798846a9bbd240de8906f006e66c03af53b1b382dbbc55
136-
be2a44616e4959430436dc4f2a7a9659aa60bb4652aeb2120f149ed197c564e024717c64
137-
5972dcb82ab2dde83376d82b2e3c09ffc
138-
152+
default trusted:kmk 32 2375725ad57798846a9bbd240de8906f006e66c03af53b1b3
153+
82dbbc55be2a44616e4959430436dc4f2a7a9659aa60bb4652aeb2120f149ed197c564e0
154+
24717c64 5972dcb82ab2dde83376d82b2e3c09ffc
139155

140-
The initial consumer of trusted keys is EVM, which at boot time needs a high
141-
quality symmetric key for HMAC protection of file metadata. The use of a
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.
156+
Other uses for trusted and encrypted keys, such as for disk and file encryption
157+
are anticipated.

‎include/keys/encrypted-type.h‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
/*
22
* 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>
49
*
510
* This program is free software; you can redistribute it and/or modify
611
* it under the terms of the GNU General Public License as published by
@@ -15,13 +20,17 @@
1520

1621
struct encrypted_key_payload {
1722
struct rcu_head rcu;
23+
char *format; /* datablob: format */
1824
char *master_desc; /* datablob: master key name */
1925
char *datalen; /* datablob: decrypted key length */
2026
u8 *iv; /* datablob: iv */
2127
u8 *encrypted_data; /* datablob: encrypted data */
2228
unsigned short datablob_len; /* length of datablob */
2329
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 */
2534
};
2635

2736
extern struct key_type key_type_encrypted;

0 commit comments

Comments
 (0)