public class KDF2Helper extends Object
MessageDigest
class to accomplish
the digest portion of the key derivation. The digest algorithm: MessageDigestAlgorithm
is defined at
creation.Constructor and Description |
---|
KDF2Helper()
Create a KDF2 helper using
MessageDigestAlgorithm.DEFAULT as the digest algorithm. |
KDF2Helper(MessageDigestAlgorithm algorithm)
Create a KDF2 helper using the given
MessageDigestAlgorithm as the digest algorithm. |
Modifier and Type | Method and Description |
---|---|
byte[] |
deriveKey(byte[] secret,
int keySize)
Derive a new key of the given size using KDF2 with the defined
MessageDigestAlgorithm and the given
secret. |
public KDF2Helper() throws NoSuchAlgorithmException
MessageDigestAlgorithm.DEFAULT
as the digest algorithm.NoSuchAlgorithmException
- thrown if the digest algorithm is not supportedpublic KDF2Helper(MessageDigestAlgorithm algorithm) throws NoSuchAlgorithmException
MessageDigestAlgorithm
as the digest algorithm.algorithm
- the digest algorithm for key derivationNoSuchAlgorithmException
- thrown if the digest algorithm is not supportedpublic byte[] deriveKey(byte[] secret, int keySize) throws InvalidKeyException
MessageDigestAlgorithm
and the given
secret.secret
- the secret to derive the key fromkeySize
- the size of the key in bytes to deriveInvalidKeyException
- thrown if there is an issue deriving the keyCopyright © 2021. All rights reserved.