public final class DetSigDSAParameterSpec
extends java.security.spec.DSAParameterSpec
By default every time when calculating a DSA signature a new random value ("k") is required. In some environments (e.g. embedded systems) the generation of strong secure random numbers might be an extensive task. Especially for such environments RFC 6979 provides an alternative by specifying a deterministic method for calculating the value k.
To enable deterministic signing create an instance of this class and then
call Signature.setParameter(AlgorithmParameterSpec)
:
Signature dsa = Signature.getInstance("SHA256withDSA", IAIK.getInstance()); dsa.setParameter(new DetSigDSAParameterSpec()); dsa.initSign(...); ...When using a raw DSA signature engine ("NONEwithDSA") it is necessary to announce the hash algorithm to be used for calculation of the k value, e.g. (using SHA256):
Signature dsa = Signature.getInstance("NONEwithDSA", IAIK.getInstance()); DetSigDSAParameterSpec paramSpec = new DetSigDSAParameterSpec("SHA256"); dsa.setParameter(paramSpec); dsa.initSign(...); ...The hash algorithm shall be the same as used for calculating the hash from the data to be signed.
References:
[1] T. Pornin, "Deterministic Usage of the Digital Signature Algorithm (DSA) and Elliptic Curve Digital Signature Algorithm (ECDSA)", https://tools.ietf.org/html/rfc6979
Constructor and Description |
---|
DetSigDSAParameterSpec()
Default constructor for enabling deterministic signing.
|
DetSigDSAParameterSpec(AlgorithmID hashAlg)
Creates a new DetSigDSAParameterSpec for enabling deterministic signing
by using the given hash algorithm when calculating the k value.
|
DetSigDSAParameterSpec(java.math.BigInteger p,
java.math.BigInteger q,
java.math.BigInteger g,
boolean enableDeterministic)
Creates a new DSAParameterSpec for deterministic signing with the
specified parameter values.
|
DetSigDSAParameterSpec(java.math.BigInteger p,
java.math.BigInteger q,
java.math.BigInteger g,
boolean enableDeterministic,
AlgorithmID hashAlg)
Creates a new DSAParameterSpec for deterministic signing with the
specified parameter values.
|
DetSigDSAParameterSpec(java.math.BigInteger p,
java.math.BigInteger q,
java.math.BigInteger g,
boolean enableDeterministic,
java.lang.String hashAlg)
Creates a new DSAParameterSpec for deterministic signing with the
specified parameter values.
|
DetSigDSAParameterSpec(boolean enableDeterministic)
Creates a new DetSigDSAParameterSpec for en/disabling deterministic signing.
|
DetSigDSAParameterSpec(boolean enableDeterministic,
AlgorithmID hashAlg)
Creates a new DetSigDSAParameterSpec for en/disabling deterministic signing
by using the given hash algorithm when calculating the k value.
|
DetSigDSAParameterSpec(boolean enableDeterministic,
java.lang.String hashAlg)
Creates a new DetSigDSAParameterSpec for en/disabling deterministic signing
by using the given hash algorithm when calculating the k value.
|
DetSigDSAParameterSpec(java.lang.String hashAlg)
Creates a new DetSigDSAParameterSpec for enabling deterministic signing
by using the given hash algorithm when calculating the k value.
|
public DetSigDSAParameterSpec()
public DetSigDSAParameterSpec(java.lang.String hashAlg)
hashAlg
- the name of the hash algorithm to be usedpublic DetSigDSAParameterSpec(AlgorithmID hashAlg)
hashAlg
- the hash algorithm to be used as AlgorithmIDpublic DetSigDSAParameterSpec(boolean enableDeterministic)
enableDeterministic
- flag indicating whether deterministic signing should be enabledpublic DetSigDSAParameterSpec(boolean enableDeterministic, java.lang.String hashAlg)
enableDeterministic
- flag indicating whether deterministic signing should be enabledhashAlg
- the name of the hash algorithm to be usedpublic DetSigDSAParameterSpec(boolean enableDeterministic, AlgorithmID hashAlg)
enableDeterministic
- flag indicating whether deterministic signing should be enabledhashAlg
- the hash algorithm to be used as AlgorithmIDpublic DetSigDSAParameterSpec(java.math.BigInteger p, java.math.BigInteger q, java.math.BigInteger g, boolean enableDeterministic)
p
- the primeq
- the sub-primeg
- the baseenableDeterministic
- flag indicating whether deterministic signing should be enabledpublic DetSigDSAParameterSpec(java.math.BigInteger p, java.math.BigInteger q, java.math.BigInteger g, boolean enableDeterministic, java.lang.String hashAlg)
p
- the primeq
- the sub-primeg
- the baseenableDeterministic
- flag indicating whether deterministic signing should be enabledhashAlg
- the name of the hash algorithm to be usedpublic DetSigDSAParameterSpec(java.math.BigInteger p, java.math.BigInteger q, java.math.BigInteger g, boolean enableDeterministic, AlgorithmID hashAlg)
p
- the primeq
- the sub-primeg
- the baseenableDeterministic
- flag indicating whether deterministic signing should be enabledhashAlg
- the hash algorithm to be used as AlgorithmID