ccdc_eth_init();
#endif
ret = get_tpm(&tpm);
- if (ret || tpm_init(tpm) || tpm_startup(tpm, TPM_ST_CLEAR) ||
- tpm_continue_self_test(tpm)) {
+ if (ret || tpm_init(tpm) || tpm1_startup(tpm, TPM_ST_CLEAR) ||
+ tpm1_continue_self_test(tpm)) {
return 1;
}
uint8_t *ptr;
uint16_t v16;
- err = tpm_get_capability(tpm, TPM_CAP_NV_INDEX, index,
- info, sizeof(info));
+ err = tpm1_get_capability(tpm, TPM_CAP_NV_INDEX, index, info,
+ sizeof(info));
if (err) {
printf("tpm_get_capability(CAP_NV_INDEX, %08x) failed: %u\n",
index, err);
unsigned int i;
/* fetch list of already loaded keys in the TPM */
- err = tpm_get_capability(tpm, TPM_CAP_HANDLE, TPM_RT_KEY, buf,
- sizeof(buf));
+ err = tpm1_get_capability(tpm, TPM_CAP_HANDLE, TPM_RT_KEY, buf,
+ sizeof(buf));
if (err)
return -1;
key_count = get_unaligned_be16(buf);
/* now search a(/ the) key which we can access with the given auth */
for (i = 0; i < key_count; ++i) {
buf_len = sizeof(buf);
- err = tpm_get_pub_key_oiap(tpm, key_handles[i], auth, buf,
- &buf_len);
+ err = tpm1_get_pub_key_oiap(tpm, key_handles[i], auth, buf,
+ &buf_len);
if (err && err != TPM_AUTHFAIL)
return -1;
if (err)
if (get_tpm_nv_size(tpm, NV_COMMON_DATA_INDEX, &size) ||
size < NV_COMMON_DATA_MIN_SIZE)
return 1;
- err = tpm_nv_read_value(tpm, NV_COMMON_DATA_INDEX,
- buf, min(sizeof(buf), size));
+ err = tpm1_nv_read_value(tpm, NV_COMMON_DATA_INDEX, buf,
+ min(sizeof(buf), size));
if (err) {
printf("tpm_nv_read_value() failed: %u\n", err);
return 1;
if (mode & HREG_RD) {
if (!result->valid) {
if (IS_PCR_HREG(spec)) {
- hre_tpm_err = tpm_pcr_read(tpm, HREG_IDX(spec),
- result->digest, 20);
+ hre_tpm_err = tpm1_pcr_read(tpm, HREG_IDX(spec),
+ result->digest, 20);
result->valid = (hre_tpm_err == TPM_SUCCESS);
} else if (IS_FIX_HREG(spec)) {
switch (HREG_IDX(spec)) {
return -1;
if (find_key(tpm, src_reg->digest, dst_reg->digest, &parent_handle))
return -1;
- hre_tpm_err = tpm_load_key2_oiap(tpm, parent_handle, key, key_size,
- src_reg->digest, &key_handle);
+ hre_tpm_err = tpm1_load_key2_oiap(tpm, parent_handle, key, key_size,
+ src_reg->digest, &key_handle);
if (hre_tpm_err) {
hre_err = HRE_E_TPM_FAILURE;
return -1;
}
if (dst_reg && dst_modified && IS_PCR_HREG(dst_spec)) {
- hre_tpm_err = tpm_extend(tpm, HREG_IDX(dst_spec),
- dst_reg->digest, dst_reg->digest);
+ hre_tpm_err = tpm1_extend(tpm, HREG_IDX(dst_spec),
+ dst_reg->digest, dst_reg->digest);
if (hre_tpm_err) {
hre_err = HRE_E_TPM_FAILURE;
return NULL;
uint i;
/* fetch list of already loaded keys in the TPM */
- err = tpm_get_capability(tpm, TPM_CAP_HANDLE, TPM_RT_KEY, buf,
- sizeof(buf));
+ err = tpm1_get_capability(tpm, TPM_CAP_HANDLE, TPM_RT_KEY, buf,
+ sizeof(buf));
if (err)
return -1;
key_count = get_unaligned_be16(buf);
ptr = buf + 2;
for (i = 0; i < key_count; ++i, ptr += 4) {
- err = tpm_flush_specific(tpm, get_unaligned_be32(ptr),
- TPM_RT_KEY);
+ err = tpm1_flush_specific(tpm, get_unaligned_be32(ptr),
+ TPM_RT_KEY);
if (err && err != TPM_KEY_OWNER_CONTROL)
return err;
}
env_set_ulong("fpga_hw_rev", fpga_hw_rev);
ret = get_tpm(&tpm);
- if (ret || tpm_init(tpm) || tpm_startup(tpm, TPM_ST_CLEAR) ||
- tpm_continue_self_test(tpm)) {
+ if (ret || tpm_init(tpm) || tpm1_startup(tpm, TPM_ST_CLEAR) ||
+ tpm1_continue_self_test(tpm)) {
printf("TPM init failed\n");
}
uint8_t *ptr;
uint16_t v16;
- err = tpm_get_capability(tpm, TPM_CAP_NV_INDEX, index,
- info, sizeof(info));
+ err = tpm1_get_capability(tpm, TPM_CAP_NV_INDEX, index, info,
+ sizeof(info));
if (err) {
printf("tpm_get_capability(CAP_NV_INDEX, %08x) failed: %u\n",
index, err);
unsigned int i;
/* fetch list of already loaded keys in the TPM */
- err = tpm_get_capability(tpm, TPM_CAP_HANDLE, TPM_RT_KEY, buf,
- sizeof(buf));
+ err = tpm1_get_capability(tpm, TPM_CAP_HANDLE, TPM_RT_KEY, buf,
+ sizeof(buf));
if (err)
return -1;
key_count = get_unaligned_be16(buf);
/* now search a(/ the) key which we can access with the given auth */
for (i = 0; i < key_count; ++i) {
buf_len = sizeof(buf);
- err = tpm_get_pub_key_oiap(tpm, key_handles[i], auth, buf,
- &buf_len);
+ err = tpm1_get_pub_key_oiap(tpm, key_handles[i], auth, buf,
+ &buf_len);
if (err && err != TPM_AUTHFAIL)
return -1;
if (err)
if (get_tpm_nv_size(tpm, NV_COMMON_DATA_INDEX, &size) ||
size < NV_COMMON_DATA_MIN_SIZE)
return 1;
- err = tpm_nv_read_value(tpm, NV_COMMON_DATA_INDEX,
- buf, min(sizeof(buf), size));
+ err = tpm1_nv_read_value(tpm, NV_COMMON_DATA_INDEX, buf,
+ min(sizeof(buf), size));
if (err) {
printf("tpm_nv_read_value() failed: %u\n", err);
return 1;
if (mode & HREG_RD) {
if (!result->valid) {
if (IS_PCR_HREG(spec)) {
- hre_tpm_err = tpm_pcr_read(tpm, HREG_IDX(spec),
- result->digest, 20);
+ hre_tpm_err = tpm1_pcr_read(tpm, HREG_IDX(spec),
+ result->digest, 20);
result->valid = (hre_tpm_err == TPM_SUCCESS);
} else if (IS_FIX_HREG(spec)) {
switch (HREG_IDX(spec)) {
return -1;
if (find_key(tpm, src_reg->digest, dst_reg->digest, &parent_handle))
return -1;
- hre_tpm_err = tpm_load_key2_oiap(tpm, parent_handle, key, key_size,
- src_reg->digest, &key_handle);
+ hre_tpm_err = tpm1_load_key2_oiap(tpm, parent_handle, key, key_size,
+ src_reg->digest, &key_handle);
if (hre_tpm_err) {
hre_err = HRE_E_TPM_FAILURE;
return -1;
}
if (dst_reg && dst_modified && IS_PCR_HREG(dst_spec)) {
- hre_tpm_err = tpm_extend(tpm, HREG_IDX(dst_spec),
- dst_reg->digest, dst_reg->digest);
+ hre_tpm_err = tpm1_extend(tpm, HREG_IDX(dst_spec),
+ dst_reg->digest, dst_reg->digest);
if (hre_tpm_err) {
hre_err = HRE_E_TPM_FAILURE;
return NULL;
puts("CCDM S1: start actions\n");
#ifndef CCDM_SECOND_STAGE
- if (tpm_continue_self_test(tpm))
+ if (tpm1_continue_self_test(tpm))
goto failure;
#else
- tpm_continue_self_test(tpm);
+ tpm1_continue_self_test(tpm);
#endif
mdelay(37);
puts("CCDM S1\n");
ret = get_tpm(&tpm);
- if (ret || tpm_init(tpm) || tpm_startup(tpm, TPM_ST_CLEAR))
+ if (ret || tpm_init(tpm) || tpm1_startup(tpm, TPM_ST_CLEAR))
return 1;
ret = first_stage_actions(tpm);
#ifndef CCDM_SECOND_STAGE
ret = get_tpm(&tpm);
if (ret || tpm_init(tpm))
return 1;
- err = tpm_startup(tpm, TPM_ST_CLEAR);
+ err = tpm1_startup(tpm, TPM_ST_CLEAR);
if (err != TPM_INVALID_POSTINIT)
did_first_stage_run = false;
#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[])
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,
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));
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,
if (rc)
return rc;
- err = tpm_oiap(dev, &auth_handle);
+ err = tpm1_oiap(dev, &auth_handle);
return report_return_code(err);
}
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);
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);
return report_return_code(err);
}
-TPM_COMMAND_NO_ARG(tpm_end_oiap)
+TPM_COMMAND_NO_ARG(tpm1_end_oiap)
#endif /* CONFIG_TPM_AUTH_SESSIONS */
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);
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;
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
#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 { \
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)
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;
}
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)
/* 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");
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");
* @param mode TPM startup mode
* @return return code of the operation
*/
-u32 tpm_startup(struct udevice *dev, enum tpm_startup_type mode);
+u32 tpm1_startup(struct udevice *dev, enum tpm_startup_type mode);
/**
* Issue a TPM_SelfTestFull command.
* @param dev TPM device
* @return return code of the operation
*/
-u32 tpm_self_test_full(struct udevice *dev);
+u32 tpm1_self_test_full(struct udevice *dev);
/**
* Issue a TPM_ContinueSelfTest command.
* @param dev TPM device
* @return return code of the operation
*/
-u32 tpm_continue_self_test(struct udevice *dev);
+u32 tpm1_continue_self_test(struct udevice *dev);
/**
* Issue a TPM_NV_DefineSpace command. The implementation is limited
* @param size size of the area
* @return return code of the operation
*/
-u32 tpm_nv_define_space(struct udevice *dev, u32 index, u32 perm, u32 size);
+u32 tpm1_nv_define_space(struct udevice *dev, u32 index, u32 perm, u32 size);
/**
* Issue a TPM_NV_ReadValue command. This implementation is limited
* @param count size of output buffer
* @return return code of the operation
*/
-u32 tpm_nv_read_value(struct udevice *dev, u32 index, void *data, u32 count);
+u32 tpm1_nv_read_value(struct udevice *dev, u32 index, void *data, u32 count);
/**
* Issue a TPM_NV_WriteValue command. This implementation is limited
* @param length length of data bytes of input buffer
* @return return code of the operation
*/
-u32 tpm_nv_write_value(struct udevice *dev, u32 index, const void *data,
- u32 length);
+u32 tpm1_nv_write_value(struct udevice *dev, u32 index, const void *data,
+ u32 length);
/**
* Issue a TPM_Extend command.
* command
* @return return code of the operation
*/
-u32 tpm_extend(struct udevice *dev, u32 index, const void *in_digest,
- void *out_digest);
+u32 tpm1_extend(struct udevice *dev, u32 index, const void *in_digest,
+ void *out_digest);
/**
* Issue a TPM_PCRRead command.
* @param count size of output buffer
* @return return code of the operation
*/
-u32 tpm_pcr_read(struct udevice *dev, u32 index, void *data, size_t count);
+u32 tpm1_pcr_read(struct udevice *dev, u32 index, void *data, size_t count);
/**
* Issue a TSC_PhysicalPresence command. TPM physical presence flag
* @param presence TPM physical presence flag
* @return return code of the operation
*/
-u32 tpm_tsc_physical_presence(struct udevice *dev, u16 presence);
+u32 tpm1_tsc_physical_presence(struct udevice *dev, u16 presence);
/**
* Issue a TPM_ReadPubek command.
* @param count size of output buffer
* @return return code of the operation
*/
-u32 tpm_read_pubek(struct udevice *dev, void *data, size_t count);
+u32 tpm1_read_pubek(struct udevice *dev, void *data, size_t count);
/**
* Issue a TPM_ForceClear command.
* @param dev TPM device
* @return return code of the operation
*/
-u32 tpm_force_clear(struct udevice *dev);
+u32 tpm1_force_clear(struct udevice *dev);
/**
* Issue a TPM_PhysicalEnable command.
* @param dev TPM device
* @return return code of the operation
*/
-u32 tpm_physical_enable(struct udevice *dev);
+u32 tpm1_physical_enable(struct udevice *dev);
/**
* Issue a TPM_PhysicalDisable command.
* @param dev TPM device
* @return return code of the operation
*/
-u32 tpm_physical_disable(struct udevice *dev);
+u32 tpm1_physical_disable(struct udevice *dev);
/**
* Issue a TPM_PhysicalSetDeactivated command.
* @param state boolean state of the deactivated flag
* @return return code of the operation
*/
-u32 tpm_physical_set_deactivated(struct udevice *dev, u8 state);
+u32 tpm1_physical_set_deactivated(struct udevice *dev, u8 state);
/**
* Issue a TPM_GetCapability command. This implementation is limited
* @param count size of output buffer
* @return return code of the operation
*/
-u32 tpm_get_capability(struct udevice *dev, u32 cap_area, u32 sub_cap,
- void *cap, size_t count);
+u32 tpm1_get_capability(struct udevice *dev, u32 cap_area, u32 sub_cap,
+ void *cap, size_t count);
/**
* Issue a TPM_FlushSpecific command for a AUTH resource.
* @param auth_handle handle of the auth session
* @return return code of the operation
*/
-u32 tpm_terminate_auth_session(struct udevice *dev, u32 auth_handle);
+u32 tpm1_terminate_auth_session(struct udevice *dev, u32 auth_handle);
/**
* Issue a TPM_OIAP command to setup an object independent authorization
* @param auth_handle pointer to the (new) auth handle or NULL.
* @return return code of the operation
*/
-u32 tpm_oiap(struct udevice *dev, u32 *auth_handle);
+u32 tpm1_oiap(struct udevice *dev, u32 *auth_handle);
/**
* Ends an active OIAP session.
* @param dev TPM device
* @return return code of the operation
*/
-u32 tpm_end_oiap(struct udevice *dev);
+u32 tpm1_end_oiap(struct udevice *dev);
/**
* Issue a TPM_LoadKey2 (Auth1) command using an OIAP session for authenticating
* @param key_handle pointer to the key handle
* @return return code of the operation
*/
-u32 tpm_load_key2_oiap(struct udevice *dev, u32 parent_handle, const void *key,
- size_t key_length, const void *parent_key_usage_auth,
- u32 *key_handle);
+u32 tpm1_load_key2_oiap(struct udevice *dev, u32 parent_handle, const void *key,
+ size_t key_length, const void *parent_key_usage_auth,
+ u32 *key_handle);
/**
* Issue a TPM_GetPubKey (Auth1) command using an OIAP session for
* of the stored TPM_PUBKEY structure (iff pubkey != NULL).
* @return return code of the operation
*/
-u32 tpm_get_pub_key_oiap(struct udevice *dev, u32 key_handle,
- const void *usage_auth, void *pubkey,
- size_t *pubkey_len);
+u32 tpm1_get_pub_key_oiap(struct udevice *dev, u32 key_handle,
+ const void *usage_auth, void *pubkey,
+ size_t *pubkey_len);
/**
* Get the TPM permanent flags value
* @param pflags Place to put permanent flags
* @return return code of the operation
*/
-u32 tpm_get_permanent_flags(struct udevice *dev,
- struct tpm_permanent_flags *pflags);
+u32 tpm1_get_permanent_flags(struct udevice *dev,
+ struct tpm_permanent_flags *pflags);
/**
* Get the TPM permissions
* @param perm Returns permissions value
* @return return code of the operation
*/
-u32 tpm_get_permissions(struct udevice *dev, u32 index, u32 *perm);
+u32 tpm1_get_permissions(struct udevice *dev, u32 index, u32 *perm);
/**
* Flush a resource with a given handle and type from the TPM
* @param resource_type type of the resource
* @return return code of the operation
*/
-u32 tpm_flush_specific(struct udevice *dev, u32 key_handle, u32 resource_type);
+u32 tpm1_flush_specific(struct udevice *dev, u32 key_handle, u32 resource_type);
#ifdef CONFIG_TPM_LOAD_KEY_BY_SHA1
/**
* @param[out] handle The handle of the key (Non-null iff found)
* @return 0 if key was found in TPM; != 0 if not.
*/
-u32 tpm_find_key_sha1(struct udevice *dev, const u8 auth[20],
- const u8 pubkey_digest[20], u32 *handle);
+u32 tpm1_find_key_sha1(struct udevice *dev, const u8 auth[20],
+ const u8 pubkey_digest[20], u32 *handle);
#endif /* CONFIG_TPM_LOAD_KEY_BY_SHA1 */
/**
* @param count size of output buffer
* @return return code of the operation
*/
-u32 tpm_get_random(struct udevice *dev, void *data, u32 count);
+u32 tpm1_get_random(struct udevice *dev, void *data, u32 count);
/**
* tpm_finalise_physical_presence() - Finalise physical presence
* @param dev TPM device
* @return return code of the operation (0 = success)
*/
-u32 tpm_finalise_physical_presence(struct udevice *dev);
+u32 tpm1_finalise_physical_presence(struct udevice *dev);
/**
- * tpm_nv_set_locked() - lock the non-volatile space
+ * tpm_nv_enable_locking() - lock the non-volatile space
*
* @param dev TPM device
* @return return code of the operation (0 = success)
*/
-u32 tpm_nv_set_locked(struct udevice *dev);
+u32 tpm1_nv_set_locked(struct udevice *dev);
/**
* tpm_set_global_lock() - set the global lock
* @param dev TPM device
* @return return code of the operation (0 = success)
*/
-u32 tpm_resume(struct udevice *dev);
+u32 tpm1_resume(struct udevice *dev);
#endif /* __TPM_V1_H */
obj-$(CONFIG_$(SPL_TPL_)TPM) += tpm-common.o
ifeq ($(CONFIG_$(SPL_TPL_)TPM),y)
obj-y += crc8.o
+obj-$(CONFIG_TPM) += tpm_api.o
obj-$(CONFIG_TPM_V1) += tpm-v1.o
obj-$(CONFIG_TPM_V2) += tpm-v2.o
endif
#endif /* CONFIG_TPM_AUTH_SESSIONS */
-u32 tpm_startup(struct udevice *dev, enum tpm_startup_type mode)
+u32 tpm1_startup(struct udevice *dev, enum tpm_startup_type mode)
{
const u8 command[12] = {
0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0x99, 0x0, 0x0,
return tpm_sendrecv_command(dev, buf, NULL, NULL);
}
-u32 tpm_resume(struct udevice *dev)
+u32 tpm1_resume(struct udevice *dev)
{
- return tpm_startup(dev, TPM_ST_STATE);
+ return tpm1_startup(dev, TPM_ST_STATE);
}
-u32 tpm_self_test_full(struct udevice *dev)
+u32 tpm1_self_test_full(struct udevice *dev)
{
const u8 command[10] = {
0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x50,
return tpm_sendrecv_command(dev, command, NULL, NULL);
}
-u32 tpm_continue_self_test(struct udevice *dev)
+u32 tpm1_continue_self_test(struct udevice *dev)
{
const u8 command[10] = {
0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x53,
return tpm_sendrecv_command(dev, command, NULL, NULL);
}
-u32 tpm_clear_and_reenable(struct udevice *dev)
+u32 tpm1_clear_and_reenable(struct udevice *dev)
{
u32 ret;
log_info("TPM: Clear and re-enable\n");
- ret = tpm_force_clear(dev);
+ ret = tpm1_force_clear(dev);
if (ret != TPM_SUCCESS) {
log_err("Can't initiate a force clear\n");
return ret;
}
- if (tpm_get_version(dev) == TPM_V1) {
- ret = tpm_physical_enable(dev);
- if (ret != TPM_SUCCESS) {
- log_err("TPM: Can't set enabled state\n");
- return ret;
- }
+ ret = tpm1_physical_enable(dev);
+ if (ret != TPM_SUCCESS) {
+ log_err("TPM: Can't set enabled state\n");
+ return ret;
+ }
- ret = tpm_physical_set_deactivated(dev, 0);
- if (ret != TPM_SUCCESS) {
- log_err("TPM: Can't set deactivated state\n");
- return ret;
- }
+ ret = tpm1_physical_set_deactivated(dev, 0);
+ if (ret != TPM_SUCCESS) {
+ log_err("TPM: Can't set deactivated state\n");
+ return ret;
}
return TPM_SUCCESS;
}
-u32 tpm_nv_define_space(struct udevice *dev, u32 index, u32 perm, u32 size)
+u32 tpm1_nv_define_space(struct udevice *dev, u32 index, u32 perm, u32 size)
{
const u8 command[101] = {
0x0, 0xc1, /* TPM_TAG */
return tpm_sendrecv_command(dev, buf, NULL, NULL);
}
-u32 tpm_nv_set_locked(struct udevice *dev)
+u32 tpm1_nv_set_locked(struct udevice *dev)
{
- return tpm_nv_define_space(dev, TPM_NV_INDEX_LOCK, 0, 0);
+ return tpm1_nv_define_space(dev, TPM_NV_INDEX_LOCK, 0, 0);
}
-u32 tpm_nv_read_value(struct udevice *dev, u32 index, void *data, u32 count)
+u32 tpm1_nv_read_value(struct udevice *dev, u32 index, void *data, u32 count)
{
const u8 command[22] = {
0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0xcf,
return 0;
}
-u32 tpm_nv_write_value(struct udevice *dev, u32 index, const void *data,
- u32 length)
+u32 tpm1_nv_write_value(struct udevice *dev, u32 index, const void *data,
+ u32 length)
{
const u8 command[256] = {
0x0, 0xc1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xcd,
return 0;
}
-uint32_t tpm_set_global_lock(struct udevice *dev)
-{
- return tpm_nv_write_value(dev, TPM_NV_INDEX_0, NULL, 0);
-}
-
-u32 tpm_extend(struct udevice *dev, u32 index, const void *in_digest,
- void *out_digest)
+u32 tpm1_extend(struct udevice *dev, u32 index, const void *in_digest,
+ void *out_digest)
{
const u8 command[34] = {
0x0, 0xc1, 0x0, 0x0, 0x0, 0x22, 0x0, 0x0, 0x0, 0x14,
return 0;
}
-u32 tpm_pcr_read(struct udevice *dev, u32 index, void *data, size_t count)
+u32 tpm1_pcr_read(struct udevice *dev, u32 index, void *data, size_t count)
{
const u8 command[14] = {
0x0, 0xc1, 0x0, 0x0, 0x0, 0xe, 0x0, 0x0, 0x0, 0x15,
return 0;
}
-u32 tpm_tsc_physical_presence(struct udevice *dev, u16 presence)
+u32 tpm1_tsc_physical_presence(struct udevice *dev, u16 presence)
{
const u8 command[12] = {
0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x0, 0x0,
return tpm_sendrecv_command(dev, buf, NULL, NULL);
}
-u32 tpm_finalise_physical_presence(struct udevice *dev)
+u32 tpm1_finalise_physical_presence(struct udevice *dev)
{
const u8 command[12] = {
0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x2, 0xa0,
return tpm_sendrecv_command(dev, command, NULL, NULL);
}
-u32 tpm_read_pubek(struct udevice *dev, void *data, size_t count)
+u32 tpm1_read_pubek(struct udevice *dev, void *data, size_t count)
{
const u8 command[30] = {
0x0, 0xc1, 0x0, 0x0, 0x0, 0x1e, 0x0, 0x0, 0x0, 0x7c,
return 0;
}
-u32 tpm_force_clear(struct udevice *dev)
+u32 tpm1_force_clear(struct udevice *dev)
{
const u8 command[10] = {
0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x5d,
return tpm_sendrecv_command(dev, command, NULL, NULL);
}
-u32 tpm_physical_enable(struct udevice *dev)
+u32 tpm1_physical_enable(struct udevice *dev)
{
const u8 command[10] = {
0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x6f,
return tpm_sendrecv_command(dev, command, NULL, NULL);
}
-u32 tpm_physical_disable(struct udevice *dev)
+u32 tpm1_physical_disable(struct udevice *dev)
{
const u8 command[10] = {
0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x70,
return tpm_sendrecv_command(dev, command, NULL, NULL);
}
-u32 tpm_physical_set_deactivated(struct udevice *dev, u8 state)
+u32 tpm1_physical_set_deactivated(struct udevice *dev, u8 state)
{
const u8 command[11] = {
0x0, 0xc1, 0x0, 0x0, 0x0, 0xb, 0x0, 0x0, 0x0, 0x72,
return tpm_sendrecv_command(dev, buf, NULL, NULL);
}
-u32 tpm_get_capability(struct udevice *dev, u32 cap_area, u32 sub_cap,
- void *cap, size_t count)
+u32 tpm1_get_capability(struct udevice *dev, u32 cap_area, u32 sub_cap,
+ void *cap, size_t count)
{
const u8 command[22] = {
0x0, 0xc1, /* TPM_TAG */
return 0;
}
-u32 tpm_get_permanent_flags(struct udevice *dev,
- struct tpm_permanent_flags *pflags)
+u32 tpm1_get_permanent_flags(struct udevice *dev,
+ struct tpm_permanent_flags *pflags)
{
const u8 command[22] = {
0x0, 0xc1, /* TPM_TAG */
return 0;
}
-u32 tpm_get_permissions(struct udevice *dev, u32 index, u32 *perm)
+u32 tpm1_get_permissions(struct udevice *dev, u32 index, u32 *perm)
{
const u8 command[22] = {
0x0, 0xc1, /* TPM_TAG */
}
#ifdef CONFIG_TPM_FLUSH_RESOURCES
-u32 tpm_flush_specific(struct udevice *dev, u32 key_handle, u32 resource_type)
+u32 tpm1_flush_specific(struct udevice *dev, u32 key_handle, u32 resource_type)
{
const u8 command[18] = {
0x00, 0xc1, /* TPM_TAG */
return TPM_SUCCESS;
}
-u32 tpm_terminate_auth_session(struct udevice *dev, u32 auth_handle)
+u32 tpm1_terminate_auth_session(struct udevice *dev, u32 auth_handle)
{
const u8 command[18] = {
0x00, 0xc1, /* TPM_TAG */
return tpm_sendrecv_command(dev, request, NULL, NULL);
}
-u32 tpm_end_oiap(struct udevice *dev)
+u32 tpm1_end_oiap(struct udevice *dev)
{
u32 err = TPM_SUCCESS;
if (oiap_session.valid)
- err = tpm_terminate_auth_session(dev, oiap_session.handle);
+ err = tpm1_terminate_auth_session(dev, oiap_session.handle);
return err;
}
-u32 tpm_oiap(struct udevice *dev, u32 *auth_handle)
+u32 tpm1_oiap(struct udevice *dev, u32 *auth_handle)
{
const u8 command[10] = {
0x00, 0xc1, /* TPM_TAG */
u32 err;
if (oiap_session.valid)
- tpm_terminate_auth_session(dev, oiap_session.handle);
+ tpm1_terminate_auth_session(dev, oiap_session.handle);
err = tpm_sendrecv_command(dev, command, response, &response_length);
if (err)
return 0;
}
-u32 tpm_load_key2_oiap(struct udevice *dev, u32 parent_handle, const void *key,
- size_t key_length, const void *parent_key_usage_auth,
- u32 *key_handle)
+u32 tpm1_load_key2_oiap(struct udevice *dev, u32 parent_handle, const void *key,
+ size_t key_length, const void *parent_key_usage_auth,
+ u32 *key_handle)
{
const u8 command[14] = {
0x00, 0xc2, /* TPM_TAG */
u32 err;
if (!oiap_session.valid) {
- err = tpm_oiap(dev, NULL);
+ err = tpm1_oiap(dev, NULL);
if (err)
return err;
}
return 0;
}
-u32 tpm_get_pub_key_oiap(struct udevice *dev, u32 key_handle,
- const void *usage_auth, void *pubkey,
- size_t *pubkey_len)
+u32 tpm1_get_pub_key_oiap(struct udevice *dev, u32 key_handle,
+ const void *usage_auth, void *pubkey,
+ size_t *pubkey_len)
{
const u8 command[14] = {
0x00, 0xc2, /* TPM_TAG */
u32 err;
if (!oiap_session.valid) {
- err = tpm_oiap(dev, NULL);
+ err = tpm1_oiap(dev, NULL);
if (err)
return err;
}
}
#ifdef CONFIG_TPM_LOAD_KEY_BY_SHA1
-u32 tpm_find_key_sha1(struct udevice *dev, const u8 auth[20],
- const u8 pubkey_digest[20], u32 *handle)
+u32 tpm1_find_key_sha1(struct udevice *dev, const u8 auth[20],
+ const u8 pubkey_digest[20], u32 *handle)
{
u16 key_count;
u32 key_handles[10];
#endif /* CONFIG_TPM_AUTH_SESSIONS */
-u32 tpm_get_random(struct udevice *dev, void *data, u32 count)
+u32 tpm1_get_random(struct udevice *dev, void *data, u32 count)
{
const u8 command[14] = {
0x0, 0xc1, /* TPM_TAG */