summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-03-11 09:08:47 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2017-03-11 09:08:47 -0800
commit84c37c168c0e49a412d7021cda3183a72adac0d0 (patch)
tree2a50857925f3b89c9b5b3b0cc7e2e7f485a95b50 /include
parent434fd6353b4c83938029ca6ea7dfa4fc82d602bd (diff)
parentdb61ffe3a71c697aaa91c42c862a5f7557a0e562 (diff)
downloadlinux-stable-84c37c168c0e49a412d7021cda3183a72adac0d0.tar.gz
linux-stable-84c37c168c0e49a412d7021cda3183a72adac0d0.tar.bz2
linux-stable-84c37c168c0e49a412d7021cda3183a72adac0d0.zip
Merge tag 'random_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random
Pull random updates from Ted Ts'o: "Change get_random_{int,log} to use the CRNG used by /dev/urandom and getrandom(2). It's faster and arguably more secure than cut-down MD5 that we had been using. Also do some code cleanup" * tag 'random_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random: random: move random_min_urandom_seed into CONFIG_SYSCTL ifdef block random: convert get_random_int/long into get_random_u32/u64 random: use chacha20 for get_random_int/long random: fix comment for unused random_min_urandom_seed random: remove variable limit random: remove stale urandom_init_wait random: remove stale maybe_reseed_primary_crng
Diffstat (limited to 'include')
-rw-r--r--include/linux/random.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/include/linux/random.h b/include/linux/random.h
index 7bd2403e4fef..ed5c3838780d 100644
--- a/include/linux/random.h
+++ b/include/linux/random.h
@@ -37,14 +37,26 @@ extern void get_random_bytes(void *buf, int nbytes);
extern int add_random_ready_callback(struct random_ready_callback *rdy);
extern void del_random_ready_callback(struct random_ready_callback *rdy);
extern void get_random_bytes_arch(void *buf, int nbytes);
-extern int random_int_secret_init(void);
#ifndef MODULE
extern const struct file_operations random_fops, urandom_fops;
#endif
-unsigned int get_random_int(void);
-unsigned long get_random_long(void);
+u32 get_random_u32(void);
+u64 get_random_u64(void);
+static inline unsigned int get_random_int(void)
+{
+ return get_random_u32();
+}
+static inline unsigned long get_random_long(void)
+{
+#if BITS_PER_LONG == 64
+ return get_random_u64();
+#else
+ return get_random_u32();
+#endif
+}
+
unsigned long randomize_page(unsigned long start, unsigned long range);
u32 prandom_u32(void);