Class HmacKeyDerivationFunction
java.lang.Object
com.amazonaws.encryptionsdk.internal.HmacKeyDerivationFunction
HMAC-based Key Derivation Function. Adapted from Hkdf.java in aws-dynamodb-encryption-java
- See Also:
- RFC 5869
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]deriveKey(byte[] info, int length)Returns a pseudorandom key oflengthbytes.static HmacKeyDerivationFunctiongetInstance(String algorithm)Returns anHmacKeyDerivationFunctionobject using the specified algorithm.voidinit(byte[] ikm)Initializes this Hkdf with input keying material.voidinit(byte[] ikm, byte[] salt)Initializes this Hkdf with input keying material and a salt.
-
Method Details
-
getInstance
public static HmacKeyDerivationFunction getInstance(String algorithm) throws NoSuchAlgorithmExceptionReturns anHmacKeyDerivationFunctionobject using the specified algorithm.- Parameters:
algorithm- the standard name of the requested MAC algorithm. See the Mac section in the Java Cryptography Architecture Standard Algorithm Name Documentation for information about standard algorithm names.- Returns:
- the new
Hkdfobject - Throws:
NoSuchAlgorithmException- if no Provider supports a MacSpi implementation for the specified algorithm.
-
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. Ifsaltisnullor 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
Returns a pseudorandom key oflengthbytes.- 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
lengthbytes. - Throws:
IllegalStateException- if this object has not been initialized
-