PointyCastle / pointycastle

Moved into the Bouncy Castle project: https://github.com/bcgit/pc-dart
MIT License
271 stars 75 forks source link

RSA encryption slow decoding #169

Closed 1AlexFix1 closed 5 years ago

1AlexFix1 commented 5 years ago

Hello, on the physical device(iOS), on Android it fast, wild slow work with rsa, decryption with a private key on average 6 seconds, generation of keys with such parameters RSAKeyGeneratorParameters (BigInt.from (65537), 2048, 12); Flutter: start time 42:48 Flutter: time is the end 46:10 which is very long. At the moment there is no possibility to collect the release version, so the question with the release version somehow helps or the problem lies deeper?

Tuple2<RSAPublicKey, RSAPrivateKey> generateKeyPair() {
    var random = Random.secure();
    var key = Uint8List.fromList(List.generate(32, (_) => random.nextInt(255)));
    var secureRandom = FortunaRandom()..seed(KeyParameter(key));
    var rsaParams = RSAKeyGeneratorParameters(BigInt.from(65537), 2048, 12);
    var keyGenerator = RSAKeyGenerator()
      ..init(ParametersWithRandom(rsaParams, secureRandom));
    AsymmetricKeyPair keys = keyGenerator.generateKeyPair();
    return Tuple2(keys.publicKey, keys.privateKey);
  }
Vanethos commented 5 years ago

In my experience, the release version boosted the speed of creating the keys.

Also, using https://api.dartlang.org/stable/2.1.0/dart-isolate/dart-isolate-library.html helped me boosting performance

1AlexFix1 commented 5 years ago

In release build RSA encryption fast