diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2022-10-10 08:11:20 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-10-11 16:46:25 +0200 |
commit | 95826c7f99f6f56a38b3f325a1c8c5e403cd28db (patch) | |
tree | 66d043e5311e661b12bbe0b67e69a3cc12c58d1d /include | |
parent | 8f97a2adf7ea7335f9b0c9813cd05cfe5a7b062d (diff) | |
download | barebox-95826c7f99f6f56a38b3f325a1c8c5e403cd28db.tar.gz barebox-95826c7f99f6f56a38b3f325a1c8c5e403cd28db.tar.xz |
lib: random: add hwrng_get_crypto_bytes
We already have get_crypto_bytes to get access to hardware generated
randomness. barebox as EFI loader would provide a handle for each HWRNG,
so add a hwrng_get_crypto_bytes function that can be used to implement
the load-side protocol.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20221010061122.2084009-9-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/hw_random.h | 6 | ||||
-rw-r--r-- | include/stdlib.h | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/include/linux/hw_random.h b/include/linux/hw_random.h index 116afd9721..e541abfa17 100644 --- a/include/linux/hw_random.h +++ b/include/linux/hw_random.h @@ -36,12 +36,16 @@ struct hwrng { /* Register a new Hardware Random Number Generator driver. */ int hwrng_register(struct device_d *dev, struct hwrng *rng); -int hwrng_get_data(struct hwrng *rng, void *buffer, size_t size, int wait); #ifdef CONFIG_HWRNG struct hwrng *hwrng_get_first(void); +int hwrng_get_data(struct hwrng *rng, void *buffer, size_t size, int wait); #else static inline struct hwrng *hwrng_get_first(void) { return ERR_PTR(-ENODEV); }; +static inline int hwrng_get_data(struct hwrng *rng, void *buffer, size_t size, int wait) +{ + return -ENODEV; +} #endif void hwrng_unregister(struct hwrng *rng); diff --git a/include/stdlib.h b/include/stdlib.h index 8eb419e111..0305970557 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -15,6 +15,8 @@ void srand(unsigned int seed); /* fill a buffer with pseudo-random data */ void get_random_bytes(void *buf, int len); int get_crypto_bytes(void *buf, int len); +struct hwrng; +int hwrng_get_crypto_bytes(struct hwrng *rng, void *buf, int len); static inline u32 random32(void) { |