Class EcdsaPublicKeySpec
java.lang.Object
zeroecho.core.alg.ecdsa.EcdsaPublicKeySpec
- All Implemented Interfaces:
AlgorithmKeySpec
ECDSA Public Key Specification
An immutable wrapper around an X.509-encoded ECDSA public key. This specification is used byEcdsaPublicKeyBuilder to import keys into
the JCA PublicKey representation.
Encoding
- Keys are stored internally in X.509 SubjectPublicKeyInfo DER format.
- Instances are defensive: the internal byte array is cloned on construction and on every access.
- For serialization,
marshal(EcdsaPublicKeySpec)encodes the X.509 bytes in Base64 without padding.
Usage
// Construct from X.509 DER
byte[] x509 = ...; // load from certificate or key file
EcdsaPublicKeySpec spec = new EcdsaPublicKeySpec(x509);
// Import into a PublicKey
PublicKey pub = new EcdsaPublicKeyBuilder().importPublic(spec);
// Marshal/unmarshal for transport or storage
PairSeq seq = EcdsaPublicKeySpec.marshal(spec);
EcdsaPublicKeySpec restored = EcdsaPublicKeySpec.unmarshal(seq);
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionEcdsaPublicKeySpec(byte[] x509) Creates a new public key specification from an X.509 encoded byte array. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]encoded()Returns a defensive copy of the encoded X.509 data.static PairSeqmarshal(EcdsaPublicKeySpec spec) Serializes this specification into aPairSeq.static EcdsaPublicKeySpecReconstructs a public key specification from aPairSeq.
-
Constructor Details
-
EcdsaPublicKeySpec
public EcdsaPublicKeySpec(byte[] x509) Creates a new public key specification from an X.509 encoded byte array.- Parameters:
x509- X.509 SubjectPublicKeyInfo DER-encoded public key (must not benull)- Throws:
IllegalArgumentException- ifx509isnull
-
-
Method Details
-
encoded
public byte[] encoded()Returns a defensive copy of the encoded X.509 data.- Returns:
- cloned X.509 byte array
-
marshal
Serializes this specification into aPairSeq.The X.509 data is Base64-encoded (without padding) and emitted with the key
"x509.b64".- Parameters:
spec- public key spec to marshal- Returns:
- serialized representation in key-value form
-
unmarshal
Reconstructs a public key specification from aPairSeq.The sequence must contain a
"x509.b64"field with Base64-encoded X.509 DER data. If missing, anIllegalArgumentExceptionis thrown.- Parameters:
p- serialized key-value sequence- Returns:
- reconstructed
EcdsaPublicKeySpec - Throws:
IllegalArgumentException- ifx509.b64is absent
-