Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 57090
b: refs/heads/master
c: 602b6ae
h: refs/heads/master
v: v3
  • Loading branch information
Matt Mackall authored and Linus Torvalds committed May 30, 2007
1 parent 033d04f commit f77f040
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 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: f717221b4e51284c153ab4265c4607e86037047b
refs/heads/master: 602b6aeefe8932dd8bb15014e8fe6bb25d736361
12 changes: 7 additions & 5 deletions trunk/drivers/char/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,

static void extract_buf(struct entropy_store *r, __u8 *out)
{
int i, x;
int i;
__u32 data[16], buf[5 + SHA_WORKSPACE_WORDS];

sha_init(buf);
Expand All @@ -772,17 +772,19 @@ static void extract_buf(struct entropy_store *r, __u8 *out)
* attempts to find previous ouputs), unless the hash
* function can be inverted.
*/
for (i = 0, x = 0; i < r->poolinfo->poolwords; i += 16, x+=2) {
sha_transform(buf, (__u8 *)r->pool+i, buf + 5);
add_entropy_words(r, &buf[x % 5], 1);
for (i = 0; i < r->poolinfo->poolwords; i += 16) {
/* hash blocks of 16 words = 512 bits */
sha_transform(buf, (__u8 *)(r->pool + i), buf + 5);
/* feed back portion of the resulting hash */
add_entropy_words(r, &buf[i % 5], 1);
}

/*
* To avoid duplicates, we atomically extract a
* portion of the pool while mixing, and hash one
* final time.
*/
__add_entropy_words(r, &buf[x % 5], 1, data);
__add_entropy_words(r, &buf[i % 5], 1, data);
sha_transform(buf, (__u8 *)data, buf + 5);

/*
Expand Down

0 comments on commit f77f040

Please sign in to comment.