Skip to content

Commit 1b1c639

Browse files
authored
Merge branch 'develop' into bcl-ciphermode
2 parents 84df56a + 2f0ae31 commit 1b1c639

File tree

6 files changed

+37
-28
lines changed

6 files changed

+37
-28
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-24.04
1111
steps:
1212
- name: Checkout
13-
uses: actions/checkout@v4
13+
uses: actions/checkout@v5
1414
with:
1515
fetch-depth: 0 # needed for Nerdbank.GitVersioning
1616

@@ -57,7 +57,7 @@ jobs:
5757
runs-on: windows-2025
5858
steps:
5959
- name: Checkout
60-
uses: actions/checkout@v4
60+
uses: actions/checkout@v5
6161
with:
6262
fetch-depth: 0 # needed for Nerdbank.GitVersioning
6363

@@ -108,7 +108,7 @@ jobs:
108108
runs-on: windows-2025
109109
steps:
110110
- name: Checkout
111-
uses: actions/checkout@v4
111+
uses: actions/checkout@v5
112112
with:
113113
fetch-depth: 0 # needed for Nerdbank.GitVersioning
114114

@@ -155,7 +155,7 @@ jobs:
155155
- Linux
156156
steps:
157157
- name: Download NuGet Package
158-
uses: actions/download-artifact@v4
158+
uses: actions/download-artifact@v5
159159
with:
160160
name: NuGet Package
161161

.github/workflows/docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
runs-on: ubuntu-latest
2323
steps:
2424
- name: Checkout repository
25-
uses: actions/checkout@v4
25+
uses: actions/checkout@v5
2626

2727
- name: Setup Pages
2828
uses: actions/configure-pages@v5
@@ -37,7 +37,7 @@ jobs:
3737
run: docfx ./docfx/docfx.json
3838

3939
- name: Upload documentation
40-
uses: actions/upload-pages-artifact@v3
40+
uses: actions/upload-pages-artifact@v4
4141
with:
4242
path: './docfx/_site'
4343

Directory.Packages.props

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44
<CentralPackageVersionOverrideEnabled>false</CentralPackageVersionOverrideEnabled>
55
</PropertyGroup>
66
<ItemGroup>
7-
<PackageVersion Include="BenchmarkDotNet" Version="0.15.2" />
7+
<PackageVersion Include="BenchmarkDotNet" Version="0.15.3" />
88
<PackageVersion Include="BouncyCastle.Cryptography" Version="2.6.2" />
99
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
1010
<PackageVersion Include="coverlet.msbuild" Version="6.0.4" />
1111
<PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1" />
12-
<PackageVersion Include="Meziantou.Analyzer" Version="2.0.210" />
12+
<PackageVersion Include="Meziantou.Analyzer" Version="2.0.220" />
1313
<!-- Should stay on LTS .NET releases. -->
1414
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.3" />
15-
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="9.0.7" />
16-
<PackageVersion Include="MSTest" Version="3.10.0" />
15+
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="9.0.9" />
16+
<PackageVersion Include="MSTest" Version="3.9.3" />
1717
<PackageVersion Include="Moq" Version="4.20.72" />
1818
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.7.115" />
1919
<PackageVersion Include="PolySharp" Version="1.15.0" />
2020
<PackageVersion Include="SonarAnalyzer.CSharp" Version="10.15.0.120848" />
2121
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
2222
<!-- Should stay on LTS .NET releases. -->
2323
<PackageVersion Include="System.Formats.Asn1" Version="8.0.2" />
24-
<PackageVersion Include="Testcontainers" Version="4.6.0" />
24+
<PackageVersion Include="Testcontainers" Version="4.7.0" />
2525
</ItemGroup>
26-
</Project>
26+
</Project>

src/Renci.SshNet/Security/KeyExchange.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Linq;
43
using System.Security.Cryptography;
54

@@ -530,9 +529,7 @@ protected void SendMessage(Message message)
530529
/// </returns>
531530
private byte[] GenerateSessionKey(byte[] sharedKey, byte[] exchangeHash, byte[] key, int size)
532531
{
533-
var result = new List<byte>(key);
534-
535-
while (size > result.Count)
532+
while (key.Length < size)
536533
{
537534
var sessionKeyAdjustment = new SessionKeyAdjustment
538535
{
@@ -541,10 +538,10 @@ private byte[] GenerateSessionKey(byte[] sharedKey, byte[] exchangeHash, byte[]
541538
Key = key,
542539
};
543540

544-
result.AddRange(Hash(sessionKeyAdjustment.GetBytes()));
541+
key = key.Concat(Hash(sessionKeyAdjustment.GetBytes()));
545542
}
546543

547-
return result.ToArray();
544+
return key;
548545
}
549546

550547
/// <summary>

test/Renci.SshNet.IntegrationTests/HmacTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@ public void HmacSha2_512()
4040
DoTest(MessageAuthenticationCodeAlgorithm.HmacSha2_512);
4141
}
4242

43+
[TestMethod]
44+
public void HmacSha2_512_ShortKexOutput()
45+
{
46+
_remoteSshdConfig.ClearMessageAuthenticationCodeAlgorithms()
47+
.AddMessageAuthenticationCodeAlgorithm(MessageAuthenticationCodeAlgorithm.HmacSha2_512)
48+
.ClearKeyExchangeAlgorithms()
49+
.AddKeyExchangeAlgorithm(KeyExchangeAlgorithm.DiffieHellmanGroupExchangeSha1)
50+
.Update()
51+
.Restart();
52+
53+
using (var client = new SshClient(_connectionInfoFactory.Create()))
54+
{
55+
client.Connect();
56+
client.Disconnect();
57+
}
58+
}
4359

4460
[TestMethod]
4561
public void HmacSha1_Etm()

test/Renci.SshNet.IntegrationTests/SshTests.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -527,12 +527,9 @@ public void Ssh_LocalPortForwardingCloseChannels()
527527
{
528528
client.Connect();
529529

530-
var localEndPoint = new IPEndPoint(IPAddress.Loopback, 1225);
531-
532530
for (var i = 0; i < (connectionInfo.MaxSessions + 1); i++)
533531
{
534-
var forwardedPort = new ForwardedPortLocal(localEndPoint.Address.ToString(),
535-
(uint)localEndPoint.Port,
532+
var forwardedPort = new ForwardedPortLocal(IPAddress.Loopback.ToString(),
536533
hostNameAlias,
537534
80);
538535
client.AddForwardedPort(forwardedPort);
@@ -547,7 +544,8 @@ public void Ssh_LocalPortForwardingCloseChannels()
547544

548545
using HttpClient httpClient = new(handler);
549546

550-
using HttpResponseMessage httpResponse = httpClient.GetAsync("http://" + localEndPoint).Result;
547+
using HttpResponseMessage httpResponse = httpClient.GetAsync(
548+
$"http://{forwardedPort.BoundHost}:{forwardedPort.BoundPort}").Result;
551549

552550
Assert.AreEqual(HttpStatusCode.MovedPermanently, httpResponse.StatusCode);
553551
}
@@ -583,10 +581,7 @@ public void Ssh_LocalPortForwarding()
583581
{
584582
client.Connect();
585583

586-
var localEndPoint = new IPEndPoint(IPAddress.Loopback, 1225);
587-
588-
var forwardedPort = new ForwardedPortLocal(localEndPoint.Address.ToString(),
589-
(uint)localEndPoint.Port,
584+
var forwardedPort = new ForwardedPortLocal(IPAddress.Loopback.ToString(),
590585
hostNameAlias,
591586
80);
592587
forwardedPort.Exception +=
@@ -603,7 +598,8 @@ public void Ssh_LocalPortForwarding()
603598

604599
using HttpClient httpClient = new(handler);
605600

606-
using HttpResponseMessage httpResponse = httpClient.GetAsync("http://" + localEndPoint).Result;
601+
using HttpResponseMessage httpResponse = httpClient.GetAsync(
602+
$"http://{forwardedPort.BoundHost}:{forwardedPort.BoundPort}").Result;
607603

608604
Assert.AreEqual(HttpStatusCode.MovedPermanently, httpResponse.StatusCode);
609605
}

0 commit comments

Comments
 (0)