Class KeySecret

All Implemented Interfaces:
Cloneable

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

    • PREFIX

      public static final String PREFIX
      Prefix used to encode secret type as strings.
      See Also:
    • MIN_KEY_LENGTH

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

      protected byte[] key
      The password.
  • Constructor Details

    • KeySecret

      public KeySecret()
      Creates the secret.
    • KeySecret

      public KeySecret(String encodedkey)
      Creates the secret.
    • KeySecret

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

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

    • 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 String toString()
      Creates encoded secret.
      Overrides:
      toString in class Object
      Returns:
      Encoded secret.
    • createRandom

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

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