Package zeroecho.core.alg.ecdsa
Class EcdsaPrivateKeyBuilder
java.lang.Object
zeroecho.core.alg.ecdsa.EcdsaPrivateKeyBuilder
- All Implemented Interfaces:
AsymmetricKeyBuilder<EcdsaPrivateKeySpec>
public final class EcdsaPrivateKeyBuilder
extends Object
implements AsymmetricKeyBuilder<EcdsaPrivateKeySpec>
ECDSA Private Key Builder
Implementation ofAsymmetricKeyBuilder for
EcdsaPrivateKeySpec. This builder is responsible for importing ECDSA
private keys from encoded representations.
Supported operations
importPrivate(EcdsaPrivateKeySpec)- construct aPrivateKeyinstance from a PKCS#8 encoded key.generateKeyPair(EcdsaPrivateKeySpec)- unsupported; useEcdsaKeyGenBuilderinstead.importPublic(EcdsaPrivateKeySpec)- unsupported; useEcdsaPublicKeySpecwithEcdsaPublicKeyBuilderinstead.
Encoding
TheEcdsaPrivateKeySpec stores the private key in
PKCS#8 DER format. This builder delegates to a JCA KeyFactory for the
"EC" algorithm to reconstruct a usable PrivateKey.
Usage
Typically accessed indirectly throughCryptoAlgorithms.privateKey(String, zeroecho.core.spec.AlgorithmKeySpec)
or
CryptoAlgorithm.importPrivate(zeroecho.core.spec.AlgorithmKeySpec).
// Example: Import an ECDSA private key
byte[] pkcs8 = ...; // load PKCS#8 DER data
EcdsaPrivateKeySpec spec = new EcdsaPrivateKeySpec(pkcs8);
PrivateKey priv = new EcdsaPrivateKeyBuilder().importPrivate(spec);
- Since:
- 1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionUnsupported operation for this builder.Imports a private key from a PKCS#8 encoded specification.Unsupported operation for this builder.
-
Constructor Details
-
EcdsaPrivateKeyBuilder
public EcdsaPrivateKeyBuilder()
-
-
Method Details
-
generateKeyPair
Unsupported operation for this builder.ECDSA key pair generation should be performed using
EcdsaKeyGenBuilder, not from a private key specification.- Specified by:
generateKeyPairin interfaceAsymmetricKeyBuilder<EcdsaPrivateKeySpec>- Parameters:
spec- unused private key specification- Returns:
- never returns normally
- Throws:
UnsupportedOperationException- always thrown
-
importPublic
Unsupported operation for this builder.Public key import should be performed using
EcdsaPublicKeySpecwithEcdsaPublicKeyBuilder.- Specified by:
importPublicin interfaceAsymmetricKeyBuilder<EcdsaPrivateKeySpec>- Parameters:
spec- unused private key specification- Returns:
- never returns normally
- Throws:
UnsupportedOperationException- always thrown
-
importPrivate
Imports a private key from a PKCS#8 encoded specification.Uses a JCA
KeyFactoryinstance for"EC"to parse the givenEcdsaPrivateKeySpecand construct aPrivateKey.- Specified by:
importPrivatein interfaceAsymmetricKeyBuilder<EcdsaPrivateKeySpec>- Parameters:
spec- private key specification containing PKCS#8 DER encoding- Returns:
- reconstructed
PrivateKeyinstance - Throws:
GeneralSecurityException- if the encoding is invalid or the key cannot be reconstructed
-