On 22.02.22 20:58, Ahmad Fatoum wrote: > The two existing trusted key sources don't make use of the kernel RNG, > but instead let the hardware that does the sealing/unsealing also > generate the random key material. While a previous change offers users > the choice to use the kernel RNG instead for both, new trust sources > may want to unconditionally use the kernel RNG for generating key > material, like it's done elsewhere in the kernel. > > This is especially prudent for hardware that has proven-in-production > HWRNG drivers implemented, as otherwise code would have to be duplicated > only to arrive at a possibly worse result. > > Make this possible by turning struct trusted_key_ops::get_random > into an optional member. If a driver leaves it NULL, kernel RNG > will be used instead. The rebase on the change in scope of the previous commit made this one here quite small. I would squash it into the previous commit for v6, unless there are objections. > > Acked-by: Sumit Garg <sumit.garg@xxxxxxxxxx> > Reviewed-by: David Gstir <david@xxxxxxxxxxxxx> > Tested-By: Tim Harvey <tharvey@xxxxxxxxxxxxx> > Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> > --- > To: James Bottomley <jejb@xxxxxxxxxxxxx> > To: Jarkko Sakkinen <jarkko@xxxxxxxxxx> > To: Mimi Zohar <zohar@xxxxxxxxxxxxx> > To: David Howells <dhowells@xxxxxxxxxx> > Cc: James Morris <jmorris@xxxxxxxxx> > Cc: "Serge E. Hallyn" <serge@xxxxxxxxxx> > Cc: "Horia Geantă" <horia.geanta@xxxxxxx> > Cc: Aymen Sghaier <aymen.sghaier@xxxxxxx> > Cc: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> > Cc: "David S. Miller" <davem@xxxxxxxxxxxxx> > Cc: Eric Biggers <ebiggers@xxxxxxxxxx> > Cc: Jan Luebbe <j.luebbe@xxxxxxxxxxxxxx> > Cc: David Gstir <david@xxxxxxxxxxxxx> > Cc: Richard Weinberger <richard@xxxxxx> > Cc: Franck LENORMAND <franck.lenormand@xxxxxxx> > Cc: Sumit Garg <sumit.garg@xxxxxxxxxx> > Cc: Tim Harvey <tharvey@xxxxxxxxxxxxx> > Cc: Matthias Schiffer <matthias.schiffer@xxxxxxxxxxxxxxx> > Cc: Pankaj Gupta <pankaj.gupta@xxxxxxx> > Cc: keyrings@xxxxxxxxxxxxxxx > Cc: linux-crypto@xxxxxxxxxxxxxxx > Cc: linux-integrity@xxxxxxxxxxxxxxx > Cc: linux-kernel@xxxxxxxxxxxxxxx > Cc: linux-security-module@xxxxxxxxxxxxxxx > --- > include/keys/trusted-type.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/keys/trusted-type.h b/include/keys/trusted-type.h > index d89fa2579ac0..4eb64548a74f 100644 > --- a/include/keys/trusted-type.h > +++ b/include/keys/trusted-type.h > @@ -64,7 +64,7 @@ struct trusted_key_ops { > /* Unseal a key. */ > int (*unseal)(struct trusted_key_payload *p, char *datablob); > > - /* Get a randomized key. */ > + /* Optional: Get a randomized key. */ > int (*get_random)(unsigned char *key, size_t key_len); > > /* Exit key interface. */ -- 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 |