ssh-parser icon indicating copy to clipboard operation
ssh-parser copied to clipboard

Add support for all Diffie-Hellman Key Exchange protocols.

Open thb-sb opened this issue 1 year ago • 0 comments

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.

thb-sb avatar Mar 19 '24 11:03 thb-sb