diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2012-12-17 16:04:25 -0800 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2013-02-22 10:12:20 +0200 |
commit | ead71fd20b54f426ae393c0919327fcb1c7c2356 (patch) | |
tree | aa390dbcad56df7f484901fde327cdd129936bb4 /include/linux | |
parent | 7f7b3145889da64644f04f026101f33e1702357f (diff) |
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 <akinobu.mita@gmail.com>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Artem Bityutskiy <dedekind1@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Eilon Greenstein <eilong@broadcom.com>
Cc: David Laight <david.laight@aculab.com>
Cc: Michel Lespinasse <walken@google.com>
Cc: Robert Love <robert.w.love@intel.com>
Cc: Valdis Kletnieks <valdis.kletnieks@vt.edu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/random.h | 2 |
1 files changed, 2 insertions, 0 deletions
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 |