[PATCH v3 07/15] crypto: rsa: include key name hint into CONFIG_CRYPTO_RSA_KEY

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Sep 11 01:27:42 PDT 2024


Hello Sascha,

On 06.09.24 12:40, Sascha Hauer wrote:
> Set the key name hint in CONFIG_CRYPTO_RSA_KEY. CONFIG_CRYPTO_RSA_KEY
> now has the form:
> 
> <key_name_hint>:<filename/uri>
> 
> This is done in preparation to make CONFIG_CRYPTO_RSA_KEY a list of
> keys.

IIUC, existing users that do make oldconfig will:

  - either lose the key hint and need to add it back or just live with
    an iteration of the list

  - have pkcs11:$uri URIs which will be interpreted as key hint and
    result on some error message that the URI is not a valid path.

Can we check if the hint is pkcs11 in the rsa-keys.h rule and bail out with
a sensible error message?

Cheers,
Ahmad


> 
> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> ---
>  crypto/Kconfig  | 9 ++-------
>  crypto/Makefile | 7 +++----
>  2 files changed, 5 insertions(+), 11 deletions(-)
> 
> diff --git a/crypto/Kconfig b/crypto/Kconfig
> index 78b499f646..64a016eb2c 100644
> --- a/crypto/Kconfig
> +++ b/crypto/Kconfig
> @@ -130,17 +130,12 @@ config CRYPTO_RSA_KEY
>  	  This option should be a filename of a PEM-formatted file containing
>  	  X.509 certificates to be included into barebox. If the string starts
>  	  with "pkcs11:" it is interpreted as a PKCS#11 URI rather than a file.
> +	  If the string starts with a <hint>: prefix, <hint> is used as a key
> +	  name hint to find a key without iterating over all keys.
>  
>  	  This avoids the mkimage dependency of CONFIG_BOOTM_FITIMAGE_PUBKEY
>  	  at the cost of an openssl build-time dependency.
>  
> -config CRYPTO_RSA_KEY_NAME_HINT
> -	depends on CRYPTO_RSA
> -	string "FIT image key name hint"
> -	help
> -	  In FIT images keys are identified by a key name hint string. Provide
> -	  the key name hint here.
> -
>  config CRYPTO_KEYSTORE
>  	bool "Keystore"
>  	help
> diff --git a/crypto/Makefile b/crypto/Makefile
> index d7a06a721d..f3e49ab7ba 100644
> --- a/crypto/Makefile
> +++ b/crypto/Makefile
> @@ -29,10 +29,9 @@ $(obj)/rsa.o: $(obj)/rsa-keys.h
>  
>  CONFIG_CRYPTO_RSA_KEY := $(CONFIG_CRYPTO_RSA_KEY:"%"=%)
>  
> -ifneq ($(filter-out pkcs11:% __ENV__%, $(CONFIG_CRYPTO_RSA_KEY)),)
> -RSA_DEP := $(CONFIG_CRYPTO_RSA_KEY)
> -endif
> +RSA_DEP := $(filter-out pkcs11:% __ENV__%, $(CONFIG_CRYPTO_RSA_KEY))
> +RSA_DEP := $(shell echo $(RSA_DEP) | sed -e "s/[[:alnum:]]*://g")
>  
>  $(obj)/rsa-keys.h: $(RSA_DEP) FORCE
> -	$(call cmd,public_keys,$(CONFIG_CRYPTO_RSA_KEY_NAME_HINT):$(CONFIG_CRYPTO_RSA_KEY))
> +	$(call cmd,public_keys,$(CONFIG_CRYPTO_RSA_KEY))
>  endif


-- 
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