Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

X25519 unsupported public key length [46] Error message #957

Closed
Atharva-2157 opened this issue Aug 19, 2024 · 5 comments
Closed

X25519 unsupported public key length [46] Error message #957

Atharva-2157 opened this issue Aug 19, 2024 · 5 comments

Comments

@Atharva-2157
Copy link

I am trying to connect to sftp server using SSHClient.

        SSHClient sshClient = new SSHClient();
        sshClient.addHostKeyVerifier(new PromiscuousVerifier());
        // Connect and authenticate
        sshClient.connect(sftpHost, sftpPort);
        sshClient.authPassword(sftpUser, sftpPass);

But at connect method I am getting this error - X25519 unsupported public key length [46]
I tried to find the solution online but not found any can anyone help me to solve this.

@exceptionfactory
Copy link
Contributor

@Atharva-2157 This error looks like it is coming from the Curve25519DH class as part of the key agreement initialization process.

Some Java Security Provider implementations have slight variations the encoded key handling, which could be an area for improvement in this class.

Can you provide the specific version of Java, and the version of the Bouncy Castle library that results in this particular error?

@Atharva-2157
Copy link
Author

Atharva-2157 commented Aug 19, 2024

Java 11.0.19

Bouncy Castle -

org.bouncycastle bcprov-jdk18on 1.75 org.bouncycastle bcpkix-jdk18on 1.75

sshj -

com.hierynomus
sshj
0.38.0

@exceptionfactory
Copy link
Contributor

Thanks for those details @Atharva-2157, that will be helpful in attempting to reproduce the problem.

@exceptionfactory
Copy link
Contributor

@Atharva-2157 I was able to reproduce the problem on Java 11.

The problem is the result of different behavior in the Java 11 implementation of X25519 public keys, as opposed to Bouncy Castle and more recent Java versions.

I submitted pull request #959 to improve the behavior, making it more compatible across versions and providers.

With the existing version, it seems like the Bouncy Castle Provider is not being registered, and registering it may resolve the issue without code changes.

@hierynomus
Copy link
Owner

Closing this as #959 is merged.

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

No branches or pull requests

3 participants