diff options
Diffstat (limited to 'drivers/char/random.c')
-rw-r--r-- | drivers/char/random.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index f824ef8a9273..b2ced39d76b2 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
@@ -1665,15 +1665,20 @@ EXPORT_SYMBOL(secure_dccp_sequence_number); | |||
1665 | * value is not cryptographically secure but for several uses the cost of | 1665 | * value is not cryptographically secure but for several uses the cost of |
1666 | * depleting entropy is too high | 1666 | * depleting entropy is too high |
1667 | */ | 1667 | */ |
1668 | DEFINE_PER_CPU(__u32 [4], get_random_int_hash); | ||
1668 | unsigned int get_random_int(void) | 1669 | unsigned int get_random_int(void) |
1669 | { | 1670 | { |
1670 | /* | 1671 | struct keydata *keyptr; |
1671 | * Use IP's RNG. It suits our purpose perfectly: it re-keys itself | 1672 | __u32 *hash = get_cpu_var(get_random_int_hash); |
1672 | * every second, from the entropy pool (and thus creates a limited | 1673 | int ret; |
1673 | * drain on it), and uses halfMD4Transform within the second. We | 1674 | |
1674 | * also mix it with jiffies and the PID: | 1675 | keyptr = get_keyptr(); |
1675 | */ | 1676 | hash[0] += current->pid + jiffies + get_cycles() + (int)(long)&ret; |
1676 | return secure_ip_id((__force __be32)(current->pid + jiffies)); | 1677 | |
1678 | ret = half_md4_transform(hash, keyptr->secret); | ||
1679 | put_cpu_var(get_random_int_hash); | ||
1680 | |||
1681 | return ret; | ||
1677 | } | 1682 | } |
1678 | 1683 | ||
1679 | /* | 1684 | /* |