Class CmcePrivateKeySpec
java.lang.Object
zeroecho.core.alg.cmce.CmcePrivateKeySpec
- All Implemented Interfaces:
Destroyable, AlgorithmKeySpec
Classic McEliece (CMCE) private key specification
Wraps a CMCE private key in PKCS#8 (DER) encoding. This spec is used to import or serialize private keys into the ZeroEcho SPI.
The internal byte array is cloned on construction and on every accessor. Access and destruction are synchronized.
Marshalling
marshal(CmcePrivateKeySpec)produces aPairSeqwith Base64-encoded PKCS#8.unmarshal(PairSeq)reconstructs a spec from that format.
Example:
// Wrap an existing PKCS#8 byte array
CmcePrivateKeySpec spec = new CmcePrivateKeySpec(pkcs8Bytes);
// Serialize to PairSeq for storage or transport
PairSeq encoded = CmcePrivateKeySpec.marshal(spec);
// Reconstruct later
CmcePrivateKeySpec restored = CmcePrivateKeySpec.unmarshal(encoded);
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionCmcePrivateKeySpec(byte[] pkcs8Der) Creates a new specification from a PKCS#8-encoded CMCE private key. -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()booleanstatic PairSeqmarshal(CmcePrivateKeySpec spec) Serializes the given private key spec into aPairSeq.byte[]pkcs8()Returns a defensive copy of the PKCS#8 bytes.toString()Returns a diagnostic string with the length of the encoded key.static CmcePrivateKeySpecDeserializes aCmcePrivateKeySpecfrom aPairSeq.
-
Constructor Details
-
CmcePrivateKeySpec
public CmcePrivateKeySpec(byte[] pkcs8Der) Creates a new specification from a PKCS#8-encoded CMCE private key.The input is defensively copied.
- Parameters:
pkcs8Der- DER-encoded PKCS#8 private key- Throws:
NullPointerException- ifpkcs8Deris null
-
-
Method Details
-
pkcs8
public byte[] pkcs8()Returns a defensive copy of the PKCS#8 bytes.- Returns:
- a fresh copy of the underlying PKCS#8 encoding
-
marshal
Serializes the given private key spec into aPairSeq.The PKCS#8 bytes are Base64-encoded (without padding) and stored under the key
"pkcs8.b64". The type tag"CmcePrivateKeySpec"is also included.- Parameters:
spec- the spec to serialize- Returns:
- a PairSeq containing type and Base64-encoded key
- Throws:
NullPointerException- ifspecis null
-
unmarshal
Deserializes aCmcePrivateKeySpecfrom aPairSeq.The method scans for a key named
"pkcs8.b64", decodes its value from Base64, and reconstructs the spec.- Parameters:
p- PairSeq containing serialized fields- Returns:
- reconstructed
CmcePrivateKeySpec - Throws:
IllegalArgumentException- if no"pkcs8.b64"field is found
-
toString
-
destroy
public void destroy()- Specified by:
destroyin interfaceDestroyable
-
isDestroyed
public boolean isDestroyed()- Specified by:
isDestroyedin interfaceDestroyable
-