diff options
| author | Tom Rini <[email protected]> | 2017-04-04 09:18:57 -0400 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2017-04-04 09:18:57 -0400 |
| commit | 7d67bb1daf2daae7bce49147494f8c45001e76b1 (patch) | |
| tree | cd53bbf4d3fd5701a6396a8918e629b95b70b1fa /lib | |
| parent | f532703665ae5e5957211bbc4e7296a8313cc403 (diff) | |
| parent | 44d5c371a63e56eb53866b645e75396fa1d95510 (diff) | |
Merge git://git.denx.de/u-boot-dm
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/fdtdec.c | 2 | ||||
| -rw-r--r-- | lib/tpm.c | 40 |
2 files changed, 41 insertions, 1 deletions
diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 81f47ef2c7f..1edfbf2d392 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -112,7 +112,7 @@ fdt_addr_t fdtdec_get_addr_size_fixed(const void *blob, int node, return FDT_ADDR_T_NONE; } -#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_OF_LIBFDT) +#if CONFIG_IS_ENABLED(OF_TRANSLATE) if (translate) addr = fdt_translate_address(blob, node, prop_addr); else diff --git a/lib/tpm.c b/lib/tpm.c index fb1221472a5..cd7f88f2204 100644 --- a/lib/tpm.c +++ b/lib/tpm.c @@ -996,4 +996,44 @@ uint32_t tpm_get_pub_key_oiap(uint32_t key_handle, const void *usage_auth, return 0; } +#ifdef CONFIG_TPM_LOAD_KEY_BY_SHA1 +uint32_t tpm_find_key_sha1(const uint8_t auth[20], const uint8_t + pubkey_digest[20], uint32_t *handle) +{ + uint16_t key_count; + uint32_t key_handles[10]; + uint8_t buf[288]; + uint8_t *ptr; + uint32_t err; + uint8_t digest[20]; + size_t buf_len; + unsigned int i; + + /* fetch list of already loaded keys in the TPM */ + err = tpm_get_capability(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) + key_handles[i] = get_unaligned_be32(ptr); + + /* 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); + if (err && err != TPM_AUTHFAIL) + return -1; + if (err) + continue; + sha1_csum(buf, buf_len, digest); + if (!memcmp(digest, pubkey_digest, 20)) { + *handle = key_handles[i]; + return 0; + } + } + return 1; +} +#endif /* CONFIG_TPM_LOAD_KEY_BY_SHA1 */ + #endif /* CONFIG_TPM_AUTH_SESSIONS */ |
