Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use hardware-accelerated AES CryptoServiceProvider #865

Merged
merged 25 commits into from
Nov 28, 2023
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
af5b858
Add FEATURE_AES_CSP to use hardware-accelerated AesCryptoServiceProvider
Aug 29, 2021
9622631
Restructure, move most of the feature code to AesCipher.cs
Aug 30, 2021
75fa982
Fix the AES Padding
Aug 30, 2021
5cc5d4a
fix rebase issues
Nov 1, 2023
086ad43
Minor fixes
Nov 1, 2023
a9f68fb
Merge branch 'develop' into feature_AES_CSP
zybexXL Nov 5, 2023
39db35b
Rework based on suggestions
Nov 6, 2023
63bfc76
Move all changes to AesCypher.cs, as per Rob-Hague suggestion
Nov 7, 2023
5ef1df6
update AesCipherTest.cs generator
Nov 7, 2023
ac2c36d
Fix continuous session encrypt/decrypt
Nov 9, 2023
ada6ccb
Reduce CTR memory usage in Net 6+
Nov 10, 2023
799a5c5
Factor out the implementations and re-add the existing constructor
Rob-Hague Nov 12, 2023
0a9be47
Merge branch 'develop' into feature_AES_CSP
zybexXL Nov 12, 2023
0d5ecd9
Merge branch 'sshnet:develop' into feature_AES_CSP
zybexXL Nov 13, 2023
36cea67
remove ctor; revert tests; remove unused _iv member
Rob-Hague Nov 13, 2023
d53c12c
Merge pull request #1 from Rob-Hague/feature_AES_CSP
zybexXL Nov 20, 2023
2a11508
Merge branch 'develop' into feature_AES_CSP
zybexXL Nov 20, 2023
84df6e4
Reorder Encryption cipher preference list
Nov 20, 2023
c056fbc
Remove redundant AES tests
Nov 20, 2023
1902ed7
Refactor ArrayXOR()
Nov 20, 2023
d34f521
Merge branch 'develop' into feature_AES_CSP
zybexXL Nov 20, 2023
6529a63
Add test for IV overflow
Rob-Hague Nov 21, 2023
2cedd26
Performance bump for AES CTR (thanks @robhague)
Nov 21, 2023
15de75e
fix merge conflict
Nov 21, 2023
554c2d6
Move AesCipherMode enum to its own file
Nov 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rework based on suggestions
Pedro Fonseca committed Nov 6, 2023
commit 39db35b96dc0854b1f14fc8145fc4321eac57223
9 changes: 8 additions & 1 deletion src/Renci.SshNet/PrivateKeyFile.cs
Original file line number Diff line number Diff line change
@@ -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
14 changes: 1 addition & 13 deletions src/Renci.SshNet/Security/Cryptography/BlockCipher.cs
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ protected BlockCipher(byte[] key, byte blockSize, CipherMode mode, CipherPadding
_mode = mode;
_padding = padding;

_mode?.Init(this);
_mode?.Init(key, blockSize, padding);
}

/// <summary>
@@ -110,18 +110,6 @@ public override byte[] Encrypt(byte[] input, int offset, int length)
return output;
}

/// <summary>
/// Decrypts the specified data.
/// </summary>
/// <param name="input">The data.</param>
/// <returns>
/// The decrypted data.
/// </returns>
public override byte[] Decrypt(byte[] input)
{
return Decrypt(input, 0, input.Length);
}

/// <summary>
/// Decrypts the specified input.
/// </summary>
7 changes: 5 additions & 2 deletions src/Renci.SshNet/Security/Cryptography/Cipher.cs
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ public abstract class Cipher
/// </summary>
/// <param name="input">The input.</param>
/// <returns>Encrypted data.</returns>
public byte[] Encrypt(byte[] input)
public virtual byte[] Encrypt(byte[] input)
{
return Encrypt(input, 0, input.Length);
}
@@ -41,7 +41,10 @@ public byte[] Encrypt(byte[] input)
/// <returns>
/// The decrypted data.
/// </returns>
public abstract byte[] Decrypt(byte[] input);
public virtual byte[] Decrypt(byte[] input)
{
return Decrypt(input, 0, input.Length);
}

/// <summary>
/// Decrypts the specified input.
831 changes: 28 additions & 803 deletions src/Renci.SshNet/Security/Cryptography/Ciphers/AesCipher.cs

Large diffs are not rendered by default.

240 changes: 0 additions & 240 deletions src/Renci.SshNet/Security/Cryptography/Ciphers/AesCipherCSP.cs

This file was deleted.

Loading