[U-Boot] [PATCH v3 06/14] hash: Export the function to show a hash

Simon Glass sjg at chromium.org
Tue Jun 3 06:04:49 CEST 2014


This function is useful for displaying a hash value, so export it.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

Changes in v3:
- Rebase to master and update commit message

Changes in v2: None

 common/hash.c  |  7 +++----
 include/hash.h | 15 +++++++++++++++
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/common/hash.c b/common/hash.c
index 7627b84..41a4a28 100644
--- a/common/hash.c
+++ b/common/hash.c
@@ -311,8 +311,7 @@ int hash_lookup_algo(const char *algo_name, struct hash_algo **algop)
 	return -EPROTONOSUPPORT;
 }
 
-static void show_hash(struct hash_algo *algo, ulong addr, ulong len,
-		      u8 *output)
+void hash_show(struct hash_algo *algo, ulong addr, ulong len, u8 *output)
 {
 	int i;
 
@@ -392,7 +391,7 @@ int hash_command(const char *algo_name, int flags, cmd_tbl_t *cmdtp, int flag,
 			if (memcmp(output, vsum, algo->digest_size) != 0) {
 				int i;
 
-				show_hash(algo, addr, len, output);
+				hash_show(algo, addr, len, output);
 				printf(" != ");
 				for (i = 0; i < algo->digest_size; i++)
 					printf("%02x", vsum[i]);
@@ -400,7 +399,7 @@ int hash_command(const char *algo_name, int flags, cmd_tbl_t *cmdtp, int flag,
 				return 1;
 			}
 		} else {
-			show_hash(algo, addr, len, output);
+			hash_show(algo, addr, len, output);
 			printf("\n");
 
 			if (argc) {
diff --git a/include/hash.h b/include/hash.h
index dc21678..c6de20d 100644
--- a/include/hash.h
+++ b/include/hash.h
@@ -125,4 +125,19 @@ int hash_block(const char *algo_name, const void *data, unsigned int len,
  * @return 0 if ok, -EPROTONOSUPPORT for an unknown algorithm.
  */
 int hash_lookup_algo(const char *algo_name, struct hash_algo **algop);
+
+/**
+ * hash_show() - Print out a hash algorithm and value
+ *
+ * You will get a message like this (without a newline at the end):
+ *
+ * "sha1 for 9eb3337c ... 9eb3338f ==> 7942ef1df479fd3130f716eb9613d107dab7e257"
+ *
+ * @algo:		Algorithm used for hash
+ * @addr:		Address of data that was hashed
+ * @len:		Length of data that was hashed
+ * @output:		Hash value to display
+ */
+void hash_show(struct hash_algo *algo, ulong addr, ulong len, u8 *output);
+
 #endif
-- 
1.9.1.423.g4596e3a



More information about the U-Boot mailing list