summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorprovos <provos@openbsd.org>1997-03-27 00:36:32 +0000
committerprovos <provos@openbsd.org>1997-03-27 00:36:32 +0000
commitcbb44dcd7c6e55b944a093fc7155d309b79d011a (patch)
tree0b9dd9f16e1df00a2e4b987c8cefbd6114713bb2
parentSlight cleanup, more needed (diff)
downloadwireguard-openbsd-cbb44dcd7c6e55b944a093fc7155d309b79d011a.tar.xz
wireguard-openbsd-cbb44dcd7c6e55b944a093fc7155d309b79d011a.zip
use arc4random instead of random
-rw-r--r--usr.bin/passwd/pwd_gensalt.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/usr.bin/passwd/pwd_gensalt.c b/usr.bin/passwd/pwd_gensalt.c
index a4729cbdc80..cf6ad0dc3e3 100644
--- a/usr.bin/passwd/pwd_gensalt.c
+++ b/usr.bin/passwd/pwd_gensalt.c
@@ -66,24 +66,21 @@ pwd_gensalt(salt, max, pwd, type)
if (!strcmp(now, "old")) {
if( max < 3 )
return 0;
- (void) srandom((int) time((time_t *) NULL));
- to64(&salt[0], random(), 2);
+ to64(&salt[0], arc4random(), 2);
salt[2] = '\0';
} else if (!strcmp(now, "newsalt")) {
if( max < 10 )
return 0;
- (void) srandom((int) time((time_t *) NULL));
salt[0] = _PASSWORD_EFMT1;
to64(&salt[1], (long) (29 * 25), 4);
- to64(&salt[5], random(), 4);
+ to64(&salt[5], arc4random(), 4);
salt[9] = '\0';
} else if (!strcmp(now, "md5")) {
if( max < 13 ) /* $1$8salt$\0 */
return 0;
strcpy(salt, "$1$");
- (void) srandom((int) time((time_t *) NULL));
- to64(&salt[3], random(), 4);
- to64(&salt[7], random(), 4);
+ to64(&salt[3], arc4random(), 4);
+ to64(&salt[7], arc4random(), 4);
strcpy(&salt[11], "$");
} else if (!strcmp(now, "blowfish")) {
int rounds = atoi(next);