From e1eb658db2f04b9235a10d210a1ed551511bff78 Mon Sep 17 00:00:00 2001 From: tony Date: Sat, 4 Mar 2017 16:49:38 +0000 Subject: Calculate the required size for PossChars based on the dictionary used. The fix for this by hannob in commit ad2ef761 works for the current dictionary, but would fail if a dictionary is used with 49 or more possible characters for one of its nodes. --- test.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'test.c') diff --git a/test.c b/test.c index f2e48d5..05dcbf7 100644 --- a/test.c +++ b/test.c @@ -124,6 +124,8 @@ int DoChecks(char *file) int y = 0; int w = 0; int r = 0; + int Less = 0; + int More = 0; FILE *f = fopen(file, "r"); if (f == NULL) { @@ -185,17 +187,28 @@ int DoChecks(char *file) e = ZxcvbnMatch(Pwd, UsrDict, 0); x = e / Ent; /* More than 1% difference is a fail. */ - if ((x > 1.01) || (x < 1.0/1.01)) + if (x > 1.01) { - printf("Line %2d Calculated entropy %5.2f, expected %5.2f <%s>\n", y, e, Ent, Pwd); - r = 1; - break; + ++More; + if (r < 10) + { + printf("Line %2d Calculated entropy %5.2f, expected %5.2f <%s>\n", y, e, Ent, Pwd); + ++r; + } + } + else if (x < 1.0/1.01) + { + ++Less; + if (r < 10) + { + printf("Line %2d Calculated entropy %5.2f, expected %5.2f <%s>\n", y, e, Ent, Pwd); + ++r; + } } ++w; } fclose(f); - if (!r) - printf("Tested %d words\n", w); + printf("Tested %d words, %d with low entropy, %d with high\n", w, Less, More); return r; } -- cgit v1.2.3