[U-Boot] [PATCH v2 2/3] fit: allow fit to call hardware accelerated hash

Tom Rini trini at konsulko.com
Mon Jun 18 16:59:28 UTC 2018


On Wed, Jun 06, 2018 at 05:03:57PM +0100, Ben Whitten wrote:

> Move to calling the abstraction which allows for hardware acceleration.
> We also remove unneeded defines and only include objects if required.
> 
> Signed-off-by: Ben Whitten <ben.whitten at lairdtech.com>
[snip]
> diff --git a/common/image-fit.c b/common/image-fit.c
> index 8c15ed1..7d8c961 100644
> --- a/common/image-fit.c
> +++ b/common/image-fit.c
> @@ -1082,26 +1082,17 @@ int fit_set_timestamp(void *fit, int noffset, time_t timestamp)
>  int calculate_hash(const void *data, int data_len, const char *algo,
>  			uint8_t *value, int *value_len)
>  {
> -	if (IMAGE_ENABLE_CRC32 && strcmp(algo, "crc32") == 0) {
> -		*((uint32_t *)value) = crc32_wd(0, data, data_len,
> -							CHUNKSZ_CRC32);
> -		*((uint32_t *)value) = cpu_to_uimage(*((uint32_t *)value));
> -		*value_len = 4;
> -	} else if (IMAGE_ENABLE_SHA1 && strcmp(algo, "sha1") == 0) {
> -		sha1_csum_wd((unsigned char *)data, data_len,
> -			     (unsigned char *)value, CHUNKSZ_SHA1);
> -		*value_len = 20;
> -	} else if (IMAGE_ENABLE_SHA256 && strcmp(algo, "sha256") == 0) {
> -		sha256_csum_wd((unsigned char *)data, data_len,
> -			       (unsigned char *)value, CHUNKSZ_SHA256);
> -		*value_len = SHA256_SUM_LEN;
> -	} else if (IMAGE_ENABLE_MD5 && strcmp(algo, "md5") == 0) {
> -		md5_wd((unsigned char *)data, data_len, value, CHUNKSZ_MD5);
> -		*value_len = 16;
> -	} else {
> +	struct hash_algo *hash_algo;
> +	int ret;
> +
> +	ret = hash_lookup_algo(algo, &hash_algo);

This is unfortunately not code equivalent.  There's a little bit missing
to switch this over to using SPL_CRC32_SUPPORT as well.  A good test
would be to make sure that a sunxi platform still builds after this (it
doesn't currently with the series) and use buildman -Ssdel to compare
before/after sizes and make sure it's a tiny change in size related to
the code switch and not a huge change due to droppped (or added!)
support.  Thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180618/585cbd04/attachment.sig>


More information about the U-Boot mailing list