Class SlhDsaPrivateKeySpec
java.lang.Object
zeroecho.core.alg.slhdsa.SlhDsaPrivateKeySpec
- All Implemented Interfaces:
Destroyable, AlgorithmKeySpec
Encoded representation of an SLH-DSA private key.
SlhDsaPrivateKeySpec is a destroyable value object that wraps a
PKCS#8-encoded SLH-DSA private key together with the JCA provider name that
should be used when importing the key.
Encoding
- The private key material is stored as a defensive copy of the provided PKCS#8 byte array.
- Marshalling/unmarshalling uses
PairSeqwith Base64 encoding under"pkcs8.b64".
Provider selection
The default provider is "BC" because SLH-DSA is registered by the
Bouncy Castle core provider (as opposed to the PQC-only provider).
Security considerations
- All byte arrays returned by this class are defensive copies.
- This class performs no cryptographic operations.
- Callers must protect serialized private key material at rest and in transit.
Thread-safety
Access and destruction are synchronized.
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionSlhDsaPrivateKeySpec(byte[] encodedPkcs8) Creates a new specification using the default provider"BC".SlhDsaPrivateKeySpec(byte[] encodedPkcs8, String providerName) Creates a new specification using the supplied provider. -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()byte[]encoded()Returns a defensive copy of the PKCS#8-encoded private key bytes.booleanstatic PairSeqmarshal(SlhDsaPrivateKeySpec spec) Serializes the given spec into aPairSeq.Returns the provider name associated with this specification.static SlhDsaPrivateKeySpecDeserializes aSlhDsaPrivateKeySpecfrom aPairSeq.
-
Constructor Details
-
SlhDsaPrivateKeySpec
public SlhDsaPrivateKeySpec(byte[] encodedPkcs8) Creates a new specification using the default provider"BC".- Parameters:
encodedPkcs8- PKCS#8-encoded SLH-DSA private key bytes- Throws:
IllegalArgumentException- ifencodedPkcs8isnull
-
SlhDsaPrivateKeySpec
Creates a new specification using the supplied provider.If
providerNameisnull, the default provider"BC"is used.- Parameters:
encodedPkcs8- PKCS#8-encoded SLH-DSA private key bytesproviderName- JCA provider name to use for import; may benull- Throws:
IllegalArgumentException- ifencodedPkcs8isnull
-
-
Method Details
-
encoded
public byte[] encoded()Returns a defensive copy of the PKCS#8-encoded private key bytes.- Returns:
- a copy of the encoded private 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
"pkcs8.b64". The provider is stored under"provider".- Parameters:
spec- the private key specification to serialize- Returns:
- serialized representation
- Throws:
NullPointerException- ifspecisnull
-
unmarshal
Deserializes aSlhDsaPrivateKeySpecfrom aPairSeq.Expects key
"pkcs8.b64"(required) and"provider"(optional; defaults to"BC").- Parameters:
p- serialized input- Returns:
- reconstructed private key specification
- Throws:
IllegalArgumentException- if"pkcs8.b64"is missingNullPointerException- ifpisnull
-
destroy
public void destroy()- Specified by:
destroyin interfaceDestroyable
-
isDestroyed
public boolean isDestroyed()- Specified by:
isDestroyedin interfaceDestroyable
-