Replace Curve25519 class with X25519 Key Agreement #838
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request addresses an unresolved issue in the
Curve25519DH
implementation related to the use of Bouncy Castle for Curve25519 Diffie-Hellman Key Agreement as defined in RFC 8731.The existing implementation creates an instance of
ECParameterSpec
but does not use it for key agreement processing. The existing implementation also uses a ported implementation of the Curve25519 algorithm in thedjb.Curve25519
class.This pull request refactors the
Curve25519DH
to use the standard Java CryptographyKeyPairGenerator
andKeyAgreement
interfaces, which are instantiated in the parentDHBase
class using the standardX25519
algorithm identifier.The
KeyPairGenerator
implementation is based on the registered Security Provider, which is Bouncy Castle in normal operation. Java 11 introduced direct support forX25519
, so this implementation approach provides greater flexibility for future versions of SSHJ using the standard Java Cryptography interfaces.Changing to the standard interfaces removes the need for the ported
djb.Curve25519
implementation class, and also removes direct references to Bouncy Castle classes from theCurve25519DH
class. These changes pass existing Key Exchange integration tests, and also include a unit test with basic key generation operations.