propagate from branch 'au.asn.ucc.matt.dropbear' (head 138a11bc1e2babcd8b1182e6cb2a85d4e9404b11)

to branch 'au.asn.ucc.matt.dropbear.cli-agent' (head 12b2f59db65e7339d340e95ac67d6d9ddb193c2b)

--HG--
branch : agent-client
extra : convert_revision : d82c25da2f7e4fb6da510d806c64344e80bb270d
This commit is contained in:
Matt Johnston
2006-06-06 15:40:09 +00:00
9 changed files with 55 additions and 42 deletions

View File

@@ -31,7 +31,8 @@ static int donerandinit = 0;
/* this is used to generate unique output from the same hashpool */
static uint32_t counter = 0;
#define MAX_COUNTER 1<<31 /* the max value for the counter, so it won't loop */
/* the max value for the counter, so it won't integer overflow */
#define MAX_COUNTER 1<<30
static unsigned char hashpool[SHA1_HASH_SIZE];
@@ -129,7 +130,7 @@ void seedrandom() {
hash_state hs;
/* initialise so that things won't warn about
* hashing an undefined buffer */
* hashing an undefined buffer */
if (!donerandinit) {
m_burn(hashpool, sizeof(hashpool));
}
@@ -152,18 +153,17 @@ void seedrandom() {
* the random pools for fork()ed processes. */
void reseedrandom() {
pid_t pid;
struct timeval tv;
pid_t pid;
hash_state hs;
struct timeval tv;
if (!donerandinit) {
dropbear_exit("seedrandom not done");
}
pid = getpid();
gettimeofday(&tv, NULL);
pid = getpid();
gettimeofday(&tv, NULL);
hash_state hs;
unsigned char hash[SHA1_HASH_SIZE];
sha1_init(&hs);
sha1_process(&hs, (void*)hashpool, sizeof(hashpool));
sha1_process(&hs, (void*)&pid, sizeof(pid));