generateAdbKeyPair static method

AsymmetricKeyPair<RSAPublicKey, RSAPrivateKey> generateAdbKeyPair()

Implementation

static AsymmetricKeyPair<RSAPublicKey, RSAPrivateKey> generateAdbKeyPair() {
  final secureRandom = SecureRandom('Fortuna')
    ..seed(KeyParameter(Platform.instance.platformEntropySource().getBytes(32)));
  final keyGen = RSAKeyGenerator();

  keyGen.init(
    ParametersWithRandom(
      RSAKeyGeneratorParameters(BigInt.parse('65537'), KEY_LENGTH_BITS, 64),
      secureRandom,
    ),
  );

  final pair = keyGen.generateKeyPair();
  // Cast the generated key pair into the RSA key types

  final myPublic = pair.publicKey as RSAPublicKey;
  final myPrivate = pair.privateKey as RSAPrivateKey;

  return AsymmetricKeyPair<RSAPublicKey, RSAPrivateKey>(myPublic, myPrivate);
}