Skip to content

Commit

Permalink
Use System.Security.Cryptography in AesCipher (#1235)
Browse files Browse the repository at this point in the history
* Use System.Security.Cryptography in AesCipher

* don't set the IV - it is unused by ECB

* Dispose ciphers in Session if applicable

---------

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
  • Loading branch information
Rob-Hague and WojciechNagorski authored Nov 16, 2023
1 parent b4c8291 commit 5021f6d
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 783 deletions.
9 changes: 8 additions & 1 deletion src/Renci.SshNet/PrivateKeyFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,14 @@ private static Key ParseOpenSshV1Key(byte[] keyFileData, string passPhrase)
throw new SshException("Cipher '" + cipherName + "' is not supported for an OpenSSH key.");
}

privateKeyBytes = cipher.Decrypt(privateKeyBytes);
try
{
privateKeyBytes = cipher.Decrypt(privateKeyBytes);
}
finally
{
cipher.Dispose();
}
}

// validate private key length
Expand Down
Loading

0 comments on commit 5021f6d

Please sign in to comment.