summaryrefslogtreecommitdiff
path: root/lectures/12-hardware-modules.org
blob: 1f8bad67b03a878f370e4f5e63532a92ca0f2108 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
#+title: Hardware Modules
#+date: 2026-06-08 Mon
#+author: W. Kosior
#+email: wkosior@agh.edu.pl

* Hardware Security Module
- key generation
- secrets store
- cryptographic operations
  - non-exportable keys
- sample uses
  - malware-resistant SSH keys
  - DNSSEC signing
  - cryptocurrency transactions
  - rng
  - TOTP/HOTP
- https://www.iana.org/dnssec/ceremonies
- API (PKCS#11 or other)

* HSM Types
- PCIe
- USB
- smart card
- virtualized/emulated
- wire protocol often proprietary, non-standard

* HSM Diversity
- firmware-based?
  - updatable?
- display?
- input device (e.g., fingerprint reader)?

* PKCS#11
- RSA Laboratories
- slot
- token
  - label, serial
- PIN

* PKCS#11, Cont.
- RSA Laboratories
- slot
- token
  - label, serial
- PIN
- mechanism (cipher + hash function + block mode)
  - capabilities
  - parameters
- object classes
  - keys
  - domain parameters
  - certs
- object attributes (class-specific)
- sessions

* SIM Cards
- K
- symmetric cryptography
  - user-operator shared secret
  - 128-bit

* Measured Boot
- Secure Boot → verify software to be booted
- Measured Boot → attest what has been booted

* Trusted Platform Module
- "Trusted" Computing Group
- aka HSM integrated with hardware
- sample uses
  - BitLocker/LUKS
  - SSH
  - GPG
  - file integrity
  - rng

* Trusted Platform Module, Cont.
- "Trusted" Computing Group
- aka HSM integrated with hardware
- sample uses
  - BitLocker/LUKS
  - SSH
  - GPG
  - file integrity
  - rng
  - eSIM

* TPM Versions
- TPM 1.0-1.2
  - SHA1, 2048-bit RSA
- TPM 2.0
  - algorithm-agnostic (in practice: SHA256, ECC, AES)
- =/sys/class/tpm/tpm0/tpm_version_major=

* Interfaces
- TCG specification
  - SAPI
  - ESAPI
  - FAPI
- tpm-tools (CLI)
  - https://tpm2-tools.readthedocs.io

* TPM Types
discrete TPM*
integrated TPM
firmware TPM
virtual TPM

* TPM Entities
- types
  - objects
    - *keys*
    - data
  - NVRAM indexes
  - Platform Configuration Registers (PCRs)
  - hierarchies
  - …
- handles (4 bytes)
- objects & NVRAM indexes can be removed

* TPM Hierarchies
- collections of entities
- defined hierarchies
  - endorsement/privacy
    - remote attestation (device state confirmation)
  - platform
    - use by motherboard manufacturer
  - storage/owner
    - most uses
  - null/ephemeral
    - entities not persisted

* PCRs
- extending (concatenate+hash)
- banks (hash algorithm)
- =tpm2_pcrlist=
- =tpm2_pcrread=

* Firmware-Extended PCRs
| 0 | "Core system firmware executable code"     | e.g., UEFI BIOS code                |
| 1 | "Core System Firmware data"                | e.g., UEFI BIOS settings            |
| 2 | "Extended or pluggable executable code"    | e.g., option ROMs                   |
| 3 | "Extended or pluggable firmware data"      |                                     |
| 4 | "Boot Manager Code and Boot Attempts"      | e.g., bootloader code               |
| 5 | "Boot Manager Configuration and Data"      | e.g., bootloader config, part table |
| 6 | "Resume from S4 and S5 Power State Events" |                                     |
| 7 | "Secure Boot State"                        | e.g., PK, KEK, db                   |

Based on: https://wiki.archlinux.org/title/Trusted_Platform_Module

* Other PCRs
| 8-16 | defined by OS         | e.g., kernel, kernel command line, initrd(s) |
|   23 | "Application support" | resettable by the OS                         |

* TPM Entity Sealing
- particular PCR values
- PCR values signed with configured key

* TPM Keys
- derivation
  - storing not needed
- endorsement key (& cert)

* TPM NVRAM
- data entities
  - size
  - attributes
  - 0x10000000-0x1fffffff
  - reading&writing
- =tpm2_nvreadpublic=
- =tpm2_nvdefine=
- =tpm2_nvwrite=
- =tpm2_nvread=
- =tpm2_nvundefine=

* TPM NVRAM Entity Locking
- =tpm2_nvwritelock=
- =tpm2_nvreadlock=

* TPM Authorization
- password (single-command sessions)
- HMAC (shared secret)
- Enhanced Authorization (policy)

* side-channel attacks
- bus snooping (passive, discrete TPM)
- MITM (active, discrete TPM)
- desolder-and-move (active, discrete TPM)
- fault injection (active)
- spectre-like? (firmware TPM)
- power analysis

* TPM Encrypted Commands / Response Buffers
- unbound, bound, salted
- first parameter only

* Application Support for TPM (2.0)
- LUKS
  - systemd-cryptenroll
- SSH
  - https://github.com/Foxboron/ssh-tpm-agent
- others
  - https://github.com/tpm2-software/tpm2-pkcs11
- PGP
  - GnuPG (since 2.3, 2021)

* "Secure" Boot for Firmware
- Intel TXT
  - using TPM to verify UEFI firmware (and more)
- one-time-programmable fuses
  - motherboard vendor's public key
  - firmware signing
  - AMD PSP
  - Intel Boot Guard

* Trusted/Treacherous Execution Environment
- remote attestation (of hardware by software vendor)
- encrypted memory regions
- application not inspectable by host OS
- IO (e.g., PCIe) not interceptible by host OS
- sample use: client-attested VM hosting
- Intel Software Guard Extensions (SGX)
  - application-level
  - deprecated on consumer PCs
- AMD Secure Encrypted Virtualization
  - encryption of guest-selected memory pages
  - also server CPUs
- Intel Trust Domain Extensions
  - shared & private VM memory
  - also server CPUs
- ARM TrustZone

* Dangers
- inability to exercise fair use rights (DRM)
  - media backup
  - software reverse engineering
- elimination of competition
- inability to audit/fix
- no software freedom :c