use of org.bouncycastle.crypto.params.DSAPrivateKeyParameters in project robovm by robovm.
the class DSASigner method generateSignature.
/**
* generate a signature for the given message using the key we were
* initialised with. For conventional DSA the message should be a SHA-1
* hash of the message of interest.
*
* @param message the message that will be verified later.
*/
public BigInteger[] generateSignature(byte[] message) {
DSAParameters params = key.getParameters();
BigInteger m = calculateE(params.getQ(), message);
BigInteger k;
int qBitLength = params.getQ().bitLength();
do {
k = new BigInteger(qBitLength, random);
} while (k.compareTo(params.getQ()) >= 0);
BigInteger r = params.getG().modPow(k, params.getP()).mod(params.getQ());
k = k.modInverse(params.getQ()).multiply(m.add(((DSAPrivateKeyParameters) key).getX().multiply(r)));
BigInteger s = k.mod(params.getQ());
BigInteger[] res = new BigInteger[2];
res[0] = r;
res[1] = s;
return res;
}
use of org.bouncycastle.crypto.params.DSAPrivateKeyParameters in project Skein3Fish by wernerd.
the class DSASigner method generateSignature.
/**
* generate a signature for the given message using the key we were
* initialised with. For conventional DSA the message should be a SHA-1
* hash of the message of interest.
*
* @param message the message that will be verified later.
*/
public BigInteger[] generateSignature(byte[] message) {
DSAParameters params = key.getParameters();
BigInteger m = calculateE(params.getQ(), message);
BigInteger k;
int qBitLength = params.getQ().bitLength();
do {
k = new BigInteger(qBitLength, random);
} while (k.compareTo(params.getQ()) >= 0);
BigInteger r = params.getG().modPow(k, params.getP()).mod(params.getQ());
k = k.modInverse(params.getQ()).multiply(m.add(((DSAPrivateKeyParameters) key).getX().multiply(r)));
BigInteger s = k.mod(params.getQ());
BigInteger[] res = new BigInteger[2];
res[0] = r;
res[1] = s;
return res;
}
use of org.bouncycastle.crypto.params.DSAPrivateKeyParameters in project XobotOS by xamarin.
the class DSASigner method generateSignature.
/**
* generate a signature for the given message using the key we were
* initialised with. For conventional DSA the message should be a SHA-1
* hash of the message of interest.
*
* @param message the message that will be verified later.
*/
public BigInteger[] generateSignature(byte[] message) {
DSAParameters params = key.getParameters();
BigInteger m = calculateE(params.getQ(), message);
BigInteger k;
int qBitLength = params.getQ().bitLength();
do {
k = new BigInteger(qBitLength, random);
} while (k.compareTo(params.getQ()) >= 0);
BigInteger r = params.getG().modPow(k, params.getP()).mod(params.getQ());
k = k.modInverse(params.getQ()).multiply(m.add(((DSAPrivateKeyParameters) key).getX().multiply(r)));
BigInteger s = k.mod(params.getQ());
BigInteger[] res = new BigInteger[2];
res[0] = r;
res[1] = s;
return res;
}
Aggregations