diff options
-rw-r--r-- | firmware/include/tpm2_marshaling.h | 18 | ||||
-rw-r--r-- | firmware/lib/tpm2_lite/marshaling.c | 17 | ||||
-rw-r--r-- | firmware/lib/tpm2_lite/tlcl.c | 12 |
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) |