[PATCH 3/4] cmd: mvebu/bubt: Add support for sha512 checksum validation for Armada 3700
Stefan Roese
sr at denx.de
Thu Jul 28 08:37:58 CEST 2022
On 26.07.22 16:11, Pali Rohár wrote:
> Armada 3700 BootROM supports also images with sha512 checksums and
> mox-imager tool [1] generates such bootable images. Without sha512 support
> U-Boot bubt command just prints error message:
>
> Error: Unsupported hash_algorithm_id = 64
> Error: Image header verification failed
>
> This patch adds support for sha512 checksum validation for Armada 3700
> images. With it bubt prints:
>
> Image checksum...OK!
>
> [1] - https://gitlab.nic.cz/turris/mox-boot-builder.git
>
> Signed-off-by: Pali Rohár <pali at kernel.org>
Reviewed-by: Stefan Roese <sr at denx.de>
Thanks,
Stefan
> ---
> cmd/mvebu/Kconfig | 1 +
> cmd/mvebu/bubt.c | 9 +++++++++
> 2 files changed, 10 insertions(+)
>
> diff --git a/cmd/mvebu/Kconfig b/cmd/mvebu/Kconfig
> index 39963db82c98..120397d6d4d0 100644
> --- a/cmd/mvebu/Kconfig
> +++ b/cmd/mvebu/Kconfig
> @@ -4,6 +4,7 @@ depends on ARCH_MVEBU
> config CMD_MVEBU_BUBT
> bool "bubt"
> select SHA256 if ARMADA_3700
> + select SHA512 if ARMADA_3700
> help
> bubt - Burn a u-boot image to flash
> For details about bubt command please see the documentation
> diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c
> index 2924b1539f32..276069a0efc2 100644
> --- a/cmd/mvebu/bubt.c
> +++ b/cmd/mvebu/bubt.c
> @@ -26,6 +26,7 @@
> #endif
> #include <u-boot/sha1.h>
> #include <u-boot/sha256.h>
> +#include <u-boot/sha512.h>
>
> #if defined(CONFIG_ARMADA_8K)
> #define MAIN_HDR_MAGIC 0xB105B002
> @@ -566,8 +567,10 @@ static int check_image_header(void)
> int image_num;
> u8 hash_160_output[SHA1_SUM_LEN];
> u8 hash_256_output[SHA256_SUM_LEN];
> + u8 hash_512_output[SHA512_SUM_LEN];
> sha1_context hash1_text;
> sha256_context hash256_text;
> + sha512_context hash512_text;
> u8 *hash_output;
> u32 hash_algorithm_id;
> u32 image_size_to_hash;
> @@ -637,6 +640,12 @@ static int check_image_header(void)
> sha256_finish(&hash256_text, hash_256_output);
> hash_output = hash_256_output;
> break;
> + case SHA512_SUM_LEN:
> + sha512_starts(&hash512_text);
> + sha512_update(&hash512_text, buff, image_size_to_hash);
> + sha512_finish(&hash512_text, hash_512_output);
> + hash_output = hash_512_output;
> + break;
> default:
> printf("Error: Unsupported hash_algorithm_id = %d\n",
> hash_algorithm_id);
Viele Grüße,
Stefan Roese
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de
More information about the U-Boot
mailing list