From ead71fd20b54f426ae393c0919327fcb1c7c2356 Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Mon, 17 Dec 2012 16:04:25 -0800 Subject: prandom: introduce prandom_bytes() and prandom_bytes_state() Add functions to get the requested number of pseudo-random bytes. The difference from get_random_bytes() is that it generates pseudo-random numbers by prandom_u32(). It doesn't consume the entropy pool, and the sequence is reproducible if the same rnd_state is used. So it is suitable for generating random bytes for testing. Signed-off-by: Akinobu Mita Cc: "Theodore Ts'o" Cc: Artem Bityutskiy Cc: Adrian Hunter Cc: David Woodhouse Cc: Eilon Greenstein Cc: David Laight Cc: Michel Lespinasse Cc: Robert Love Cc: Valdis Kletnieks Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/random.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/linux/random.h b/include/linux/random.h index f262b9dddc87..fe0e2605af5d 100644 --- a/include/linux/random.h +++ b/include/linux/random.h @@ -65,6 +65,7 @@ unsigned int get_random_int(void); unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len); u32 prandom_u32(void); +void prandom_bytes(void *buf, int nbytes); void prandom_seed(u32 seed); /* @@ -75,6 +76,7 @@ void prandom_seed(u32 seed); #define srandom32(seed) prandom_seed(seed) u32 prandom_u32_state(struct rnd_state *); +void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes); /* * Handle minimum values for seeds -- cgit v1.2.3