Class FrodoPublicKeySpec
java.lang.Object
zeroecho.core.alg.frodo.FrodoPublicKeySpec
- All Implemented Interfaces:
AlgorithmKeySpec
Specification for importing a Frodo public key
FrodoPublicKeySpec is a wrapper around an X.509-encoded FrodoKEM
public key. It provides immutable access to the raw encoding and utility
methods for serialization.
Encoding format
- Keys are stored in the standard X.509 SubjectPublicKeyInfo format as produced by providers such as BouncyCastle PQC.
- The encoding is preserved exactly as provided; no parsing or validation is performed by this class.
Usage
- Instances of this spec can be passed to
KeyBuilders.Asymmetric.importPublic(String, AlgorithmKeySpec)to construct a usablePublicKey. - The
marshal(FrodoPublicKeySpec)andunmarshal(PairSeq)methods allow safe serialization into and recovery from structured textual form.
// Import an existing Frodo public key
byte[] encoded = Files.readAllBytes(Paths.get("frodo.pub"));
FrodoPublicKeySpec spec = new FrodoPublicKeySpec(encoded);
PublicKey pub = session.keyBuilders().asymmetric().importPublic("FrodoKEM", spec);
Thread-safety
This class is immutable; the internal byte array is cloned on construction
and when accessed via x509().
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionFrodoPublicKeySpec(byte[] x509Der) Creates a new specification from an X.509 DER-encoded public key. -
Method Summary
Modifier and TypeMethodDescriptionstatic PairSeqmarshal(FrodoPublicKeySpec spec) Serializes this spec into aPairSeq, encoding the key in Base64 without padding.toString()Returns a diagnostic string containing the encoded length.static FrodoPublicKeySpecParses aPairSeqpreviously produced bymarshal(FrodoPublicKeySpec).byte[]x509()Returns a clone of the underlying X.509 encoding.
-
Constructor Details
-
FrodoPublicKeySpec
public FrodoPublicKeySpec(byte[] x509Der) Creates a new specification from an X.509 DER-encoded public key.- Parameters:
x509Der- the encoded public key bytes (will be cloned)- Throws:
NullPointerException- ifx509Derisnull
-
-
Method Details
-
x509
public byte[] x509()Returns a clone of the underlying X.509 encoding.- Returns:
- defensive copy of the X.509-encoded public key
-
marshal
Serializes this spec into aPairSeq, encoding the key in Base64 without padding.- Parameters:
spec- Frodo public key specification to serialize- Returns:
- a
PairSeqwith type and Base64-encoded key
-
unmarshal
Parses aPairSeqpreviously produced bymarshal(FrodoPublicKeySpec).- Parameters:
p- input sequence containing ax509.b64entry- Returns:
- a new public key spec initialized with the decoded bytes
- Throws:
IllegalArgumentException- ifx509.b64entry is missing
-
toString
-