Summary
During the matches operation, SCryptPasswordEncoder retains the instance keyLength rather than the target digest keyLength. It makes it very difficult to verify non-homogenous digests with different key lengths.
Why is that? A security consideration?
Actual Behavior
SCryptPasswordEncoder matches operation fails if instance keyLength differs from target digest key length.
Expected Behavior
SCryptPasswordEncoder matches operation ought to use the target digest key length.
Configuration
SCryptPasswordEncoder instance keyLength differs from target digest key length.
Version
4.2.3.RELEASE
Sample
Simple example prints true
SCryptPasswordEncoder encoder = new SCryptPasswordEncoder(8192, 16, 1, 32, 32);
String raw = "password";
String digest = encoder.encode(raw);
System.out.println(encoder.matches(raw, digest));
Instance parameters differ from digest parameters, except key length - prints true
SCryptPasswordEncoder encoder = new SCryptPasswordEncoder(8192, 16, 1, 32, 32);
SCryptPasswordEncoder tester = new SCryptPasswordEncoder(1024, 8, 1, 32, 24);
String raw = "password";
String digest = encoder.encode(raw);
System.out.println(tester.matches(raw, digest));
Only the key length differs - prints false
SCryptPasswordEncoder encoder = new SCryptPasswordEncoder(8192, 16, 1, 32, 32);
SCryptPasswordEncoder tester = new SCryptPasswordEncoder(8192, 16, 1, 24, 32);
String raw = "password";
String digest = encoder.encode(raw);
System.out.println(tester.matches(raw, digest));
Summary
During the
matchesoperation, SCryptPasswordEncoder retains the instancekeyLengthrather than the target digestkeyLength. It makes it very difficult to verify non-homogenous digests with different key lengths.Why is that? A security consideration?
Actual Behavior
SCryptPasswordEncoder
matchesoperation fails if instancekeyLengthdiffers from target digest key length.Expected Behavior
SCryptPasswordEncoder
matchesoperation ought to use the target digest key length.Configuration
SCryptPasswordEncoder instance
keyLengthdiffers from target digest key length.Version
4.2.3.RELEASESample
Simple example prints
trueInstance parameters differ from digest parameters, except key length - prints
trueOnly the key length differs - prints
false