Class SalmonPassword

java.lang.Object
com.mku.salmon.password.SalmonPassword

public class SalmonPassword extends Object
Generates security keys based on text passwords.
  • Constructor Details

    • SalmonPassword

      public SalmonPassword()
  • Method Details

    • getPbkdfAlgo

      public static PbkdfAlgo getPbkdfAlgo()
      Returns the current global PBKDF algorithm.
      Returns:
      The PBKDF algorithm to be used.
    • setPbkdfAlgo

      public static void setPbkdfAlgo(PbkdfAlgo pbkdfAlgo)
      Set the global PDKDF algorithm to be used for key derivation.
      Parameters:
      pbkdfAlgo - The PBKDF algorithm to use
    • setPbkdfType

      public static void setPbkdfType(PbkdfType pbkdfType)
      Set the global PBKDF implementation to be used for text key derivation.
      Parameters:
      pbkdfType - The PBKDF implementation to use
    • setPbkdfProvider

      public static void setPbkdfProvider(ISalmonPbkdfProvider pbkdfProvider)
      Set the global PBKDF provider to be used for text key derivation.
      Parameters:
      pbkdfProvider - The PBKDF provider
    • getMasterKey

      public static byte[] getMasterKey(String pass, byte[] salt, int iterations, int length)
      Derives the key from a text password
      Parameters:
      pass - The text password to be used
      salt - The salt to be used for the key derivation
      iterations - The number of iterations the key derivation algorithm will use
      length - The length of master key to return
      Returns:
      The derived master key.
      Throws:
      SalmonSecurityException - Thrown if there is a security exception
    • getKeyFromPassword

      public static byte[] getKeyFromPassword(String password, byte[] salt, int iterations, int outputBytes)
      Function will derive a key from a text password
      Parameters:
      password - The password that will be used to derive the key
      salt - The salt byte array that will be used together with the password
      iterations - The iterations to be used with Pbkdf2
      outputBytes - The number of bytes for the key
      Returns:
      The derived key.
      Throws:
      SalmonSecurityException - Thrown if there is a security exception