summaryrefslogtreecommitdiff
path: root/common/hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/hash.c')
-rw-r--r--common/hash.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/common/hash.c b/common/hash.c
index 71c4bef5826..5cbb4926c1d 100644
--- a/common/hash.c
+++ b/common/hash.c
@@ -11,6 +11,7 @@
#ifndef USE_HOSTCC
#include <command.h>
+#include <dm.h>
#include <env.h>
#include <log.h>
#include <malloc.h>
@@ -20,6 +21,7 @@
#include <asm/global_data.h>
#include <asm/io.h>
#include <linux/errno.h>
+#include <u-boot/hash.h>
#else
#include "mkimage.h"
#include <linux/compiler_attributes.h>
@@ -614,7 +616,26 @@ int hash_command(const char *algo_name, int flags, struct cmd_tbl *cmdtp,
return CMD_RET_FAILURE;
buf = map_sysmem(addr, len);
+ if (CONFIG_IS_ENABLED(DM_HASH)) {
+ enum HASH_ALGO hash_algo;
+ int ret;
+
+ hash_algo = hash_algo_lookup_by_name(algo_name);
+ if (hash_algo != HASH_ALGO_INVALID) {
+ ret = hash_digest_wd_lookup(hash_algo, buf, len,
+ output,
+ algo->chunk_size);
+ if (ret && ret != -ENODEV && ret != -EOPNOTSUPP) {
+ unmap_sysmem(buf);
+ free(output);
+ return CMD_RET_FAILURE;
+ }
+ if (!ret)
+ goto done;
+ }
+ }
algo->hash_func_ws(buf, len, output, algo->chunk_size);
+done:
unmap_sysmem(buf);
/* Try to avoid code bloat when verify is not needed */