summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Pronin <apronin@google.com>2016-07-25 16:28:39 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-07-26 23:54:31 -0700
commit5be84679e5157aaa6d785083b98c4c393630e491 (patch)
tree6595227e547192c67483ec7a98e50dde84c0fc84
parent8926d350c8e45a9cb426d6815cd2e6215f9bd207 (diff)
downloadvboot-5be84679e5157aaa6d785083b98c4c393630e491.tar.gz
tlcl: support sending raw commands
Implement TlclSendReceive and TlclPacketSize required for sending raw commands. BRANCH=none BUG=chrome-os-partner:55210 TEST=boot on kevin, verify that 'tpmc raw' works Change-Id: Iba41b95dd7790a6b7a3a7af6cf5f897f45dce1e5 Reviewed-on: https://chromium-review.googlesource.com/363033 Commit-Ready: Andrey Pronin <apronin@chromium.org> Tested-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--firmware/include/tpm2_marshaling.h18
-rw-r--r--firmware/lib/tpm2_lite/marshaling.c17
-rw-r--r--firmware/lib/tpm2_lite/tlcl.c12
3 files changed, 43 insertions, 4 deletions
diff --git a/firmware/include/tpm2_marshaling.h b/firmware/include/tpm2_marshaling.h
index 3d6fb8aa..cbfded11 100644
--- a/firmware/include/tpm2_marshaling.h
+++ b/firmware/include/tpm2_marshaling.h
@@ -47,6 +47,24 @@ struct tpm2_response *tpm_unmarshal_response(TPM_CC command,
int response_size);
/**
+ * tpm_get_packet_size
+ *
+ * @packet: pointer to the start of the command or response packet.
+ *
+ * Returns the size of the tpm packet.
+ */
+uint32_t tpm_get_packet_size(const uint8_t *packet);
+
+/**
+ * tpm_get_packet_response_code
+ *
+ * @packet: pointer to the start of the response packet.
+ *
+ * Returns the response code.
+ */
+uint32_t tpm_get_packet_response_code(const uint8_t *packet);
+
+/**
* tpm_set_ph_disabled
*
* Sets the flag that indicates if platform hierarchy is disabled.
diff --git a/firmware/lib/tpm2_lite/marshaling.c b/firmware/lib/tpm2_lite/marshaling.c
index 037e696d..fd94a51e 100644
--- a/firmware/lib/tpm2_lite/marshaling.c
+++ b/firmware/lib/tpm2_lite/marshaling.c
@@ -516,6 +516,23 @@ struct tpm2_response *tpm_unmarshal_response(TPM_CC command,
return &tpm2_resp;
}
+uint32_t tpm_get_packet_size(const uint8_t *packet)
+{
+ /* 0: tag (16 bit)
+ * 2: size (32 bit)
+ */
+ return read_be32(packet + 2);
+}
+
+uint32_t tpm_get_packet_response_code(const uint8_t *packet)
+{
+ /* 0: tag (16 bit)
+ * 2: size (32 bit)
+ * 6: resp code (32 bit)
+ */
+ return read_be32(packet + 6);
+}
+
void tpm_set_ph_disabled(int flag)
{
ph_disabled = flag;
diff --git a/firmware/lib/tpm2_lite/tlcl.c b/firmware/lib/tpm2_lite/tlcl.c
index efc528d1..d7d853bf 100644
--- a/firmware/lib/tpm2_lite/tlcl.c
+++ b/firmware/lib/tpm2_lite/tlcl.c
@@ -82,14 +82,18 @@ uint32_t TlclLibClose(void)
uint32_t TlclSendReceive(const uint8_t *request, uint8_t *response,
int max_length)
{
- VBDEBUG(("%s called, NOT YET IMPLEMENTED\n", __func__));
- return TPM_SUCCESS;
+ uint32_t rv, resp_size;
+
+ resp_size = max_length;
+ rv = VbExTpmSendReceive(request, tpm_get_packet_size(request),
+ response, &resp_size);
+
+ return rv ? rv : tpm_get_packet_response_code(response);
}
int TlclPacketSize(const uint8_t *packet)
{
- VBDEBUG(("%s called, NOT YET IMPLEMENTED\n", __func__));
- return 0;
+ return tpm_get_packet_size(packet);
}
uint32_t TlclStartup(void)