Skip to content

Conversation

ghost
Copy link

@ghost ghost commented Mar 19, 2024

Add support for all Diffie-Hellman Key Exchange protocols.

In the SSH 2.0 protocol, there are roughly three different Diffie-Hellman key exchange protocols:

  • The first one, simply called Diffie-Hellman Key Exchange, defined in RFC4253 § 8
  • The second one that use ECDH, defined in RFC6239 § 4
  • The last one, called Diffie-Hellman Group and Key Exchange, defined in RFC4419 § 3

The Diffie-Hellman key exhange protocol depends on the KEX algorithms that has been negociated
during the Key Exchange Init stage.

This commit adds support for these three Diffie-Hellman key exchange protocols, by implementing
a new API called SshKEX.

To use SshKEX, users must have retrieved the SshPacketKeyExchange
from the client and the server. Then, SshKEX::init is called to initialize
the KEX stage.

Later, depending on the type of the messages that come, SshKEX::parse_ssh_packet
is called to feed the pending KEX stage.

Finally, the various sub-stages specific to each DH key exchange protocols are
exposed through the SshKEX interface.

Tests have been added to ensure that these three protocols are well supported.

If the feature flag integers is enabled, some sub-stages may expose BigInt
instead of the integers in raw format.

No copy or no memory allocation is used here.

@ghost ghost marked this pull request as ready for review March 19, 2024 11:20
@ghost ghost marked this pull request as draft March 19, 2024 13:16
@ghost ghost changed the title Add support for Diffie-Hellman Request, RequestOld and Group. Add support for all Diffie-Hellman Key Exchange protocols. Mar 21, 2024
@ghost ghost marked this pull request as ready for review March 21, 2024 16:24
In the SSH 2.0 protocol, there are roughly three different Diffie-Hellman key exchange protocols:

 - The first one, simply called Diffie-Hellman Key Exchange, defined in [RFC4253 § 8](https://datatracker.ietf.org/doc/html/rfc4253#section-8)
 - The second one that use ECDH, defined in [RFC6239 § 4](https://datatracker.ietf.org/doc/html/rfc6239#section-4)
 - The last one, called Diffie-Hellman Group and Key Exchange, defined in [RFC4419 § 3](https://datatracker.ietf.org/doc/html/rfc4419#section-3)

The Diffie-Hellman key exhange protocol depends on the KEX algorithms that has been negociated
during the _Key Exchange Init_ stage.

This commit adds support for these three Diffie-Hellman key exchange protocols, by implementing
a new API called `SshKEX`.

To use `SshKEX`, users must have retrieved the `SshPacketKeyExchange`
from the client and the server. Then, `SshKEX::init` is called to initialize
the KEX stage.

Later, depending on the type of the messages that come, `SshKEX::parse_ssh_packet`
is called to feed the pending KEX stage.

Finally, the various sub-stages specific to each DH key exchange protocols are
exposed through the `SshKEX` interface.

Tests have been added to ensure that these three protocols are well supported.

If the feature flag `integers` is enabled, some sub-stages may expose `BigInt`
instead of the integers in raw format.

No copy or no memory allocation is used here.
@chifflier chifflier self-assigned this Apr 4, 2024
@ghost ghost closed this by deleting the head repository Oct 7, 2024
@gcsbt
Copy link
Contributor

gcsbt commented Aug 26, 2025

Hello,

The GitHub account of this PR's author was deleted, hence the PR being automatically closed.
Is it possible to re-open this PR (or should I open a new one)? I'm willing to address the reviewers comments ;)

Thanks!

@chifflier
Copy link
Member

Hi,
It seems I cannot reopen, github complains that the repository was deleted.
Can you submit a new PR?
Thanks

@gcsbt
Copy link
Contributor

gcsbt commented Sep 1, 2025

Sure, I submitted #10.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants