Class DHLegacyKDF
- java.lang.Object
-
- org.opensaml.xmlsec.derivation.impl.DHLegacyKDF
-
public class DHLegacyKDF extends Object
Implementation of the key derivation function used with Diffie-Hellman Key Agreement With Legacy Key Derivation Function as defined in XML Encryption 1.1.
-
-
Field Summary
Fields Modifier and Type Field Description private StringdigestMethodDigest method.private org.slf4j.LoggerlogLogger.private StringnonceNonce.
-
Constructor Summary
Constructors Constructor Description DHLegacyKDF()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SecretKeyderive(byte[] secret, String keyAlgorithm, Integer keyLength)protected byte[]deriveBytes(byte[] secret, String encryptionAlgorithm, Integer keyLength)Derive the key bytes from the specified inputs.protected byte[]digest(int counter, String digestAlgorithm, byte[] secret, String encryptionAlgorithm, Integer keyLength, byte[] nonceBytes)Produce the digest of the specified inputs according to XML Encryption section 1.1, section 5.6.2.2.StringgetDigestMethod()Get the digest method algorithm URI.StringgetNonce()Get the Base64-encoded nonce value.voidsetDigestMethod(String newDigestMethod)Set the digest method algorithm URI.voidsetNonce(String newNonce)Set the digest method algorithm URI.
-
-
-
Method Detail
-
getDigestMethod
@Nullable public String getDigestMethod()
Get the digest method algorithm URI.- Returns:
- the algorithm URI
-
setDigestMethod
public void setDigestMethod(@Nullable String newDigestMethod)Set the digest method algorithm URI.- Parameters:
newDigestMethod- the algorithm URI
-
getNonce
@Nullable public String getNonce()
Get the Base64-encoded nonce value.- Returns:
- the nonce value
-
setNonce
public void setNonce(@Nullable String newNonce)Set the digest method algorithm URI.- Parameters:
newNonce- the algorithm URI
-
derive
public SecretKey derive(@Nonnull byte[] secret, @Nonnull String keyAlgorithm, @Nullable Integer keyLength) throws KeyDerivationException
- Throws:
KeyDerivationException
-
deriveBytes
protected byte[] deriveBytes(@Nonnull byte[] secret, @Nonnull String encryptionAlgorithm, @Nonnull Integer keyLength) throws KeyDerivationExceptionDerive the key bytes from the specified inputs.- Parameters:
secret- the input secretencryptionAlgorithm- the encryption algorithm URI to be used with the derived keykeyLength- the key length- Returns:
- derived bytes the derived key bytes
- Throws:
KeyDerivationException- if any of the inputs are invalid
-
digest
protected byte[] digest(int counter, @Nonnull String digestAlgorithm, @Nonnull byte[] secret, @Nonnull String encryptionAlgorithm, @Nonnull Integer keyLength, @Nonnull byte[] nonceBytes) throws KeyDerivationExceptionProduce the digest of the specified inputs according to XML Encryption section 1.1, section 5.6.2.2.- Parameters:
counter- the counter valuedigestAlgorithm- the JCA digest algorithmsecret- the input secretencryptionAlgorithm- the encryption algorithm URI to be used with the derived keykeyLength- the key lengthnonceBytes- the nonce, which may be an empty byte[] array, but not null- Returns:
- digest output for the specified inputs
- Throws:
KeyDerivationException- if any of the inputs are invalid
-
-