diff options
-rw-r--r-- | drivers/char/random.c | 22 | ||||
-rw-r--r-- | include/linux/random.h | 1 |
2 files changed, 23 insertions, 0 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index e7e479c..d423b8c 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1467,6 +1467,28 @@ unsigned int get_random_int(void) } /* + * Same as get_random_int(), but returns unsigned long. + */ +unsigned long get_random_long(void) +{ + __u32 *hash; + unsigned long ret; + + if (arch_get_random_long(&ret)) + return ret; + + hash = get_cpu_var(get_random_int_hash); + + hash[0] += current->pid + jiffies + get_cycles(); + md5_transform(hash, random_int_secret); + ret = *(unsigned long *)hash; + put_cpu_var(get_random_int_hash); + + return ret; +} +EXPORT_SYMBOL(get_random_long); + +/* * randomize_range() returns a start address such that * * [...... <range> .....] diff --git a/include/linux/random.h b/include/linux/random.h index 7e58ad2..766e669 100644 --- a/include/linux/random.h +++ b/include/linux/random.h @@ -63,6 +63,7 @@ extern const struct file_operations random_fops, urandom_fops; #endif unsigned int get_random_int(void); +unsigned long get_random_long(void); unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len); u32 random32(void); |