Package zeroecho.core.alg.hqc
Class HqcPublicKeySpec
java.lang.Object
zeroecho.core.alg.hqc.HqcPublicKeySpec
- All Implemented Interfaces:
AlgorithmKeySpec
HQC Public Key Specification
AlgorithmKeySpec wrapper for HQC public keys,
encoded in standard X.509 DER format.
This class is used to transport and import HQC public keys into the
HqcAlgorithm. The encoded form is immutable and defensively copied on
construction and retrieval.
Serialization
marshal(HqcPublicKeySpec) encodes the key material into a
PairSeq with Base64 (unpadded) representation. The inverse
unmarshal(PairSeq) restores the specification from such a sequence.
Security note
- Public keys are not confidential, but integrity is critical. They should only be distributed over authenticated or integrity-protected channels.
- The contained byte array is immutable and returned as a defensive copy to avoid accidental modification.
Usage example
// Wrap an existing X.509 HQC public key
HqcPublicKeySpec spec = new HqcPublicKeySpec(x509Bytes);
// Import into a PublicKey via HqcAlgorithm
HqcAlgorithm hqc = new HqcAlgorithm();
PublicKey pub = hqc.importPublic(spec);
// Serialize for transport
PairSeq serialized = HqcPublicKeySpec.marshal(spec);
// Reconstruct from serialized form
HqcPublicKeySpec restored = HqcPublicKeySpec.unmarshal(serialized);
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionHqcPublicKeySpec(byte[] x509Der) Constructs a new public key spec from an X.509-encoded byte array. -
Method Summary
Modifier and TypeMethodDescriptionstatic PairSeqmarshal(HqcPublicKeySpec spec) Serializes this spec into aPairSeqwith Base64-encoded key data.toString()Returns a diagnostic string containing the encoded length.static HqcPublicKeySpecReconstructs a spec from itsPairSeqrepresentation.byte[]x509()Returns a defensive copy of the X.509-encoded key material.
-
Constructor Details
-
HqcPublicKeySpec
public HqcPublicKeySpec(byte[] x509Der) Constructs a new public key spec from an X.509-encoded byte array.- Parameters:
x509Der- DER-encoded X.509 public key- Throws:
NullPointerException- ifx509Derisnull
-
-
Method Details
-
x509
public byte[] x509()Returns a defensive copy of the X.509-encoded key material.- Returns:
- cloned X.509 byte array
-
marshal
Serializes this spec into aPairSeqwith Base64-encoded key data.The resulting sequence has keys:
type="HqcPublicKeySpec"x509.b64= Base64 of the X.509 key
- Parameters:
spec- the spec to serialize- Returns:
- serialized representation in a
PairSeq
-
unmarshal
Reconstructs a spec from itsPairSeqrepresentation.- Parameters:
p- sequence containingx509.b64- Returns:
- reconstructed
HqcPublicKeySpec - Throws:
IllegalArgumentException- if required fieldx509.b64is missing
-
toString
Returns a diagnostic string containing the encoded length.The actual key material is not exposed in this representation.
-