Package zeroecho.core.alg.xdh
Class XdhKeyGenBuilder
java.lang.Object
zeroecho.core.alg.xdh.XdhKeyGenBuilder
- All Implemented Interfaces:
AsymmetricKeyBuilder<XdhSpec>
KeyPair generator for XDH curves using the JCA KeyPairGenerator SPI.
This builder produces XDH key pairs (e.g., X25519, X448 depending on the
runtime provider) by instantiating a JCA KeyPairGenerator with the
algorithm name supplied by XdhSpec.kpgName().
Design and scope
- Generation only: This builder supports key generation.
Public/private import is intentionally unsupported and will throw
UnsupportedOperationException. - Provider resolution: The default JCA provider selection is used. If a specific provider is required, supply or register one that exposes the requested XDH algorithm name.
- Thread-safety: Instances are stateless and thread-safe.
Example
// Generate an X25519 key pair
XdhKeyGenBuilder builder = new XdhKeyGenBuilder();
KeyPair kp = builder.generateKeyPair(XdhSpec.X25519);
PublicKey pub = kp.getPublic();
PrivateKey prv = kp.getPrivate();
- Since:
- 1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongenerateKeyPair(XdhSpec spec) Generates a new XDH key pair using the JCAKeyPairGenerator.importPrivate(XdhSpec spec) Not supported: importing XDH private keys is outside the scope of this builder.importPublic(XdhSpec spec) Not supported: importing XDH public keys is outside the scope of this builder.
-
Constructor Details
-
XdhKeyGenBuilder
public XdhKeyGenBuilder()
-
-
Method Details
-
generateKeyPair
Generates a new XDH key pair using the JCAKeyPairGenerator.The generator instance is obtained via
KeyPairGenerator.getInstance(String)withXdhSpec.kpgName()(for example,"XDH"or"X25519"). No additional initialization parameters are supplied; providers are expected to choose safe defaults for the requested curve.- Specified by:
generateKeyPairin interfaceAsymmetricKeyBuilder<XdhSpec>- Parameters:
spec- the XDH key specification indicating which XDH variant to use (e.g.,X25519)- Returns:
- a freshly generated
KeyPairfor the requested XDH variant - Throws:
GeneralSecurityException- if the algorithm is not available, the provider rejects the request, or key generation fails
-
importPublic
Not supported: importing XDH public keys is outside the scope of this builder.Use a dedicated import builder or provider-specific utilities if you need to wrap encoded public keys.
- Specified by:
importPublicin interfaceAsymmetricKeyBuilder<XdhSpec>- Parameters:
spec- the XDH key specification- Returns:
- never returns normally
- Throws:
UnsupportedOperationException- always thrown to indicate unsupported operation
-
importPrivate
Not supported: importing XDH private keys is outside the scope of this builder.Use a dedicated import builder or provider-specific utilities if you need to wrap encoded private keys.
- Specified by:
importPrivatein interfaceAsymmetricKeyBuilder<XdhSpec>- Parameters:
spec- the XDH key specification- Returns:
- never returns normally
- Throws:
UnsupportedOperationException- always thrown to indicate unsupported operation
-