OLD | NEW |
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
4 * | 4 * |
5 * TPM command utility. Runs simple TPM commands. Mostly useful when physical | 5 * TPM command utility. Runs simple TPM commands. Mostly useful when physical |
6 * presence has not been locked. | 6 * presence has not been locked. |
7 */ | 7 */ |
8 | 8 |
9 #include <stdio.h> | 9 #include <stdio.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 fprintf(stderr, "<index> must be 32-bit hex (0x[0-9a-f]+)\n"); | 193 fprintf(stderr, "<index> must be 32-bit hex (0x[0-9a-f]+)\n"); |
194 exit(1); | 194 exit(1); |
195 } | 195 } |
196 result = TlclGetPermissions(index, &permissions); | 196 result = TlclGetPermissions(index, &permissions); |
197 if (result == 0) { | 197 if (result == 0) { |
198 printf("space 0x%x has permissions 0x%x\n", index, permissions); | 198 printf("space 0x%x has permissions 0x%x\n", index, permissions); |
199 } | 199 } |
200 return result; | 200 return result; |
201 } | 201 } |
202 | 202 |
| 203 static uint32_t HandlerGetPermanentFlags(void) { |
| 204 TPM_PERMANENT_FLAGS pflags; |
| 205 uint32_t result = TlclGetPermanentFlags(&pflags); |
| 206 if (result == 0) { |
| 207 #define P(name) printf("%s %d\n", #name, pflags.name) |
| 208 P(disable); |
| 209 P(ownership); |
| 210 P(deactivated); |
| 211 P(readPubek); |
| 212 P(disableOwnerClear); |
| 213 P(allowMaintenance); |
| 214 P(physicalPresenceLifetimeLock); |
| 215 P(physicalPresenceHWEnable); |
| 216 P(physicalPresenceCMDEnable); |
| 217 P(CEKPUsed); |
| 218 P(TPMpost); |
| 219 P(TPMpostLock); |
| 220 P(FIPS); |
| 221 P(Operator); |
| 222 P(enableRevokeEK); |
| 223 P(nvLocked); |
| 224 P(readSRKPub); |
| 225 P(tpmEstablished); |
| 226 P(maintenanceDone); |
| 227 P(disableFullDALogicInfo); |
| 228 #undef P |
| 229 } |
| 230 return result; |
| 231 } |
| 232 |
| 233 static uint32_t HandlerGetSTClearFlags(void) { |
| 234 TPM_STCLEAR_FLAGS vflags; |
| 235 uint32_t result = TlclGetSTClearFlags(&vflags); |
| 236 if (result == 0) { |
| 237 #define P(name) printf("%s %d\n", #name, vflags.name) |
| 238 P(deactivated); |
| 239 P(disableForceClear); |
| 240 P(physicalPresence); |
| 241 P(physicalPresenceLock); |
| 242 P(bGlobalLock); |
| 243 #undef P |
| 244 } |
| 245 return result; |
| 246 } |
| 247 |
| 248 |
203 /* Table of TPM commands. | 249 /* Table of TPM commands. |
204 */ | 250 */ |
205 command_record command_table[] = { | 251 command_record command_table[] = { |
206 { "getflags", "getf", "read and print the value of selected flags", | 252 { "getflags", "getf", "read and print the value of selected flags", |
207 HandlerGetFlags }, | 253 HandlerGetFlags }, |
208 { "startup", "sta", "issue a Startup command", TlclStartup }, | 254 { "startup", "sta", "issue a Startup command", TlclStartup }, |
209 { "selftestfull", "test", "issue a SelfTestFull command", TlclSelfTestFull }, | 255 { "selftestfull", "test", "issue a SelfTestFull command", TlclSelfTestFull }, |
210 { "continueselftest", "ctest", "issue a ContinueSelfTest command", | 256 { "continueselftest", "ctest", "issue a ContinueSelfTest command", |
211 TlclContinueSelfTest }, | 257 TlclContinueSelfTest }, |
212 { "assertphysicalpresence", "ppon", "assert Physical Presence", | 258 { "assertphysicalpresence", "ppon", "assert Physical Presence", |
(...skipping 12 matching lines...) Expand all Loading... |
225 { "setbgloballock", "block", "set the bGlobalLock until reboot", | 271 { "setbgloballock", "block", "set the bGlobalLock until reboot", |
226 TlclSetGlobalLock }, | 272 TlclSetGlobalLock }, |
227 { "definespace", "def", "define a space (def <index> <size> <perm>)", | 273 { "definespace", "def", "define a space (def <index> <size> <perm>)", |
228 HandlerDefineSpace }, | 274 HandlerDefineSpace }, |
229 { "write", "write", "write to a space (write <index> [<byte0> <byte1> ...])", | 275 { "write", "write", "write to a space (write <index> [<byte0> <byte1> ...])", |
230 HandlerWrite }, | 276 HandlerWrite }, |
231 { "read", "read", "read from a space (read <index> <size>)", | 277 { "read", "read", "read from a space (read <index> <size>)", |
232 HandlerRead }, | 278 HandlerRead }, |
233 { "getpermissions", "getp", "print space permissions (getp <index>)", | 279 { "getpermissions", "getp", "print space permissions (getp <index>)", |
234 HandlerGetPermissions }, | 280 HandlerGetPermissions }, |
| 281 { "getpermanentflags", "getpf", "print all permanent flags", |
| 282 HandlerGetPermanentFlags }, |
| 283 { "getstclearflags", "getvf", "print all volatile (ST_CLEAR) flags", |
| 284 HandlerGetSTClearFlags }, |
235 }; | 285 }; |
236 | 286 |
237 static int n_commands = sizeof(command_table) / sizeof(command_table[0]); | 287 static int n_commands = sizeof(command_table) / sizeof(command_table[0]); |
238 | 288 |
239 int main(int argc, char* argv[]) { | 289 int main(int argc, char* argv[]) { |
240 if (argc < 2) { | 290 if (argc < 2) { |
241 fprintf(stderr, "usage: %s <TPM command> [args]\n or: %s help\n", | 291 fprintf(stderr, "usage: %s <TPM command> [args]\n or: %s help\n", |
242 argv[0], argv[0]); | 292 argv[0], argv[0]); |
243 exit(1); | 293 exit(1); |
244 } else { | 294 } else { |
(...skipping 16 matching lines...) Expand all Loading... |
261 if (strcmp(cmd, c->name) == 0 || strcmp(cmd, c->abbr) == 0) { | 311 if (strcmp(cmd, c->name) == 0 || strcmp(cmd, c->abbr) == 0) { |
262 return ErrorCheck(c->handler(), cmd); | 312 return ErrorCheck(c->handler(), cmd); |
263 } | 313 } |
264 } | 314 } |
265 | 315 |
266 /* No command matched. */ | 316 /* No command matched. */ |
267 fprintf(stderr, "%s: unknown command: %s\n", argv[0], cmd); | 317 fprintf(stderr, "%s: unknown command: %s\n", argv[0], cmd); |
268 return 1; | 318 return 1; |
269 } | 319 } |
270 } | 320 } |
OLD | NEW |