From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5B058C00140 for ; Tue, 26 Jul 2022 14:12:34 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 59012840C3; Tue, 26 Jul 2022 16:12:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="CXG2Q5mY"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8C37B8407F; Tue, 26 Jul 2022 16:12:19 +0200 (CEST) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D7ED28409F for ; Tue, 26 Jul 2022 16:12:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7479EB81675; Tue, 26 Jul 2022 14:12:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 102FCC433D7; Tue, 26 Jul 2022 14:12:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658844735; bh=qi5Byh4e7i79s6FvRcxPfreHJcjereaChNIbRAEtUy8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CXG2Q5mYLrxywdR7XkYJpo+BVOhIfMJ9BWDQqhMvHeA0Xxh/+dLmYTXTo5AR19xYg wILRd8p1uBGM+Or5AmqOCTqcyeQAQK+Rb+beVTb6pJI0kJuYl3ONLHm/UJSosMgn9V j2ZWBO+R2NSITG9xRVjosAZMTWfhLhLJsGdyJnmP2zXG1AMs7K9rsufhX7AAfArpzH WCalW8NU4VJXCXRnp6KJrMjmX4M8nrhdkSjMRI/JybMZLstUU/qnNtMMBnyReT/xYn fkfrBewbbNaIRMQfkpITJiJEYKbNZA/ZkNXzEE37QeCz1yfq7wQebqieX69C1fMHFZ bhkqzKeB1Z2qg== Received: by pali.im (Postfix) id 9CA324A13; Tue, 26 Jul 2022 16:12:12 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Stefan Roese , Michal Simek , Simon Glass Cc: u-boot@lists.denx.de Subject: [PATCH 3/4] cmd: mvebu/bubt: Add support for sha512 checksum validation for Armada 3700 Date: Tue, 26 Jul 2022 16:11:58 +0200 Message-Id: <20220726141159.19774-4-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220726141159.19774-1-pali@kernel.org> References: <20220726141159.19774-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean 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 --- 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 #include +#include #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); -- 2.20.1