]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - common/cmd_tpm.c
tpm: Report tpm errors on the command line
[karo-tx-uboot.git] / common / cmd_tpm.c
1 /*
2  * Copyright (c) 2013 The Chromium OS Authors.
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6
7 #include <common.h>
8 #include <command.h>
9 #include <dm.h>
10 #include <malloc.h>
11 #include <tpm.h>
12 #include <asm/unaligned.h>
13 #include <linux/string.h>
14
15 /* Useful constants */
16 enum {
17         DIGEST_LENGTH           = 20,
18         /* max lengths, valid for RSA keys <= 2048 bits */
19         TPM_PUBKEY_MAX_LENGTH   = 288,
20 };
21
22 /**
23  * Print a byte string in hexdecimal format, 16-bytes per line.
24  *
25  * @param data          byte string to be printed
26  * @param count         number of bytes to be printed
27  */
28 static void print_byte_string(uint8_t *data, size_t count)
29 {
30         int i, print_newline = 0;
31
32         for (i = 0; i < count; i++) {
33                 printf(" %02x", data[i]);
34                 print_newline = (i % 16 == 15);
35                 if (print_newline)
36                         putc('\n');
37         }
38         /* Avoid duplicated newline at the end */
39         if (!print_newline)
40                 putc('\n');
41 }
42
43 /**
44  * Convert a text string of hexdecimal values into a byte string.
45  *
46  * @param bytes         text string of hexdecimal values with no space
47  *                      between them
48  * @param data          output buffer for byte string.  The caller has to make
49  *                      sure it is large enough for storing the output.  If
50  *                      NULL is passed, a large enough buffer will be allocated,
51  *                      and the caller must free it.
52  * @param count_ptr     output variable for the length of byte string
53  * @return pointer to output buffer
54  */
55 static void *parse_byte_string(char *bytes, uint8_t *data, size_t *count_ptr)
56 {
57         char byte[3];
58         size_t count, length;
59         int i;
60
61         length = strlen(bytes);
62         count = length / 2;
63
64         if (!data)
65                 data = malloc(count);
66         if (!data)
67                 return NULL;
68
69         byte[2] = '\0';
70         for (i = 0; i < length; i += 2) {
71                 byte[0] = bytes[i];
72                 byte[1] = bytes[i + 1];
73                 data[i / 2] = (uint8_t)simple_strtoul(byte, NULL, 16);
74         }
75
76         if (count_ptr)
77                 *count_ptr = count;
78
79         return data;
80 }
81
82 /**
83  * report_return_code() - Report any error and return failure or success
84  *
85  * @param return_code   TPM command return code
86  * @return value of enum command_ret_t
87  */
88 static int report_return_code(int return_code)
89 {
90         if (return_code) {
91                 printf("Error: %d\n", return_code);
92                 return CMD_RET_FAILURE;
93         } else {
94                 return CMD_RET_SUCCESS;
95         }
96 }
97
98 /**
99  * Return number of values defined by a type string.
100  *
101  * @param type_str      type string
102  * @return number of values of type string
103  */
104 static int type_string_get_num_values(const char *type_str)
105 {
106         return strlen(type_str);
107 }
108
109 /**
110  * Return total size of values defined by a type string.
111  *
112  * @param type_str      type string
113  * @return total size of values of type string, or 0 if type string
114  *  contains illegal type character.
115  */
116 static size_t type_string_get_space_size(const char *type_str)
117 {
118         size_t size;
119
120         for (size = 0; *type_str; type_str++) {
121                 switch (*type_str) {
122                 case 'b':
123                         size += 1;
124                         break;
125                 case 'w':
126                         size += 2;
127                         break;
128                 case 'd':
129                         size += 4;
130                         break;
131                 default:
132                         return 0;
133                 }
134         }
135
136         return size;
137 }
138
139 /**
140  * Allocate a buffer large enough to hold values defined by a type
141  * string.  The caller has to free the buffer.
142  *
143  * @param type_str      type string
144  * @param count         pointer for storing size of buffer
145  * @return pointer to buffer or NULL on error
146  */
147 static void *type_string_alloc(const char *type_str, uint32_t *count)
148 {
149         void *data;
150         size_t size;
151
152         size = type_string_get_space_size(type_str);
153         if (!size)
154                 return NULL;
155         data = malloc(size);
156         if (data)
157                 *count = size;
158
159         return data;
160 }
161
162 /**
163  * Pack values defined by a type string into a buffer.  The buffer must have
164  * large enough space.
165  *
166  * @param type_str      type string
167  * @param values        text strings of values to be packed
168  * @param data          output buffer of values
169  * @return 0 on success, non-0 on error
170  */
171 static int type_string_pack(const char *type_str, char * const values[],
172                 uint8_t *data)
173 {
174         size_t offset;
175         uint32_t value;
176
177         for (offset = 0; *type_str; type_str++, values++) {
178                 value = simple_strtoul(values[0], NULL, 0);
179                 switch (*type_str) {
180                 case 'b':
181                         data[offset] = value;
182                         offset += 1;
183                         break;
184                 case 'w':
185                         put_unaligned_be16(value, data + offset);
186                         offset += 2;
187                         break;
188                 case 'd':
189                         put_unaligned_be32(value, data + offset);
190                         offset += 4;
191                         break;
192                 default:
193                         return -1;
194                 }
195         }
196
197         return 0;
198 }
199
200 /**
201  * Read values defined by a type string from a buffer, and write these values
202  * to environment variables.
203  *
204  * @param type_str      type string
205  * @param data          input buffer of values
206  * @param vars          names of environment variables
207  * @return 0 on success, non-0 on error
208  */
209 static int type_string_write_vars(const char *type_str, uint8_t *data,
210                 char * const vars[])
211 {
212         size_t offset;
213         uint32_t value;
214
215         for (offset = 0; *type_str; type_str++, vars++) {
216                 switch (*type_str) {
217                 case 'b':
218                         value = data[offset];
219                         offset += 1;
220                         break;
221                 case 'w':
222                         value = get_unaligned_be16(data + offset);
223                         offset += 2;
224                         break;
225                 case 'd':
226                         value = get_unaligned_be32(data + offset);
227                         offset += 4;
228                         break;
229                 default:
230                         return -1;
231                 }
232                 if (setenv_ulong(*vars, value))
233                         return -1;
234         }
235
236         return 0;
237 }
238
239 static int do_tpm_startup(cmd_tbl_t *cmdtp, int flag,
240                 int argc, char * const argv[])
241 {
242         enum tpm_startup_type mode;
243
244         if (argc != 2)
245                 return CMD_RET_USAGE;
246         if (!strcasecmp("TPM_ST_CLEAR", argv[1])) {
247                 mode = TPM_ST_CLEAR;
248         } else if (!strcasecmp("TPM_ST_STATE", argv[1])) {
249                 mode = TPM_ST_STATE;
250         } else if (!strcasecmp("TPM_ST_DEACTIVATED", argv[1])) {
251                 mode = TPM_ST_DEACTIVATED;
252         } else {
253                 printf("Couldn't recognize mode string: %s\n", argv[1]);
254                 return CMD_RET_FAILURE;
255         }
256
257         return report_return_code(tpm_startup(mode));
258 }
259
260 static int do_tpm_nv_define_space(cmd_tbl_t *cmdtp, int flag,
261                 int argc, char * const argv[])
262 {
263         uint32_t index, perm, size;
264
265         if (argc != 4)
266                 return CMD_RET_USAGE;
267         index = simple_strtoul(argv[1], NULL, 0);
268         perm = simple_strtoul(argv[2], NULL, 0);
269         size = simple_strtoul(argv[3], NULL, 0);
270
271         return report_return_code(tpm_nv_define_space(index, perm, size));
272 }
273
274 static int do_tpm_nv_read_value(cmd_tbl_t *cmdtp, int flag,
275                 int argc, char * const argv[])
276 {
277         uint32_t index, count, rc;
278         void *data;
279
280         if (argc != 4)
281                 return CMD_RET_USAGE;
282         index = simple_strtoul(argv[1], NULL, 0);
283         data = (void *)simple_strtoul(argv[2], NULL, 0);
284         count = simple_strtoul(argv[3], NULL, 0);
285
286         rc = tpm_nv_read_value(index, data, count);
287         if (!rc) {
288                 puts("area content:\n");
289                 print_byte_string(data, count);
290         }
291
292         return report_return_code(rc);
293 }
294
295 static int do_tpm_nv_write_value(cmd_tbl_t *cmdtp, int flag,
296                 int argc, char * const argv[])
297 {
298         uint32_t index, rc;
299         size_t count;
300         void *data;
301
302         if (argc != 3)
303                 return CMD_RET_USAGE;
304         index = simple_strtoul(argv[1], NULL, 0);
305         data = parse_byte_string(argv[2], NULL, &count);
306         if (!data) {
307                 printf("Couldn't parse byte string %s\n", argv[2]);
308                 return CMD_RET_FAILURE;
309         }
310
311         rc = tpm_nv_write_value(index, data, count);
312         free(data);
313
314         return report_return_code(rc);
315 }
316
317 static int do_tpm_extend(cmd_tbl_t *cmdtp, int flag,
318                 int argc, char * const argv[])
319 {
320         uint32_t index, rc;
321         uint8_t in_digest[20], out_digest[20];
322
323         if (argc != 3)
324                 return CMD_RET_USAGE;
325         index = simple_strtoul(argv[1], NULL, 0);
326         if (!parse_byte_string(argv[2], in_digest, NULL)) {
327                 printf("Couldn't parse byte string %s\n", argv[2]);
328                 return CMD_RET_FAILURE;
329         }
330
331         rc = tpm_extend(index, in_digest, out_digest);
332         if (!rc) {
333                 puts("PCR value after execution of the command:\n");
334                 print_byte_string(out_digest, sizeof(out_digest));
335         }
336
337         return report_return_code(rc);
338 }
339
340 static int do_tpm_pcr_read(cmd_tbl_t *cmdtp, int flag,
341                 int argc, char * const argv[])
342 {
343         uint32_t index, count, rc;
344         void *data;
345
346         if (argc != 4)
347                 return CMD_RET_USAGE;
348         index = simple_strtoul(argv[1], NULL, 0);
349         data = (void *)simple_strtoul(argv[2], NULL, 0);
350         count = simple_strtoul(argv[3], NULL, 0);
351
352         rc = tpm_pcr_read(index, data, count);
353         if (!rc) {
354                 puts("Named PCR content:\n");
355                 print_byte_string(data, count);
356         }
357
358         return report_return_code(rc);
359 }
360
361 static int do_tpm_tsc_physical_presence(cmd_tbl_t *cmdtp, int flag,
362                 int argc, char * const argv[])
363 {
364         uint16_t presence;
365
366         if (argc != 2)
367                 return CMD_RET_USAGE;
368         presence = (uint16_t)simple_strtoul(argv[1], NULL, 0);
369
370         return report_return_code(tpm_tsc_physical_presence(presence));
371 }
372
373 static int do_tpm_read_pubek(cmd_tbl_t *cmdtp, int flag,
374                 int argc, char * const argv[])
375 {
376         uint32_t count, rc;
377         void *data;
378
379         if (argc != 3)
380                 return CMD_RET_USAGE;
381         data = (void *)simple_strtoul(argv[1], NULL, 0);
382         count = simple_strtoul(argv[2], NULL, 0);
383
384         rc = tpm_read_pubek(data, count);
385         if (!rc) {
386                 puts("pubek value:\n");
387                 print_byte_string(data, count);
388         }
389
390         return report_return_code(rc);
391 }
392
393 static int do_tpm_physical_set_deactivated(cmd_tbl_t *cmdtp, int flag,
394                 int argc, char * const argv[])
395 {
396         uint8_t state;
397
398         if (argc != 2)
399                 return CMD_RET_USAGE;
400         state = (uint8_t)simple_strtoul(argv[1], NULL, 0);
401
402         return report_return_code(tpm_physical_set_deactivated(state));
403 }
404
405 static int do_tpm_get_capability(cmd_tbl_t *cmdtp, int flag,
406                 int argc, char * const argv[])
407 {
408         uint32_t cap_area, sub_cap, rc;
409         void *cap;
410         size_t count;
411
412         if (argc != 5)
413                 return CMD_RET_USAGE;
414         cap_area = simple_strtoul(argv[1], NULL, 0);
415         sub_cap = simple_strtoul(argv[2], NULL, 0);
416         cap = (void *)simple_strtoul(argv[3], NULL, 0);
417         count = simple_strtoul(argv[4], NULL, 0);
418
419         rc = tpm_get_capability(cap_area, sub_cap, cap, count);
420         if (!rc) {
421                 puts("capability information:\n");
422                 print_byte_string(cap, count);
423         }
424
425         return report_return_code(rc);
426 }
427
428 #define TPM_COMMAND_NO_ARG(cmd)                         \
429 static int do_##cmd(cmd_tbl_t *cmdtp, int flag,         \
430                 int argc, char * const argv[])          \
431 {                                                       \
432         if (argc != 1)                                  \
433                 return CMD_RET_USAGE;                   \
434         return report_return_code(cmd());               \
435 }
436
437 TPM_COMMAND_NO_ARG(tpm_init)
438 TPM_COMMAND_NO_ARG(tpm_self_test_full)
439 TPM_COMMAND_NO_ARG(tpm_continue_self_test)
440 TPM_COMMAND_NO_ARG(tpm_force_clear)
441 TPM_COMMAND_NO_ARG(tpm_physical_enable)
442 TPM_COMMAND_NO_ARG(tpm_physical_disable)
443
444 #ifdef CONFIG_DM_TPM
445 static int get_tpm(struct udevice **devp)
446 {
447         int rc;
448
449         rc = uclass_first_device(UCLASS_TPM, devp);
450         if (rc) {
451                 printf("Could not find TPM (ret=%d)\n", rc);
452                 return CMD_RET_FAILURE;
453         }
454
455         return 0;
456 }
457 #endif
458
459 static int do_tpm_raw_transfer(cmd_tbl_t *cmdtp, int flag,
460                 int argc, char * const argv[])
461 {
462         void *command;
463         uint8_t response[1024];
464         size_t count, response_length = sizeof(response);
465         uint32_t rc;
466
467         command = parse_byte_string(argv[1], NULL, &count);
468         if (!command) {
469                 printf("Couldn't parse byte string %s\n", argv[1]);
470                 return CMD_RET_FAILURE;
471         }
472
473 #ifdef CONFIG_DM_TPM
474         struct udevice *dev;
475
476         rc = get_tpm(&dev);
477         if (rc)
478                 return rc;
479
480         rc = tpm_xfer(dev, command, count, response, &response_length);
481 #else
482         rc = tis_sendrecv(command, count, response, &response_length);
483 #endif
484         free(command);
485         if (!rc) {
486                 puts("tpm response:\n");
487                 print_byte_string(response, response_length);
488         }
489
490         return report_return_code(rc);
491 }
492
493 static int do_tpm_nv_define(cmd_tbl_t *cmdtp, int flag,
494                 int argc, char * const argv[])
495 {
496         uint32_t index, perm, size;
497
498         if (argc != 4)
499                 return CMD_RET_USAGE;
500         size = type_string_get_space_size(argv[1]);
501         if (!size) {
502                 printf("Couldn't parse arguments\n");
503                 return CMD_RET_USAGE;
504         }
505         index = simple_strtoul(argv[2], NULL, 0);
506         perm = simple_strtoul(argv[3], NULL, 0);
507
508         return report_return_code(tpm_nv_define_space(index, perm, size));
509 }
510
511 static int do_tpm_nv_read(cmd_tbl_t *cmdtp, int flag,
512                 int argc, char * const argv[])
513 {
514         uint32_t index, count, err;
515         void *data;
516
517         if (argc < 3)
518                 return CMD_RET_USAGE;
519         if (argc != 3 + type_string_get_num_values(argv[1]))
520                 return CMD_RET_USAGE;
521         index = simple_strtoul(argv[2], NULL, 0);
522         data = type_string_alloc(argv[1], &count);
523         if (!data) {
524                 printf("Couldn't parse arguments\n");
525                 return CMD_RET_USAGE;
526         }
527
528         err = tpm_nv_read_value(index, data, count);
529         if (!err) {
530                 if (type_string_write_vars(argv[1], data, argv + 3)) {
531                         printf("Couldn't write to variables\n");
532                         err = ~0;
533                 }
534         }
535         free(data);
536
537         return report_return_code(err);
538 }
539
540 static int do_tpm_nv_write(cmd_tbl_t *cmdtp, int flag,
541                 int argc, char * const argv[])
542 {
543         uint32_t index, count, err;
544         void *data;
545
546         if (argc < 3)
547                 return CMD_RET_USAGE;
548         if (argc != 3 + type_string_get_num_values(argv[1]))
549                 return CMD_RET_USAGE;
550         index = simple_strtoul(argv[2], NULL, 0);
551         data = type_string_alloc(argv[1], &count);
552         if (!data) {
553                 printf("Couldn't parse arguments\n");
554                 return CMD_RET_USAGE;
555         }
556         if (type_string_pack(argv[1], argv + 3, data)) {
557                 printf("Couldn't parse arguments\n");
558                 free(data);
559                 return CMD_RET_USAGE;
560         }
561
562         err = tpm_nv_write_value(index, data, count);
563         free(data);
564
565         return report_return_code(err);
566 }
567
568 #ifdef CONFIG_TPM_AUTH_SESSIONS
569
570 static int do_tpm_oiap(cmd_tbl_t *cmdtp, int flag,
571                 int argc, char * const argv[])
572 {
573         uint32_t auth_handle, err;
574
575         err = tpm_oiap(&auth_handle);
576
577         return report_return_code(err);
578 }
579
580 static int do_tpm_load_key2_oiap(cmd_tbl_t *cmdtp, int flag,
581                 int argc, char * const argv[])
582 {
583         uint32_t parent_handle, key_len, key_handle, err;
584         uint8_t usage_auth[DIGEST_LENGTH];
585         void *key;
586
587         if (argc < 5)
588                 return CMD_RET_USAGE;
589
590         parent_handle = simple_strtoul(argv[1], NULL, 0);
591         key = (void *)simple_strtoul(argv[2], NULL, 0);
592         key_len = simple_strtoul(argv[3], NULL, 0);
593         if (strlen(argv[4]) != 2 * DIGEST_LENGTH)
594                 return CMD_RET_FAILURE;
595         parse_byte_string(argv[4], usage_auth, NULL);
596
597         err = tpm_load_key2_oiap(parent_handle, key, key_len, usage_auth,
598                         &key_handle);
599         if (!err)
600                 printf("Key handle is 0x%x\n", key_handle);
601
602         return report_return_code(err);
603 }
604
605 static int do_tpm_get_pub_key_oiap(cmd_tbl_t *cmdtp, int flag,
606                 int argc, char * const argv[])
607 {
608         uint32_t key_handle, err;
609         uint8_t usage_auth[DIGEST_LENGTH];
610         uint8_t pub_key_buffer[TPM_PUBKEY_MAX_LENGTH];
611         size_t pub_key_len = sizeof(pub_key_buffer);
612
613         if (argc < 3)
614                 return CMD_RET_USAGE;
615
616         key_handle = simple_strtoul(argv[1], NULL, 0);
617         if (strlen(argv[2]) != 2 * DIGEST_LENGTH)
618                 return CMD_RET_FAILURE;
619         parse_byte_string(argv[2], usage_auth, NULL);
620
621         err = tpm_get_pub_key_oiap(key_handle, usage_auth,
622                         pub_key_buffer, &pub_key_len);
623         if (!err) {
624                 printf("dump of received pub key structure:\n");
625                 print_byte_string(pub_key_buffer, pub_key_len);
626         }
627         return report_return_code(err);
628 }
629
630 TPM_COMMAND_NO_ARG(tpm_end_oiap)
631
632 #endif /* CONFIG_TPM_AUTH_SESSIONS */
633
634 #define MAKE_TPM_CMD_ENTRY(cmd) \
635         U_BOOT_CMD_MKENT(cmd, 0, 1, do_tpm_ ## cmd, "", "")
636
637 static cmd_tbl_t tpm_commands[] = {
638         U_BOOT_CMD_MKENT(init, 0, 1,
639                         do_tpm_init, "", ""),
640         U_BOOT_CMD_MKENT(startup, 0, 1,
641                         do_tpm_startup, "", ""),
642         U_BOOT_CMD_MKENT(self_test_full, 0, 1,
643                         do_tpm_self_test_full, "", ""),
644         U_BOOT_CMD_MKENT(continue_self_test, 0, 1,
645                         do_tpm_continue_self_test, "", ""),
646         U_BOOT_CMD_MKENT(force_clear, 0, 1,
647                         do_tpm_force_clear, "", ""),
648         U_BOOT_CMD_MKENT(physical_enable, 0, 1,
649                         do_tpm_physical_enable, "", ""),
650         U_BOOT_CMD_MKENT(physical_disable, 0, 1,
651                         do_tpm_physical_disable, "", ""),
652         U_BOOT_CMD_MKENT(nv_define_space, 0, 1,
653                         do_tpm_nv_define_space, "", ""),
654         U_BOOT_CMD_MKENT(nv_read_value, 0, 1,
655                         do_tpm_nv_read_value, "", ""),
656         U_BOOT_CMD_MKENT(nv_write_value, 0, 1,
657                         do_tpm_nv_write_value, "", ""),
658         U_BOOT_CMD_MKENT(extend, 0, 1,
659                         do_tpm_extend, "", ""),
660         U_BOOT_CMD_MKENT(pcr_read, 0, 1,
661                         do_tpm_pcr_read, "", ""),
662         U_BOOT_CMD_MKENT(tsc_physical_presence, 0, 1,
663                         do_tpm_tsc_physical_presence, "", ""),
664         U_BOOT_CMD_MKENT(read_pubek, 0, 1,
665                         do_tpm_read_pubek, "", ""),
666         U_BOOT_CMD_MKENT(physical_set_deactivated, 0, 1,
667                         do_tpm_physical_set_deactivated, "", ""),
668         U_BOOT_CMD_MKENT(get_capability, 0, 1,
669                         do_tpm_get_capability, "", ""),
670         U_BOOT_CMD_MKENT(raw_transfer, 0, 1,
671                         do_tpm_raw_transfer, "", ""),
672         U_BOOT_CMD_MKENT(nv_define, 0, 1,
673                         do_tpm_nv_define, "", ""),
674         U_BOOT_CMD_MKENT(nv_read, 0, 1,
675                         do_tpm_nv_read, "", ""),
676         U_BOOT_CMD_MKENT(nv_write, 0, 1,
677                         do_tpm_nv_write, "", ""),
678 #ifdef CONFIG_TPM_AUTH_SESSIONS
679         U_BOOT_CMD_MKENT(oiap, 0, 1,
680                          do_tpm_oiap, "", ""),
681         U_BOOT_CMD_MKENT(end_oiap, 0, 1,
682                          do_tpm_end_oiap, "", ""),
683         U_BOOT_CMD_MKENT(load_key2_oiap, 0, 1,
684                          do_tpm_load_key2_oiap, "", ""),
685         U_BOOT_CMD_MKENT(get_pub_key_oiap, 0, 1,
686                          do_tpm_get_pub_key_oiap, "", ""),
687 #endif /* CONFIG_TPM_AUTH_SESSIONS */
688 };
689
690 static int do_tpm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
691 {
692         cmd_tbl_t *tpm_cmd;
693
694         if (argc < 2)
695                 return CMD_RET_USAGE;
696         tpm_cmd = find_cmd_tbl(argv[1], tpm_commands, ARRAY_SIZE(tpm_commands));
697         if (!tpm_cmd)
698                 return CMD_RET_USAGE;
699
700         return tpm_cmd->cmd(cmdtp, flag, argc - 1, argv + 1);
701 }
702
703 U_BOOT_CMD(tpm, CONFIG_SYS_MAXARGS, 1, do_tpm,
704 "Issue a TPM command",
705 "cmd args...\n"
706 "    - Issue TPM command <cmd> with arguments <args...>.\n"
707 "Admin Startup and State Commands:\n"
708 "  init\n"
709 "    - Put TPM into a state where it waits for 'startup' command.\n"
710 "  startup mode\n"
711 "    - Issue TPM_Starup command.  <mode> is one of TPM_ST_CLEAR,\n"
712 "      TPM_ST_STATE, and TPM_ST_DEACTIVATED.\n"
713 "Admin Testing Commands:\n"
714 "  self_test_full\n"
715 "    - Test all of the TPM capabilities.\n"
716 "  continue_self_test\n"
717 "    - Inform TPM that it should complete the self-test.\n"
718 "Admin Opt-in Commands:\n"
719 "  physical_enable\n"
720 "    - Set the PERMANENT disable flag to FALSE using physical presence as\n"
721 "      authorization.\n"
722 "  physical_disable\n"
723 "    - Set the PERMANENT disable flag to TRUE using physical presence as\n"
724 "      authorization.\n"
725 "  physical_set_deactivated 0|1\n"
726 "    - Set deactivated flag.\n"
727 "Admin Ownership Commands:\n"
728 "  force_clear\n"
729 "    - Issue TPM_ForceClear command.\n"
730 "  tsc_physical_presence flags\n"
731 "    - Set TPM device's Physical Presence flags to <flags>.\n"
732 "The Capability Commands:\n"
733 "  get_capability cap_area sub_cap addr count\n"
734 "    - Read <count> bytes of TPM capability indexed by <cap_area> and\n"
735 "      <sub_cap> to memory address <addr>.\n"
736 #ifdef CONFIG_TPM_AUTH_SESSIONS
737 "Storage functions\n"
738 "  loadkey2_oiap parent_handle key_addr key_len usage_auth\n"
739 "    - loads a key data from memory address <key_addr>, <key_len> bytes\n"
740 "      into TPM using the parent key <parent_handle> with authorization\n"
741 "      <usage_auth> (20 bytes hex string).\n"
742 "  get_pub_key_oiap key_handle usage_auth\n"
743 "    - get the public key portion of a loaded key <key_handle> using\n"
744 "      authorization <usage auth> (20 bytes hex string)\n"
745 #endif /* CONFIG_TPM_AUTH_SESSIONS */
746 "Endorsement Key Handling Commands:\n"
747 "  read_pubek addr count\n"
748 "    - Read <count> bytes of the public endorsement key to memory\n"
749 "      address <addr>\n"
750 "Integrity Collection and Reporting Commands:\n"
751 "  extend index digest_hex_string\n"
752 "    - Add a new measurement to a PCR.  Update PCR <index> with the 20-bytes\n"
753 "      <digest_hex_string>\n"
754 "  pcr_read index addr count\n"
755 "    - Read <count> bytes from PCR <index> to memory address <addr>.\n"
756 #ifdef CONFIG_TPM_AUTH_SESSIONS
757 "Authorization Sessions\n"
758 "  oiap\n"
759 "    - setup an OIAP session\n"
760 "  end_oiap\n"
761 "    - terminates an active OIAP session\n"
762 #endif /* CONFIG_TPM_AUTH_SESSIONS */
763 "Non-volatile Storage Commands:\n"
764 "  nv_define_space index permission size\n"
765 "    - Establish a space at index <index> with <permission> of <size> bytes.\n"
766 "  nv_read_value index addr count\n"
767 "    - Read <count> bytes from space <index> to memory address <addr>.\n"
768 "  nv_write_value index addr count\n"
769 "    - Write <count> bytes from memory address <addr> to space <index>.\n"
770 "Miscellaneous helper functions:\n"
771 "  raw_transfer byte_string\n"
772 "    - Send a byte string <byte_string> to TPM and print the response.\n"
773 " Non-volatile storage helper functions:\n"
774 "    These helper functions treat a non-volatile space as a non-padded\n"
775 "    sequence of integer values.  These integer values are defined by a type\n"
776 "    string, which is a text string of 'bwd' characters: 'b' means a 8-bit\n"
777 "    value, 'w' 16-bit value, 'd' 32-bit value.  All helper functions take\n"
778 "    a type string as their first argument.\n"
779 "  nv_define type_string index perm\n"
780 "    - Define a space <index> with permission <perm>.\n"
781 "  nv_read types_string index vars...\n"
782 "    - Read from space <index> to environment variables <vars...>.\n"
783 "  nv_write types_string index values...\n"
784 "    - Write to space <index> from values <values...>.\n"
785 );