Class ConcatKDF
- All Implemented Interfaces:
Cloneable,Component,DestructableComponent,InitializableComponent,CloneableKeyAgreementParameter,KeyAgreementParameter,XMLExpressableKeyAgreementParameter,KeyDerivation
The following rules apply to the concatenation parameters:
- AlgorithmID
- PartyUInfo
- PartyVInfo
- SuppPubInfo
- SuppPrivInfo
Configured parameter string values must conform to the XML hexBinary representation defined in
XML Encryption 1.1, section 5.4.1, except in unpadded form, with number of padding bits not indicated.
Per the recommendation in the XML Encryption specification, this implementation only supports whole byte
(bye-aligned) values, not arbitrary length bit-strings as theoretically allowed in the NIST specification,
so the # of padding bits for each parameter value in the XML representation must and will always be 0.
This means the methods unpadParam(String, String) and fromXMLObject(KeyDerivationMethod)
which consume external values from the XML representation will throw if the number of indicated padding bits
is non-zero. Similarly buildXMLObject() will always emit values which indicate 0 padding bits.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()protected byte[]decodeParam(String value, String name) Decode the specified concatenation parameter value for input to the derivation operation.protected byte[]Derive the key bytes.protected voidstatic ConcatKDFfromXMLObject(KeyDerivationMethod xmlObject) Create and initialize a new instance from the specifiedXMLObject.Get the AlgorithmID in its unpadded hex-encoded form.protected org.bouncycastle.crypto.DigestgetDigestInstance(String digestURI) Get a new instance of the Bouncy CastleDigestfor the specified digest algorithm URI.Get the digest method algorithm URI.Get the PartyUInfo in its unpadded hex-encoded form.Get the PartyVInfo in its unpadded hex-encoded form.Get the SuppPrivInfo in its unpadded hex-encoded form.Get the SuppPubInfo in its unpadded hex-encoded form.protected static StringPad the specified concatenation parameter value for output in the formed required by XML Encryption 1.1.voidsetAlgorithmID(String newAlgorithmID) Set the AlgorithmID in its unpadded hex-encoded form.voidsetDigestMethod(String newDigestMethod) Set the digest method algorithm URI.voidsetPartyUInfo(String newPartyUInfo) Set the PartyUInfo in its unpadded hex-encoded form.voidsetPartyVInfo(String newPartyVInfo) Set the PartyVInfo in its unpadded hex-encoded form.voidsetSuppPrivInfo(String newSuppPrivInfo) Set the SuppPrivInfo in its unpadded hex-encoded form.voidsetSuppPubInfo(String newSuppPubInfo) Set the SuppPubInfo in its unpadded hex-encoded form.protected static StringunpadParam(String value, String name) Unpad the specified concatenation parameter value from the padded from required by XML Encryption 1.1 for input to the derivation operation.Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, doDestroy, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, initialize, isDestroyed, isInitialized
-
Field Details
-
DEFAULT_DIGEST_METHOD
Default digest method.- See Also:
-
digestMethod
Digest method. -
algorithmID
AlgorithmID. -
partyUInfo
PartyUInfo. -
partyVInfo
PartyVInfo. -
suppPubInfo
SuppPubInfo. -
suppPrivInfo
SuppPrivInfo.
-
-
Constructor Details
-
ConcatKDF
public ConcatKDF()
-
-
Method Details
-
getAlgorithm
- Specified by:
getAlgorithmin interfaceKeyDerivation
-
getDigestMethod
Get the digest method algorithm URI.- Returns:
- the algorithm URI
-
setDigestMethod
Set the digest method algorithm URI.- Parameters:
newDigestMethod- the algorithm URI
-
getAlgorithmID
Get the AlgorithmID in its unpadded hex-encoded form.- Returns:
- the AlgorithmID
-
setAlgorithmID
Set the AlgorithmID in its unpadded hex-encoded form.- Parameters:
newAlgorithmID- the AlgorithmID
-
getPartyUInfo
Get the PartyUInfo in its unpadded hex-encoded form.- Returns:
- the PartyUInfo
-
setPartyUInfo
Set the PartyUInfo in its unpadded hex-encoded form.- Parameters:
newPartyUInfo- the PartyUInfo
-
getPartyVInfo
Get the PartyVInfo in its unpadded hex-encoded form.- Returns:
- the PartyUInfo
-
setPartyVInfo
Set the PartyVInfo in its unpadded hex-encoded form.- Parameters:
newPartyVInfo- the PartyVInfo
-
getSuppPubInfo
Get the SuppPubInfo in its unpadded hex-encoded form.- Returns:
- the SuppPubInfo
-
setSuppPubInfo
Set the SuppPubInfo in its unpadded hex-encoded form.- Parameters:
newSuppPubInfo- the SuppPubInfo
-
getSuppPrivInfo
Get the SuppPrivInfo in its unpadded hex-encoded form.- Returns:
- the SuppPrivInfo
-
setSuppPrivInfo
Set the SuppPrivInfo in its unpadded hex-encoded form.- Parameters:
newSuppPrivInfo- the SuppPrivInfo
-
doInitialize
- Overrides:
doInitializein classAbstractInitializableComponent- Throws:
ComponentInitializationException
-
derive
@Nonnull public SecretKey derive(@Nonnull byte[] secret, @Nonnull String keyAlgorithm, @Nullable Integer keyLength) throws KeyDerivationException - Specified by:
derivein interfaceKeyDerivation- Throws:
KeyDerivationException
-
derive
protected byte[] derive(@Nonnull byte[] secret, @Nonnull byte[] otherInfo, @Nonnull Integer keyLength) throws KeyDerivationException Derive the key bytes.This re-factored method mostly exists to facilitate unit testing using external test vectors which only specify the OtherInfo as an input, rather than its 5 constituent parts as defined in NIST SP 800-56A and XML Encryption 1.1.
- Parameters:
secret- the input secret from which to derive the keyotherInfo- the OtherInfo bit string as defined in NIST SP 800-56AkeyLength- the length of the derived key, in bits- Returns:
- the derived key bytes
- Throws:
KeyDerivationException- if key derivation does not complete successfully
-
getDigestInstance
@Nonnull protected org.bouncycastle.crypto.Digest getDigestInstance(@Nonnull String digestURI) throws KeyDerivationException Get a new instance of the Bouncy CastleDigestfor the specified digest algorithm URI.- Parameters:
digestURI- the digest algorithm URI- Returns:
- a new corresponding instance of BC Digest
- Throws:
KeyDerivationException- if the specified digest algorithm is unsupported
-
clone
- Specified by:
clonein interfaceCloneableKeyAgreementParameter- Overrides:
clonein classObject
-
decodeParam
@Nonnull protected byte[] decodeParam(@Nullable String value, @Nonnull String name) throws KeyDerivationException Decode the specified concatenation parameter value for input to the derivation operation.- Parameters:
value- the value to processname- the name of the value being processed, for diagnostic purposes- Returns:
- the decoded value, which may be an empty array
- Throws:
KeyDerivationException- if parameter value could not be decoded successfully
-
padParam
Pad the specified concatenation parameter value for output in the formed required by XML Encryption 1.1.No syntactic validation is done on the input value. Since only whole byte-aligned values are supported, this method merely prepends "00" to indicate 0 padding bits.
- Parameters:
value- the value to process- Returns:
- the padded value, which may be null
-
unpadParam
@Nullable protected static String unpadParam(@Nullable String value, @Nullable String name) throws KeyDerivationException Unpad the specified concatenation parameter value from the padded from required by XML Encryption 1.1 for input to the derivation operation.Since only whole byte-aligned values are supported, this method requires input values to begin with "00", indicating 0 padding bits.
- Parameters:
value- the value to processname- the name of the value being processed, for diagnostic purposes- Returns:
- the unpadded value, which may be null
- Throws:
KeyDerivationException- if the input value is invalid
-
buildXMLObject
- Specified by:
buildXMLObjectin interfaceXMLExpressableKeyAgreementParameter
-
fromXMLObject
@Nonnull public static ConcatKDF fromXMLObject(@Nonnull KeyDerivationMethod xmlObject) throws ComponentInitializationException Create and initialize a new instance from the specifiedXMLObject.- Parameters:
xmlObject- the XML object- Returns:
- new parameter instance
- Throws:
ComponentInitializationException- if component initialization fails
-