Skip to content

Commit 79c0f90

Browse files
committed
Modify our DH kex to generate a private component that is twice the size of the hash that a given algorithm produces, with a minimum of 1024 bits.
Fixes issue #304. Avoid using TryParse in diffie-hellman-group1-sha1 and diffie-hellman-group14-sha1. Improve test coverage.
1 parent b5d0762 commit 79c0f90

10 files changed

+185
-61
lines changed
Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,60 @@
11
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using Renci.SshNet.Common;
3+
using Renci.SshNet.Security;
24
using Renci.SshNet.Tests.Common;
35

46
namespace Renci.SshNet.Tests.Classes.Security
57
{
6-
/// <summary>
7-
/// Represents "diffie-hellman-group14-sha1" algorithm implementation.
8-
/// </summary>
98
[TestClass]
109
public class KeyExchangeDiffieHellmanGroup14Sha1Test : TestBase
1110
{
11+
private static readonly byte[] SecondOkleyGroup =
12+
{
13+
0x00,
14+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc9, 0x0f, 0xda, 0xa2,
15+
0x21, 0x68, 0xc2, 0x34, 0xc4, 0xc6, 0x62, 0x8b, 0x80, 0xdc, 0x1c, 0xd1,
16+
0x29, 0x02, 0x4e, 0x08, 0x8a, 0x67, 0xcc, 0x74, 0x02, 0x0b, 0xbe, 0xa6,
17+
0x3b, 0x13, 0x9b, 0x22, 0x51, 0x4a, 0x08, 0x79, 0x8e, 0x34, 0x04, 0xdd,
18+
0xef, 0x95, 0x19, 0xb3, 0xcd, 0x3a, 0x43, 0x1b, 0x30, 0x2b, 0x0a, 0x6d,
19+
0xf2, 0x5f, 0x14, 0x37, 0x4f, 0xe1, 0x35, 0x6d, 0x6d, 0x51, 0xc2, 0x45,
20+
0xe4, 0x85, 0xb5, 0x76, 0x62, 0x5e, 0x7e, 0xc6, 0xf4, 0x4c, 0x42, 0xe9,
21+
0xa6, 0x37, 0xed, 0x6b, 0x0b, 0xff, 0x5c, 0xb6, 0xf4, 0x06, 0xb7, 0xed,
22+
0xee, 0x38, 0x6b, 0xfb, 0x5a, 0x89, 0x9f, 0xa5, 0xae, 0x9f, 0x24, 0x11,
23+
0x7c, 0x4b, 0x1f, 0xe6, 0x49, 0x28, 0x66, 0x51, 0xec, 0xe4, 0x5b, 0x3d,
24+
0xc2, 0x00, 0x7c, 0xb8, 0xa1, 0x63, 0xbf, 0x05, 0x98, 0xda, 0x48, 0x36,
25+
0x1c, 0x55, 0xd3, 0x9a, 0x69, 0x16, 0x3f, 0xa8, 0xfd, 0x24, 0xcf, 0x5f,
26+
0x83, 0x65, 0x5d, 0x23, 0xdc, 0xa3, 0xad, 0x96, 0x1c, 0x62, 0xf3, 0x56,
27+
0x20, 0x85, 0x52, 0xbb, 0x9e, 0xd5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6d,
28+
0x67, 0x0c, 0x35, 0x4e, 0x4a, 0xbc, 0x98, 0x04, 0xf1, 0x74, 0x6c, 0x08,
29+
0xca, 0x18, 0x21, 0x7c, 0x32, 0x90, 0x5e, 0x46, 0x2e, 0x36, 0xce, 0x3b,
30+
0xe3, 0x9e, 0x77, 0x2c, 0x18, 0x0e, 0x86, 0x03, 0x9b, 0x27, 0x83, 0xa2,
31+
0xec, 0x07, 0xa2, 0x8f, 0xb5, 0xc5, 0x5d, 0xf0, 0x6f, 0x4c, 0x52, 0xc9,
32+
0xde, 0x2b, 0xcb, 0xf6, 0x95, 0x58, 0x17, 0x18, 0x39, 0x95, 0x49, 0x7c,
33+
0xea, 0x95, 0x6a, 0xe5, 0x15, 0xd2, 0x26, 0x18, 0x98, 0xfa, 0x05, 0x10,
34+
0x15, 0x72, 0x8e, 0x5a, 0x8a, 0xac, 0xaa, 0x68, 0xff, 0xff, 0xff, 0xff,
35+
0xff, 0xff, 0xff, 0xff
36+
};
37+
38+
private KeyExchangeDiffieHellmanGroup14Sha1 _group14;
39+
40+
protected override void OnInit()
41+
{
42+
base.OnInit();
43+
44+
_group14 = new KeyExchangeDiffieHellmanGroup14Sha1();
45+
}
46+
47+
[TestMethod]
48+
public void GroupPrimeShouldBeSecondOakleyGroup()
49+
{
50+
var bytes = _group14.GroupPrime.ToByteArray().Reverse();
51+
Assert.IsTrue(SecondOkleyGroup.IsEqualTo(bytes));
52+
}
53+
54+
[TestMethod]
55+
public void NameShouldBeDiffieHellmanGroup14Sha1()
56+
{
57+
Assert.AreEqual("diffie-hellman-group14-sha1", _group14.Name);
58+
}
1259
}
1360
}

src/Renci.SshNet.Tests/Classes/Security/KeyExchangeDiffieHellmanGroup1Sha1Test.cs

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,47 @@
55

66
namespace Renci.SshNet.Tests.Classes.Security
77
{
8-
/// <summary>
9-
///This is a test class for KeyExchangeDiffieHellmanGroup1Sha1Test and is intended
10-
///to contain all KeyExchangeDiffieHellmanGroup1Sha1Test Unit Tests
11-
///</summary>
128
[TestClass]
139
public class KeyExchangeDiffieHellmanGroup1Sha1Test : TestBase
1410
{
15-
/// <summary>
16-
///A test for KeyExchangeDiffieHellmanGroup1Sha1 Constructor
17-
///</summary>
18-
[TestMethod]
19-
[Ignore] // placeholder for actual test
20-
public void KeyExchangeDiffieHellmanGroup1Sha1ConstructorTest()
11+
private static readonly byte[] SecondOkleyGroup =
12+
{
13+
0x00,
14+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc9, 0x0f, 0xda, 0xa2,
15+
0x21, 0x68, 0xc2, 0x34, 0xc4, 0xc6, 0x62, 0x8b, 0x80, 0xdc, 0x1c, 0xd1,
16+
0x29, 0x02, 0x4e, 0x08, 0x8a, 0x67, 0xcc, 0x74, 0x02, 0x0b, 0xbe, 0xa6,
17+
0x3b, 0x13, 0x9b, 0x22, 0x51, 0x4a, 0x08, 0x79, 0x8e, 0x34, 0x04, 0xdd,
18+
0xef, 0x95, 0x19, 0xb3, 0xcd, 0x3a, 0x43, 0x1b, 0x30, 0x2b, 0x0a, 0x6d,
19+
0xf2, 0x5f, 0x14, 0x37, 0x4f, 0xe1, 0x35, 0x6d, 0x6d, 0x51, 0xc2, 0x45,
20+
0xe4, 0x85, 0xb5, 0x76, 0x62, 0x5e, 0x7e, 0xc6, 0xf4, 0x4c, 0x42, 0xe9,
21+
0xa6, 0x37, 0xed, 0x6b, 0x0b, 0xff, 0x5c, 0xb6, 0xf4, 0x06, 0xb7, 0xed,
22+
0xee, 0x38, 0x6b, 0xfb, 0x5a, 0x89, 0x9f, 0xa5, 0xae, 0x9f, 0x24, 0x11,
23+
0x7c, 0x4b, 0x1f, 0xe6, 0x49, 0x28, 0x66, 0x51, 0xec, 0xe6, 0x53, 0x81,
24+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
25+
};
26+
27+
private KeyExchangeDiffieHellmanGroup1Sha1 _group1;
28+
29+
protected override void OnInit()
2130
{
22-
KeyExchangeDiffieHellmanGroup1Sha1 target = new KeyExchangeDiffieHellmanGroup1Sha1();
23-
Assert.Inconclusive("TODO: Implement code to verify target");
31+
base.OnInit();
32+
33+
_group1 = new KeyExchangeDiffieHellmanGroup1Sha1();
2434
}
2535

26-
/// <summary>
27-
///A test for GroupPrime
28-
///</summary>
2936
[TestMethod]
30-
[Ignore] // placeholder for actual test
31-
public void GroupPrimeTest()
37+
public void GroupPrimeShouldBeSecondOakleyGroup()
3238
{
33-
KeyExchangeDiffieHellmanGroup1Sha1 target = new KeyExchangeDiffieHellmanGroup1Sha1(); // TODO: Initialize to an appropriate value
34-
BigInteger actual;
35-
actual = target.GroupPrime;
36-
Assert.Inconclusive("Verify the correctness of this test method.");
39+
var bytes = _group1.GroupPrime.ToByteArray().Reverse();
40+
Assert.IsTrue(SecondOkleyGroup.IsEqualTo(bytes));
41+
42+
SecondOkleyGroup.Reverse().DebugPrint();
3743
}
3844

39-
/// <summary>
40-
///A test for Name
41-
///</summary>
4245
[TestMethod]
43-
[Ignore] // placeholder for actual test
44-
public void NameTest()
46+
public void NameShouldBeDiffieHellmanGroup1Sha1()
4547
{
46-
KeyExchangeDiffieHellmanGroup1Sha1 target = new KeyExchangeDiffieHellmanGroup1Sha1(); // TODO: Initialize to an appropriate value
47-
string actual;
48-
actual = target.Name;
49-
Assert.Inconclusive("Verify the correctness of this test method.");
48+
Assert.AreEqual("diffie-hellman-group1-sha1", _group1.Name);
5049
}
5150
}
52-
}
51+
}

src/Renci.SshNet/Renci.SshNet.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
<ItemGroup>
4848
<Reference Include="System" />
4949
<Reference Include="System.Core" />
50+
<Reference Include="System.Numerics" />
5051
<Reference Include="System.Xml" />
5152
</ItemGroup>
5253
<ItemGroup>

src/Renci.SshNet/Security/KeyExchangeDiffieHellman.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Renci.SshNet.Security
88
/// <summary>
99
/// Represents base class for Diffie Hellman key exchange algorithm
1010
/// </summary>
11-
public abstract class KeyExchangeDiffieHellman : KeyExchange
11+
internal abstract class KeyExchangeDiffieHellman : KeyExchange
1212
{
1313
/// <summary>
1414
/// Specifies key exchange group number.
@@ -43,7 +43,7 @@ public abstract class KeyExchangeDiffieHellman : KeyExchange
4343
/// <summary>
4444
/// Specifies random generated number.
4545
/// </summary>
46-
protected BigInteger _randomValue;
46+
protected BigInteger _privateExponent;
4747

4848
/// <summary>
4949
/// Specifies host key data.
@@ -55,6 +55,14 @@ public abstract class KeyExchangeDiffieHellman : KeyExchange
5555
/// </summary>
5656
protected byte[] _signature;
5757

58+
/// <summary>
59+
/// Gets the size, in bits, of the computed hash code.
60+
/// </summary>
61+
/// <value>
62+
/// The size, in bits, of the computed hash code.
63+
/// </value>
64+
protected abstract int HashSize { get; }
65+
5866
/// <summary>
5967
/// Validates the exchange hash.
6068
/// </summary>
@@ -102,14 +110,16 @@ protected void PopulateClientExchangeValue()
102110
if (_prime.IsZero)
103111
throw new ArgumentNullException("_prime");
104112

105-
var bitLength = _prime.BitLength;
113+
// generate private component that is twice the hash size (RFC 4419) with a minimum
114+
// of 1024 bits (whatever is less)
115+
var privateComponentSize = Math.Max(HashSize * 2, 1024);
106116

107117
do
108118
{
109-
_randomValue = BigInteger.Random(bitLength);
110-
111-
_clientExchangeValue = BigInteger.ModPow(_group, _randomValue, _prime);
112-
119+
// create private component
120+
_privateExponent = BigInteger.Random(privateComponentSize);
121+
// generate public component
122+
_clientExchangeValue = BigInteger.ModPow(_group, _privateExponent, _prime);
113123
} while (_clientExchangeValue < 1 || _clientExchangeValue > (_prime - 1));
114124
}
115125

@@ -123,7 +133,7 @@ protected virtual void HandleServerDhReply(byte[] hostKey, BigInteger serverExch
123133
{
124134
_serverExchangeValue = serverExchangeValue;
125135
_hostKey = hostKey;
126-
SharedKey = BigInteger.ModPow(serverExchangeValue, _randomValue, _prime);
136+
SharedKey = BigInteger.ModPow(serverExchangeValue, _privateExponent, _prime);
127137
_signature = signature;
128138
}
129139
}

src/Renci.SshNet/Security/KeyExchangeDiffieHellmanGroup14Sha1.cs

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Renci.SshNet.Common;
2-
using System.Globalization;
32

43
namespace Renci.SshNet.Security
54
{
@@ -8,7 +7,35 @@ namespace Renci.SshNet.Security
87
/// </summary>
98
internal class KeyExchangeDiffieHellmanGroup14Sha1 : KeyExchangeDiffieHellmanGroupSha1
109
{
11-
private const string SecondOkleyGroup = "00FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF";
10+
/// <summary>
11+
/// https://tools.ietf.org/html/rfc2409#section-6.2
12+
/// </summary>
13+
private static readonly byte[] SecondOkleyGroupReversed =
14+
{
15+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x68, 0xaa, 0xac, 0x8a,
16+
0x5a, 0x8e, 0x72, 0x15, 0x10, 0x05, 0xfa, 0x98, 0x18, 0x26, 0xd2, 0x15,
17+
0xe5, 0x6a, 0x95, 0xea, 0x7c, 0x49, 0x95, 0x39, 0x18, 0x17, 0x58, 0x95,
18+
0xf6, 0xcb, 0x2b, 0xde, 0xc9, 0x52, 0x4c, 0x6f, 0xf0, 0x5d, 0xc5, 0xb5,
19+
0x8f, 0xa2, 0x07, 0xec, 0xa2, 0x83, 0x27, 0x9b, 0x03, 0x86, 0x0e, 0x18,
20+
0x2c, 0x77, 0x9e, 0xe3, 0x3b, 0xce, 0x36, 0x2e, 0x46, 0x5e, 0x90, 0x32,
21+
0x7c, 0x21, 0x18, 0xca, 0x08, 0x6c, 0x74, 0xf1, 0x04, 0x98, 0xbc, 0x4a,
22+
0x4e, 0x35, 0x0c, 0x67, 0x6d, 0x96, 0x96, 0x70, 0x07, 0x29, 0xd5, 0x9e,
23+
0xbb, 0x52, 0x85, 0x20, 0x56, 0xf3, 0x62, 0x1c, 0x96, 0xad, 0xa3, 0xdc,
24+
0x23, 0x5d, 0x65, 0x83, 0x5f, 0xcf, 0x24, 0xfd, 0xa8, 0x3f, 0x16, 0x69,
25+
0x9a, 0xd3, 0x55, 0x1c, 0x36, 0x48, 0xda, 0x98, 0x05, 0xbf, 0x63, 0xa1,
26+
0xb8, 0x7c, 0x00, 0xc2, 0x3d, 0x5b, 0xe4, 0xec, 0x51, 0x66, 0x28, 0x49,
27+
0xe6, 0x1f, 0x4b, 0x7c, 0x11, 0x24, 0x9f, 0xae, 0xa5, 0x9f, 0x89, 0x5a,
28+
0xfb, 0x6b, 0x38, 0xee, 0xed, 0xb7, 0x06, 0xf4, 0xb6, 0x5c, 0xff, 0x0b,
29+
0x6b, 0xed, 0x37, 0xa6, 0xe9, 0x42, 0x4c, 0xf4, 0xc6, 0x7e, 0x5e, 0x62,
30+
0x76, 0xb5, 0x85, 0xe4, 0x45, 0xc2, 0x51, 0x6d, 0x6d, 0x35, 0xe1, 0x4f,
31+
0x37, 0x14, 0x5f, 0xf2, 0x6d, 0x0a, 0x2b, 0x30, 0x1b, 0x43, 0x3a, 0xcd,
32+
0xb3, 0x19, 0x95, 0xef, 0xdd, 0x04, 0x34, 0x8e, 0x79, 0x08, 0x4a, 0x51,
33+
0x22, 0x9b, 0x13, 0x3b, 0xa6, 0xbe, 0x0b, 0x02, 0x74, 0xcc, 0x67, 0x8a,
34+
0x08, 0x4e, 0x02, 0x29, 0xd1, 0x1c, 0xdc, 0x80, 0x8b, 0x62, 0xc6, 0xc4,
35+
0x34, 0xc2, 0x68, 0x21, 0xa2, 0xda, 0x0f, 0xc9, 0xff, 0xff, 0xff, 0xff,
36+
0xff, 0xff, 0xff, 0xff,
37+
0x00
38+
};
1239

1340
/// <summary>
1441
/// Gets algorithm name.
@@ -28,10 +55,8 @@ public override BigInteger GroupPrime
2855
{
2956
get
3057
{
31-
BigInteger prime;
32-
BigInteger.TryParse(SecondOkleyGroup, NumberStyles.AllowHexSpecifier, NumberFormatInfo.CurrentInfo, out prime);
33-
return prime;
58+
return new BigInteger(SecondOkleyGroupReversed);
3459
}
3560
}
3661
}
37-
}
62+
}

src/Renci.SshNet/Security/KeyExchangeDiffieHellmanGroup1Sha1.cs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
11
using Renci.SshNet.Common;
2-
using System.Globalization;
32

43
namespace Renci.SshNet.Security
54
{
65
/// <summary>
76
/// Represents "diffie-hellman-group1-sha1" algorithm implementation.
87
/// </summary>
9-
public class KeyExchangeDiffieHellmanGroup1Sha1 : KeyExchangeDiffieHellmanGroupSha1
8+
internal class KeyExchangeDiffieHellmanGroup1Sha1 : KeyExchangeDiffieHellmanGroupSha1
109
{
11-
private const string SecondOkleyGroup = @"00FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF";
10+
private static readonly byte[] SecondOkleyGroupReversed =
11+
{
12+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x81, 0x53, 0xe6, 0xec,
13+
0x51, 0x66, 0x28, 0x49, 0xe6, 0x1f, 0x4b, 0x7c, 0x11, 0x24, 0x9f, 0xae,
14+
0xa5, 0x9f, 0x89, 0x5a, 0xfb, 0x6b, 0x38, 0xee, 0xed, 0xb7, 0x06, 0xf4,
15+
0xb6, 0x5c, 0xff, 0x0b, 0x6b, 0xed, 0x37, 0xa6, 0xe9, 0x42, 0x4c, 0xf4,
16+
0xc6, 0x7e, 0x5e, 0x62, 0x76, 0xb5, 0x85, 0xe4, 0x45, 0xc2, 0x51, 0x6d,
17+
0x6d, 0x35, 0xe1, 0x4f, 0x37, 0x14, 0x5f, 0xf2, 0x6d, 0x0a, 0x2b, 0x30,
18+
0x1b, 0x43, 0x3a, 0xcd, 0xb3, 0x19, 0x95, 0xef, 0xdd, 0x04, 0x34, 0x8e,
19+
0x79, 0x08, 0x4a, 0x51, 0x22, 0x9b, 0x13, 0x3b, 0xa6, 0xbe, 0x0b, 0x02,
20+
0x74, 0xcc, 0x67, 0x8a, 0x08, 0x4e, 0x02, 0x29, 0xd1, 0x1c, 0xdc, 0x80,
21+
0x8b, 0x62, 0xc6, 0xc4, 0x34, 0xc2, 0x68, 0x21, 0xa2, 0xda, 0x0f, 0xc9,
22+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
23+
0x00
24+
};
1225

1326
/// <summary>
1427
/// Gets algorithm name.
@@ -28,9 +41,7 @@ public override BigInteger GroupPrime
2841
{
2942
get
3043
{
31-
BigInteger prime;
32-
BigInteger.TryParse(SecondOkleyGroup, NumberStyles.AllowHexSpecifier, NumberFormatInfo.CurrentInfo, out prime);
33-
return prime;
44+
return new BigInteger(SecondOkleyGroupReversed);
3445
}
3546
}
3647
}

src/Renci.SshNet/Security/KeyExchangeDiffieHellmanGroupExchangeSha1.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/// <summary>
44
/// Represents "diffie-hellman-group-exchange-sha1" algorithm implementation.
55
/// </summary>
6-
public class KeyExchangeDiffieHellmanGroupExchangeSha1 : KeyExchangeDiffieHellmanGroupExchangeShaBase
6+
internal class KeyExchangeDiffieHellmanGroupExchangeSha1 : KeyExchangeDiffieHellmanGroupExchangeShaBase
77
{
88
/// <summary>
99
/// Gets algorithm name.
@@ -12,5 +12,16 @@ public override string Name
1212
{
1313
get { return "diffie-hellman-group-exchange-sha1"; }
1414
}
15+
16+
/// <summary>
17+
/// Gets the size, in bits, of the computed hash code.
18+
/// </summary>
19+
/// <value>
20+
/// The size, in bits, of the computed hash code.
21+
/// </value>
22+
protected override int HashSize
23+
{
24+
get { return 160; }
25+
}
1526
}
1627
}

src/Renci.SshNet/Security/KeyExchangeDiffieHellmanGroupExchangeSha256.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Renci.SshNet.Security
55
/// <summary>
66
/// Represents "diffie-hellman-group-exchange-sha256" algorithm implementation.
77
/// </summary>
8-
public class KeyExchangeDiffieHellmanGroupExchangeSha256 : KeyExchangeDiffieHellmanGroupExchangeShaBase
8+
internal class KeyExchangeDiffieHellmanGroupExchangeSha256 : KeyExchangeDiffieHellmanGroupExchangeShaBase
99
{
1010
/// <summary>
1111
/// Gets algorithm name.
@@ -15,6 +15,17 @@ public override string Name
1515
get { return "diffie-hellman-group-exchange-sha256"; }
1616
}
1717

18+
/// <summary>
19+
/// Gets the size, in bits, of the computed hash code.
20+
/// </summary>
21+
/// <value>
22+
/// The size, in bits, of the computed hash code.
23+
/// </value>
24+
protected override int HashSize
25+
{
26+
get { return 256; }
27+
}
28+
1829
/// <summary>
1930
/// Hashes the specified data bytes.
2031
/// </summary>

src/Renci.SshNet/Security/KeyExchangeDiffieHellmanGroupExchangeShaBase.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
using Renci.SshNet.Messages;
2-
using Renci.SshNet.Messages.Transport;
1+
using Renci.SshNet.Messages.Transport;
32

43
namespace Renci.SshNet.Security
54
{
65
/// <summary>
76
/// Base class for "diffie-hellman-group-exchange" algorithms.
87
/// </summary>
9-
public abstract class KeyExchangeDiffieHellmanGroupExchangeShaBase : KeyExchangeDiffieHellman
8+
internal abstract class KeyExchangeDiffieHellmanGroupExchangeShaBase : KeyExchangeDiffieHellman
109
{
1110
private const int MinimumGroupSize = 1024;
1211
private const int PreferredGroupSize = 1024;

0 commit comments

Comments
 (0)