From 6582c665d6b882dad8329e05749fbcf119f1ab88 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 db6debc6649e..d9846088c2c5 100644 --- a/include/linux/random.h +++ b/include/linux/random.h @@ -26,6 +26,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); /* @@ -36,6 +37,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-59-g8ed1b