summaryrefslogtreecommitdiff
path: root/host
diff options
context:
space:
mode:
Diffstat (limited to 'host')
-rw-r--r--host/lib/include/util_misc.h8
-rw-r--r--host/lib/util_misc.c19
2 files changed, 25 insertions, 2 deletions
diff --git a/host/lib/include/util_misc.h b/host/lib/include/util_misc.h
index 0a6ed4c4..d5a08fe3 100644
--- a/host/lib/include/util_misc.h
+++ b/host/lib/include/util_misc.h
@@ -8,11 +8,15 @@
#ifndef VBOOT_REFERENCE_UTIL_MISC_H_
#define VBOOT_REFERENCE_UTIL_MISC_H_
+#include "host_key.h"
#include "vboot_struct.h"
struct rsa_st;
-/* Prints the sha1sum of the given VbPublicKey to stdout. */
-void PrintPubKeySha1Sum(VbPublicKey* key);
+/* Prints the sha1sum of a VbPublicKey to stdout. */
+void PrintPubKeySha1Sum(VbPublicKey *key);
+
+/* Prints the sha1sum of a VbPrivateKey to stdout. */
+void PrintPrivKeySha1Sum(VbPrivateKey *key);
/*
* Our packed RSBPublicKey buffer (historically in files ending with ".keyb",
diff --git a/host/lib/util_misc.c b/host/lib/util_misc.c
index d2c21f52..ecaf8ea3 100644
--- a/host/lib/util_misc.c
+++ b/host/lib/util_misc.c
@@ -29,6 +29,25 @@ void PrintPubKeySha1Sum(VbPublicKey *key)
free(digest);
}
+void PrintPrivKeySha1Sum(VbPrivateKey *key)
+{
+ uint8_t *buf, *digest;
+ uint32_t buflen;
+ int i;
+
+ if (vb_keyb_from_rsa(key->rsa_private_key, &buf, &buflen)) {
+ printf("<error>");
+ return;
+ }
+
+ digest = DigestBuf(buf, buflen, SHA1_DIGEST_ALGORITHM);
+ for (i = 0; i < SHA1_DIGEST_SIZE; i++)
+ printf("%02x", digest[i]);
+
+ free(digest);
+ free(buf);
+}
+
int vb_keyb_from_rsa(struct rsa_st *rsa_private_key,
uint8_t **keyb_data, uint32_t *keyb_size)
{