getPrivateKeys method

RsaPrivateKey getPrivateKeys([
  1. String? passphrase
])

Implementation

RsaPrivateKey getPrivateKeys([String? passphrase]) {
  var keyBlob = this.keyBlob;

  if (isEncrypted) {
    if (passphrase == null) {
      throw ArgumentError('passphrase is required for encrypted key');
    }
    final passphraseBytes = Utf8Encoder().convert(passphrase);
    keyBlob = _decryptPrivateKeyBlob(passphraseBytes);
  }

  try {
    return RsaPrivateKey.decode(keyBlob);
  } catch (e) {
    throw SSHKeyDecodeError('Failed to decode private key', e);
  }
}