use of com.github.zhenwei.core.crypto.params.ParametersWithRandom in project LinLong-Java by zhenwei1108.
the class CramerShoupCoreEngine method init.
/**
* initialise the CramerShoup engine.
*
* @param forEncryption whether this engine should encrypt or decrypt
* @param param the necessary CramerShoup key parameters.
*/
public void init(boolean forEncryption, CipherParameters param) {
SecureRandom providedRandom = null;
if (param instanceof ParametersWithRandom) {
ParametersWithRandom rParam = (ParametersWithRandom) param;
key = (CramerShoupKeyParameters) rParam.getParameters();
providedRandom = rParam.getRandom();
} else {
key = (CramerShoupKeyParameters) param;
}
this.random = initSecureRandom(forEncryption, providedRandom);
this.forEncryption = forEncryption;
}
use of com.github.zhenwei.core.crypto.params.ParametersWithRandom in project LinLong-Java by zhenwei1108.
the class GOST28147WrapEngine method init.
public void init(boolean forWrapping, CipherParameters param) {
if (param instanceof ParametersWithRandom) {
ParametersWithRandom pr = (ParametersWithRandom) param;
param = pr.getParameters();
}
ParametersWithUKM pU = (ParametersWithUKM) param;
cipher.init(forWrapping, pU.getParameters());
mac.init(new ParametersWithIV(pU.getParameters(), pU.getUKM()));
}
use of com.github.zhenwei.core.crypto.params.ParametersWithRandom in project LinLong-Java by zhenwei1108.
the class ECNewRandomnessTransform method init.
/**
* initialise the underlying EC ElGamal engine.
*
* @param param the necessary EC key parameters.
*/
public void init(CipherParameters param) {
if (param instanceof ParametersWithRandom) {
ParametersWithRandom p = (ParametersWithRandom) param;
if (!(p.getParameters() instanceof ECPublicKeyParameters)) {
throw new IllegalArgumentException("ECPublicKeyParameters are required for new randomness transform.");
}
this.key = (ECPublicKeyParameters) p.getParameters();
this.random = p.getRandom();
} else {
if (!(param instanceof ECPublicKeyParameters)) {
throw new IllegalArgumentException("ECPublicKeyParameters are required for new randomness transform.");
}
this.key = (ECPublicKeyParameters) param;
this.random = CryptoServicesRegistrar.getSecureRandom();
}
}
use of com.github.zhenwei.core.crypto.params.ParametersWithRandom in project LinLong-Java by zhenwei1108.
the class ISO9796d1Encoding method init.
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, param);
modulus = kParam.getModulus();
bitSize = modulus.bitLength();
this.forEncryption = forEncryption;
}
use of com.github.zhenwei.core.crypto.params.ParametersWithRandom in project LinLong-Java by zhenwei1108.
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 {
kParam = (AsymmetricKeyParameter) param;
if (!kParam.isPrivate() && forEncryption) {
this.random = CryptoServicesRegistrar.getSecureRandom();
}
}
engine.init(forEncryption, param);
this.forPrivateKey = kParam.isPrivate();
this.forEncryption = forEncryption;
this.blockBuffer = new byte[engine.getOutputBlockSize()];
if (pLen > 0 && fallback == null && random == null) {
throw new IllegalArgumentException("encoder requires random");
}
}
Aggregations