capitalone / fpe

A format-preserving encryption implementation in Go
Apache License 2.0
201 stars 40 forks source link

FF3: redundant maxLen check #34

Open bschoening opened 3 years ago

bschoening commented 3 years ago

Description of Issue

In the FF3 constructor. The 3rd check in the ‘if’ statement looks redundant. It seems to test if maxLen > maxLen, which must always be false?

maxLen := uint32(math.Floor((192 / math.Log2(float64(radix)))))

// Make sure 2 <= minLength <= maxLength < 2*floor(log base radix of 2^96) is satisfied if (minLen < 2) || (maxLen < minLen) || (float64(maxLen) > (192 / math.Log2(float64(radix)))) { return newCipher, errors.New("minLen or maxLen invalid, adjust your radix”) }