Revert zxcvbn changes from f3d88f

This commit is contained in:
Jonathan White 2021-03-01 20:57:08 -05:00
parent 4e8b00da34
commit 6c7b04fee8
No known key found for this signature in database
GPG Key ID: 440FC65F2E0C6E01
3 changed files with 16 additions and 16 deletions

View File

@ -64,7 +64,7 @@ static void estimate(const char* pwd, bool advanced)
double m = 0.0;
const auto e = ZxcvbnMatch(pwd, nullptr, &info);
for (p = info; p; p = p->Next) {
m += p->Entropy;
m += p->Entrpy;
}
m = e - m;
// clang-format off
@ -139,7 +139,7 @@ static void estimate(const char* pwd, bool advanced)
}
pwdLen += p->Length;
out << QObject::tr("Length %1").arg(p->Length) << '\t'
<< QObject::tr("Entropy %1 (%2)").arg(p->Entropy, 6, 'f', 3).arg(p->Entropy * 0.301029996, 0, 'f', 2)
<< QObject::tr("Entropy %1 (%2)").arg(p->Entrpy, 6, 'f', 3).arg(p->Entrpy * 0.301029996, 0, 'f', 2)
<< '\t';
for (n = 0; n < p->Length; ++n, ++pwd) {
out << *pwd;

View File

@ -180,12 +180,12 @@ static void AddResult(ZxcMatch_t **HeadRef, ZxcMatch_t *Nu, int MaxLen)
if (Nu->Begin)
{
if (Nu->Length >= MaxLen)
Nu->MltEnpy = Nu->Entropy + MULTI_END_ADDITION * log(2.0);
Nu->MltEnpy = Nu->Entrpy + MULTI_END_ADDITION * log(2.0);
else
Nu->MltEnpy = Nu->Entropy + MULTI_MID_ADDITION * log(2.0);
Nu->MltEnpy = Nu->Entrpy + MULTI_MID_ADDITION * log(2.0);
}
else
Nu->MltEnpy = Nu->Entropy;
Nu->MltEnpy = Nu->Entrpy;
/* Find the correct insert point */
while(*HeadRef && ((*HeadRef)->Length < Nu->Length))
@ -231,7 +231,7 @@ static void AddMatchRepeats(ZxcMatch_t **Result, ZxcMatch_t *Match, const uint8_
{
/* Found a repeat */
ZxcMatch_t *p = AllocMatch();
p->Entropy = Match->Entropy + log(RepeatCount);
p->Entrpy = Match->Entrpy + log(RepeatCount);
p->Type = (ZxcTypeMatch_t)(Match->Type + MULTIPLE_MATCH);
p->Length = Len * RepeatCount;
p->Begin = Match->Begin;
@ -616,7 +616,7 @@ static void DictionaryEntropy(ZxcMatch_t *m, DictMatchInfo_t *Extra, const uint8
}
/* Add entropy due to word's rank */
e += log((double)Extra->Rank);
m->Entropy = e;
m->Entrpy = e;
}
/**********************************************************************************
@ -877,7 +877,7 @@ static void UserMatch(ZxcMatch_t **Result, const char *Words[], const uint8_t *P
p->Type = USER_LEET_MATCH;
p->Length = Len;
p->Begin = Start;
/* Add Entropy */
/* Add Entrpy */
Extra.Caps = Caps;
Extra.Lower = Lowers;
Extra.NumLeet = Leets;
@ -1206,7 +1206,7 @@ static void SpatialMatch(ZxcMatch_t **Result, const uint8_t *Passwd, int Start,
p = AllocMatch();
p->Type = SPATIAL_MATCH;
p->Begin = Start;
p->Entropy = Entropy;
p->Entrpy = Entropy;
p->Length = Len;
AddMatchRepeats(Result, p, Passwd, MaxLen);
AddResult(Result, p, MaxLen);
@ -1345,7 +1345,7 @@ static void DateMatch(ZxcMatch_t **Result, const uint8_t *Passwd, int Start, int
e = log(31 * 12 * 100.0);
if (Sep)
e += log(4.0); /* Extra 2 bits for separator */
p->Entropy = e;
p->Entrpy = e;
p->Type = DATE_MATCH;
p->Length = Len;
p->Begin = Start;
@ -1390,7 +1390,7 @@ static void RepeatMatch(ZxcMatch_t **Result, const uint8_t *Passwd, int Start, i
p->Type = REPEATS_MATCH;
p->Begin = Start;
p->Length = i;
p->Entropy = log(Card * i);
p->Entrpy = log(Card * i);
AddResult(Result, p, MaxLen);
}
}
@ -1407,7 +1407,7 @@ static void RepeatMatch(ZxcMatch_t **Result, const uint8_t *Passwd, int Start, i
/* Found a repeat */
int c = Cardinality(Passwd, Len);
ZxcMatch_t *p = AllocMatch();
p->Entropy = log((double)c) * Len + log(RepeatCount);
p->Entrpy = log((double)c) * Len + log(RepeatCount);
p->Type = (ZxcTypeMatch_t)(BRUTE_MATCH + MULTIPLE_MATCH);
p->Length = Len * RepeatCount;
p->Begin = Start;
@ -1525,7 +1525,7 @@ static void SequenceMatch(ZxcMatch_t **Result, const uint8_t *Passwd, int Start,
p->Type = SEQUENCE_MATCH;
p->Begin = Start;
p->Length = i;
p->Entropy = e + log((double)i);
p->Entrpy = e + log((double)i);
AddMatchRepeats(Result, p, Pwd, MaxLen);
AddResult(Result, p, MaxLen);
}
@ -1654,7 +1654,7 @@ double ZxcvbnMatch(const char *Pwd, const char *UserDict[], ZxcMatch_t **Info)
Zp->Type = BRUTE_MATCH;
Zp->Begin = i;
Zp->Length = j - i;
Zp->Entropy = e * (j - i);
Zp->Entrpy = e * (j - i);
AddResult(&(Nodes[i].Paths), Zp, MaxLen);
}
}
@ -1723,7 +1723,7 @@ double ZxcvbnMatch(const char *Pwd, const char *UserDict[], ZxcMatch_t **Info)
if (Xp == Zp)
{
/* Adjust the entropy to log to base 2 */
Xp->Entropy /= log(2.0);
Xp->Entrpy /= log(2.0);
Xp->MltEnpy /= log(2.0);
/* Put previous part at head of info list */

View File

@ -70,7 +70,7 @@ struct ZxcMatch
{
int Begin; /* Char position of begining of match */
int Length; /* Number of chars in the match */
double Entropy; /* The entropy of the match */
double Entrpy; /* The entropy of the match */
double MltEnpy; /* Entropy with additional allowance for multipart password */
ZxcTypeMatch_t Type; /* Type of match (Spatial/Dictionary/Order/Repeat) */
struct ZxcMatch *Next;