Skip to content

Commit

Permalink
Added Kex integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
hierynomus committed Jul 25, 2018
1 parent 02cfeb9 commit c5792fe
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ key exchange::
`diffie-hellman-group14-sha256`, `diffie-hellman-group15-sha512`, `diffie-hellman-group16-sha512`, `diffie-hellman-group17-sha512`, `diffie-hellman-group18-sha512`
`diffie-hellman-group-exchange-sha1`, `diffie-hellman-group-exchange-sha256`,
`ecdh-sha2-nistp256`, `ecdh-sha2-nistp384`, `ecdh-sha2-nistp521`, `[email protected]`

SSHJ also supports the following extended (non official) key exchange algoriths:
`[email protected]`, `diffie-hellman-group15-sha256`, `[email protected]`, `[email protected]`,
`diffie-hellman-group16-sha256`, `[email protected]`, `[email protected]`, `[email protected]`
Expand All @@ -81,7 +82,7 @@ signatures::
`ssh-rsa`, `ssh-dss`, `ecdsa-sha2-nistp256`, `ecdsa-sha2-nistp384`, `ecdsa-sha2-nistp521`, `ssh-ed25519`

mac::
`hmac-md5`, `hmac-md5-96`, `hmac-sha1`, `hmac-sha1-96`, `hmac-sha2-256`, `hmac-sha2-512`, `hmac-ripemd160`
`hmac-md5`, `hmac-md5-96`, `hmac-sha1`, `hmac-sha1-96`, `hmac-sha2-256`, `hmac-sha2-512`, `hmac-ripemd160`, `[email protected]`

compression::
`zlib` and `[email protected]` (delayed zlib)
Expand Down
2 changes: 1 addition & 1 deletion src/itest/docker-image/test-container/sshd_config
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,5 @@ Subsystem sftp /usr/lib/ssh/sftp-server
# PermitTTY no
# ForceCommand cvs server


KexAlgorithms curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha1
macs [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected]
46 changes: 46 additions & 0 deletions src/itest/groovy/com/hierynomus/sshj/transport/kex/KexSpec.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.hierynomus.sshj.transport.kex

import com.hierynomus.sshj.IntegrationBaseSpec
import com.hierynomus.sshj.transport.mac.Macs
import net.schmizz.sshj.DefaultConfig
import net.schmizz.sshj.transport.kex.Curve25519DH
import net.schmizz.sshj.transport.kex.Curve25519SHA256
import net.schmizz.sshj.transport.kex.DH
import net.schmizz.sshj.transport.kex.DHGexSHA1
import net.schmizz.sshj.transport.kex.DHGexSHA256
import net.schmizz.sshj.transport.kex.ECDH
import net.schmizz.sshj.transport.kex.ECDHNistP
import spock.lang.Unroll

class KexSpec extends IntegrationBaseSpec {

@Unroll
def "should correctly connect with #kex Key Exchange"() {
given:
def cfg = new DefaultConfig()
cfg.setKeyExchangeFactories(kexFactory)
def client = getConnectedClient(cfg)

when:
client.authPublickey(USERNAME, KEYFILE)

then:
client.authenticated

where:
kexFactory << [DHGroups.Group1SHA1(),
DHGroups.Group14SHA1(),
DHGroups.Group14SHA256(),
DHGroups.Group16SHA512(),
DHGroups.Group18SHA512(),
new DHGexSHA1.Factory(),
new DHGexSHA256.Factory(),
new Curve25519SHA256.Factory(),
new Curve25519SHA256.FactoryLibSsh(),
new ECDHNistP.Factory256(),
new ECDHNistP.Factory384(),
new ECDHNistP.Factory521()]
kex = kexFactory.name
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

public class Curve25519SHA256 extends AbstractDHG {
/** Named factory for Curve25519SHA256 key exchange */
public static class Factory
public static class FactoryLibSsh
implements net.schmizz.sshj.common.Factory.Named<KeyExchange> {

@Override
Expand All @@ -35,6 +35,21 @@ public String getName() {
}
}

/** Named factory for Curve25519SHA256 key exchange */
public static class Factory
implements net.schmizz.sshj.common.Factory.Named<KeyExchange> {

@Override
public KeyExchange create() {
return new Curve25519SHA256();
}

@Override
public String getName() {
return "curve25519-sha256";
}
}

public Curve25519SHA256() {
super(new Curve25519DH(), new SHA256());
}
Expand Down

0 comments on commit c5792fe

Please sign in to comment.