Class CmcePublicKeySpec
java.lang.Object
zeroecho.core.alg.cmce.CmcePublicKeySpec
- All Implemented Interfaces:
AlgorithmKeySpec
Classic McEliece (CMCE) public key specification
Wraps a CMCE public key in X.509 (DER) encoding. This spec is used to import or serialize public keys into the ZeroEcho SPI.
Instances are immutable. The internal byte array is cloned on construction and on every accessor to prevent accidental mutation.
Marshalling
marshal(CmcePublicKeySpec)produces aPairSeqwith Base64-encoded X.509 data.unmarshal(PairSeq)reconstructs a spec from that format.
Example:
// Wrap an existing X.509-encoded public key
CmcePublicKeySpec spec = new CmcePublicKeySpec(x509Bytes);
// Serialize to PairSeq for storage or transport
PairSeq encoded = CmcePublicKeySpec.marshal(spec);
// Reconstruct later
CmcePublicKeySpec restored = CmcePublicKeySpec.unmarshal(encoded);
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionCmcePublicKeySpec(byte[] x509Der) Creates a new specification from an X.509-encoded CMCE public key. -
Method Summary
Modifier and TypeMethodDescriptionstatic PairSeqmarshal(CmcePublicKeySpec spec) Serializes the given public key spec into aPairSeq.toString()Returns a diagnostic string with the length of the encoded key.static CmcePublicKeySpecDeserializes aCmcePublicKeySpecfrom aPairSeq.byte[]x509()Returns a defensive copy of the X.509 bytes.
-
Constructor Details
-
CmcePublicKeySpec
public CmcePublicKeySpec(byte[] x509Der) Creates a new specification from an X.509-encoded CMCE public key.The input is defensively copied.
- Parameters:
x509Der- DER-encoded X.509 public key- Throws:
NullPointerException- ifx509Deris null
-
-
Method Details
-
x509
public byte[] x509()Returns a defensive copy of the X.509 bytes.- Returns:
- a fresh copy of the underlying X.509 encoding
-
marshal
Serializes the given public key spec into aPairSeq.The X.509 bytes are Base64-encoded (without padding) and stored under the key
"x509.b64". The type tag"CmcePublicKeySpec"is also included.- Parameters:
spec- the spec to serialize- Returns:
- a PairSeq containing type and Base64-encoded key
- Throws:
NullPointerException- ifspecis null
-
unmarshal
Deserializes aCmcePublicKeySpecfrom aPairSeq.The method scans for a key named
"x509.b64", decodes its value from Base64, and reconstructs the spec.- Parameters:
p- PairSeq containing serialized fields- Returns:
- reconstructed
CmcePublicKeySpec - Throws:
IllegalArgumentException- if no"x509.b64"field is found
-
toString
-