summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/tpm-v1.c25
-rw-r--r--cmd/tpm_test.c40
2 files changed, 35 insertions, 30 deletions
diff --git a/cmd/tpm-v1.c b/cmd/tpm-v1.c
index 0e2168aea6..3a7e35d525 100644
--- a/cmd/tpm-v1.c
+++ b/cmd/tpm-v1.c
@@ -11,6 +11,7 @@
#include <tpm-common.h>
#include <tpm-v1.h>
#include "tpm-user-utils.h"
+#include <tpm_api.h>
static int do_tpm_startup(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
@@ -55,7 +56,7 @@ static int do_tpm_nv_define_space(struct cmd_tbl *cmdtp, int flag, int argc,
perm = simple_strtoul(argv[2], NULL, 0);
size = simple_strtoul(argv[3], NULL, 0);
- return report_return_code(tpm_nv_define_space(dev, index, perm, size));
+ return report_return_code(tpm1_nv_define_space(dev, index, perm, size));
}
static int do_tpm_nv_read_value(struct cmd_tbl *cmdtp, int flag, int argc,
@@ -130,7 +131,7 @@ static int do_tpm_extend(struct cmd_tbl *cmdtp, int flag, int argc,
return CMD_RET_FAILURE;
}
- rc = tpm_extend(dev, index, in_digest, out_digest);
+ rc = tpm_pcr_extend(dev, index, in_digest, out_digest);
if (!rc) {
puts("PCR value after execution of the command:\n");
print_byte_string(out_digest, sizeof(out_digest));
@@ -304,7 +305,7 @@ static int do_tpm_nv_define(struct cmd_tbl *cmdtp, int flag, int argc,
index = simple_strtoul(argv[2], NULL, 0);
perm = simple_strtoul(argv[3], NULL, 0);
- return report_return_code(tpm_nv_define_space(dev, index, perm, size));
+ return report_return_code(tpm1_nv_define_space(dev, index, perm, size));
}
static int do_tpm_nv_read(struct cmd_tbl *cmdtp, int flag, int argc,
@@ -389,7 +390,7 @@ static int do_tpm_oiap(struct cmd_tbl *cmdtp, int flag, int argc,
if (rc)
return rc;
- err = tpm_oiap(dev, &auth_handle);
+ err = tpm1_oiap(dev, &auth_handle);
return report_return_code(err);
}
@@ -461,8 +462,8 @@ static int do_tpm_load_key2_oiap(struct cmd_tbl *cmdtp, int flag, int argc,
return CMD_RET_FAILURE;
parse_byte_string(argv[4], usage_auth, NULL);
- err = tpm_load_key2_oiap(dev, parent_handle, key, key_len, usage_auth,
- &key_handle);
+ err = tpm1_load_key2_oiap(dev, parent_handle, key, key_len, usage_auth,
+ &key_handle);
if (!err)
printf("Key handle is 0x%x\n", key_handle);
@@ -491,8 +492,8 @@ static int do_tpm_get_pub_key_oiap(struct cmd_tbl *cmdtp, int flag, int argc,
return CMD_RET_FAILURE;
parse_byte_string(argv[2], usage_auth, NULL);
- err = tpm_get_pub_key_oiap(dev, key_handle, usage_auth, pub_key_buffer,
- &pub_key_len);
+ err = tpm1_get_pub_key_oiap(dev, key_handle, usage_auth, pub_key_buffer,
+ &pub_key_len);
if (!err) {
printf("dump of received pub key structure:\n");
print_byte_string(pub_key_buffer, pub_key_len);
@@ -500,7 +501,7 @@ static int do_tpm_get_pub_key_oiap(struct cmd_tbl *cmdtp, int flag, int argc,
return report_return_code(err);
}
-TPM_COMMAND_NO_ARG(tpm_end_oiap)
+TPM_COMMAND_NO_ARG(tpm1_end_oiap)
#endif /* CONFIG_TPM_AUTH_SESSIONS */
@@ -562,7 +563,7 @@ static int do_tpm_flush(struct cmd_tbl *cmdtp, int flag, int argc,
res_count = get_unaligned_be16(buf);
ptr = buf + 2;
for (i = 0; i < res_count; ++i, ptr += 4)
- tpm_flush_specific(dev, get_unaligned_be32(ptr), type);
+ tpm1_flush_specific(dev, get_unaligned_be32(ptr), type);
} else {
u32 handle = simple_strtoul(argv[2], NULL, 0);
@@ -570,7 +571,7 @@ static int do_tpm_flush(struct cmd_tbl *cmdtp, int flag, int argc,
printf("Illegal resource handle %s\n", argv[2]);
return -1;
}
- tpm_flush_specific(dev, cpu_to_be32(handle), type);
+ tpm1_flush_specific(dev, cpu_to_be32(handle), type);
}
return 0;
@@ -691,7 +692,7 @@ static struct cmd_tbl tpm1_commands[] = {
U_BOOT_CMD_MKENT(oiap, 0, 1,
do_tpm_oiap, "", ""),
U_BOOT_CMD_MKENT(end_oiap, 0, 1,
- do_tpm_end_oiap, "", ""),
+ do_tpm1_end_oiap, "", ""),
U_BOOT_CMD_MKENT(load_key2_oiap, 0, 1,
do_tpm_load_key2_oiap, "", ""),
#ifdef CONFIG_TPM_LOAD_KEY_BY_SHA1
diff --git a/cmd/tpm_test.c b/cmd/tpm_test.c
index 3fb964c371..a3ccb12f53 100644
--- a/cmd/tpm_test.c
+++ b/cmd/tpm_test.c
@@ -9,6 +9,7 @@
#include <log.h>
#include <tpm-v1.h>
#include "tpm-user-utils.h"
+#include <tpm_api.h>
/* Prints error and returns on failure */
#define TPM_CHECK(tpm_command) do { \
@@ -49,7 +50,7 @@ static uint32_t tpm_get_flags(struct udevice *dev, uint8_t *disable,
struct tpm_permanent_flags pflags;
uint32_t result;
- result = tpm_get_permanent_flags(dev, &pflags);
+ result = tpm1_get_permanent_flags(dev, &pflags);
if (result)
return result;
if (disable)
@@ -90,7 +91,7 @@ static int test_early_extend(struct udevice *dev)
tpm_init(dev);
TPM_CHECK(tpm_startup(dev, TPM_ST_CLEAR));
TPM_CHECK(tpm_continue_self_test(dev));
- TPM_CHECK(tpm_extend(dev, 1, value_in, value_out));
+ TPM_CHECK(tpm_pcr_extend(dev, 1, value_in, value_out));
printf("done\n");
return 0;
}
@@ -238,18 +239,18 @@ static void initialise_spaces(struct udevice *dev)
uint32_t perm = TPM_NV_PER_WRITE_STCLEAR | TPM_NV_PER_PPWRITE;
printf("\tInitialising spaces\n");
- tpm_nv_set_locked(dev); /* useful only the first time */
- tpm_nv_define_space(dev, INDEX0, perm, 4);
+ tpm1_nv_set_locked(dev); /* useful only the first time */
+ tpm1_nv_define_space(dev, INDEX0, perm, 4);
tpm_nv_write_value(dev, INDEX0, (uint8_t *)&zero, 4);
- tpm_nv_define_space(dev, INDEX1, perm, 4);
+ tpm1_nv_define_space(dev, INDEX1, perm, 4);
tpm_nv_write_value(dev, INDEX1, (uint8_t *)&zero, 4);
- tpm_nv_define_space(dev, INDEX2, perm, 4);
+ tpm1_nv_define_space(dev, INDEX2, perm, 4);
tpm_nv_write_value(dev, INDEX2, (uint8_t *)&zero, 4);
- tpm_nv_define_space(dev, INDEX3, perm, 4);
+ tpm1_nv_define_space(dev, INDEX3, perm, 4);
tpm_nv_write_value(dev, INDEX3, (uint8_t *)&zero, 4);
perm = TPM_NV_PER_READ_STCLEAR | TPM_NV_PER_WRITE_STCLEAR |
TPM_NV_PER_PPWRITE;
- tpm_nv_define_space(dev, INDEX_INITIALISED, perm, 1);
+ tpm1_nv_define_space(dev, INDEX_INITIALISED, perm, 1);
}
static int test_readonly(struct udevice *dev)
@@ -325,30 +326,33 @@ static int test_redefine_unowned(struct udevice *dev)
/* Redefines spaces a couple of times. */
perm = TPM_NV_PER_PPWRITE | TPM_NV_PER_GLOBALLOCK;
- TPM_CHECK(tpm_nv_define_space(dev, INDEX0, perm, 2 * sizeof(uint32_t)));
- TPM_CHECK(tpm_nv_define_space(dev, INDEX0, perm, sizeof(uint32_t)));
+ TPM_CHECK(tpm1_nv_define_space(dev, INDEX0, perm,
+ 2 * sizeof(uint32_t)));
+ TPM_CHECK(tpm1_nv_define_space(dev, INDEX0, perm, sizeof(uint32_t)));
perm = TPM_NV_PER_PPWRITE;
- TPM_CHECK(tpm_nv_define_space(dev, INDEX1, perm, 2 * sizeof(uint32_t)));
- TPM_CHECK(tpm_nv_define_space(dev, INDEX1, perm, sizeof(uint32_t)));
+ TPM_CHECK(tpm1_nv_define_space(dev, INDEX1, perm,
+ 2 * sizeof(uint32_t)));
+ TPM_CHECK(tpm1_nv_define_space(dev, INDEX1, perm, sizeof(uint32_t)));
/* Sets the global lock */
tpm_set_global_lock(dev);
/* Verifies that index0 cannot be redefined */
- result = tpm_nv_define_space(dev, INDEX0, perm, sizeof(uint32_t));
+ result = tpm1_nv_define_space(dev, INDEX0, perm, sizeof(uint32_t));
assert(result == TPM_AREA_LOCKED);
/* Checks that index1 can */
- TPM_CHECK(tpm_nv_define_space(dev, INDEX1, perm, 2 * sizeof(uint32_t)));
- TPM_CHECK(tpm_nv_define_space(dev, INDEX1, perm, sizeof(uint32_t)));
+ TPM_CHECK(tpm1_nv_define_space(dev, INDEX1, perm,
+ 2 * sizeof(uint32_t)));
+ TPM_CHECK(tpm1_nv_define_space(dev, INDEX1, perm, sizeof(uint32_t)));
/* Turns off PP */
tpm_tsc_physical_presence(dev, PHYS_PRESENCE);
/* Verifies that neither index0 nor index1 can be redefined */
- result = tpm_nv_define_space(dev, INDEX0, perm, sizeof(uint32_t));
+ result = tpm1_nv_define_space(dev, INDEX0, perm, sizeof(uint32_t));
assert(result == TPM_BAD_PRESENCE);
- result = tpm_nv_define_space(dev, INDEX1, perm, sizeof(uint32_t));
+ result = tpm1_nv_define_space(dev, INDEX1, perm, sizeof(uint32_t));
assert(result == TPM_BAD_PRESENCE);
printf("done\n");
@@ -434,7 +438,7 @@ static int test_timing(struct udevice *dev)
100);
TTPM_CHECK(tpm_nv_read_value(dev, INDEX0, (uint8_t *)&x, sizeof(x)),
100);
- TTPM_CHECK(tpm_extend(dev, 0, in, out), 200);
+ TTPM_CHECK(tpm_pcr_extend(dev, 0, in, out), 200);
TTPM_CHECK(tpm_set_global_lock(dev), 50);
TTPM_CHECK(tpm_tsc_physical_presence(dev, PHYS_PRESENCE), 100);
printf("done\n");