[PATCH v2 4/6] KEYS: trusted: allow trust sources to use kernel RNG for key material
Ahmad Fatoum
a.fatoum at pengutronix.de
Tue Jun 22 12:37:50 UTC 2021
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.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
To: James Bottomley <jejb at linux.ibm.com>
To: Jarkko Sakkinen <jarkko at kernel.org>
To: Mimi Zohar <zohar at linux.ibm.com>
To: David Howells <dhowells at redhat.com>
Cc: James Morris <jmorris at namei.org>
Cc: "Serge E. Hallyn" <serge at hallyn.com>
Cc: "Horia Geantă" <horia.geanta at nxp.com>
Cc: Aymen Sghaier <aymen.sghaier at nxp.com>
Cc: Herbert Xu <herbert at gondor.apana.org.au>
Cc: "David S. Miller" <davem at davemloft.net>
Cc: Udit Agarwal <udit.agarwal at nxp.com>
Cc: Eric Biggers <ebiggers at kernel.org>
Cc: Jan Luebbe <j.luebbe at pengutronix.de>
Cc: David Gstir <david at sigma-star.at>
Cc: Richard Weinberger <richard at nod.at>
Cc: Franck LENORMAND <franck.lenormand at nxp.com>
Cc: Sumit Garg <sumit.garg at linaro.org>
Cc: keyrings at vger.kernel.org
Cc: linux-crypto at vger.kernel.org
Cc: linux-integrity at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Cc: linux-security-module at vger.kernel.org
---
include/keys/trusted-type.h | 2 +-
security/keys/trusted-keys/trusted_core.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
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. */
diff --git a/security/keys/trusted-keys/trusted_core.c b/security/keys/trusted-keys/trusted_core.c
index 2eeb7117e86b..8d829e6866ca 100644
--- a/security/keys/trusted-keys/trusted_core.c
+++ b/security/keys/trusted-keys/trusted_core.c
@@ -351,7 +351,7 @@ static int __init init_trusted(void)
continue;
get_random = trusted_key_sources[i].ops->get_random;
- if (trusted_kernel_rng)
+ if (trusted_kernel_rng || !get_random)
get_random = kernel_get_random;
static_call_update(trusted_key_init,
--
git-series 0.9.1
More information about the Linux-security-module-archive
mailing list