use of org.bouncycastle.crypto.params.ParametersWithRandom in project robovm by robovm.
the class RSACoreEngine 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) {
if (param instanceof ParametersWithRandom) {
ParametersWithRandom rParam = (ParametersWithRandom) param;
key = (RSAKeyParameters) rParam.getParameters();
} else {
key = (RSAKeyParameters) param;
}
this.forEncryption = forEncryption;
}
use of org.bouncycastle.crypto.params.ParametersWithRandom in project robovm by robovm.
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 robovm by robovm.
the class OAEPEncoding method init.
public void init(boolean forEncryption, CipherParameters param) {
if (param instanceof ParametersWithRandom) {
ParametersWithRandom rParam = (ParametersWithRandom) param;
this.random = rParam.getRandom();
} else {
this.random = new SecureRandom();
}
engine.init(forEncryption, param);
this.forEncryption = forEncryption;
}
use of org.bouncycastle.crypto.params.ParametersWithRandom in project robovm by robovm.
the class PKCS1Encoding method init.
public void init(boolean forEncryption, CipherParameters param) {
AsymmetricKeyParameter kParam;
if (param instanceof ParametersWithRandom) {
ParametersWithRandom rParam = (ParametersWithRandom) param;
this.random = rParam.getRandom();
kParam = (AsymmetricKeyParameter) rParam.getParameters();
} else {
this.random = new SecureRandom();
kParam = (AsymmetricKeyParameter) param;
}
engine.init(forEncryption, param);
this.forPrivateKey = kParam.isPrivate();
this.forEncryption = forEncryption;
}
use of org.bouncycastle.crypto.params.ParametersWithRandom in project XobotOS by xamarin.
the class Signature method engineInitSign.
protected void engineInitSign(PrivateKey privateKey, SecureRandom random) throws InvalidKeyException {
CipherParameters param;
if (privateKey instanceof ECKey) {
param = ECUtil.generatePrivateKeyParameter(privateKey);
} else {
throw new InvalidKeyException("can't recognise key type in ECDSA based signer");
}
digest.reset();
if (random != null) {
signer.init(true, new ParametersWithRandom(param, random));
} else {
signer.init(true, param);
}
}
Aggregations