Re: [PATCH v4 09/16] crypto: rsa: encapsulate rsa keys in public keys struct

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Sep 27, 2024 at 10:02:08AM +0200, Ahmad Fatoum wrote:
> On 13.09.24 09:59, Sascha Hauer wrote:
> > This encapsulates struct rsa_public_key into a struct public_key. So far
> > RSA keys are the only supported key type. With adding ECDSA keys we need
> > a container struct so that we can add ECDSA keys using the same
> > mechanisms.
> > 
> > Also we rename CONFIG_CRYPTO_RSA_KEY to CONFIG_CRYPTO_PUBLIC_KEYS and
> > CONFIG_CRYPTO_RSA_BUILTIN_KEYS to CONFIG_CRYPTO_BUILTIN_KEYS as these
> > variables will be used for all types of keys, not only RSA keys.
> > 
> > Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
> 
> Reviewed-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
> 
> But two comments below.
> 
> > diff --git a/crypto/public-keys.c b/crypto/public-keys.c
> > new file mode 100644
> > index 0000000000..a3ef3bafc8
> > --- /dev/null
> > +++ b/crypto/public-keys.c
> > @@ -0,0 +1,39 @@
> 
> add a pr_fmt?
> 
> > +#include <common.h>
> > +#include <crypto/public_key.h>
> > +#include <rsa.h>
> > +
> > +extern const struct public_key * const __public_keys_start;
> > +extern const struct public_key * const __public_keys_end;
> > +
> > +static int init_public_keys(void)
> > +{
> > +	const struct public_key * const *iter;
> > +	int ret;
> > +
> > +	for (iter = &__public_keys_start; iter != &__public_keys_end; iter++) {
> > +		struct rsa_public_key *rsa_key;
> > +
> > +		switch ((*iter)->type) {
> > +		case PUBLIC_KEY_TYPE_RSA:
> > +			rsa_key = rsa_key_dup((*iter)->rsa);
> > +			if (!rsa_key)
> > +				continue;
> > +
> > +			ret = rsa_key_add(rsa_key);
> > +			if (ret)
> > +				pr_err("Cannot add rsa key: %pe\n", ERR_PTR(ret));
> > +			break;
> > +		default:
> > +			pr_err("Ignoring unknown key type %u\n", (*iter)->type);
> > +		}
> > +
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> > +device_initcall(init_public_keys);
> > +
> 
> > -extern const struct rsa_public_key * const __rsa_keys_start;
> > -extern const struct rsa_public_key * const __rsa_keys_end;
> 
> I know you are just moving these around, but defining
> these with [] is way less confusing IMO.

This is changed in 12/16.

Sascha

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




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux