Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1327219
| From | Daniel Cashman <dcashman@android.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 1/2] drivers: char: random: Add get_random_long(). |
| Date | 2016-02-04 23:10 +0100 |
| Message-ID | <qYAg9-84a-5@gated-at.bofh.it> (permalink) |
| References | <qYAg9-84a-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Signed-off-by: Daniel Cashman <dcashman@android.com>
---
drivers/char/random.c | 22 ++++++++++++++++++++++
include/linux/random.h | 1 +
2 files changed, 23 insertions(+)
diff --git a/drivers/char/random.c b/drivers/char/random.c
index d0da5d8..b583e53 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1819,6 +1819,28 @@ unsigned int get_random_int(void)
EXPORT_SYMBOL(get_random_int);
/*
+ * 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 + random_get_entropy();
+ 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 a75840c..9c29122 100644
--- a/include/linux/random.h
+++ b/include/linux/random.h
@@ -34,6 +34,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 prandom_u32(void);
--
2.7.0.rc3.207.g0ac5344
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH 1/2] drivers: char: random: Add get_random_long(). Daniel Cashman <dcashman@android.com> - 2016-02-04 23:10 +0100
csiph-web