init method

  1. @override
void init(
  1. bool forSigning,
  2. CipherParameters params
)
override

Init the signer 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 forSigning to tell the signer if you want to generate or verify signatures.

Implementation

@override
void init(bool forSigning, CipherParameters params) {
  _forSigning = forSigning;

  AsymmetricKeyParameter akparams;
  if (params is ParametersWithRandom) {
    akparams = params.parameters as AsymmetricKeyParameter<AsymmetricKey>;
  } else {
    akparams = params as AsymmetricKeyParameter<AsymmetricKey>;
  }
  var k = akparams.key as RSAAsymmetricKey;

  if (forSigning && (k is! RSAPrivateKey)) {
    throw ArgumentError('Signing requires private key');
  }

  if (!forSigning && (k is! RSAPublicKey)) {
    throw ArgumentError('Verification requires public key');
  }

  reset();

  _rsa.init(forSigning, params);
}