Package org.bouncycastle.crypto.signers
Class HMacDSAKCalculator
java.lang.Object
org.bouncycastle.crypto.signers.HMacDSAKCalculator
- All Implemented Interfaces:
DSAKCalculator
A deterministic K calculator based on the algorithm in section 3.2 of RFC 6979.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidinit(BigInteger n, BigInteger d, byte[] message) Deterministic initialiser.voidinit(BigInteger n, SecureRandom random) Non-deterministic initialiser.protected voidinitAdditionalInput0(HMac hmac0) Supply additional input to HMAC_K(V || 0x00 || int2octets(x) || bits2octets(h1)).protected voidinitAdditionalInput1(HMac hmac1) Supply additional input to HMAC_K(V || 0x01 || int2octets(x) || bits2octets(h1)).booleanReturn true if this calculator is deterministic, false otherwise.nextK()Return the next valid value of K.
-
Constructor Details
-
HMacDSAKCalculator
Base constructor.- Parameters:
digest- digest to build the HMAC on.
-
-
Method Details
-
isDeterministic
public boolean isDeterministic()Description copied from interface:DSAKCalculatorReturn true if this calculator is deterministic, false otherwise.- Specified by:
isDeterministicin interfaceDSAKCalculator- Returns:
- true if deterministic, otherwise false.
-
init
Description copied from interface:DSAKCalculatorNon-deterministic initialiser.- Specified by:
initin interfaceDSAKCalculator- Parameters:
n- the order of the DSA group.random- a source of randomness.
-
init
Description copied from interface:DSAKCalculatorDeterministic initialiser.- Specified by:
initin interfaceDSAKCalculator- Parameters:
n- the order of the DSA group.d- the DSA private value.message- the message being signed.
-
nextK
Description copied from interface:DSAKCalculatorReturn the next valid value of K.- Specified by:
nextKin interfaceDSAKCalculator- Returns:
- a K value.
-
initAdditionalInput0
Supply additional input to HMAC_K(V || 0x00 || int2octets(x) || bits2octets(h1)). RFC 6979 3.6. Additional data may be added to the input of HMAC [..]. A use case may be a protocol that requires a non-deterministic signature algorithm on a system that does not have access to a high-quality random source. It suffices that the additional data [..] is non-repeating (e.g., a signature counter or a monotonic clock) to ensure "random-looking" signatures are indistinguishable, in a cryptographic way, from plain (EC)DSA signatures. By default there is no additional input. Override this method to supply additional input, bearing in mind that this calculator may be used for many signatures.- Parameters:
hmac0- theHMacto which the additional input should be added.
-
initAdditionalInput1
Supply additional input to HMAC_K(V || 0x01 || int2octets(x) || bits2octets(h1)). Refer to comments forinitAdditionalInput0(HMac).- Parameters:
hmac1- theHMacto which the additional input should be added.
-