Class HmacKeyDerivationFunction


  • public final class HmacKeyDerivationFunction
    extends Object
    HMAC-based Key Derivation Function. Adapted from Hkdf.java in aws-dynamodb-encryption-java
    See Also:
    RFC 5869
    • Method Detail

      • init

        public void init​(byte[] ikm)
        Initializes this Hkdf with input keying material. A default salt of HashLen zeros will be used (where HashLen is the length of the return value of the supplied algorithm).
        Parameters:
        ikm - the Input Keying Material
      • init

        public void init​(byte[] ikm,
                         byte[] salt)
        Initializes this Hkdf with input keying material and a salt. If salt is null or of length 0, then a default salt of HashLen zeros will be used (where HashLen is the length of the return value of the supplied algorithm).
        Parameters:
        salt - the salt used for key extraction (optional)
        ikm - the Input Keying Material
      • deriveKey

        public byte[] deriveKey​(byte[] info,
                                int length)
                         throws IllegalStateException
        Returns a pseudorandom key of length bytes.
        Parameters:
        info - optional context and application specific information (can be a zero-length array).
        length - the length of the output key in bytes
        Returns:
        a pseudorandom key of length bytes.
        Throws:
        IllegalStateException - if this object has not been initialized