summaryrefslogtreecommitdiffstats
path: root/lib/tpm.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-08-22 18:31:41 -0600
committerSimon Glass <sjg@chromium.org>2015-08-31 07:57:29 -0600
commit2132f971ba2443bc31046cbbf18bbf5e7c017b50 (patch)
tree4d21fac12c7a0f035780d06ef33276154d484a98 /lib/tpm.c
parentad77694e23be841feeb91e8173d4d3d4e8ef2bf0 (diff)
downloadtalos-obmc-uboot-2132f971ba2443bc31046cbbf18bbf5e7c017b50.tar.gz
talos-obmc-uboot-2132f971ba2443bc31046cbbf18bbf5e7c017b50.zip
tpm: Add functions to access flags and permissions
Add a few new functions which will be used by the test command in a future patch. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Christophe Ricard<christophe-h.ricard@st.com> Reviewed-by: Heiko Schocher <hs@denx.de>
Diffstat (limited to 'lib/tpm.c')
-rw-r--r--lib/tpm.c51
1 files changed, 50 insertions, 1 deletions
diff --git a/lib/tpm.c b/lib/tpm.c
index 19bf0b5990..5d5f707e37 100644
--- a/lib/tpm.c
+++ b/lib/tpm.c
@@ -18,7 +18,6 @@
/* Useful constants */
enum {
COMMAND_BUFFER_SIZE = 256,
- TPM_PUBEK_SIZE = 256,
TPM_REQUEST_HEADER_LENGTH = 10,
TPM_RESPONSE_HEADER_LENGTH = 10,
PCR_DIGEST_LENGTH = 20,
@@ -610,6 +609,56 @@ uint32_t tpm_get_capability(uint32_t cap_area, uint32_t sub_cap,
return 0;
}
+uint32_t tpm_get_permanent_flags(struct tpm_permanent_flags *pflags)
+{
+ const uint8_t command[22] = {
+ 0x0, 0xc1, /* TPM_TAG */
+ 0x0, 0x0, 0x0, 0x16, /* parameter size */
+ 0x0, 0x0, 0x0, 0x65, /* TPM_COMMAND_CODE */
+ 0x0, 0x0, 0x0, 0x4, /* TPM_CAP_FLAG_PERM */
+ 0x0, 0x0, 0x0, 0x4, /* subcap size */
+ 0x0, 0x0, 0x1, 0x8, /* subcap value */
+ };
+ uint8_t response[COMMAND_BUFFER_SIZE];
+ size_t response_length = sizeof(response);
+ uint32_t err;
+
+ err = tpm_sendrecv_command(command, response, &response_length);
+ if (err)
+ return err;
+ memcpy(pflags, response + TPM_HEADER_SIZE, sizeof(*pflags));
+
+ return 0;
+}
+
+uint32_t tpm_get_permissions(uint32_t index, uint32_t *perm)
+{
+ const uint8_t command[22] = {
+ 0x0, 0xc1, /* TPM_TAG */
+ 0x0, 0x0, 0x0, 0x16, /* parameter size */
+ 0x0, 0x0, 0x0, 0x65, /* TPM_COMMAND_CODE */
+ 0x0, 0x0, 0x0, 0x11,
+ 0x0, 0x0, 0x0, 0x4,
+ };
+ const size_t index_offset = 18;
+ const size_t perm_offset = 60;
+ uint8_t buf[COMMAND_BUFFER_SIZE], response[COMMAND_BUFFER_SIZE];
+ size_t response_length = sizeof(response);
+ uint32_t err;
+
+ if (pack_byte_string(buf, sizeof(buf), "d", 0, command, sizeof(command),
+ index_offset, index))
+ return TPM_LIB_ERROR;
+ err = tpm_sendrecv_command(buf, response, &response_length);
+ if (err)
+ return err;
+ if (unpack_byte_string(response, response_length, "d",
+ perm_offset, perm))
+ return TPM_LIB_ERROR;
+
+ return 0;
+}
+
#ifdef CONFIG_TPM_AUTH_SESSIONS
/**
OpenPOWER on IntegriCloud