Class Password


  • public class Password
    extends java.lang.Object
    Generates security keys based on text passwords.
    • Constructor Summary

      Constructors 
      Constructor Description
      Password()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] getKeyFromPassword​(java.lang.String password, byte[] salt, int iterations, int outputBytes)
      Function will derive a key from a text password
      static byte[] getMasterKey​(java.lang.String pass, byte[] salt, int iterations, int length)
      Derives the key from a text password
      static PbkdfAlgo getPbkdfAlgo()
      Returns the current global PBKDF algorithm.
      static void setPbkdfAlgo​(PbkdfAlgo pbkdfAlgo)
      Set the global PDKDF algorithm to be used for key derivation.
      static void setPbkdfProvider​(IPbkdfProvider pbkdfProvider)
      Set the global PBKDF provider to be used for text key derivation.
      static void setPbkdfType​(PbkdfType pbkdfType)
      Set the global PBKDF implementation to be used for text key derivation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Password

        public Password()
    • Method Detail

      • 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​(IPbkdfProvider pbkdfProvider)
        Set the global PBKDF provider to be used for text key derivation.
        Parameters:
        pbkdfProvider - The PBKDF provider
      • getMasterKey

        public static byte[] getMasterKey​(java.lang.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:
        SecurityException - Thrown if there is a security exception
      • getKeyFromPassword

        public static byte[] getKeyFromPassword​(java.lang.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:
        SecurityException - Thrown if there is a security exception