use of com.github.zhenwei.core.crypto.params.RSABlindingParameters in project LinLong-Java by zhenwei1108.
the class PSSSigner method init.
public void init(boolean forSigning, CipherParameters param) {
CipherParameters params;
if (param instanceof ParametersWithRandom) {
ParametersWithRandom p = (ParametersWithRandom) param;
params = p.getParameters();
random = p.getRandom();
} else {
params = param;
if (forSigning) {
random = CryptoServicesRegistrar.getSecureRandom();
}
}
RSAKeyParameters kParam;
if (params instanceof RSABlindingParameters) {
kParam = ((RSABlindingParameters) params).getPublicKey();
// pass on random
cipher.init(forSigning, param);
} else {
kParam = (RSAKeyParameters) params;
cipher.init(forSigning, params);
}
emBits = kParam.getModulus().bitLength() - 1;
if (emBits < (8 * hLen + 8 * sLen + 9)) {
throw new IllegalArgumentException("key too small for specified hash and salt lengths");
}
block = new byte[(emBits + 7) / 8];
reset();
}
use of com.github.zhenwei.core.crypto.params.RSABlindingParameters in project LinLong-Java by zhenwei1108.
the class RSABlindingEngine method init.
/**
* Initialise the blinding engine.
*
* @param forEncryption true if we are encrypting (blinding), false otherwise.
* @param param the necessary RSA key parameters.
*/
public void init(boolean forEncryption, CipherParameters param) {
RSABlindingParameters p;
if (param instanceof ParametersWithRandom) {
ParametersWithRandom rParam = (ParametersWithRandom) param;
p = (RSABlindingParameters) rParam.getParameters();
} else {
p = (RSABlindingParameters) param;
}
core.init(forEncryption, p.getPublicKey());
this.forEncryption = forEncryption;
this.key = p.getPublicKey();
this.blindingFactor = p.getBlindingFactor();
}
Aggregations