public class KeyUtils extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
KeyUtils.KeyAlgorithmType
Enumeration of Supported key algorithm types.
|
static class |
KeyUtils.KeyType
Enumeration of specific key types.
|
| Constructor and Description |
|---|
KeyUtils() |
| Modifier and Type | Method and Description |
|---|---|
static SecretKey |
aesWrapKeyWithDHGeneratedKey(KeyAgreementParameters parameterSpec)
Method generates a secret key for given KeyAgreementParameterSpec.
|
static KeyPairGenerator |
createKeyPairGenerator(String algorithm,
Provider provider)
Create a KeyPairGenerator for the given algorithm and provider.
|
static byte[] |
deriveKeyEncryptionKey(byte[] sharedSecret,
KeyDerivationParameters keyDerivationParameter)
Derive a key encryption key from a shared secret and keyDerivationParameter.
|
static byte[] |
deriveKeyWithConcatKDF(byte[] sharedSecret,
ConcatKDFParams ckdfParameter)
Derive a key using the Concatenation Key Derivation Function (ConcatKDF)
with implementation instance
ConcatKDFParams. |
static byte[] |
deriveKeyWithHKDF(byte[] sharedSecret,
HKDFParams hkdfParameter)
Derive a key using the HMAC-based Extract-and-Expand Key Derivation
Function (HKDF) with implementation instance
HKDFParams. |
static KeyPair |
generateEphemeralDHKeyPair(PublicKey recipientPublicKey,
Provider provider)
Method generates DH keypair which match the type of given public key type.
|
static int |
getAESKeyBitSizeForWrapAlgorithm(String keyWrapAlg)
Defines the key size for the encrypting algorithm.
|
public static KeyPair generateEphemeralDHKeyPair(PublicKey recipientPublicKey, Provider provider) throws XMLEncryptionException
recipientPublicKey - public key of recipientprovider - provider to use for key generationXMLEncryptionException - if the keys cannot be generatedpublic static KeyPairGenerator createKeyPairGenerator(String algorithm, Provider provider) throws NoSuchAlgorithmException
algorithm - the key JCE algorithm nameprovider - the provider to use or null if default JCE provider should be usedNoSuchAlgorithmException - if the algorithm is not supportedpublic static SecretKey aesWrapKeyWithDHGeneratedKey(KeyAgreementParameters parameterSpec) throws XMLEncryptionException
parameterSpec - KeyAgreementParameterSpec which defines algorithm to derive keyXMLEncryptionException - if the secret key cannot be generated as: Key agreement is not supported,
wrong key types, etc.public static int getAESKeyBitSizeForWrapAlgorithm(String keyWrapAlg) throws XMLEncryptionException
keyWrapAlg - the key wrap algorithm URIXMLEncryptionException - if the key wrap algorithm is not supportedpublic static byte[] deriveKeyEncryptionKey(byte[] sharedSecret,
KeyDerivationParameters keyDerivationParameter)
throws XMLSecurityException
sharedSecret - the shared secretkeyDerivationParameter - the key derivation parametersIllegalArgumentException - if the keyDerivationParameter is nullXMLSecurityException - if the key derivation algorithm is not supportedpublic static byte[] deriveKeyWithHKDF(byte[] sharedSecret,
HKDFParams hkdfParameter)
throws XMLSecurityException
HKDFParams.sharedSecret - the shared secrethkdfParameter - the HKDF parametersXMLSecurityException - if the key derivation parameters are invalid or
the hmac algorithm is not supported.public static byte[] deriveKeyWithConcatKDF(byte[] sharedSecret,
ConcatKDFParams ckdfParameter)
throws XMLSecurityException
ConcatKDFParams.sharedSecret - the shared secret/ input keying materialckdfParameter - the ConcatKDF parametersXMLSecurityException - if the key derivation parameters are invalid or
the hash algorithm is not supported.Copyright © 2000–2025 The Apache Software Foundation. All rights reserved.