Project

General

Profile

Trusted Platform Module 2.0 » History » Version 11

Andreas Steffen, 18.02.2017 18:31

1 7 Andreas Steffen
h1. Trusted Platform Module 2.0
2 1 Andreas Steffen
3 6 Andreas Steffen
{{>toc}}
4 6 Andreas Steffen
5 2 Andreas Steffen
h2. Connect to a TPM 2.0 device
6 2 Andreas Steffen
7 5 Andreas Steffen
In order to connect to a TPM 2.0 hardware or firmware device, the TSS2 software stack developed by Intel is needed. Because the official Ubuntu *tpm2-tss* package is rather outdated (e.g. since version 0.98 the TCTI interface to the TPM 2.0 resource manager has changed several times), strongSwan is currently based on a recent version directly drawn from the TPM2-TSS git repository https://github.com/01org/TPM2.0-TSS. Avoid any TCTI interface incompatibilities by fetching the latest *tpm2-tools* version from https://github.com/01org/tpm2.0-tools as well.
8 1 Andreas Steffen
9 11 Andreas Steffen
Build and install both the *tpm2-tss* stack and the *tpm2.0-tools*, start the *tpm2-resourcemgr* as a service in the background and try to connect to the TPM 2.0 by listing e.g. the contents of the SHA-1 bank of PCR registers
10 1 Andreas Steffen
11 7 Andreas Steffen
   
12 7 Andreas Steffen
 tpm2_listpcrs -g 0x0004
13 3 Andreas Steffen
14 7 Andreas Steffen
 Bank/Algorithm: TPM_ALG_SHA1(0x0004)
15 3 Andreas Steffen
PCR_00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
16 3 Andreas Steffen
PCR_01: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
17 3 Andreas Steffen
PCR_02: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
18 3 Andreas Steffen
PCR_03: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
19 3 Andreas Steffen
PCR_04: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
20 3 Andreas Steffen
PCR_05: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
21 3 Andreas Steffen
PCR_06: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
22 3 Andreas Steffen
PCR_07: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
23 3 Andreas Steffen
PCR_08: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
24 3 Andreas Steffen
PCR_09: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
25 3 Andreas Steffen
PCR_10: a9 45 e7 0f 42 a2 79 f0 78 ca d4 64 60 39 39 da 9d 6a d1 a5
26 3 Andreas Steffen
PCR_11: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
27 3 Andreas Steffen
PCR_12: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
28 3 Andreas Steffen
PCR_13: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
29 3 Andreas Steffen
PCR_14: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
30 3 Andreas Steffen
PCR_15: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
31 3 Andreas Steffen
PCR_16: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
32 3 Andreas Steffen
PCR_17: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
33 3 Andreas Steffen
PCR_18: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
34 3 Andreas Steffen
PCR_19: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
35 3 Andreas Steffen
PCR_20: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
36 1 Andreas Steffen
PCR_21: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
37 1 Andreas Steffen
PCR_22: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
38 1 Andreas Steffen
PCR_23: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
39 1 Andreas Steffen
40 7 Andreas Steffen
A manual showing all *tpm2-tools* functions with their arguments can be found "here":https://github.com/01org/tpm2.0-tools/blob/master/manual.
41 7 Andreas Steffen
42 7 Andreas Steffen
h2. TPM 2.0 Algorithm IDs
43 7 Andreas Steffen
44 8 Andreas Steffen
h3. Hash Algorithms
45 8 Andreas Steffen
46 7 Andreas Steffen
|0x0004 |SHA-1     |
47 7 Andreas Steffen
|0x000B |SHA-2_256 |
48 7 Andreas Steffen
|0x000C |SHA-2_384 |
49 1 Andreas Steffen
|0x000D |SHA-2_512 |
50 7 Andreas Steffen
51 8 Andreas Steffen
Currently available TPM 2.0 devices like the Infineon *Optiga SLB 9670 VQ2.0* hardware TPM or Intel's *PTT* firmware TPM support the *SHA-1* and *SHA-2_256* algorithms.
52 1 Andreas Steffen
53 8 Andreas Steffen
h3. Public Key Types
54 8 Andreas Steffen
55 8 Andreas Steffen
|0x0001 |RSA |
56 8 Andreas Steffen
|0x0023 |ECC |
57 1 Andreas Steffen
58 11 Andreas Steffen
h3. Signature Schemes
59 11 Andreas Steffen
60 11 Andreas Steffen
|0x0014 |RSASSA |
61 11 Andreas Steffen
|0x0016 |RSAPSS |
62 11 Andreas Steffen
|0x0018 |ECDSA  |
63 11 Andreas Steffen
                    
64 9 Andreas Steffen
The RSA keys have a modulus size of 2048 bits and the ECC keys are based on the 256 bit NIST curve.
65 9 Andreas Steffen
66 9 Andreas Steffen
h2. Derivation of a Persistent RSA Endorsement Key
67 1 Andreas Steffen
68 11 Andreas Steffen
The following tpm2-tools command derives a 2048 bit RSA Endorsement Key (EK) in a deterministic way from the secret _Endorsement Seed_ *unique* to each TPM device and makes the key persistent in the non-volatile memory of the TPM under the object handle 0x81010001
69 11 Andreas Steffen
70 1 Andreas Steffen
 tpm2_getpubek -H 0x81010001 -g 0x0001
71 9 Andreas Steffen
72 11 Andreas Steffen
The EK public key can be exported in PKCS#1 format from the TPM using the *pki* tool
73 9 Andreas Steffen
74 9 Andreas Steffen
  pki --pub --keyid 81010001 --outform pem > ek_rsa_pub.pem
75 9 Andreas Steffen
76 9 Andreas Steffen
The fingerprint of the RSA EK public key can be displayed with the command
77 9 Andreas Steffen
78 9 Andreas Steffen
 pki --print --type pub --in ek_rsa_pub.pem
79 9 Andreas Steffen
  pubkey:    RSA 2048 bits
80 9 Andreas Steffen
  keyid:     d1:f1:49:84:36:44:e6:8c:d2:a6:69:ee:fd:b5:7d:56:2f:39:ff:58
81 1 Andreas Steffen
  subjkey:   c1:1b:8e:f1:c7:f8:8a:1e:9a:dd:7e:82:2f:7a:a3:f5:c0:e2:4d:7d
82 1 Andreas Steffen
83 11 Andreas Steffen
h2. Generation of a a Persistent RSA Attestation Key
84 11 Andreas Steffen
85 11 Andreas Steffen
A 2048 RSA Attestation Key (AK) bound to the EK with handle 0x81010001 can be created and made persistent under the handle 0x81010002 with the following tpm2-tools command
86 11 Andreas Steffen
87 11 Andreas Steffen
  tpm2_getpubak tpm2_getpubak -E 0x81010001 -g 0x0001 -D 0x000B -s 0x0014 -k 0x81010002
88 11 Andreas Steffen
89 1 Andreas Steffen
h2. Derivation of a Persistent ECC Endorsement Key
90 1 Andreas Steffen
91 11 Andreas Steffen
The following tpm2-tools command derives a 256 bit ECC Endorsement Key (EK) in a deterministic way from the secret _Endorsement Seed_ *unique* to each TPM device and makes the key persistent in the non-volatile memory of the TPM under the object handle 0x81010003:
92 1 Andreas Steffen
93 11 Andreas Steffen
 tpm2_getpubek -H 0x81010003 -g 0x0023
94 9 Andreas Steffen
95 11 Andreas Steffen
The EK public key can be exported in PKCS#1 format from the TPM using the *pki* tool:
96 11 Andreas Steffen
97 11 Andreas Steffen
  pki --pub --keyid 81010003 > ek_ecc_pub.der
98 9 Andreas Steffen
99 9 Andreas Steffen
The fingerprint of the ECC EK public key can be displayed with the command
100 9 Andreas Steffen
101 10 Andreas Steffen
 pki --print --type pub --in ek_ecc_pub.der
102 9 Andreas Steffen
  pubkey:    ECDSA 256 bits
103 9 Andreas Steffen
  keyid:     7f:39:ca:e6:83:9b:a9:06:97:40:27:6a:e1:bf:8f:f5:9f:d3:a5:31
104 9 Andreas Steffen
  subjkey:   8b:43:4d:5e:5e:7b:ff:c2:54:4d:ef:88:cb:0c:7c:47:75:28:4d:09
105 9 Andreas Steffen
106 2 Andreas Steffen
h2. TPM Private Key Access via VICI Interface
107 1 Andreas Steffen
108 7 Andreas Steffen
Configuration of TPM private key access in *swanctl.conf*:
109 1 Andreas Steffen
110 7 Andreas Steffen
 secrets {
111 1 Andreas Steffen
    token_ak_rsa {
112 7 Andreas Steffen
       handle = 81010002
113 1 Andreas Steffen
    }
114 1 Andreas Steffen
    token_ak_ecc {
115 7 Andreas Steffen
       handle = 81010004
116 1 Andreas Steffen
    }
117 1 Andreas Steffen
}