use of com.squareup.jnagmp.GmpInteger in project universa by UniversaBlockchain.
the class NativeRSACoreEngine 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;
if (key instanceof RSAPrivateCrtKeyParameters) {
isPrivate = true;
//
// we have the extra factors, use the Chinese Remainder Theorem - the author
// wishes to express his thanks to Dirk Bonekaemper at rtsffm.com for
// advice regarding the expression of this.
//
RSAPrivateCrtKeyParameters crtKey = (RSAPrivateCrtKeyParameters) key;
p = new GmpInteger(crtKey.getP());
q = new GmpInteger(crtKey.getQ());
dP = new GmpInteger(crtKey.getDP());
dQ = new GmpInteger(crtKey.getDQ());
qInv = crtKey.getQInv();
exponent = modulus = null;
} else {
isPrivate = false;
exponent = new GmpInteger(key.getExponent());
modulus = new GmpInteger(key.getModulus());
isSmallExponent = exponent.bitLength() < 64;
p = q = dP = dQ = null;
qInv = null;
}
}
Aggregations