Class HqcPrivateKeySpec
java.lang.Object
zeroecho.core.alg.hqc.HqcPrivateKeySpec
- All Implemented Interfaces:
Destroyable, AlgorithmKeySpec
HQC Private Key Specification
AlgorithmKeySpec wrapper for HQC private keys,
encoded in standard PKCS#8 DER format.
This class is used to transport and import HQC private keys into the
HqcAlgorithm. The encoded form is defensively copied on construction
and retrieval and may be destroyed.
Serialization
marshal(HqcPrivateKeySpec) encodes the key material into a
PairSeq with Base64 (unpadded) representation. The inverse
unmarshal(PairSeq) restores the specification from such a sequence.
Security note
- The contained byte array represents sensitive key material. Applications should minimize retention and ensure secure erasure when possible.
- Use only for import into a trusted
KeyFactoryorHqcAlgorithm. Never log or transmit the raw array.
Usage example
// Wrap an existing PKCS#8 HQC private key
HqcPrivateKeySpec spec = new HqcPrivateKeySpec(pkcs8Bytes);
// Import into a PrivateKey via HqcAlgorithm
HqcAlgorithm hqc = new HqcAlgorithm();
PrivateKey priv = hqc.privateKeyImporter(HqcPrivateKeySpec.class).importPrivate(spec);
// Serialize for transport
PairSeq serialized = HqcPrivateKeySpec.marshal(spec);
// Reconstruct from serialized form
HqcPrivateKeySpec restored = HqcPrivateKeySpec.unmarshal(serialized);
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionHqcPrivateKeySpec(byte[] pkcs8Der) Constructs a new private key spec from a PKCS#8-encoded byte array. -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()booleanstatic PairSeqmarshal(HqcPrivateKeySpec spec) Serializes this spec into aPairSeqwith Base64-encoded key data.byte[]pkcs8()Returns a defensive copy of the PKCS#8-encoded key material.toString()Returns a diagnostic string containing the encoded length.static HqcPrivateKeySpecReconstructs a spec from itsPairSeqrepresentation.
-
Constructor Details
-
HqcPrivateKeySpec
public HqcPrivateKeySpec(byte[] pkcs8Der) Constructs a new private key spec from a PKCS#8-encoded byte array.- Parameters:
pkcs8Der- DER-encoded PKCS#8 private key- Throws:
NullPointerException- ifpkcs8Derisnull
-
-
Method Details
-
pkcs8
public byte[] pkcs8()Returns a defensive copy of the PKCS#8-encoded key material.- Returns:
- cloned PKCS#8 byte array
-
marshal
-
unmarshal
Reconstructs a spec from itsPairSeqrepresentation.- Parameters:
p- sequence containingpkcs8.b64- Returns:
- reconstructed
HqcPrivateKeySpec - Throws:
IllegalArgumentException- if required fieldpkcs8.b64is missing
-
toString
-
destroy
public void destroy()- Specified by:
destroyin interfaceDestroyable
-
isDestroyed
public boolean isDestroyed()- Specified by:
isDestroyedin interfaceDestroyable
-