Module org.apache.santuario.xmlsec
Class ConcatKDF
java.lang.Object
org.apache.xml.security.encryption.keys.content.derivedKey.ConcatKDF
- All Implemented Interfaces:
DerivationAlgorithm<ConcatKDFParams>
Key DerivationAlgorithm implementation, defined in Section 5.8.1 of NIST SP 800-56A [SP800-56A], and is equivalent
to the KDF3 function defined in ANSI X9.44-2007 [ANSI-X9-44-2007] when the contents of the OtherInfo parameter
is structured as in NIST SP 800-56A.
Identifier of the key derivation algorithm: http://www.w3.org/2009/xmlenc11#ConcatKDF
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static byte[]concatParameters(String... parameters) Simple method to concatenate non-padded bitstream ConcatKDF parameters.byte[]deriveKey(byte[] sharedSecret, ConcatKDFParams concatKDFParams) Derives a key from the shared secret and other concat kdf parameters.private static intgetSize(byte[] array) Method returns the size of the array or 0 if the array is null.private static byte[]parseBitString(String kdfParameter) The method validates the bitstring parameter structure and returns byte array of the parameter.
-
Field Details
-
LOG
-
-
Constructor Details
-
ConcatKDF
public ConcatKDF()
-
-
Method Details
-
deriveKey
public byte[] deriveKey(byte[] sharedSecret, ConcatKDFParams concatKDFParams) throws XMLSecurityException Derives a key from the shared secret and other concat kdf parameters.- Specified by:
deriveKeyin interfaceDerivationAlgorithm<ConcatKDFParams>- Parameters:
sharedSecret- The "shared" secret used for the key derivation (e.g. the secret key)concatKDFParams- The concat key derivation parameters- Returns:
- the derived key bytes
- Throws:
IllegalArgumentException- if the concat KDF parameters are not setXMLSecurityException- if the key derivation parameters are invalid
-
concatParameters
Simple method to concatenate non-padded bitstream ConcatKDF parameters. If parameters are null the value is ignored.- Parameters:
parameters- the parameters to concatenate- Returns:
- the concatenated parameters as byte array
- Throws:
XMLEncryptionException
-
parseBitString
The method validates the bitstring parameter structure and returns byte array of the parameter. The bitstring is divided into octets using big-endian encoding. Parameter starts with two characters (hex number) defining the number of padding bits followed by hex-string. The length of the bitstring is not a multiple of 8 then add padding bits (value 0) as necessary to the last octet to make it a multiple of 8.- Parameters:
kdfParameter- the parameter to parse- Returns:
- the parsed parameter as byte array
- Throws:
XMLEncryptionException
-
getSize
private static int getSize(byte[] array) Method returns the size of the array or 0 if the array is null.- Parameters:
array- the array to get the size from- Returns:
- the size of the array or 0 if the array is null
-