Class MldsaPrivateKeySpec
java.lang.Object
zeroecho.core.alg.mldsa.MldsaPrivateKeySpec
- All Implemented Interfaces:
Destroyable, AlgorithmKeySpec
Encoded representation of an ML-DSA private key.
MldsaPrivateKeySpec is a destroyable value object that wraps a
PKCS#8-encoded ML-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".
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionMldsaPrivateKeySpec(byte[] encodedPkcs8) Creates a new specification using the default provider"BC".MldsaPrivateKeySpec(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(MldsaPrivateKeySpec spec) Serializes the given spec into aPairSeq.Returns the provider name associated with this specification.static MldsaPrivateKeySpecDeserializes aMldsaPrivateKeySpecfrom aPairSeq.
-
Constructor Details
-
MldsaPrivateKeySpec
public MldsaPrivateKeySpec(byte[] encodedPkcs8) Creates a new specification using the default provider"BC".- Parameters:
encodedPkcs8- PKCS#8-encoded ML-DSA private key bytes- Throws:
IllegalArgumentException- ifencodedPkcs8isnull
-
MldsaPrivateKeySpec
Creates a new specification using the supplied provider.- Parameters:
encodedPkcs8- PKCS#8-encoded ML-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.- Parameters:
spec- the private key specification to serialize- Returns:
- serialized representation
- Throws:
NullPointerException- ifspecisnull
-
unmarshal
Deserializes aMldsaPrivateKeySpecfrom aPairSeq.- 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
-