use of org.bouncycastle.crypto.params.ParametersWithRandom in project XobotOS by xamarin.
the class JDKDSASigner method engineInitSign.
protected void engineInitSign(PrivateKey privateKey) throws InvalidKeyException {
CipherParameters param;
// BEGIN android-removed
// if (privateKey instanceof GOST3410Key)
// {
// param = GOST3410Util.generatePrivateKeyParameter(privateKey);
// }
// else
// {
// END android-removed
param = DSAUtil.generatePrivateKeyParameter(privateKey);
if (random != null) {
param = new ParametersWithRandom(param, random);
}
digest.reset();
signer.init(true, param);
}
use of org.bouncycastle.crypto.params.ParametersWithRandom in project XobotOS by xamarin.
the class RSADigestSigner method init.
/**
* initialise the signer for signing or verification.
*
* @param forSigning
* true if for signing, false otherwise
* @param parameters
* necessary parameters.
*/
public void init(boolean forSigning, CipherParameters parameters) {
this.forSigning = forSigning;
AsymmetricKeyParameter k;
if (parameters instanceof ParametersWithRandom) {
k = (AsymmetricKeyParameter) ((ParametersWithRandom) parameters).getParameters();
} else {
k = (AsymmetricKeyParameter) parameters;
}
if (forSigning && !k.isPrivate()) {
throw new IllegalArgumentException("signing requires private key");
}
if (!forSigning && k.isPrivate()) {
throw new IllegalArgumentException("verification requires public key");
}
reset();
rsaEngine.init(forSigning, parameters);
}
use of org.bouncycastle.crypto.params.ParametersWithRandom in project XobotOS by xamarin.
the class DHBasicAgreement method init.
public void init(CipherParameters param) {
AsymmetricKeyParameter kParam;
if (param instanceof ParametersWithRandom) {
ParametersWithRandom rParam = (ParametersWithRandom) param;
kParam = (AsymmetricKeyParameter) rParam.getParameters();
} else {
kParam = (AsymmetricKeyParameter) param;
}
if (!(kParam instanceof DHPrivateKeyParameters)) {
throw new IllegalArgumentException("DHEngine expects DHPrivateKeyParameters");
}
this.key = (DHPrivateKeyParameters) kParam;
this.dhParams = key.getParameters();
}
use of org.bouncycastle.crypto.params.ParametersWithRandom in project XobotOS by xamarin.
the class RSABlindedEngine method init.
/**
* initialise the RSA engine.
*
* @param forEncryption true if we are encrypting, false otherwise.
* @param param the necessary RSA key parameters.
*/
public void init(boolean forEncryption, CipherParameters param) {
core.init(forEncryption, param);
if (param instanceof ParametersWithRandom) {
ParametersWithRandom rParam = (ParametersWithRandom) param;
key = (RSAKeyParameters) rParam.getParameters();
random = rParam.getRandom();
} else {
key = (RSAKeyParameters) param;
random = new SecureRandom();
}
}
use of org.bouncycastle.crypto.params.ParametersWithRandom in project XobotOS by xamarin.
the class DSASigner method init.
public void init(boolean forSigning, CipherParameters param) {
if (forSigning) {
if (param instanceof ParametersWithRandom) {
ParametersWithRandom rParam = (ParametersWithRandom) param;
this.random = rParam.getRandom();
this.key = (DSAPrivateKeyParameters) rParam.getParameters();
} else {
this.random = new SecureRandom();
this.key = (DSAPrivateKeyParameters) param;
}
} else {
this.key = (DSAPublicKeyParameters) param;
}
}
Aggregations