init method

  1. @override
void init(
  1. bool forEncryption,
  2. covariant AsymmetricKeyParameter<RSAAsymmetricKey> params
)
override

Init the cipher with its initialization params. The type of CipherParameters depends on the algorithm being used (see the documentation of each implementation to find out more).

Use the argument forEncryption to tell the cipher if you want to encrypt or decrypt data.

Implementation

@override
void init(bool forEncryption,
    covariant AsymmetricKeyParameter<RSAAsymmetricKey> params) {
  _forEncryption = forEncryption;
  _key = params.key;

  if (_key is RSAPrivateKey) {
    var privKey = _key as RSAPrivateKey;
    var pSub1 = privKey.p! - BigInt.one;
    var qSub1 = privKey.q! - BigInt.one;
    _dP = privKey.privateExponent!.remainder(pSub1);
    _dQ = privKey.privateExponent!.remainder(qSub1);
    _qInv = privKey.q!.modInverse(privKey.p!);
  }
}