Class SCryptEncoder
- java.lang.Object
-
- pl.edu.icm.unity.stdext.credential.pass.SCryptEncoder
-
public class SCryptEncoder extends java.lang.ObjectUses 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 Constructor Description SCryptEncoder(java.util.concurrent.ForkJoinPool pool)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetMaxAllowedWorkFactor()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.byte[]scrypt(java.lang.String password, byte[] salt, ScryptParams params)
-
-
-
Method Detail
-
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
public byte[] scrypt(java.lang.String password, byte[] salt, ScryptParams params)
-
-