Class EcdsaPrivateKeySpec
java.lang.Object
zeroecho.core.alg.ecdsa.EcdsaPrivateKeySpec
- All Implemented Interfaces:
Destroyable, AlgorithmKeySpec
ECDSA Private Key Specification
A destroyable wrapper around a PKCS#8-encoded ECDSA private key. This specification is used byEcdsaPrivateKeyBuilder to import keys into
the JCA PrivateKey representation.
Encoding
- Keys are stored internally in PKCS#8 DER format.
- Instances are defensive: the internal byte array is cloned on construction and on every access.
- For serialization,
marshal(EcdsaPrivateKeySpec)encodes the PKCS#8 bytes in Base64 without padding.
Usage
// Construct from PKCS#8 DER
byte[] pkcs8 = ...; // load from file or keystore
EcdsaPrivateKeySpec spec = new EcdsaPrivateKeySpec(pkcs8);
// Import into a PrivateKey
PrivateKey priv = new EcdsaPrivateKeyBuilder().importPrivate(spec);
// Marshal/unmarshal for transport or storage
PairSeq seq = EcdsaPrivateKeySpec.marshal(spec);
EcdsaPrivateKeySpec restored = EcdsaPrivateKeySpec.unmarshal(seq);
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionEcdsaPrivateKeySpec(byte[] pkcs8) Creates a new private key specification from a PKCS#8 encoded byte array. -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()byte[]encoded()Returns a defensive copy of the encoded PKCS#8 data.booleanstatic PairSeqmarshal(EcdsaPrivateKeySpec spec) Serializes this specification into aPairSeq.static EcdsaPrivateKeySpecReconstructs a private key specification from aPairSeq.
-
Constructor Details
-
EcdsaPrivateKeySpec
public EcdsaPrivateKeySpec(byte[] pkcs8) Creates a new private key specification from a PKCS#8 encoded byte array.- Parameters:
pkcs8- PKCS#8 DER-encoded private key (must not benull)- Throws:
IllegalArgumentException- ifpkcs8isnull
-
-
Method Details
-
encoded
public byte[] encoded()Returns a defensive copy of the encoded PKCS#8 data.- Returns:
- cloned PKCS#8 byte array
-
marshal
Serializes this specification into aPairSeq.The PKCS#8 data is Base64-encoded (without padding) and emitted with the key
"pkcs8.b64".- Parameters:
spec- private key spec to marshal- Returns:
- serialized representation in key-value form
-
unmarshal
Reconstructs a private key specification from aPairSeq.The sequence must contain a
"pkcs8.b64"field with Base64-encoded PKCS#8 DER data. If missing, anIllegalArgumentExceptionis thrown.- Parameters:
p- serialized key-value sequence- Returns:
- reconstructed
EcdsaPrivateKeySpec - Throws:
IllegalArgumentException- ifpkcs8.b64is absent
-
destroy
public void destroy()- Specified by:
destroyin interfaceDestroyable
-
isDestroyed
public boolean isDestroyed()- Specified by:
isDestroyedin interfaceDestroyable
-