~zyga/checkbox/tpm-hacking-patches

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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# This file is part of Checkbox.
#
# Copyright 2015 Canonical Ltd.
# Written by:
#   Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
#
# Checkbox is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3,
# as published by the Free Software Foundation.
#
# Checkbox is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Checkbox.  If not, see <http://www.gnu.org/licenses/>.

unit: job
id: setup/enable-disabled-tpm
category_id: tpm
_summary: Use BIOS to activate a disabled TPM chip
_purpose:
 This job will reconfigure the TPM chip to be in the Active state.
_steps:
 To enable the TPM chip in the BIOS, write down the following instructions and
 exit the testing application.
 .
 INSTRUCTIONS FOR ENABLING THE TPM CHIP:
 .
  - Commence the test to restart the machine
  - Enter BIOS using machine-specific hot-key (typically F1, F2, or delete)
  - Navigate to TPM menu, the precise location may depend on your BIOS version
    and the make and model of your DUT. On some models it is under the
    following menu: Security / Security Chip.
  - Change the current setting to Active
  - Save BIOS settings
  - Power the machine off (NOTE: a reboot may not be sufficient)
  - Power the machine back on again
  - Let the machine boot
  - Restart the testing application
plugin: user-interact
user: root
command: reboot
estimated_duration: 3m
flags: preserve-locale noreturn
# NOTE: This job will only run if we know we have a TPM chip (according to the
# manifest) but we don't see one in sysfs (because it's disabled).
requires: sysfs_tpm_count.count == "0" and manifest.has_tpm_chip
imports: from 2013.com.canonical.plainbox import manifest

unit: job
id: setup/enable-inactive-tpm
category_id: tpm
_summary: Use BIOS to activate an inactive TPM chip
_purpose:
 This job will reconfigure the TPM chip to be in the Active state.
_steps:
 To enable the TPM chip in the BIOS, write down the following instructions and
 exit the testing application.
 .
 INSTRUCTIONS FOR ENABLING THE TPM CHIP:
 .
  - Commence the test to restart the machine
  - Enter BIOS using machine-specific hot-key (typically F1, F2, or delete)
  - Navigate to TPM menu, the precise location may depend on your BIOS version
    and the make and model of your DUT. On some models it is under the
    following menu: Security / Security Chip.
  - Change the current setting to Active
  - Save BIOS settings
  - Power the machine off (NOTE: a reboot may not be sufficient)
  - Power the machine back on again
  - Let the machine boot
  - Restart the testing application
plugin: user-interact
user: root
command: reboot
# NOTE: This job will only run if we know we have a TPM chip (according to the
# manifest, again) but sysfs claims it's temporarily deactivated (which is the
# confusing way to say it's inactive)
requires: sysfs_tpm_count.count != "0" and sysfs_tpm.temp_deactivated == "1"
estimated_duration: 3m
flags: preserve-locale noreturn

unit: job
id: action/clear-ownership
category_id: tpm
_summary: Clear ownership of the TPM chip
_purpose:
 This job tries to automatically clear the ownership of an owned TPM chip. It
 uses well-known owner secret (20 bytes of zeros).
 .
 NOTE: The actual TPM chip will be cleared after the machine reboots.  After
 reboot the TPM will be in the default state: unowned, disabled and inactive.
 Subsequent jobs will instruct test operator to enter BIOS and re-enable the
 chip.
_steps:
 INSTRUCTIONS FOR CLEARING THE TPM CHIP:
 .
  - Commence the test to reboot the machine
  - Let the machine boot
  - Restart the testing application
plugin: user-interact
command:
 tpm_clear --log debug --well-known && reboot
requires: sysfs_tpm.owned == "1" and sysfs_tpm.enabled == "1" and sysfs_tpm.active == "1" and sysfs_tpm.temp_deactivated == "0"
estimated_duration: 5s
flags: preserve-locale

unit: job
id: action/re-enable-tpm
category_id: tpm
_summary: Re-enable TPM chip in BIOS (after clearing ownership)
_purpose:
 This job will re-enable the TPM chip in the BIOS after having cleared the ownership.
_steps:
 To enable the TPM chip in the BIOS, write down the following instructions and
 exit the testing application.
 .
 INSTRUCTIONS FOR ENABLING THE TPM CHIP:
 .
  - Commence the test to restart the machine
  - Enter BIOS using machine-specific hot-key (typically F1, F2, or delete)
  - Navigate to TPM menu, the precise location may depend on your BIOS version
    and the make and model of your DUT. On some models it is under the
    following menu: Security / Security Chip.
  - Change the current setting to Active. If it is already in the active state
    then set it to Disabled and then back to Active. This might be a bug in the BIOS.
  - Save BIOS settings
  - Power the machine off (NOTE: a reboot may not be sufficient)
  - Power the machine back on again
  - Let the machine boot
  - Restart the testing application
plugin: user-interact
user: root
command: reboot
requires: sysfs_tpm_after_clearing_ownership.owned == "0" and sysfs_tpm_after_clearing_ownership.enabled == "0" and sysfs_tpm_after_clearing_ownership.active == "0" and sysfs_tpm_after_clearing_ownership.temp_deactivated == "1"
estimated_duration: 3m
flags: preserve-locale noreturn

unit: job
id: action/take-ownership
category_id: tpm
_summary: Take ownership of the TPM chip
_description:
 This job tries to automatically take the ownership of an unowned TPM chip. It
 uses well-known owner and SRK secretes (20 bytes of zeros).
plugin: shell
command: tpm_takeownership --log debug --owner-well-known --srk-well-known
requires: sysfs_tpm.owned == "0" and sysfs_tpm.enabled == "1" and sysfs_tpm.active == "1" and sysfs_tpm.temp_deactivated == "0"
estimated_duration: 5s
flags: preserve-locale

# A bunch of unattended attachment jobs that run various TPM commands

unit: job
id: query/tpm_version
category_id: tpm
_summary: Collect the output of tpm_version
_description:
 This job collects the output of "tpm_version" for inspection by a
 Certification engineer.
plugin: attachment
command: tpm_version 2>&1
estimated_duration: 1s
flags: preserve-locale

unit: job
id: query/tpm_selftest
category_id: tpm
_summary: Collect the output of tpm_selftest
_description:
 This job collects the output of "tpm_selftest" for inspection by the
 Certification engineer.
plugin: attachment
command: tpm_selftest 2>&1
estimated_duration: 1s
flags: preserve-locale

unit: job
id: query/tpm_setactive-status
category_id: tpm
_summary: Collect the output of tpm_setactive --status --well-known
_description:
 This simply collects the output of "tpm_setactive --status --well-known" for
 inspection by a Certification engineer.
plugin: attachment
command: tpm_setactive --status --well-known 2>&1
estimated_duration: 1s
flags: preserve-locale

unit: job
id: query/tpm_nvinfo
category_id: tpm
_summary: Collect the output of tpm_nvinfo
_description:
 This simply collects the output of "tpm_nvinfo" for inspection by a
 Certification engineer.
plugin: attachment
command: tpm_nvinfo
estimated_duration: 1s
flags: preserve-locale

unit: job
id: query/tpm_restrictpubek-status
_summary: Collect the output of tpm_restrictpubek --status --well-known
_description:
 This simply collects the output of "tpm_restrictpubek --status --well-known"
 for inspection by a Certification engineer.
plugin: attachment
command: tpm_restrictpubek --status --well-known
estimated_duration: 1s
flags: preserve-locale

unit: job
id: query/tpm_restrictsrk-status
_summary: Collect the output of tpm_restrictsrk --status --well-known
_description:
 This simply collects the output of "tpm_restrictsrk --status --well-known"
 for inspection by a Certification engineer.
plugin: attachment
command: tpm_restrictsrk --status --well-known
estimated_duration: 1s
flags: preserve-locale

unit: job
id: query/tpm_setclearable-status
_summary: Collect the output of tpm_setclearable--status --well-known
_description:
 This simply collects the output of "tpm_setclearable --status --well-known"
 for inspection by a Certification engineer.
plugin: attachment
command: tpm_setclearable --status --well-known
estimated_duration: 1s
flags: preserve-locale

unit: job
id: query/tpm_setenable-status
_summary: Collect the output of tpm_setenable --status --well-known
_description:
 This simply collects the output of "tpm_setenable --status --well-known"
 for inspection by a Certification engineer.
plugin: attachment
command: tpm_setenable --status --well-known
estimated_duration: 1s
flags: preserve-locale

unit: job
id: query/tpm_setownable-status
_summary: Collect the output of tpm_setownable --status --well-known
_description:
 This simply collects the output of "tpm_setownable --status --well-known"
 for inspection by a Certification engineer.
plugin: attachment
command: tpm_setownable --status --well-known
estimated_duration: 1s
flags: preserve-locale

unit: job
id: query/tpm_setpresence -status
_summary: Collect the output of tpm_setpresence --status --well-known
_description:
 This simply collects the output of "tpm_setpresence --status --well-known"
 for inspection by a Certification engineer.
plugin: attachment
command: tpm_setpresence --status --well-known
estimated_duration: 1s
flags: preserve-locale

unit: job
id: query/tpm_getpubek
_summary: Collect the output of tpm_getpubek --well-known
_description:
 This simply collects the output of "tpm_getpubek --well-known"
 for inspection by a Certification engineer.
plugin: attachment
command: tpm_getpubek --well-known
estimated_duration: 1s
flags: preserve-locale