Class SlhDsaPublicKeySpec
java.lang.Object
zeroecho.core.alg.slhdsa.SlhDsaPublicKeySpec
- All Implemented Interfaces:
AlgorithmKeySpec
Encoded representation of an SLH-DSA public key.
SlhDsaPublicKeySpec is an immutable value object that wraps an X.509
(SubjectPublicKeyInfo) encoded SLH-DSA public key together with the JCA
provider name that should be used when importing the key.
Encoding
- The public key bytes are stored as a defensive copy of the provided X.509 byte array.
- Marshalling/unmarshalling uses
PairSeqwith Base64 encoding under"x509.b64".
Provider selection
The default provider is "BC" because SLH-DSA is registered by the
Bouncy Castle core provider.
Thread-safety
Instances are immutable and can be safely shared across threads.
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionSlhDsaPublicKeySpec(byte[] encodedX509) Creates a new specification using the default provider"BC".SlhDsaPublicKeySpec(byte[] encodedX509, String providerName) Creates a new specification using the supplied provider. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]encoded()Returns a defensive copy of the X.509-encoded public key bytes.static PairSeqmarshal(SlhDsaPublicKeySpec spec) Serializes the given spec into aPairSeq.Returns the provider name associated with this specification.static SlhDsaPublicKeySpecDeserializes aSlhDsaPublicKeySpecfrom aPairSeq.
-
Constructor Details
-
SlhDsaPublicKeySpec
public SlhDsaPublicKeySpec(byte[] encodedX509) Creates a new specification using the default provider"BC".- Parameters:
encodedX509- X.509-encoded SLH-DSA public key bytes- Throws:
IllegalArgumentException- ifencodedX509isnull
-
SlhDsaPublicKeySpec
Creates a new specification using the supplied provider.If
providerNameisnull, the default provider"BC"is used.- Parameters:
encodedX509- X.509-encoded SLH-DSA public key bytesproviderName- JCA provider name to use for import; may benull- Throws:
IllegalArgumentException- ifencodedX509isnull
-
-
Method Details
-
encoded
public byte[] encoded()Returns a defensive copy of the X.509-encoded public key bytes.- Returns:
- a copy of the encoded public key
-
providerName
Returns the provider name associated with this specification.- Returns:
- provider name, never
null
-
marshal
Serializes the given spec into aPairSeq.The encoded key is stored as Base64 without padding under
"x509.b64". The provider is stored under"provider".- Parameters:
spec- the public key specification to serialize- Returns:
- serialized representation
- Throws:
NullPointerException- ifspecisnull
-
unmarshal
Deserializes aSlhDsaPublicKeySpecfrom aPairSeq.Expects key
"x509.b64"(required) and"provider"(optional; defaults to"BC").- Parameters:
p- serialized input- Returns:
- reconstructed public key specification
- Throws:
IllegalArgumentException- if"x509.b64"is missingNullPointerException- ifpisnull
-