Package com.io7m.idstore.model
Class IdPasswordAlgorithmPBKDF2HmacSHA256
java.lang.Object
com.io7m.idstore.model.IdPasswordAlgorithmPBKDF2HmacSHA256
- All Implemented Interfaces:
IdPasswordAlgorithmType
public final class IdPasswordAlgorithmPBKDF2HmacSHA256
extends Object
implements IdPasswordAlgorithmType
The PBKDF2 hashing algorithm using a SHA-256 HMAC.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanCheck if the given plain text password matches the expected hash.static IdPasswordAlgorithmTypecreate()Create an algorithm with a strong iteration count and key length.static IdPasswordAlgorithmTypecreate(int iterationCount) Create an algorithm with the given iteration count and key length.createHashed(String passwordText, byte[] salt) Create a hashed password.booleaninthashCode()toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.io7m.idstore.model.IdPasswordAlgorithmType
createHashed
-
Method Details
-
create
Create an algorithm with the given iteration count and key length.- Parameters:
iterationCount- The iteration count- Returns:
- An algorithm
-
create
Create an algorithm with a strong iteration count and key length.- Returns:
- An algorithm
-
equals
-
hashCode
-
toString
-
check
public boolean check(String expectedHash, String receivedPassword, byte[] salt) throws IdPasswordException Description copied from interface:IdPasswordAlgorithmTypeCheck if the given plain text password matches the expected hash.- Specified by:
checkin interfaceIdPasswordAlgorithmType- Parameters:
expectedHash- The expected hexadecimal uppercase hashreceivedPassword- The received plain text passwordsalt- The salt value- Returns:
trueif the password matches- Throws:
IdPasswordException- On internal errors such as missing algorithm support
-
createHashed
Description copied from interface:IdPasswordAlgorithmTypeCreate a hashed password.- Specified by:
createHashedin interfaceIdPasswordAlgorithmType- Parameters:
passwordText- The plain text passwordsalt- A random salt value- Returns:
- A hashed password
- Throws:
IdPasswordException- On internal errors such as missing algorithm support
-
identifier
- Specified by:
identifierin interfaceIdPasswordAlgorithmType- Returns:
- The password algorithm identifier
-