diff mbox series

[v2,2/6] cmd: tpm-v1: fix load_key_by_sha1 compile errors

Message ID 20211111040631.21262-3-matt@traverse.com.au
State Accepted
Commit e845dd7c8ba8fcab504c813da0eea59550bc7b05
Delegated to: Ilias Apalodimas
Headers show
Series drivers: tpm: Fix Atmel/Microchip TPMv1.2 issues | expand

Commit Message

Mathew McBride Nov. 11, 2021, 4:06 a.m. UTC
This command is not compiled by default and has not been updated alongside
changes to the tpmv1 API, such as passing the TPM udevice to the relevant
functions.

Signed-off-by: Mathew McBride <matt@traverse.com.au>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
 cmd/tpm-v1.c | 10 +++++-----
 lib/tpm-v1.c |  4 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

Comments

Simon Glass Nov. 25, 2021, 12:12 a.m. UTC | #1
On Wed, 10 Nov 2021 at 21:06, Mathew McBride <matt@traverse.com.au> wrote:
>
> This command is not compiled by default and has not been updated alongside
> changes to the tpmv1 API, such as passing the TPM udevice to the relevant
> functions.
>
> Signed-off-by: Mathew McBride <matt@traverse.com.au>
> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> ---
>  cmd/tpm-v1.c | 10 +++++-----
>  lib/tpm-v1.c |  4 ++--
>  2 files changed, 7 insertions(+), 7 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

Can we enable this by default for sandbox, at least?
diff mbox series

Patch

diff --git a/cmd/tpm-v1.c b/cmd/tpm-v1.c
index 55f2aeff46..bf238a9f2e 100644
--- a/cmd/tpm-v1.c
+++ b/cmd/tpm-v1.c
@@ -406,9 +406,9 @@  static int do_tpm_load_key_by_sha1(struct cmd_tbl *cmdtp, int flag, int argc,
 	void *key;
 	struct udevice *dev;
 
-	rc = get_tpm(&dev);
-	if (rc)
-		return rc;
+	err = get_tpm(&dev);
+	if (err)
+		return err;
 
 	if (argc < 5)
 		return CMD_RET_USAGE;
@@ -420,7 +420,7 @@  static int do_tpm_load_key_by_sha1(struct cmd_tbl *cmdtp, int flag, int argc,
 		return CMD_RET_FAILURE;
 	parse_byte_string(argv[4], usage_auth, NULL);
 
-	err = tpm_find_key_sha1(usage_auth, parent_hash, &parent_handle);
+	err = tpm1_find_key_sha1(dev, usage_auth, parent_hash, &parent_handle);
 	if (err) {
 		printf("Could not find matching parent key (err = %d)\n", err);
 		return CMD_RET_FAILURE;
@@ -428,7 +428,7 @@  static int do_tpm_load_key_by_sha1(struct cmd_tbl *cmdtp, int flag, int argc,
 
 	printf("Found parent key %08x\n", parent_handle);
 
-	err = tpm_load_key2_oiap(parent_handle, key, key_len, usage_auth,
+	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);
diff --git a/lib/tpm-v1.c b/lib/tpm-v1.c
index 8dc144080c..22a769c587 100644
--- a/lib/tpm-v1.c
+++ b/lib/tpm-v1.c
@@ -840,7 +840,7 @@  u32 tpm1_find_key_sha1(struct udevice *dev, const u8 auth[20],
 	unsigned int i;
 
 	/* fetch list of already loaded keys in the TPM */
-	err = tpm_get_capability(dev, TPM_CAP_HANDLE, TPM_RT_KEY, buf,
+	err = tpm1_get_capability(dev, TPM_CAP_HANDLE, TPM_RT_KEY, buf,
 				 sizeof(buf));
 	if (err)
 		return -1;
@@ -852,7 +852,7 @@  u32 tpm1_find_key_sha1(struct udevice *dev, const u8 auth[20],
 	/* 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(key_handles[i], auth, buf, &buf_len);
+		err = tpm1_get_pub_key_oiap(dev, key_handles[i], auth, buf, &buf_len);
 		if (err && err != TPM_AUTHFAIL)
 			return -1;
 		if (err)