Class EcdhKeyGenBuilder
java.lang.Object
zeroecho.core.alg.ecdh.EcdhKeyGenBuilder
- All Implemented Interfaces:
AsymmetricKeyPairGenerator<EcdhCurveSpec>
public final class EcdhKeyGenBuilder
extends Object
implements AsymmetricKeyPairGenerator<EcdhCurveSpec>
ECDH Key Pair Generator
Implementation ofAsymmetricKeyPairGenerator for
elliptic curve Diffie-Hellman (ECDH) key pairs.
This builder generates fresh EC key pairs suitable for ECDH key agreement. It
accepts an EcdhCurveSpec that defines the named curve to use (e.g.,
P-256, P-384, P-521).
Usage
// Generate a key pair on P-256
KeyPair kp = new EcdhKeyGenBuilder().generateKeyPair(EcdhCurveSpec.P256);
Import of existing keys is not supported by this builder. Instead, use
EcdsaPublicKeyBuilder and EcdsaPrivateKeyBuilder together
with EcdsaPublicKeySpec or EcdsaPrivateKeySpec when importing
encoded elliptic curve keys.
- Since:
- 1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongenerateKeyPair(EcdhCurveSpec spec) Generates a new elliptic curve key pair for use in ECDH key agreement.
-
Constructor Details
-
EcdhKeyGenBuilder
public EcdhKeyGenBuilder()Creates a stateless ECDH key-pair generator.
-
-
Method Details
-
generateKeyPair
Generates a new elliptic curve key pair for use in ECDH key agreement.The curve is determined from the provided
EcdhCurveSpec. Internally, a standard JCAKeyPairGeneratorfor"EC"is initialized with the correspondingECGenParameterSpec.- Specified by:
generateKeyPairin interfaceAsymmetricKeyPairGenerator<EcdhCurveSpec>- Parameters:
spec- curve specification selecting the named curve- Returns:
- a freshly generated
KeyPairsuitable for ECDH - Throws:
GeneralSecurityException- if the curve is not supported by the underlying JCA provider or if key generation fails
-