Class SaberPublicKeySpec
java.lang.Object
zeroecho.core.alg.saber.SaberPublicKeySpec
- All Implemented Interfaces:
AlgorithmKeySpec
Encoded public key specification for the SABER post-quantum KEM algorithm.
A SaberPublicKeySpec wraps a SABER public key in standard X.509
SubjectPublicKeyInfo format. It provides safe accessors for cloning, along
with serialization helpers to marshal and unmarshal from a compact
PairSeq representation.
Immutability
The internal X.509 encoding is defensively copied on construction and when
returned by x509(). Instances are therefore immutable and safe to
share across threads.
Usage example
// Import SABER public key from encoded form
byte[] x509Bytes = ...;
SaberPublicKeySpec spec = new SaberPublicKeySpec(x509Bytes);
PublicKey key = session.keyBuilders().asymmetric().importPublic("SABER", spec);
-
Constructor Summary
ConstructorsConstructorDescriptionSaberPublicKeySpec(byte[] x509Der) Constructs a public key specification from an X.509-encoded SABER public key. -
Method Summary
Modifier and TypeMethodDescriptionstatic PairSeqmarshal(SaberPublicKeySpec spec) Serializes this specification into a compactPairSeqform.toString()Returns a diagnostic string showing the length of the encoded key.static SaberPublicKeySpecDeserializes aSaberPublicKeySpecfrom itsPairSeqform.byte[]x509()Returns a defensive copy of the X.509-encoded public key.
-
Constructor Details
-
SaberPublicKeySpec
public SaberPublicKeySpec(byte[] x509Der) Constructs a public key specification from an X.509-encoded SABER public key.- Parameters:
x509Der- the X.509 SubjectPublicKeyInfo bytes- Throws:
NullPointerException- ifx509Derisnull
-
-
Method Details
-
x509
public byte[] x509()Returns a defensive copy of the X.509-encoded public key.- Returns:
- cloned byte array containing the X.509 encoding
-
marshal
Serializes this specification into a compactPairSeqform.The encoding includes:
type=SaberPublicKeySpecx509.b64= Base64 encoding of the X.509 bytes (no padding)
- Parameters:
spec- the public key specification to serialize- Returns:
- a
PairSeqcontaining the encoded data - Throws:
NullPointerException- ifspecisnull
-
unmarshal
Deserializes aSaberPublicKeySpecfrom itsPairSeqform.The sequence must contain a field
x509.b64with the Base64-encoded X.509 public key bytes. If the field is missing, an exception is thrown.- Parameters:
p- the pair sequence to parse- Returns:
- a reconstructed
SaberPublicKeySpec - Throws:
IllegalArgumentException- if thex509.b64field is missing
-
toString
-