diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2002-06-07 21:53:44 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2002-06-07 21:53:44 +0000 |
commit | ca0ee7456b45fff3e45a0bad10334f916e920dd1 (patch) | |
tree | ddf35dd2442823e4d620ab20d22b3e52b5c70993 | |
parent | 475dfab2c278ef3aabee00943dd900b2b5b8ebd2 (diff) |
The code to append the last 5 digits of the time in Unix format to
the default seed was lost in the flat file -> directory structure
conversion. Instead of reinstating that, use arc4random() to get
some noise and append the last 5 digits to the seed.
-rw-r--r-- | usr.bin/skeyinit/skeyinit.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/usr.bin/skeyinit/skeyinit.c b/usr.bin/skeyinit/skeyinit.c index 63ce5afe724..00b7547c259 100644 --- a/usr.bin/skeyinit/skeyinit.c +++ b/usr.bin/skeyinit/skeyinit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: skeyinit.c,v 1.38 2002/06/07 21:35:26 millert Exp $ */ +/* $OpenBSD: skeyinit.c,v 1.39 2002/06/07 21:53:43 millert Exp $ */ /* OpenBSD S/Key (skeyinit.c) * @@ -53,6 +53,7 @@ main(int argc, char **argv) char seed[SKEY_MAX_SEED_LEN + 1]; char buf[256], key[SKEY_BINKEY_SIZE], filename[PATH_MAX], *ht; char lastc, me[UT_NAMESIZE + 1], *p, *auth_type; + u_int32_t noise; struct skey skey; struct passwd *pp; @@ -60,7 +61,7 @@ main(int argc, char **argv) defaultsetup = 1; ht = auth_type = NULL; - /* Build up a default seed based on the hostname and time */ + /* Build up a default seed based on the hostname and some noise */ if (gethostname(hostname, sizeof(hostname)) < 0) err(1, "gethostname"); for (i = 0, p = seed; hostname[i] && i < SKEY_NAMELEN; i++) { @@ -71,6 +72,11 @@ main(int argc, char **argv) } else if (isdigit(hostname[i])) *p++ = hostname[i]; } + noise = arc4random(); + for (i = 0; i < 5; i++) { + *p++ = (noise % 10) + '0'; + noise /= 10; + } *p = '\0'; if ((pp = getpwuid(getuid())) == NULL) |