[PATCH u-boot v2019.04-aspeed-openbmc 06/11] image-fit: use hashing infra

Klaus Heinrich Kiwi klaus at linux.vnet.ibm.com
Tue Apr 13 22:38:39 AEST 2021



On 4/13/2021 5:07 AM, Joel Stanley wrote:
> Signed-off-by: Joel Stanley <joel at jms.id.au>
> ---
>   common/image-fit.c | 16 +++++++++++++++-
>   1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/common/image-fit.c b/common/image-fit.c
> index e64949dfa73d..b9c3d79b83e1 100644
> --- a/common/image-fit.c
> +++ b/common/image-fit.c
> @@ -1135,9 +1135,22 @@ int fit_set_timestamp(void *fit, int noffset, time_t timestamp)
>    *     0, on success
>    *    -1, when algo is unsupported
>    */
> -int calculate_hash(const void *data, int data_len, const char *algo,
> +int calculate_hash(const void *data, int data_len, const char *algo_name,
>   			uint8_t *value, int *value_len)
Is the API changing here, or you just needed the 'algo' variable name for something else?
Are all callers OK with that?

>   {
> +	struct hash_algo *algo;
> +
> +	if (hash_lookup_algo(algo_name, &algo)) {
> +		debug("Unsupported hash alogrithm\n");
> +		return -1;
> +	}
> +
> +	algo->hash_func_ws(data, data_len, value, algo->chunk_size);
> +	*value_len = algo->digest_size;
> +
> +	return 0;
> +
> +#if 0

Can you expand the rationale behind keeping this dead code around?

>   	if (IMAGE_ENABLE_CRC32 && strcmp(algo, "crc32") == 0) {
>   		*((uint32_t *)value) = crc32_wd(0, data, data_len,
>   							CHUNKSZ_CRC32);
> @@ -1167,6 +1180,7 @@ int calculate_hash(const void *data, int data_len, const char *algo,
>   		return -1;
>   	}
>   	return 0;
> +#endif
>   }
> 
>   static int fit_image_check_hash(const void *fit, int noffset, const void *data,
> 

-- 
Klaus Heinrich Kiwi <klaus at linux.vnet.ibm.com>


More information about the openbmc mailing list