1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2013, Andreas Oetken.
9 #include <asm/byteorder.h>
10 #include <linux/errno.h>
11 #include <asm/unaligned.h>
16 #include <u-boot/rsa.h>
18 int hash_calculate(const char *name,
19 const struct image_region region[],
20 int region_count, uint8_t *checksum)
22 struct hash_algo *algo;
28 ret = hash_progressive_lookup_algo(name, &algo);
32 ret = algo->hash_init(algo, &ctx);
36 for (i = 0; i < region_count - 1; i++) {
37 ret = algo->hash_update(algo, ctx, region[i].data,
43 ret = algo->hash_update(algo, ctx, region[i].data, region[i].size, 1);
46 ret = algo->hash_finish(algo, ctx, checksum, algo->digest_size);