Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: third_party/fips181/randpass.cc

Issue 308503002: [Password Generation] Start using pronouncable passwords (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/fips181/randpass.cc
diff --git a/third_party/fips181/randpass.cc b/third_party/fips181/randpass.cc
index b804365ac26dcec2e03a26a60653784ee28a1fdd..f6a4ed357fa7876ea006206f69c9b19710dc8157 100644
--- a/third_party/fips181/randpass.cc
+++ b/third_party/fips181/randpass.cc
@@ -38,9 +38,10 @@
#include <pwd.h>
#endif
#include <unistd.h>
-#include "randpass.h"
+#include "base/rand_util.h"
#include "owntypes.h"
+#include "randpass.h"
#include "smbl.h"
/*
@@ -69,8 +70,8 @@ gen_rand_pass (char *password_string, int minl, int maxl, unsigned int pass_mode
if (minl > APG_MAX_PASSWORD_LENGTH || maxl > APG_MAX_PASSWORD_LENGTH ||
minl < 1 || maxl < 1 || minl > maxl)
return (-1);
- for (i = 0; i <= 93; i++) random_weight[i] = 0;
- length = minl + randint(maxl-minl+1);
+ for (i = 0; i <= 93; i++) random_weight[i] = 0;
+ length = base::RandInt(minl, maxl);
str_pointer = password_string;
for (i = 0; i < length; i++)
@@ -79,7 +80,7 @@ gen_rand_pass (char *password_string, int minl, int maxl, unsigned int pass_mode
for (j = 0; j <= 93 ; j++)
if ( ( (pass_mode & smbl[j].type) > 0) &&
!( (S_RS & smbl[j].type) > 0))
- random_weight[j] = 1 + randint(20000);
+ random_weight[j] = base::RandInt(1, 20000);
j = 0;
/* Find an element with maximum weight */
for (j = 0; j <= 93; j++)
@@ -125,7 +126,7 @@ gen_rand_symbol (char *symbol, unsigned int mode)
for (j = 0; j <= 93 ; j++)
if ( ( (mode & smbl[j].type) > 0) &&
!( (S_RS & smbl[j].type) > 0))
- random_weight[j] = 1 + randint(20000);
+ random_weight[j] = base::RandInt(1, 20000);
j = 0;
/* Find an element with maximum weight */
for (j = 0; j <= 93; j++)

Powered by Google App Engine
This is Rietveld 408576698