Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Matt Johnston
dropbear
Commits
26b07cca
Commit
26b07cca
authored
Feb 23, 2013
by
Matt Johnston
Browse files
add loadavg and entropy_avail as sources
parent
1205fa68
Changes
1
Hide whitespace changes
Inline
Side-by-side
random.c
View file @
26b07cca
...
...
@@ -73,10 +73,10 @@ process_file(hash_state *hs, const char *filename,
}
readcount
=
0
;
while
(
readcount
<
len
)
while
(
len
==
0
||
readcount
<
len
)
{
int
readlen
,
wantread
;
unsigned
char
readbuf
[
1
28
];
unsigned
char
readbuf
[
2
04
8
];
if
(
!
already_blocked
)
{
int
ret
;
...
...
@@ -93,7 +93,14 @@ process_file(hash_state *hs, const char *filename,
}
}
wantread
=
MIN
(
sizeof
(
readbuf
),
len
-
readcount
);
if
(
len
==
0
)
{
wantread
=
sizeof
(
readbuf
);
}
else
{
wantread
=
MIN
(
sizeof
(
readbuf
),
len
-
readcount
);
}
#ifdef DROPBEAR_PRNGD_SOCKET
if
(
prngd
)
...
...
@@ -185,7 +192,8 @@ void seedrandom() {
}
#endif
/* A few other sources to fall back on. Add more here for other platforms */
/* A few other sources to fall back on.
* Add more here for other platforms */
#ifdef __linux__
/* Seems to be a reasonable source of entropy from timers. Possibly hard
* for even local attackers to reproduce */
...
...
@@ -193,6 +201,9 @@ void seedrandom() {
/* Might help on systems with wireless */
process_file
(
&
hs
,
"/proc/interrupts"
,
0
,
0
);
process_file
(
&
hs
,
"/proc/loadavg"
,
0
,
0
);
process_file
(
&
hs
,
"/proc/sys/kernel/random/entropy_avail"
,
0
,
0
);
/* Mostly network visible but useful in some situations */
process_file
(
&
hs
,
"/proc/net/netstat"
,
0
,
0
);
process_file
(
&
hs
,
"/proc/net/dev"
,
0
,
0
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment