Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 144680
b: refs/heads/master
c: 8a0a9bd
h: refs/heads/master
v: v3
  • Loading branch information
Linus Torvalds committed May 7, 2009
1 parent 04c5a98 commit c0168f9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2c66fa7e6be6bdb88587ac13ac1de080d5be4f95
refs/heads/master: 8a0a9bd4db63bc45e3017bedeafbd88d0eb84d02
19 changes: 12 additions & 7 deletions trunk/drivers/char/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -1665,15 +1665,20 @@ EXPORT_SYMBOL(secure_dccp_sequence_number);
* value is not cryptographically secure but for several uses the cost of
* depleting entropy is too high
*/
DEFINE_PER_CPU(__u32 [4], get_random_int_hash);
unsigned int get_random_int(void)
{
/*
* Use IP's RNG. It suits our purpose perfectly: it re-keys itself
* every second, from the entropy pool (and thus creates a limited
* drain on it), and uses halfMD4Transform within the second. We
* also mix it with jiffies and the PID:
*/
return secure_ip_id((__force __be32)(current->pid + jiffies));
struct keydata *keyptr;
__u32 *hash = get_cpu_var(get_random_int_hash);
int ret;

keyptr = get_keyptr();
hash[0] += current->pid + jiffies + get_cycles() + (int)(long)&ret;

ret = half_md4_transform(hash, keyptr->secret);
put_cpu_var(get_random_int_hash);

return ret;
}

/*
Expand Down

0 comments on commit c0168f9

Please sign in to comment.