Skip to content

Commit faa0b00

Browse files
authored
Merge branch 'develop' into bcl-ciphermode
2 parents 7eb3126 + 9c454ba commit faa0b00

File tree

52 files changed

+480
-861
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+480
-861
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "docker"
9+
directory: "/test/Renci.SshNet.IntegrationTests/"
10+
schedule:
11+
interval: "weekly"

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ The main types provided by this library are:
8282
## Key Exchange Methods
8383

8484
**SSH.NET** supports the following key exchange methods:
85+
* mlkem768x25519-sha256
86+
* sntrup761x25519-sha512
87+
* sntrup761x25519-sha512<span></span>@openssh.com
8588
* curve25519-sha256
8689
* curve25519-sha256<span></span>@libssh.org
8790
* ecdh-sha2-nistp256

src/Renci.SshNet/AuthenticationMethod.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Renci.SshNet
77
/// <summary>
88
/// Base class for all supported authentication methods.
99
/// </summary>
10-
public abstract class AuthenticationMethod : IAuthenticationMethod
10+
public abstract class AuthenticationMethod : IAuthenticationMethod, IDisposable
1111
{
1212
/// <summary>
1313
/// Gets the name of the authentication method.
@@ -61,5 +61,23 @@ AuthenticationResult IAuthenticationMethod.Authenticate(ISession session)
6161
{
6262
return Authenticate((Session)session);
6363
}
64+
65+
/// <summary>
66+
/// Releases unmanaged and - optionally - managed resources.
67+
/// </summary>
68+
/// <param name="disposing">
69+
/// <see langword="true"/> to release both managed and unmanaged resources;
70+
/// <see langword="false"/> to release only unmanaged resources.
71+
/// </param>
72+
protected virtual void Dispose(bool disposing)
73+
{
74+
}
75+
76+
/// <inheritdoc/>
77+
public void Dispose()
78+
{
79+
Dispose(disposing: true);
80+
GC.SuppressFinalize(this);
81+
}
6482
}
6583
}

src/Renci.SshNet/ConnectionInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ public ConnectionInfo(string host, int port, string username, ProxyTypes proxyTy
349349

350350
KeyExchangeAlgorithms = new Dictionary<string, Func<IKeyExchange>>
351351
{
352+
{ "mlkem768x25519-sha256", () => new KeyExchangeMLKem768X25519Sha256() },
352353
{ "sntrup761x25519-sha512", () => new KeyExchangeSNtruP761X25519Sha512() },
353354
{ "sntrup761x25519-sha512@openssh.com", () => new KeyExchangeSNtruP761X25519Sha512() },
354355
{ "curve25519-sha256", () => new KeyExchangeECCurve25519() },
@@ -407,7 +408,6 @@ public ConnectionInfo(string host, int port, string username, ProxyTypes proxyTy
407408
hostAlgs.Add("rsa-sha2-512", data => { var key = new RsaKey(new SshKeyData(data)); return new KeyHostAlgorithm("rsa-sha2-512", key, new RsaDigitalSignature(key, HashAlgorithmName.SHA512)); });
408409
hostAlgs.Add("rsa-sha2-256", data => { var key = new RsaKey(new SshKeyData(data)); return new KeyHostAlgorithm("rsa-sha2-256", key, new RsaDigitalSignature(key, HashAlgorithmName.SHA256)); });
409410
hostAlgs.Add("ssh-rsa", data => new KeyHostAlgorithm("ssh-rsa", new RsaKey(new SshKeyData(data))));
410-
hostAlgs.Add("ssh-dss", data => new KeyHostAlgorithm("ssh-dss", new DsaKey(new SshKeyData(data))));
411411
#pragma warning restore SA1107 // Code should not contain multiple statements on one line
412412
HostKeyAlgorithms = hostAlgs;
413413

src/Renci.SshNet/ForwardedPortDynamic.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class ForwardedPortDynamic : ForwardedPort
4040
/// <summary>
4141
/// Gets the bound port.
4242
/// </summary>
43-
public uint BoundPort { get; }
43+
public uint BoundPort { get; private set; }
4444

4545
private Socket _listener;
4646
private CountdownEvent _pendingChannelCountdown;
@@ -168,6 +168,9 @@ private void InternalStart()
168168
_listener.Bind(ep);
169169
_listener.Listen(5);
170170

171+
// update bound port (in case original was passed as zero)
172+
BoundPort = (uint)((IPEndPoint)_listener.LocalEndPoint).Port;
173+
171174
Session.ErrorOccured += Session_ErrorOccured;
172175
Session.Disconnected += Session_Disconnected;
173176

src/Renci.SshNet/KeyboardInteractiveAuthenticationMethod.cs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Renci.SshNet
1313
/// <summary>
1414
/// Provides functionality to perform keyboard interactive authentication.
1515
/// </summary>
16-
public class KeyboardInteractiveAuthenticationMethod : AuthenticationMethod, IDisposable
16+
public class KeyboardInteractiveAuthenticationMethod : AuthenticationMethod
1717
{
1818
private readonly RequestMessageKeyboardInteractive _requestMessage;
1919
private AuthenticationResult _authenticationResult = AuthenticationResult.Failure;
@@ -151,20 +151,8 @@ private void Session_UserAuthenticationInformationRequestReceived(object sender,
151151
});
152152
}
153153

154-
/// <summary>
155-
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
156-
/// </summary>
157-
public void Dispose()
158-
{
159-
Dispose(disposing: true);
160-
GC.SuppressFinalize(this);
161-
}
162-
163-
/// <summary>
164-
/// Releases unmanaged and - optionally - managed resources.
165-
/// </summary>
166-
/// <param name="disposing"><see langword="true"/> to release both managed and unmanaged resources; <see langword="false"/> to release only unmanaged resources.</param>
167-
protected virtual void Dispose(bool disposing)
154+
/// <inheritdoc/>
155+
protected override void Dispose(bool disposing)
168156
{
169157
if (_isDisposed)
170158
{
@@ -182,6 +170,8 @@ protected virtual void Dispose(bool disposing)
182170

183171
_isDisposed = true;
184172
}
173+
174+
base.Dispose(disposing);
185175
}
186176
}
187177
}

src/Renci.SshNet/KeyboardInteractiveConnectionInfo.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,9 @@ protected virtual void Dispose(bool disposing)
162162
{
163163
if (AuthenticationMethods != null)
164164
{
165-
foreach (var authenticationMethods in AuthenticationMethods)
165+
foreach (var authenticationMethod in AuthenticationMethods)
166166
{
167-
if (authenticationMethods is IDisposable disposable)
168-
{
169-
disposable.Dispose();
170-
}
167+
authenticationMethod.Dispose();
171168
}
172169
}
173170

src/Renci.SshNet/Messages/Transport/KeyExchangeEcdhInitMessage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Renci.SshNet.Messages.Transport
44
{
55
/// <summary>
6-
/// Represents SSH_MSG_KEXECDH_INIT message.
6+
/// Represents SSH_MSG_KEX_ECDH_INIT message.
77
/// </summary>
88
internal sealed class KeyExchangeEcdhInitMessage : Message, IKeyExchangedAllowed
99
{

src/Renci.SshNet/Messages/Transport/KeyExchangeEcdhReplyMessage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace Renci.SshNet.Messages.Transport
22
{
33
/// <summary>
4-
/// Represents SSH_MSG_KEXECDH_REPLY message.
4+
/// Represents SSH_MSG_KEX_ECDH_REPLY message.
55
/// </summary>
66
public class KeyExchangeEcdhReplyMessage : Message
77
{
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
using System;
2+
3+
namespace Renci.SshNet.Messages.Transport
4+
{
5+
/// <summary>
6+
/// Represents SSH_MSG_KEX_HYBRID_INIT message.
7+
/// </summary>
8+
internal sealed class KeyExchangeHybridInitMessage : Message, IKeyExchangedAllowed
9+
{
10+
/// <inheritdoc />
11+
public override string MessageName
12+
{
13+
get
14+
{
15+
return "SSH_MSG_KEX_HYBRID_INIT";
16+
}
17+
}
18+
19+
/// <inheritdoc />
20+
public override byte MessageNumber
21+
{
22+
get
23+
{
24+
return 30;
25+
}
26+
}
27+
28+
/// <summary>
29+
/// Gets the client init data.
30+
/// </summary>
31+
/// <remarks>
32+
/// The init data is the concatenation of C_PK2 and C_PK1 (C_INIT = C_PK2 || C_PK1, where || depicts concatenation).
33+
/// C_PK1 and C_PK2 represent the ephemeral client public keys used for each key exchange of the PQ/T Hybrid mechanism.
34+
/// Typically, C_PK1 represents a traditional / classical (i.e., ECDH) key exchange public key.
35+
/// C_PK2 represents the 'pk' output of the corresponding post-quantum KEM's 'KeyGen' at the client.
36+
/// </remarks>
37+
public byte[] CInit { get; private set; }
38+
39+
/// <summary>
40+
/// Gets the size of the message in bytes.
41+
/// </summary>
42+
/// <value>
43+
/// The size of the messages in bytes.
44+
/// </value>
45+
protected override int BufferCapacity
46+
{
47+
get
48+
{
49+
var capacity = base.BufferCapacity;
50+
capacity += 4; // CInit length
51+
capacity += CInit.Length; // CInit
52+
return capacity;
53+
}
54+
}
55+
56+
/// <summary>
57+
/// Initializes a new instance of the <see cref="KeyExchangeHybridInitMessage"/> class.
58+
/// </summary>
59+
public KeyExchangeHybridInitMessage(byte[] init)
60+
{
61+
CInit = init;
62+
}
63+
64+
/// <summary>
65+
/// Called when type specific data need to be loaded.
66+
/// </summary>
67+
protected override void LoadData()
68+
{
69+
CInit = ReadBinary();
70+
}
71+
72+
/// <summary>
73+
/// Called when type specific data need to be saved.
74+
/// </summary>
75+
protected override void SaveData()
76+
{
77+
WriteBinaryString(CInit);
78+
}
79+
80+
internal override void Process(Session session)
81+
{
82+
throw new NotImplementedException();
83+
}
84+
}
85+
}

0 commit comments

Comments
 (0)