Package org.opensaml.security.crypto.dh
Class DHSupport
- java.lang.Object
-
- org.opensaml.security.crypto.dh.DHSupport
-
public final class DHSupport extends Object
Cryptography support related to Elliptic Curve.
-
-
Field Summary
Fields Modifier and Type Field Description private static org.slf4j.LoggerLOGLogger.
-
Constructor Summary
Constructors Modifier Constructor Description privateDHSupport()Constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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.
-
-
-
Method Detail
-
performKeyAgreement
@Nonnull public static byte[] performKeyAgreement(@Nonnull DHPublicKey publicKey, @Nonnull DHPrivateKey privateKey, @Nullable String provider) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeyExceptionPerform 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
@Nullable public static BigInteger getPrimeQDomainParameter(@Nonnull DHPublicKey publicKey)
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
-
-