Skip to content

Commit 086ad43

Browse files
author
Pedro Fonseca
committed
Minor fixes
1 parent 5cc5d4a commit 086ad43

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

src/Renci.SshNet/Security/Cryptography/BlockCipher.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public override byte[] Encrypt(byte[] input, int offset, int length)
7676
{
7777
if (length % _blockSize > 0)
7878
{
79-
if (_padding is null)
79+
if (_padding is null)
8080
{
8181
throw new ArgumentException("data");
8282
}
@@ -135,17 +135,18 @@ public override byte[] Decrypt(byte[] input, int offset, int length)
135135
{
136136
if (length % _blockSize > 0)
137137
{
138-
if (_padding is null)
138+
if (_padding is null)
139139
{
140140
throw new ArgumentException("data");
141141
}
142142

143-
input = _padding.Pad(_blockSize, input, offset, length);
144-
offset = 0;
145-
length = input.Length;
143+
input = _padding.Pad(_blockSize, input, offset, length);
144+
offset = 0;
145+
length = input.Length;
146146
}
147147

148148
var output = new byte[length];
149+
149150
var writtenBytes = 0;
150151
for (var i = 0; i < length / _blockSize; i++)
151152
{

src/Renci.SshNet/Security/Cryptography/Ciphers/AesCipher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ public override byte[] Decrypt(byte[] input, int offset, int length)
705705
return _aesCSP.Decrypt(input, offset, length);
706706
}
707707

708-
return base.Encrypt(input, offset, length);
708+
return base.Decrypt(input, offset, length);
709709
}
710710

711711
private uint[] GenerateWorkingKey(bool isEncryption, byte[] key)

src/Renci.SshNet/Security/Cryptography/Ciphers/AesCipherCSP.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
namespace Renci.SshNet.Security.Cryptography.Ciphers
66
{
7-
// allow ECB in this class
8-
#pragma warning disable CA5358
9-
107
/// <summary>
118
/// AES cipher implementation using the accelerated AesCryptoServiceProvider
129
/// This CSP makes use of AES-NI instructions if available (faster, less CPU usage).
@@ -128,7 +125,9 @@ private bool InitCryptoServiceProvider(byte[] key, byte[] iv)
128125
using var aesProvider = CSP.Aes.Create();
129126
aesProvider.BlockSize = _blockSize * 8;
130127
aesProvider.KeySize = key.Length * 8;
128+
#pragma warning disable CA5358 // allow ECB
131129
aesProvider.Mode = _isCTRMode ? CSP.CipherMode.ECB : CSP.CipherMode.CBC; // CTR uses ECB
130+
#pragma warning restore CA5358
132131
aesProvider.Padding = CSP.PaddingMode.None;
133132
aesProvider.Key = key;
134133
aesProvider.IV = iv;

src/Renci.SshNet/Security/Cryptography/Ciphers/CipherMode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public abstract class CipherMode
1717
/// <summary>
1818
/// Gets the IV vector.
1919
/// </summary>
20-
internal byte[] IV {get; private set;}
20+
internal byte[] IV;
2121

2222
/// <summary>
2323
/// Holds block size of the cipher.

0 commit comments

Comments
 (0)