Skip to content

Commit

Permalink
arc4random_buf is the easy way to fill a buffer now. ok deraadt
Browse files Browse the repository at this point in the history
  • Loading branch information
tedu committed Sep 4, 2012
1 parent 7aa8bad commit 769d2f2
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions lib/libc/crypt/bcrypt.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: bcrypt.c,v 1.24 2008/04/02 19:54:05 millert Exp $ */
/* $OpenBSD: bcrypt.c,v 1.25 2012/09/04 22:16:17 tedu Exp $ */

/*
* Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
Expand Down Expand Up @@ -148,15 +148,8 @@ char *
bcrypt_gensalt(u_int8_t log_rounds)
{
u_int8_t csalt[BCRYPT_MAXSALT];
u_int16_t i;
u_int32_t seed = 0;

for (i = 0; i < BCRYPT_MAXSALT; i++) {
if (i % 4 == 0)
seed = arc4random();
csalt[i] = seed & 0xff;
seed = seed >> 8;
}

arc4random_buf(csalt, sizeof(csalt));

if (log_rounds < 4)
log_rounds = 4;
Expand Down

0 comments on commit 769d2f2

Please sign in to comment.