[PATCH 05/15] commands: keys: update output format to include keyring

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Oct 22 02:43:06 PDT 2025


Hi,

On 10/14/25 1:02 PM, Jonas Rebmann wrote:
> Also show the algorithm used.
> 
> Signed-off-by: Jonas Rebmann <jre at pengutronix.de>
> ---
>  commands/keys.c             |  8 ++------
>  include/crypto/public_key.h | 12 ++++++++++++
>  2 files changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/commands/keys.c b/commands/keys.c
> index 2d85e8124f..e1e87f3e9e 100644
> --- a/commands/keys.c
> +++ b/commands/keys.c
> @@ -7,12 +7,8 @@ static int do_keys(int argc, char *argv[])
>  	const struct public_key *key;
>  
>  	for_each_public_key(key) {
> -		printf("KEY: %*phN", key->hashlen, key->hash);
> -
> -		if (key->key_name_hint)
> -			printf(" (%s)\n", key->key_name_hint);
> -		else
> -			printf("\n");
> +		printf("KEY: %*phN\tTYPE: %s\tKEYRING: %s\tHINT: %s\n", key->hashlen,
> +		       key->hash, public_key_type_string(key->type), key->keyring, key->key_name_hint);

Given that hint is only relevant to FIT, I think it would be better to
hide it when it's empty.

Cheers,
Ahmad

>  	}
>  
>  	return 0;
> diff --git a/include/crypto/public_key.h b/include/crypto/public_key.h
> index 44ae09e4d0..269b878a04 100644
> --- a/include/crypto/public_key.h
> +++ b/include/crypto/public_key.h
> @@ -12,6 +12,18 @@ enum public_key_type {
>  	PUBLIC_KEY_TYPE_ECDSA,
>  };
>  
> +static inline const char *public_key_type_string(enum public_key_type type)
> +{
> +	switch (type) {
> +	case PUBLIC_KEY_TYPE_RSA:
> +		return "RSA";
> +	case PUBLIC_KEY_TYPE_ECDSA:
> +		return "ECDSA";
> +	default:
> +		return "unknown";
> +	}
> +}
> +
>  struct public_key {
>  	enum public_key_type type;
>  	struct list_head list;
> 

-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |




More information about the barebox mailing list