Class KeySecret

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class KeySecret
    extends SharedSecret
    Authentication secret based on a shared key.
    • Field Detail

      • PREFIX

        public static final java.lang.String PREFIX
        Prefix used to encode secret type as strings.
        See Also:
        Constant Field Values
      • MIN_KEY_LENGTH

        protected static final int MIN_KEY_LENGTH
        Key length warning threshold.
        See Also:
        Constant Field Values
      • key

        protected byte[] key
        The password.
    • Constructor Detail

      • KeySecret

        public KeySecret()
        Creates the secret.
      • KeySecret

        public KeySecret​(java.lang.String encodedkey)
        Creates the secret.
      • KeySecret

        public KeySecret​(byte[] key)
        Creates the secret.
      • KeySecret

        public KeySecret​(byte[] key,
                         boolean warn)
        Creates the secret.
    • Method Detail

      • getKey

        public byte[] getKey()
        Gets the key.
        Returns:
        The key.
      • setKey

        public void setKey​(byte[] key)
        Sets the key.
        Parameters:
        key - The key.
      • deriveKey

        public byte[] deriveKey​(int keysize,
                                byte[] salt)
        Derives a key from the shared secret using a salt.
        Specified by:
        deriveKey in class SharedSecret
        Parameters:
        keysize - The target key size in bytes to generate.
        salt - Salt to use.
        df - Used derivation function.
        Returns:
        Derived key.
      • toString

        public java.lang.String toString()
        Creates encoded secret.
        Overrides:
        toString in class java.lang.Object
        Returns:
        Encoded secret.
      • createRandom

        public static final KeySecret createRandom()
        Creates a random shared key.
        Returns:
        Random shared key.
      • createRandomAsString

        public static final java.lang.String createRandomAsString()
        Creates a random shared key.
        Returns:
        Random shared key.