use of org.bouncycastle.crypto.AsymmetricCipherKeyPair in project robovm by robovm.
the class ECKeyPairGenerator method generateKeyPair.
/**
* Given the domain parameters this routine generates an EC key
* pair in accordance with X9.62 section 5.2.1 pages 26, 27.
*/
public AsymmetricCipherKeyPair generateKeyPair() {
BigInteger n = params.getN();
int nBitLength = n.bitLength();
BigInteger d;
do {
d = new BigInteger(nBitLength, random);
} while (d.equals(ZERO) || (d.compareTo(n) >= 0));
ECPoint Q = params.getG().multiply(d);
return new AsymmetricCipherKeyPair(new ECPublicKeyParameters(Q, params), new ECPrivateKeyParameters(d, params));
}
use of org.bouncycastle.crypto.AsymmetricCipherKeyPair in project XobotOS by xamarin.
the class DHBasicKeyPairGenerator method generateKeyPair.
public AsymmetricCipherKeyPair generateKeyPair() {
DHKeyGeneratorHelper helper = DHKeyGeneratorHelper.INSTANCE;
DHParameters dhp = param.getParameters();
BigInteger x = helper.calculatePrivate(dhp, param.getRandom());
BigInteger y = helper.calculatePublic(dhp, x);
return new AsymmetricCipherKeyPair(new DHPublicKeyParameters(y, dhp), new DHPrivateKeyParameters(x, dhp));
}
use of org.bouncycastle.crypto.AsymmetricCipherKeyPair in project XobotOS by xamarin.
the class DSAKeyPairGenerator method generateKeyPair.
public AsymmetricCipherKeyPair generateKeyPair() {
DSAParameters dsaParams = param.getParameters();
BigInteger x = generatePrivateKey(dsaParams.getQ(), param.getRandom());
BigInteger y = calculatePublicKey(dsaParams.getP(), dsaParams.getG(), x);
return new AsymmetricCipherKeyPair(new DSAPublicKeyParameters(y, dsaParams), new DSAPrivateKeyParameters(x, dsaParams));
}
use of org.bouncycastle.crypto.AsymmetricCipherKeyPair in project Skein3Fish by wernerd.
the class ECKeyPairGenerator method generateKeyPair.
/**
* Given the domain parameters this routine generates an EC key
* pair in accordance with X9.62 section 5.2.1 pages 26, 27.
*/
public AsymmetricCipherKeyPair generateKeyPair() {
BigInteger n = params.getN();
int nBitLength = n.bitLength();
BigInteger d;
do {
d = new BigInteger(nBitLength, random);
} while (d.equals(ZERO) || (d.compareTo(n) >= 0));
ECPoint Q = params.getG().multiply(d);
return new AsymmetricCipherKeyPair(new ECPublicKeyParameters(Q, params), new ECPrivateKeyParameters(d, params));
}
use of org.bouncycastle.crypto.AsymmetricCipherKeyPair in project robovm by robovm.
the class KeyPairGeneratorSpi method generateKeyPair.
public KeyPair generateKeyPair() {
if (!initialised) {
DSAParametersGenerator pGen = new DSAParametersGenerator();
pGen.init(strength, certainty, random);
param = new DSAKeyGenerationParameters(random, pGen.generateParameters());
engine.init(param);
initialised = true;
}
AsymmetricCipherKeyPair pair = engine.generateKeyPair();
DSAPublicKeyParameters pub = (DSAPublicKeyParameters) pair.getPublic();
DSAPrivateKeyParameters priv = (DSAPrivateKeyParameters) pair.getPrivate();
return new KeyPair(new BCDSAPublicKey(pub), new BCDSAPrivateKey(priv));
}
Aggregations