use of org.gudy.bouncycastle.crypto.params.ParametersWithRandom in project BiglyBT by BiglySoftware.
the class ECDSASigner method init.
@Override
public void init(boolean forSigning, CipherParameters param) {
if (forSigning) {
if (param instanceof ParametersWithRandom) {
ParametersWithRandom rParam = (ParametersWithRandom) param;
this.random = rParam.getRandom();
this.key = (ECPrivateKeyParameters) rParam.getParameters();
} else {
this.random = new SecureRandom();
this.key = (ECPrivateKeyParameters) param;
}
} else {
this.key = (ECPublicKeyParameters) param;
}
}
use of org.gudy.bouncycastle.crypto.params.ParametersWithRandom in project BiglyBT by BiglySoftware.
the class PaddedBufferedBlockCipher method init.
/**
* initialise the cipher.
*
* @param forEncryption if true the cipher is initialised for
* encryption, if false for decryption.
* @param params the key and other data required by the cipher.
* @exception IllegalArgumentException if the params argument is
* inappropriate.
*/
@Override
public void init(boolean forEncryption, CipherParameters params) throws IllegalArgumentException {
this.forEncryption = forEncryption;
reset();
if (params instanceof ParametersWithRandom) {
ParametersWithRandom p = (ParametersWithRandom) params;
padding.init(p.getRandom());
cipher.init(forEncryption, p.getParameters());
} else {
padding.init(null);
cipher.init(forEncryption, params);
}
}
use of org.gudy.bouncycastle.crypto.params.ParametersWithRandom in project BiglyBT by BiglySoftware.
the class JDKDSASigner method engineInitSign.
@Override
protected void engineInitSign(PrivateKey privateKey) throws InvalidKeyException {
CipherParameters param = null;
if (privateKey instanceof ECKey) {
param = ECUtil.generatePrivateKeyParameter(privateKey);
} else {
param = DSAUtil.generatePrivateKeyParameter(privateKey);
}
digest.reset();
if (random != null) {
signer.init(true, new ParametersWithRandom(param, random));
} else {
signer.init(true, param);
}
}
use of org.gudy.bouncycastle.crypto.params.ParametersWithRandom in project BiglyBT by BiglySoftware.
the class ISO9796d1Encoding method init.
@Override
public void init(boolean forEncryption, CipherParameters param) {
RSAKeyParameters kParam = null;
if (param instanceof ParametersWithRandom) {
ParametersWithRandom rParam = (ParametersWithRandom) param;
kParam = (RSAKeyParameters) rParam.getParameters();
} else {
kParam = (RSAKeyParameters) param;
}
engine.init(forEncryption, kParam);
bitSize = kParam.getModulus().bitLength();
this.forEncryption = forEncryption;
}
use of org.gudy.bouncycastle.crypto.params.ParametersWithRandom in project BiglyBT by BiglySoftware.
the class PKCS1Encoding method init.
@Override
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, kParam);
this.forPrivateKey = kParam.isPrivate();
this.forEncryption = forEncryption;
}
Aggregations