Skip to content

Commit 51ec19c

Browse files
b49020jforissier
authored andcommitted
doc: trusted-encrypted: updates with TEE as a new trust source
Update documentation for Trusted and Encrypted Keys with TEE as a new trust source. Following is brief description of updates: - Add a section to demonstrate a list of supported devices along with their security properties/guarantees. - Add a key generation section. - Updates for usage section including differences specific to a trust source. Co-developed-by: Elaine Palmer <[email protected]> Signed-off-by: Elaine Palmer <[email protected]> Signed-off-by: Sumit Garg <[email protected]> Signed-off-by: Jarkko Sakkinen <[email protected]>
1 parent 3021b2b commit 51ec19c

File tree

1 file changed

+138
-33
lines changed

1 file changed

+138
-33
lines changed

Documentation/security/keys/trusted-encrypted.rst

Lines changed: 138 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,127 @@ Trusted and Encrypted Keys are two new key types added to the existing kernel
66
key ring service. Both of these new types are variable length symmetric keys,
77
and in both cases all keys are created in the kernel, and user space sees,
88
stores, and loads only encrypted blobs. Trusted Keys require the availability
9-
of a Trusted Platform Module (TPM) chip for greater security, while Encrypted
10-
Keys can be used on any system. All user level blobs, are displayed and loaded
11-
in hex ascii for convenience, and are integrity verified.
9+
of a Trust Source for greater security, while Encrypted Keys can be used on any
10+
system. All user level blobs, are displayed and loaded in hex ASCII for
11+
convenience, and are integrity verified.
1212

13-
Trusted Keys use a TPM both to generate and to seal the keys. Keys are sealed
14-
under a 2048 bit RSA key in the TPM, and optionally sealed to specified PCR
15-
(integrity measurement) values, and only unsealed by the TPM, if PCRs and blob
16-
integrity verifications match. A loaded Trusted Key can be updated with new
17-
(future) PCR values, so keys are easily migrated to new pcr values, such as
18-
when the kernel and initramfs are updated. The same key can have many saved
19-
blobs under different PCR values, so multiple boots are easily supported.
2013

21-
TPM 1.2
22-
-------
14+
Trust Source
15+
============
2316

24-
By default, trusted keys are sealed under the SRK, which has the default
25-
authorization value (20 zeros). This can be set at takeownership time with the
26-
trouser's utility: "tpm_takeownership -u -z".
17+
A trust source provides the source of security for Trusted Keys. This
18+
section lists currently supported trust sources, along with their security
19+
considerations. Whether or not a trust source is sufficiently safe depends
20+
on the strength and correctness of its implementation, as well as the threat
21+
environment for a specific use case. Since the kernel doesn't know what the
22+
environment is, and there is no metric of trust, it is dependent on the
23+
consumer of the Trusted Keys to determine if the trust source is sufficiently
24+
safe.
2725

28-
TPM 2.0
29-
-------
26+
* Root of trust for storage
3027

31-
The user must first create a storage key and make it persistent, so the key is
32-
available after reboot. This can be done using the following commands.
28+
(1) TPM (Trusted Platform Module: hardware device)
29+
30+
Rooted to Storage Root Key (SRK) which never leaves the TPM that
31+
provides crypto operation to establish root of trust for storage.
32+
33+
(2) TEE (Trusted Execution Environment: OP-TEE based on Arm TrustZone)
34+
35+
Rooted to Hardware Unique Key (HUK) which is generally burnt in on-chip
36+
fuses and is accessible to TEE only.
37+
38+
* Execution isolation
39+
40+
(1) TPM
41+
42+
Fixed set of operations running in isolated execution environment.
43+
44+
(2) TEE
45+
46+
Customizable set of operations running in isolated execution
47+
environment verified via Secure/Trusted boot process.
48+
49+
* Optional binding to platform integrity state
50+
51+
(1) TPM
52+
53+
Keys can be optionally sealed to specified PCR (integrity measurement)
54+
values, and only unsealed by the TPM, if PCRs and blob integrity
55+
verifications match. A loaded Trusted Key can be updated with new
56+
(future) PCR values, so keys are easily migrated to new PCR values,
57+
such as when the kernel and initramfs are updated. The same key can
58+
have many saved blobs under different PCR values, so multiple boots are
59+
easily supported.
60+
61+
(2) TEE
62+
63+
Relies on Secure/Trusted boot process for platform integrity. It can
64+
be extended with TEE based measured boot process.
65+
66+
* Interfaces and APIs
67+
68+
(1) TPM
69+
70+
TPMs have well-documented, standardized interfaces and APIs.
71+
72+
(2) TEE
73+
74+
TEEs have well-documented, standardized client interface and APIs. For
75+
more details refer to ``Documentation/staging/tee.rst``.
76+
77+
78+
* Threat model
79+
80+
The strength and appropriateness of a particular TPM or TEE for a given
81+
purpose must be assessed when using them to protect security-relevant data.
82+
83+
84+
Key Generation
85+
==============
86+
87+
Trusted Keys
88+
------------
89+
90+
New keys are created from random numbers generated in the trust source. They
91+
are encrypted/decrypted using a child key in the storage key hierarchy.
92+
Encryption and decryption of the child key must be protected by a strong
93+
access control policy within the trust source.
94+
95+
* TPM (hardware device) based RNG
96+
97+
Strength of random numbers may vary from one device manufacturer to
98+
another.
99+
100+
* TEE (OP-TEE based on Arm TrustZone) based RNG
101+
102+
RNG is customizable as per platform needs. It can either be direct output
103+
from platform specific hardware RNG or a software based Fortuna CSPRNG
104+
which can be seeded via multiple entropy sources.
105+
106+
Encrypted Keys
107+
--------------
108+
109+
Encrypted keys do not depend on a trust source, and are faster, as they use AES
110+
for encryption/decryption. New keys are created from kernel-generated random
111+
numbers, and are encrypted/decrypted using a specified ‘master’ key. The
112+
‘master’ key can either be a trusted-key or user-key type. The main disadvantage
113+
of encrypted keys is that if they are not rooted in a trusted key, they are only
114+
as secure as the user key encrypting them. The master user key should therefore
115+
be loaded in as secure a way as possible, preferably early in boot.
116+
117+
118+
Usage
119+
=====
120+
121+
Trusted Keys usage: TPM
122+
-----------------------
123+
124+
TPM 1.2: By default, trusted keys are sealed under the SRK, which has the
125+
default authorization value (20 bytes of 0s). This can be set at takeownership
126+
time with the TrouSerS utility: "tpm_takeownership -u -z".
127+
128+
TPM 2.0: The user must first create a storage key and make it persistent, so the
129+
key is available after reboot. This can be done using the following commands.
33130

34131
With the IBM TSS 2 stack::
35132

@@ -78,14 +175,21 @@ TPM_STORED_DATA format. The key length for new keys are always in bytes.
78175
Trusted Keys can be 32 - 128 bytes (256 - 1024 bits), the upper limit is to fit
79176
within the 2048 bit SRK (RSA) keylength, with all necessary structure/padding.
80177

81-
Encrypted keys do not depend on a TPM, and are faster, as they use AES for
82-
encryption/decryption. New keys are created from kernel generated random
83-
numbers, and are encrypted/decrypted using a specified 'master' key. The
84-
'master' key can either be a trusted-key or user-key type. The main
85-
disadvantage of encrypted keys is that if they are not rooted in a trusted key,
86-
they are only as secure as the user key encrypting them. The master user key
87-
should therefore be loaded in as secure a way as possible, preferably early in
88-
boot.
178+
Trusted Keys usage: TEE
179+
-----------------------
180+
181+
Usage::
182+
183+
keyctl add trusted name "new keylen" ring
184+
keyctl add trusted name "load hex_blob" ring
185+
keyctl print keyid
186+
187+
"keyctl print" returns an ASCII hex copy of the sealed key, which is in format
188+
specific to TEE device implementation. The key length for new keys is always
189+
in bytes. Trusted Keys can be 32 - 128 bytes (256 - 1024 bits).
190+
191+
Encrypted Keys usage
192+
--------------------
89193

90194
The decrypted portion of encrypted keys can contain either a simple symmetric
91195
key or a more complex structure. The format of the more complex structure is
@@ -103,8 +207,8 @@ Where::
103207
format:= 'default | ecryptfs | enc32'
104208
key-type:= 'trusted' | 'user'
105209

106-
107-
Examples of trusted and encrypted key usage:
210+
Examples of trusted and encrypted key usage
211+
-------------------------------------------
108212

109213
Create and save a trusted key named "kmk" of length 32 bytes.
110214

@@ -150,7 +254,7 @@ Load a trusted key from the saved blob::
150254
f1f8fff03ad0acb083725535636addb08d73dedb9832da198081e5deae84bfaf0409c22b
151255
e4a8aea2b607ec96931e6f4d4fe563ba
152256

153-
Reseal a trusted key under new pcr values::
257+
Reseal (TPM specific) a trusted key under new PCR values::
154258

155259
$ keyctl update 268728824 "update pcrinfo=`cat pcr.blob`"
156260
$ keyctl print 268728824
@@ -164,11 +268,12 @@ Reseal a trusted key under new pcr values::
164268
7ef6a24defe4846104209bf0c3eced7fa1a672ed5b125fc9d8cd88b476a658a4434644ef
165269
df8ae9a178e9f83ba9f08d10fa47e4226b98b0702f06b3b8
166270

271+
167272
The initial consumer of trusted keys is EVM, which at boot time needs a high
168-
quality symmetric key for HMAC protection of file metadata. The use of a
273+
quality symmetric key for HMAC protection of file metadata. The use of a
169274
trusted key provides strong guarantees that the EVM key has not been
170-
compromised by a user level problem, and when sealed to specific boot PCR
171-
values, protects against boot and offline attacks. Create and save an
275+
compromised by a user level problem, and when sealed to a platform integrity
276+
state, protects against boot and offline attacks. Create and save an
172277
encrypted key "evm" using the above trusted key "kmk":
173278

174279
option 1: omitting 'format'::

0 commit comments

Comments
 (0)