public class MLDSA extends SignatureSpi
This class implements the ML-DSA signature algorithm as specified by NIST in FIPS 204.
The standard defines three security levels for MLDSA: 2, 3 and 5, corresponding to MLDSA-44, MLDSA-65 and MLDSA-87.
Furthermore each of these variants has a Hash variant, HashMLDSA-44 for MLDSA44, etc. At the moment only SHA512 is supported.
Use the non-hash variant if the data is hashed beforehand. If the data is not hashed beforehand, both variants are fine. The non-hash (aka. pure) variant is generally preferred.
For signing some message or verifying a signature using MLDSA, generally an application will have to perform three steps:
getInstance
method, e.g.: Signature mldsa = Signature.getInstance("MLDSA");
mldsa.initSign(mldsaPrivateKey);
mldsa.initVerify(mldsaPublicKey);
sign
method returning the
signature as a byte array. Otherwise, if the Signature object has
been initialized for verifying, first the data to be verified
is supplied to the Signature object, and subsequently the signature is
verified by calling the verify
method, supplied with the
byte array holding the corresponding signature:
mldsa.update(data); byte[] signature = mldsa.sign();
mldsa.update(data); System.out.println("Signature " + (mldsa.verify(signature) ? "correct!" : "not correct!"));
appRandom
Constructor and Description |
---|
MLDSA()
The default constructor.
|
Modifier and Type | Method and Description |
---|---|
protected Object |
engineGetParameter(String s)
Not Supported
|
protected AlgorithmParameters |
engineGetParameters()
Not Supported
|
protected void |
engineInitSign(PrivateKey privateKey) |
protected void |
engineInitSign(PrivateKey privateKey,
SecureRandom random) |
protected void |
engineInitVerify(PublicKey publicKey) |
protected void |
engineSetParameter(AlgorithmParameterSpec parameterSpec)
Sets the Signature Instance to the values defined by the
SettingsMLDSAAlgorithmParameterSpec object |
protected void |
engineSetParameter(String param,
Object o)
Not Supported
|
protected byte[] |
engineSign() |
protected void |
engineUpdate(byte b) |
protected void |
engineUpdate(byte[] bytes,
int off,
int len) |
protected boolean |
engineVerify(byte[] sigBytes) |
protected iaik.asn1.structures.AlgorithmID |
getOID() |
clone, engineSign, engineUpdate, engineVerify
public MLDSA()
Signature.getInstance("MLDSA");
to create a new signature object.Signature.getInstance(String)
protected iaik.asn1.structures.AlgorithmID getOID()
protected void engineInitVerify(PublicKey publicKey) throws InvalidKeyException
engineInitVerify
in class SignatureSpi
InvalidKeyException
protected void engineInitSign(PrivateKey privateKey, SecureRandom random) throws InvalidKeyException
engineInitSign
in class SignatureSpi
InvalidKeyException
protected void engineInitSign(PrivateKey privateKey) throws InvalidKeyException
engineInitSign
in class SignatureSpi
InvalidKeyException
protected void engineUpdate(byte b)
engineUpdate
in class SignatureSpi
protected void engineUpdate(byte[] bytes, int off, int len) throws SignatureException
engineUpdate
in class SignatureSpi
SignatureException
protected byte[] engineSign() throws SignatureException
engineSign
in class SignatureSpi
SignatureException
protected boolean engineVerify(byte[] sigBytes) throws SignatureException
engineVerify
in class SignatureSpi
SignatureException
protected void engineSetParameter(String param, Object o) throws InvalidParameterException
engineSetParameter
in class SignatureSpi
InvalidParameterException
protected void engineSetParameter(AlgorithmParameterSpec parameterSpec) throws InvalidAlgorithmParameterException
SettingsMLDSAAlgorithmParameterSpec
objectengineSetParameter
in class SignatureSpi
parameterSpec
- the parameters, has to be an instance of type SettingsMLDSAAlgorithmParameterSpec
InvalidAlgorithmParameterException
- when the AlgorithmParameterSpec is not an instance of
MlDsaAlgorithmParameterSpec, or when the method is called
after initialization.protected Object engineGetParameter(String s) throws InvalidParameterException
engineGetParameter
in class SignatureSpi
InvalidParameterException
protected AlgorithmParameters engineGetParameters()
engineGetParameters
in class SignatureSpi
Copyright © 2020–2025 Stiftung SIC. All rights reserved.