From: "Marek Behún" <kabel@kernel.org>
To: Stefan Roese <sr@denx.de>
Cc: u-boot@lists.denx.de, "Marek Behún" <kabel@kernel.org>
Subject: [PATCH u-boot-mvebu 3/4] arm: mvebu: turris_omnia: Print board ECDSA public key if available
Date: Mon, 4 Mar 2024 16:21:47 +0100 [thread overview]
Message-ID: <20240304152148.3847-4-kabel@kernel.org> (raw)
In-Reply-To: <20240304152148.3847-1-kabel@kernel.org>
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>
---
board/CZ.NIC/turris_omnia/turris_omnia.c | 29 +++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c
index 7a51ed3ace5..46f576a460e 100644
--- a/board/CZ.NIC/turris_omnia/turris_omnia.c
+++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
@@ -75,6 +75,9 @@ enum mcu_commands {
/* available if EXT_CMD bit set in features */
CMD_EXT_CONTROL = 0x12,
+ /* available if CRYPTO bit set in features */
+ CMD_CRYPTO_GET_PUBLIC_KEY = 0x29,
+
/* available if BOARD_INFO it set in features */
CMD_BOARD_INFO_GET = 0x2c,
};
@@ -94,6 +97,7 @@ enum status_word_bits {
enum features_e {
FEAT_PERIPH_MCU = BIT(0),
FEAT_EXT_CMDS = BIT(1),
+ FEAT_CRYPTO = BIT(14),
FEAT_BOARD_INFO = BIT(15),
};
@@ -285,6 +289,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);
+ reply[66] = '\0';
+
+ return 0;
+}
+
static void enable_a385_watchdog(unsigned int timeout_minutes)
{
struct sar_freq_modes sar_freq;
@@ -1060,7 +1082,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;
@@ -1080,6 +1102,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;
}
--
2.43.0
next prev parent reply other threads:[~2024-03-04 15:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-04 15:21 [PATCH u-boot-mvebu 0/4] Turris Omnia - New board revision support Marek Behún
2024-03-04 15:21 ` [PATCH u-boot-mvebu 1/4] arm: mvebu: turris_omnia: Refactor MCU status and features reading Marek Behún
2024-03-04 15:21 ` [PATCH u-boot-mvebu 2/4] arm: mvebu: turris_omnia: Implement getting board information from MCU Marek Behún
2024-03-04 15:21 ` Marek Behún [this message]
2024-03-04 15:21 ` [PATCH u-boot-mvebu 4/4] arm: mvebu: turris_omnia: Disable Atmel SHA node if not present Marek Behún
2024-03-23 16:58 ` [PATCH u-boot-mvebu 0/4] Turris Omnia - New board revision support Marek Behún
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240304152148.3847-4-kabel@kernel.org \
--to=kabel@kernel.org \
--cc=sr@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.