Class SCryptEncoder
java.lang.Object
pl.edu.icm.unity.stdext.credential.pass.SCryptEncoder
Uses scrypt to encode passwords. The class limits number of concurrent encodings so that we can have a control
about the total memory use by scrypt.
Scrypt memory appetite is: 128 bytes × 2^workFactor × blockSize.
With default block size of 8, it is 1024 x 2^workfactor.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintComputes a max currently considered safe work factor, taking into account the heap memory available for the VM and the configured number of allowed concurrent password checks.byte[]scrypt(String password, byte[] salt, ScryptParams params)
-
Constructor Details
-
SCryptEncoder
-
-
Method Details
-
getMaxAllowedWorkFactor
public int getMaxAllowedWorkFactor()Computes a max currently considered safe work factor, taking into account the heap memory available for the VM and the configured number of allowed concurrent password checks. Algorithm assumes 0.5G heap reserved for other purposes then password hashing (pretty arbitrary number, typically well enough, but may happen this is to low).- Returns:
- max WF so that 1024*2^WF < MAX_AVAILABLE_HEAP - 500MB
-
scrypt
-