verify method

  1. @override
Future<bool> verify(
  1. List<int> data, {
  2. required Signature signature,
})
override

Verifies the signature.

Implementation

@override
Future<bool> verify(List<int> data, {required Signature signature}) async {
  if (usePlugin) {
    try {
      final rsaSecretKey = signature.publicKey as RsaPublicKey;
      final result = await channel.invokeMethod(
        'rsa_ssa_pkcs1v15_verify',
        {
          'data': Uint8List.fromList(data),
          'hash': hashAlgorithmName,
          'e': Uint8List.fromList(rsaSecretKey.e),
          'n': Uint8List.fromList(rsaSecretKey.n),
        },
      );
      if (result is! Map) {
        throw StateError('Invalid output from plugin: $result');
      }
      return result['result'] as bool;
    } catch (error, stackTrace) {
      usePlugin = false;
      reportError(error, stackTrace);
    }
  }
  return super.verify(data, signature: signature);
}