Re: [PATCH u-boot-mvebu v3 06/18] arm: mvebu: turris_omnia: Print board ECDSA public key if available

Stefan Roese
2024-03-28T09:56:27Z

On 3/27/24 17:23, Marek Behún wrote:
> If MCU supports the FEAT_CRYPTO feature, read board ECDSA public key
> from MCU and print it.
>
> Signed-off-by: Marek Behún <kabel@kernel.org>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
> board/CZ.NIC/turris_omnia/turris_omnia.c | 25 +++++++++++++++++++++++-
> 1 file changed, 24 insertions(+), 1 deletion(-)
>
> diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c
> index f63640ad64..b2f0088e5e 100644
> --- a/board/CZ.NIC/turris_omnia/turris_omnia.c
> +++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
> @@ -253,6 +253,24 @@ static int omnia_mcu_board_info(char *serial, u8 *mac, char *version)
> return 0;
> }
>
> +static int omnia_mcu_get_board_public_key(char pub_key[static 67])
> +{
> + u8 reply[34];
> + int ret;
> +
> + ret = omnia_mcu_read(CMD_CRYPTO_GET_PUBLIC_KEY, reply, sizeof(reply));
> + if (ret)
> + return ret;
> +
> + if (reply[0] != 33)
> + return -EBADMSG;
> +
> + bin2hex(pub_key, &reply[1], 33);
> + pub_key[66] = '\0';
> +
> + return 0;
> +}
> +
> static void enable_a385_watchdog(unsigned int timeout_minutes)
> {
> struct sar_freq_modes sar_freq;
> @@ -1032,7 +1050,7 @@ int board_late_init(void)
>
> int checkboard(void)
> {
> - char serial[17], version[4];
> + char serial[17], version[4], pub_key[67];
> bool has_version;
> int err;
>
> @@ -1051,6 +1069,11 @@ int checkboard(void)
> printf(" Board version: %s\n", has_version ? version : "unknown");
> printf(" Serial Number: %s\n", !err ? serial : "unknown");
>
> + if (omnia_mcu_has_feature(FEAT_CRYPTO)) {
> + err = omnia_mcu_get_board_public_key(pub_key);
> + printf(" ECDSA Public Key: %s\n", !err ? pub_key : "unknown");
> + }
> +
> return 0;
> }
>

Viele Grüße,
Stefan Roese

--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de