Class LLPasswordAlgorithmPBKDF2HmacSHA256

java.lang.Object
com.io7m.looseleaf.security.LLPasswordAlgorithmPBKDF2HmacSHA256
All Implemented Interfaces:
LLPasswordAlgorithmType

public final class LLPasswordAlgorithmPBKDF2HmacSHA256 extends Object implements LLPasswordAlgorithmType
The PBKDF2 hashing algorithm using a SHA-256 HMAC.
  • Method Details

    • create

      public static LLPasswordAlgorithmType create(int iterationCount, int keyLength)
      Create an algorithm with the given iteration count and key length.
      Parameters:
      iterationCount - The iteration count
      keyLength - The key length
      Returns:
      An algorithm
    • create

      public static LLPasswordAlgorithmType create()
      Create an algorithm with a strong iteration count and key length.
      Returns:
      An algorithm
    • check

      public boolean check(String expectedHash, String receivedPassword, byte[] salt) throws LLPasswordException
      Description copied from interface: LLPasswordAlgorithmType
      Check if the given plain text password matches the expected hash.
      Specified by:
      check in interface LLPasswordAlgorithmType
      Parameters:
      expectedHash - The expected hexadecimal uppercase hash
      receivedPassword - The received plain text password
      salt - The salt value
      Returns:
      true if the password matches
      Throws:
      LLPasswordException - On com.io7m.looseleaf.cmdline.internal errors such as missing algorithm support
    • createHashed

      public LLPassword createHashed(String passwordText, byte[] salt) throws LLPasswordException
      Description copied from interface: LLPasswordAlgorithmType
      Create a hashed password.
      Specified by:
      createHashed in interface LLPasswordAlgorithmType
      Parameters:
      passwordText - The plain text password
      salt - A random salt value
      Returns:
      A hashed password
      Throws:
      LLPasswordException - On com.io7m.looseleaf.cmdline.internal errors such as missing algorithm support
    • identifier

      public String identifier()
      Specified by:
      identifier in interface LLPasswordAlgorithmType
      Returns:
      The password algorithm identifier