Top Description Fields Constructors Methods
org.bouncycastle.crypto.signers

public Class HMacDSAKCalculator

extends Object
implements DSAKCalculator
Class Inheritance
All Implemented Interfaces
org.bouncycastle.crypto.signers.DSAKCalculator
Imports
java.math.BigInteger, java.security.SecureRandom, org.bouncycastle.crypto.Digest, org.bouncycastle.crypto.macs.HMac, org.bouncycastle.crypto.params.KeyParameter, org.bouncycastle.util.Arrays, .BigIntegers

A deterministic K calculator based on the algorithm in section 3.2 of RFC 6979.

Field Summary

Modifier and TypeField and Description
private final HMac
private final byte[]
K

private BigInteger
n

private final byte[]
V

private static final BigInteger

Constructor Summary

AccessConstructor and Description
public
HMacDSAKCalculator(Digest
digest to build the HMAC on.
digest
)

Base constructor.

Method Summary

Modifier and TypeMethod and Description
private BigInteger
bitsToInt(byte[] t)

public void
init(BigInteger
the order of the DSA group.
n
,
SecureRandom
a source of randomness.
random
)

Implements org.bouncycastle.crypto.signers.DSAKCalculator.init.

Non-deterministic initialiser.
public void
init(BigInteger
the order of the DSA group.
n
,
BigInteger
the DSA private value.
d
,
byte[]
the message being signed.
message
)

Implements org.bouncycastle.crypto.signers.DSAKCalculator.init.

Deterministic initialiser.
protected void
initAdditionalInput0(HMac
the HMac to which the additional input should be added.
hmac0
)

RFC 6979 3.6.

public boolean
isDeterministic()

Implements org.bouncycastle.crypto.signers.DSAKCalculator.isDeterministic.

Return true if this calculator is deterministic, false otherwise.
public BigInteger
nextK()

Implements org.bouncycastle.crypto.signers.DSAKCalculator.nextK.

Return the next valid value of K.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

hMacback to summary
private final HMac hMac
Kback to summary
private final byte[] K
nback to summary
private BigInteger n
Vback to summary
private final byte[] V
ZEROback to summary
private static final BigInteger ZERO

Constructor Detail

HMacDSAKCalculatorback to summary
public HMacDSAKCalculator(Digest digest)

Base constructor.

Parameters
digest:Digest

digest to build the HMAC on.

Method Detail

bitsToIntback to summary
private BigInteger bitsToInt(byte[] t)
initback to summary
public void init(BigInteger n, SecureRandom random)

Implements org.bouncycastle.crypto.signers.DSAKCalculator.init.

Doc from org.bouncycastle.crypto.signers.DSAKCalculator.init.

Non-deterministic initialiser.

Parameters
n:BigInteger

the order of the DSA group.

random:SecureRandom

a source of randomness.

initback to summary
public void init(BigInteger n, BigInteger d, byte[] message)

Implements org.bouncycastle.crypto.signers.DSAKCalculator.init.

Doc from org.bouncycastle.crypto.signers.DSAKCalculator.init.

Deterministic initialiser.

Parameters
n:BigInteger

the order of the DSA group.

d:BigInteger

the DSA private value.

message:byte[]

the message being signed.

initAdditionalInput0back to summary
protected void initAdditionalInput0(HMac hmac0)

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:HMac

the HMac to which the additional input should be added.

isDeterministicback to summary
public boolean isDeterministic()

Implements org.bouncycastle.crypto.signers.DSAKCalculator.isDeterministic.

Doc from org.bouncycastle.crypto.signers.DSAKCalculator.isDeterministic.

Return true if this calculator is deterministic, false otherwise.

Returns:boolean

true if deterministic, otherwise false.

nextKback to summary
public BigInteger nextK()

Implements org.bouncycastle.crypto.signers.DSAKCalculator.nextK.

Doc from org.bouncycastle.crypto.signers.DSAKCalculator.nextK.

Return the next valid value of K.

Returns:BigInteger

a K value.