Skip to content

Commit 019b8e6

Browse files
committed
Fix instance field naming, and use static methods where possible.
1 parent e42af33 commit 019b8e6

File tree

4 files changed

+241
-234
lines changed

4 files changed

+241
-234
lines changed

src/SshNet.Security.Cryptography.Shared/MD5HashProvider.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ internal class MD5HashProvider : HashProviderBase
55
private readonly byte[] _buffer = new byte[4];
66
private int _bufferOffset;
77
private long _byteCount;
8-
private int H1, H2, H3, H4; // IV's
8+
private int _h1, _h2, _h3, _h4; // IV's
99

1010
/// <summary>
1111
/// The word buffer.
@@ -127,10 +127,10 @@ public override byte[] HashFinal()
127127

128128
var output = new byte[16];
129129

130-
UnpackWord(H1, output, 0);
131-
UnpackWord(H2, output, 0 + 4);
132-
UnpackWord(H3, output, 0 + 8);
133-
UnpackWord(H4, output, 0 + 12);
130+
UnpackWord(_h1, output, 0);
131+
UnpackWord(_h2, output, 4);
132+
UnpackWord(_h3, output, 8);
133+
UnpackWord(_h4, output, 12);
134134

135135
Initialize();
136136

@@ -154,10 +154,10 @@ private void InternalInitialize()
154154
_buffer[i] = 0;
155155
}
156156

157-
H1 = unchecked(0x67452301);
158-
H2 = unchecked((int)0xefcdab89);
159-
H3 = unchecked((int)0x98badcfe);
160-
H4 = unchecked(0x10325476);
157+
_h1 = unchecked(0x67452301);
158+
_h2 = unchecked((int)0xefcdab89);
159+
_h3 = unchecked((int)0x98badcfe);
160+
_h4 = unchecked(0x10325476);
161161

162162
_offset = 0;
163163
for (var i = 0; i != _x.Length; i++)
@@ -190,7 +190,7 @@ private void ProcessWord(byte[] input, int inOff)
190190
}
191191
}
192192

193-
private void UnpackWord(int word, byte[] outBytes, int outOff)
193+
private static void UnpackWord(int word, byte[] outBytes, int outOff)
194194
{
195195
outBytes[outOff] = (byte) word;
196196
outBytes[outOff + 1] = (byte) ((uint) word >> 8);
@@ -263,10 +263,10 @@ private static int K(int u, int v, int w)
263263

264264
private void ProcessBlock()
265265
{
266-
var a = H1;
267-
var b = H2;
268-
var c = H3;
269-
var d = H4;
266+
var a = _h1;
267+
var b = _h2;
268+
var c = _h3;
269+
var d = _h4;
270270

271271
//
272272
// Round 1 - F cycle, 16 times.
@@ -348,10 +348,10 @@ private void ProcessBlock()
348348
c = RotateLeft((c + K(d, a, b) + _x[2] + unchecked(0x2ad7d2bb)), S43) + d;
349349
b = RotateLeft((b + K(c, d, a) + _x[9] + unchecked((int)0xeb86d391)), S44) + c;
350350

351-
H1 += a;
352-
H2 += b;
353-
H3 += c;
354-
H4 += d;
351+
_h1 += a;
352+
_h2 += b;
353+
_h3 += c;
354+
_h4 += d;
355355

356356
//
357357
// reset the offset and clean out the word buffer.

0 commit comments

Comments
 (0)