Package org.opensaml.security.crypto.dh
Class DHSupport
java.lang.Object
org.opensaml.security.crypto.dh.DHSupport
Cryptography support related to Elliptic Curve.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic KeyPairgenerateCompatibleKeyPair(DHPublicKey publicKey, String provider) Generate a key pair whose parameters are compatible with those of the specified DH public key.static BigIntegergetPrimeQDomainParameter(DHPublicKey publicKey) Obtain the prime Q domain parameter from the specified DH public key.static byte[]performKeyAgreement(DHPublicKey publicKey, DHPrivateKey privateKey, String provider) Perform DH key agreement between the given public and private keys.
-
Field Details
-
LOG
@Nonnull private static final org.slf4j.Logger LOGLogger.
-
-
Constructor Details
-
DHSupport
private DHSupport()Constructor.
-
-
Method Details
-
performKeyAgreement
@Nonnull public static byte[] performKeyAgreement(@Nonnull DHPublicKey publicKey, @Nonnull DHPrivateKey privateKey, @Nullable String provider) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeyException Perform DH key agreement between the given public and private keys.- Parameters:
publicKey- the public keyprivateKey- the private keyprovider- the optional security provider to use- Returns:
- the secret produced by key agreement
- Throws:
NoSuchAlgorithmException- if algorithm is unknownNoSuchProviderException- if provider is unknownInvalidKeyException- if supplied key is invalid
-
generateCompatibleKeyPair
@Nonnull public static KeyPair generateCompatibleKeyPair(@Nonnull DHPublicKey publicKey, @Nullable String provider) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException Generate a key pair whose parameters are compatible with those of the specified DH public key.- Parameters:
publicKey- the public keyprovider- the optional security provider to use- Returns:
- the generated key pair
- Throws:
NoSuchAlgorithmException- if algorithm is unknownNoSuchProviderException- if provider is unknownInvalidAlgorithmParameterException- if the public key'sDHParameterSpecis not supported
-
getPrimeQDomainParameter
Obtain the prime Q domain parameter from the specified DH public key.Java's interface for DH domain parameters
DHParameterSpecdoesn't expose the prime Q parameter, but in some contexts it is required, e.g XML EncryptionDHKeyValueelement. The approach here is to parse the ASN.1 encoding of the key directly.- Parameters:
publicKey- the public key- Returns:
- the prime Q domain parameter, or null if could not be processed
-