Commit 4e561d38 authored by Roberto Sassu's avatar Roberto Sassu Committed by Mimi Zohar

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: default avatarRoberto Sassu <roberto.sassu@polito.it>
Acked-by: default avatarGianluca Ramunno <ramunno@polito.it>
Acked-by: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarMimi Zohar <zohar@linux.vnet.ibm.com>
parent 7103dff0
...@@ -53,12 +53,19 @@ they are only as secure as the user key encrypting them. The master user key ...@@ -53,12 +53,19 @@ they are only as secure as the user key encrypting them. The master user key
should therefore be loaded in as secure a way as possible, preferably early in should therefore be loaded in as secure a way as possible, preferably early in
boot. boot.
The decrypted portion of encrypted keys can contain either a simple symmetric
key or a more complex structure. The format of the more complex structure is
application specific, which is identified by 'format'.
Usage: Usage:
keyctl add encrypted name "new key-type:master-key-name keylen" ring keyctl add encrypted name "new [format] key-type:master-key-name keylen"
ring
keyctl add encrypted name "load hex_blob" ring keyctl add encrypted name "load hex_blob" ring
keyctl update keyid "update key-type:master-key-name" keyctl update keyid "update key-type:master-key-name"
where 'key-type' is either 'trusted' or 'user'. format:= 'default'
key-type:= 'trusted' | 'user'
Examples of trusted and encrypted key usage: Examples of trusted and encrypted key usage:
...@@ -114,15 +121,25 @@ Reseal a trusted key under new pcr values: ...@@ -114,15 +121,25 @@ Reseal a trusted key under new pcr values:
7ef6a24defe4846104209bf0c3eced7fa1a672ed5b125fc9d8cd88b476a658a4434644ef 7ef6a24defe4846104209bf0c3eced7fa1a672ed5b125fc9d8cd88b476a658a4434644ef
df8ae9a178e9f83ba9f08d10fa47e4226b98b0702f06b3b8 df8ae9a178e9f83ba9f08d10fa47e4226b98b0702f06b3b8
Create and save an encrypted key "evm" using the above trusted key "kmk": The initial consumer of trusted keys is EVM, which at boot time needs a high
quality symmetric key for HMAC protection of file metadata. The use of a
trusted key provides strong guarantees that the EVM key has not been
compromised by a user level problem, and when sealed to specific boot PCR
values, protects against boot and offline attacks. Create and save an
encrypted key "evm" using the above trusted key "kmk":
option 1: omitting 'format'
$ keyctl add encrypted evm "new trusted:kmk 32" @u $ keyctl add encrypted evm "new trusted:kmk 32" @u
159771175 159771175
option 2: explicitly defining 'format' as 'default'
$ keyctl add encrypted evm "new default trusted:kmk 32" @u
159771175
$ keyctl print 159771175 $ keyctl print 159771175
trusted:kmk 32 2375725ad57798846a9bbd240de8906f006e66c03af53b1b382dbbc55 default trusted:kmk 32 2375725ad57798846a9bbd240de8906f006e66c03af53b1b3
be2a44616e4959430436dc4f2a7a9659aa60bb4652aeb2120f149ed197c564e024717c64 82dbbc55be2a44616e4959430436dc4f2a7a9659aa60bb4652aeb2120f149ed197c564e0
5972dcb82ab2dde83376d82b2e3c09ffc 24717c64 5972dcb82ab2dde83376d82b2e3c09ffc
$ keyctl pipe 159771175 > evm.blob $ keyctl pipe 159771175 > evm.blob
...@@ -132,14 +149,9 @@ Load an encrypted key "evm" from saved blob: ...@@ -132,14 +149,9 @@ Load an encrypted key "evm" from saved blob:
831684262 831684262
$ keyctl print 831684262 $ keyctl print 831684262
trusted:kmk 32 2375725ad57798846a9bbd240de8906f006e66c03af53b1b382dbbc55 default trusted:kmk 32 2375725ad57798846a9bbd240de8906f006e66c03af53b1b3
be2a44616e4959430436dc4f2a7a9659aa60bb4652aeb2120f149ed197c564e024717c64 82dbbc55be2a44616e4959430436dc4f2a7a9659aa60bb4652aeb2120f149ed197c564e0
5972dcb82ab2dde83376d82b2e3c09ffc 24717c64 5972dcb82ab2dde83376d82b2e3c09ffc
The initial consumer of trusted keys is EVM, which at boot time needs a high Other uses for trusted and encrypted keys, such as for disk and file encryption
quality symmetric key for HMAC protection of file metadata. The use of a are anticipated.
trusted key provides strong guarantees that the EVM key has not been
compromised by a user level problem, and when sealed to specific boot PCR
values, protects against boot and offline attacks. Other uses for trusted and
encrypted keys, such as for disk and file encryption are anticipated.
/* /*
* Copyright (C) 2010 IBM Corporation * Copyright (C) 2010 IBM Corporation
* Author: Mimi Zohar <zohar@us.ibm.com> * Copyright (C) 2010 Politecnico di Torino, Italy
* TORSEC group -- http://security.polito.it
*
* Authors:
* Mimi Zohar <zohar@us.ibm.com>
* Roberto Sassu <roberto.sassu@polito.it>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -15,13 +20,17 @@ ...@@ -15,13 +20,17 @@
struct encrypted_key_payload { struct encrypted_key_payload {
struct rcu_head rcu; struct rcu_head rcu;
char *format; /* datablob: format */
char *master_desc; /* datablob: master key name */ char *master_desc; /* datablob: master key name */
char *datalen; /* datablob: decrypted key length */ char *datalen; /* datablob: decrypted key length */
u8 *iv; /* datablob: iv */ u8 *iv; /* datablob: iv */
u8 *encrypted_data; /* datablob: encrypted data */ u8 *encrypted_data; /* datablob: encrypted data */
unsigned short datablob_len; /* length of datablob */ unsigned short datablob_len; /* length of datablob */
unsigned short decrypted_datalen; /* decrypted data length */ unsigned short decrypted_datalen; /* decrypted data length */
u8 decrypted_data[0]; /* decrypted data + datablob + hmac */ unsigned short payload_datalen; /* payload data length */
unsigned short encrypted_key_format; /* encrypted key format */
u8 *decrypted_data; /* decrypted data */
u8 payload_data[0]; /* payload data + datablob + hmac */
}; };
extern struct key_type key_type_encrypted; extern struct key_type key_type_encrypted;
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment