- java.lang.Object
-
- org.apache.xml.security.encryption.XMLCipherUtil
-
public final class XMLCipherUtil extends Object
-
-
Constructor Summary
Constructors Constructor Description XMLCipherUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static KeyAgreementParametersconstructAgreementParameters(String agreementAlgorithmURI, KeyAgreementParameters.ActorType actorType, KeyDerivationParameters keyDerivationParameter, PrivateKey keyAgreementPrivateKey, PublicKey keyAgreementPublicKey)Construct an KeyAgreementParameterSpec object from the given parametersstatic AlgorithmParameterSpecconstructBlockCipherParameters(boolean gcmAlgorithm, byte[] iv)static AlgorithmParameterSpecconstructBlockCipherParameters(String algorithm, byte[] iv)Build anAlgorithmParameterSpecinstance used to initialize aCipherinstance for block cipher encryption and decryption.static ConcatKDFParamsconstructConcatKeyDerivationParameter(int keyBitLength, String digestMethod)Construct a ConcatKeyDerivationParameter object from the key length and digest method.static ConcatKDFParamsconstructConcatKeyDerivationParameter(int keyBitLength, String digestMethod, String algorithmId, String partyUInfo, String partyVInfo, String suppPubInfo, String suppPrivInfo)Construct a ConcatKeyDerivationParameter object from the given parametersstatic KeyDerivationParametersconstructKeyDerivationParameter(KeyDerivationMethod keyDerivationMethod, int keyBitLength)Construct a KeyDerivationParameter object from the given keyDerivationMethod and keyBitLengthstatic MGF1ParameterSpecconstructMGF1Parameter(String mgh1AlgorithmURI)Create MGF1ParameterSpec for the given algorithm URIstatic OAEPParameterSpecconstructOAEPParameters(String encryptionAlgorithmURI, String digestAlgorithmURI, String mgfAlgorithmURI, byte[] oaepParams)Method buildOAEPParameters from given parameters and returns OAEPParameterSpec.static KeyAgreementParametersconstructRecipientKeyAgreementParameters(String keyWrapAlgoURI, AgreementMethod agreementMethod, PrivateKey keyAgreementPrivateKey)Construct an KeyAgreementParameterSpec object from the given parametersstatic StringgetMgf1URIForParameter(MGF1ParameterSpec parameterSpec)Get the MGF1 algorithm URI for the given MGF1ParameterSpec
-
-
-
Method Detail
-
constructBlockCipherParameters
public static AlgorithmParameterSpec constructBlockCipherParameters(String algorithm, byte[] iv)
Build anAlgorithmParameterSpecinstance used to initialize aCipherinstance for block cipher encryption and decryption.- Parameters:
algorithm- the XML encryption algorithm URIiv- the initialization vector- Returns:
- the newly constructed AlgorithmParameterSpec instance, appropriate for the specified algorithm
-
constructBlockCipherParameters
public static AlgorithmParameterSpec constructBlockCipherParameters(boolean gcmAlgorithm, byte[] iv)
-
constructOAEPParameters
public static OAEPParameterSpec constructOAEPParameters(String encryptionAlgorithmURI, String digestAlgorithmURI, String mgfAlgorithmURI, byte[] oaepParams)
Method buildOAEPParameters from given parameters and returns OAEPParameterSpec. If encryptionAlgorithmURI is not RSA_OAEP or RSA_OAEP_11, null is returned.- Parameters:
encryptionAlgorithmURI- the encryption algorithm URI (RSA_OAEP or RSA_OAEP_11)digestAlgorithmURI- the digest algorithm URImgfAlgorithmURI- the MGF algorithm URI if encryptionAlgorithmURI is RSA_OAEP_11, otherwise parameter is ignoredoaepParams- the OAEP parameters bytes- Returns:
- OAEPParameterSpec or null if encryptionAlgorithmURI is not RSA_OAEP or RSA_OAEP_11
-
constructMGF1Parameter
public static MGF1ParameterSpec constructMGF1Parameter(String mgh1AlgorithmURI)
Create MGF1ParameterSpec for the given algorithm URI- Parameters:
mgh1AlgorithmURI- the algorithm URI. If null or empty, SHA-1 is used as default MGF1 digest algorithm.- Returns:
- the MGF1ParameterSpec for the given algorithm URI
-
getMgf1URIForParameter
public static String getMgf1URIForParameter(MGF1ParameterSpec parameterSpec)
Get the MGF1 algorithm URI for the given MGF1ParameterSpec- Parameters:
parameterSpec- the MGF1ParameterSpec- Returns:
- the MGF1 algorithm URI for the given MGF1ParameterSpec
-
constructRecipientKeyAgreementParameters
public static KeyAgreementParameters constructRecipientKeyAgreementParameters(String keyWrapAlgoURI, AgreementMethod agreementMethod, PrivateKey keyAgreementPrivateKey) throws XMLSecurityException
Construct an KeyAgreementParameterSpec object from the given parameters- Parameters:
keyWrapAlgoURI- key wrap algorithmagreementMethod- agreement methodkeyAgreementPrivateKey- private key to derive the shared secret in case of Diffie-Hellman key agreements- Throws:
XMLSecurityException
-
constructAgreementParameters
public static KeyAgreementParameters constructAgreementParameters(String agreementAlgorithmURI, KeyAgreementParameters.ActorType actorType, KeyDerivationParameters keyDerivationParameter, PrivateKey keyAgreementPrivateKey, PublicKey keyAgreementPublicKey)
Construct an KeyAgreementParameterSpec object from the given parameters- Parameters:
agreementAlgorithmURI- agreement algorithmkeyDerivationParameter- key derivation parameters (e.g. ConcatKDFParams for ConcatKDF key derivation)keyAgreementPrivateKey- private key to derive the shared secret in case of Diffie-Hellman key agreementskeyAgreementPublicKey- public key to derive the shared secret in case of Diffie-Hellman key agreements
-
constructKeyDerivationParameter
public static KeyDerivationParameters constructKeyDerivationParameter(KeyDerivationMethod keyDerivationMethod, int keyBitLength) throws XMLSecurityException
Construct a KeyDerivationParameter object from the given keyDerivationMethod and keyBitLength- Parameters:
keyDerivationMethod- element to parsekeyBitLength- expected derived key length- Returns:
- KeyDerivationParameter object
- Throws:
XMLSecurityException- if the keyDerivationMethod is not supported
-
constructConcatKeyDerivationParameter
public static ConcatKDFParams constructConcatKeyDerivationParameter(int keyBitLength, String digestMethod)
Construct a ConcatKeyDerivationParameter object from the key length and digest method.- Parameters:
keyBitLength- expected derived key lengthdigestMethod- digest method- Returns:
- ConcatKeyDerivationParameter object
-
constructConcatKeyDerivationParameter
public static ConcatKDFParams constructConcatKeyDerivationParameter(int keyBitLength, String digestMethod, String algorithmId, String partyUInfo, String partyVInfo, String suppPubInfo, String suppPrivInfo)
Construct a ConcatKeyDerivationParameter object from the given parameters- Parameters:
keyBitLength- expected derived key lengthdigestMethod- digest methodalgorithmId- algorithm idpartyUInfo- partyUInfopartyVInfo- partyVInfosuppPubInfo- suppPubInfosuppPrivInfo- suppPrivInfo- Returns:
- ConcatKeyDerivationParameter object
-
-