summaryrefslogtreecommitdiff
path: root/host
diff options
context:
space:
mode:
Diffstat (limited to 'host')
-rw-r--r--host/include/host_misc.h2
-rw-r--r--host/lib/host_misc.c10
2 files changed, 12 insertions, 0 deletions
diff --git a/host/include/host_misc.h b/host/include/host_misc.h
index abbfc0f6..cbf9eaff 100644
--- a/host/include/host_misc.h
+++ b/host/include/host_misc.h
@@ -24,5 +24,7 @@ uint8_t* ReadFile(const char* filename, uint64_t* size);
* Returns 0 if success, 1 if error. */
int WriteFile(const char* filename, const void *data, uint64_t size);
+/* Prints the sha1sum of the given VbPublicKey to stdout. */
+void PrintPubKeySha1Sum(VbPublicKey* key);
#endif /* VBOOT_REFERENCE_HOST_MISC_H_ */
diff --git a/host/lib/host_misc.c b/host/lib/host_misc.c
index d8f52970..91eaea25 100644
--- a/host/lib/host_misc.c
+++ b/host/lib/host_misc.c
@@ -66,3 +66,13 @@ int WriteFile(const char* filename, const void *data, uint64_t size) {
fclose(f);
return 0;
}
+
+void PrintPubKeySha1Sum(VbPublicKey* key) {
+ uint8_t* buf = ((uint8_t *)key) + key->key_offset;
+ uint64_t buflen = key->key_size;
+ uint8_t* digest = DigestBuf(buf, buflen, SHA1_DIGEST_ALGORITHM);
+ int i;
+ for (i=0; i<SHA1_DIGEST_SIZE; i++)
+ printf("%02x", digest[i]);
+ Free(digest);
+}