@@ -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;
}
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(-)