hierynomus / sshj

ssh, scp and sftp for java
Apache License 2.0
2.5k stars 601 forks source link

EdDSAPublicKeySpec NPE #478

Open solind opened 5 years ago

solind commented 5 years ago

Using the latest SSHJ/master, I ran into the following while connecting to an Ubuntu 18.04 box:

net.schmizz.sshj.transport.TransportException: null
        at net.schmizz.sshj.transport.TransportException$1.chain(TransportException.java:33)
        at net.schmizz.sshj.transport.TransportException$1.chain(TransportException.java:27)
        at net.schmizz.concurrent.Promise.deliverError(Promise.java:95)
        at net.schmizz.concurrent.Event.deliverError(Event.java:74)
        at net.schmizz.concurrent.ErrorDeliveryUtil.alertEvents(ErrorDeliveryUtil.java:34)
        at net.schmizz.sshj.transport.KeyExchanger.notifyError(KeyExchanger.java:392)
        at net.schmizz.sshj.transport.TransportImpl.die(TransportImpl.java:600)
        at net.schmizz.sshj.transport.Reader.run(Reader.java:65)
Caused by: net.schmizz.sshj.common.SSHException: null
        at net.schmizz.sshj.common.SSHException$1.chain(SSHException.java:36)
        at net.schmizz.sshj.common.SSHException$1.chain(SSHException.java:29)
        at net.schmizz.sshj.transport.TransportImpl.die(TransportImpl.java:595)
        at net.schmizz.sshj.transport.Reader.run(Reader.java:65)
Caused by: java.lang.NullPointerException: null
        at net.i2p.crypto.eddsa.spec.EdDSAPublicKeySpec.<init>(EdDSAPublicKeySpec.java:31)
        at net.schmizz.sshj.common.KeyType$6.readPubKeyFromBuffer(KeyType.java:187)
        at net.schmizz.sshj.common.Buffer.readPublicKey(Buffer.java:468)
        at net.schmizz.sshj.transport.kex.AbstractDHG.next(AbstractDHG.java:66)
        at net.schmizz.sshj.transport.KeyExchanger.handle(KeyExchanger.java:364)
        at net.schmizz.sshj.transport.TransportImpl.handle(TransportImpl.java:503)
        at net.schmizz.sshj.transport.Decoder.decodeMte(Decoder.java:159)
        at net.schmizz.sshj.transport.Decoder.decode(Decoder.java:79)
        at net.schmizz.sshj.transport.Decoder.received(Decoder.java:231)
        at net.schmizz.sshj.transport.Reader.run(Reader.java:59)

I'm guessing this means that EsDSAParameterSpec.getCurve().getField() is returning null. Obviously I only get this error when I've added an EdDSASignatureFactory in the configuration.

I don't get this error form my fork, which is relatively stale (from April 2017), even when I do have the EdDSASignatureFactory added to the config.

Any ideas, before I start digging in?

realPyR3X commented 5 years ago

I can confirm this issue. I'm looking into it now as well.

solind commented 5 years ago

It appears that updating to the latest and greatest ed25519 JAR file solves this issue, but it also appears to add a hard dependency on the BouncyCastle provider. I am investigating that now...