# HG changeset patch # User Carl Byington # Date 1405738328 25200 # Node ID db9b028016de05242611fe24ecaa83fc25c98617 # Parent 4656869af8fec42ae4af420b4269aee516e8c51b start conversion from trilead to ganymed diff -r 4656869af8fe -r db9b028016de src/ch/ethz/ssh2/Connection.java --- a/src/ch/ethz/ssh2/Connection.java Fri Jul 18 19:26:29 2014 -0700 +++ b/src/ch/ethz/ssh2/Connection.java Fri Jul 18 19:52:08 2014 -0700 @@ -13,6 +13,8 @@ import java.net.Socket; import java.net.SocketTimeoutException; import java.security.SecureRandom; +import java.security.KeyPair; +import java.security.PrivateKey; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -638,6 +640,22 @@ } /** + * Controls whether compression is used on the link or not. + *

+ * Note: This can only be called before connect() + * @param enabled whether to enable compression + * @throws IOException + */ + + public synchronized void setCompression(boolean enabled) throws IOException { + if (tm != null) + throw new IOException("Connection to " + hostname + " is already in connected state!"); + + if (enabled) enableCompression(); + else disableCompression(); + } + + /** * Close the connection to the SSH-2 server. All assigned sessions will be * closed, too. Can be called at any time. Don't forget to call this once * you don't need a connection anymore - otherwise the receiver thread may diff -r 4656869af8fe -r db9b028016de src/ch/ethz/ssh2/KnownHosts.java --- a/src/ch/ethz/ssh2/KnownHosts.java Fri Jul 18 19:26:29 2014 -0700 +++ b/src/ch/ethz/ssh2/KnownHosts.java Fri Jul 18 19:52:08 2014 -0700 @@ -564,7 +564,7 @@ * @throws IOException if the supplied key blob cannot be parsed or does not match the given hostkey type. */ public int verifyHostkey(String hostname, String serverHostKeyAlgorithm, byte[] serverHostKey) throws IOException { - Object remoteKey; + PublicKey remoteKey; if("ssh-rsa".equals(serverHostKeyAlgorithm)) { remoteKey = RSASHA1Verify.decodeSSHRSAPublicKey(serverHostKey); @@ -572,6 +572,9 @@ else if("ssh-dss".equals(serverHostKeyAlgorithm)) { remoteKey = DSASHA1Verify.decodeSSHDSAPublicKey(serverHostKey); } + else if (serverHostKeyAlgorithm.startsWith("ecdsa-sha2-")) { + remoteKey = ECDSASHA2Verify.decodeSSHECDSAPublicKey(serverHostKey); + } else { throw new IllegalArgumentException("Unknown hostkey type " + serverHostKeyAlgorithm); } diff -r 4656869af8fe -r db9b028016de src/ch/ethz/ssh2/ServerConnection.java --- a/src/ch/ethz/ssh2/ServerConnection.java Fri Jul 18 19:26:29 2014 -0700 +++ b/src/ch/ethz/ssh2/ServerConnection.java Fri Jul 18 19:52:08 2014 -0700 @@ -72,7 +72,7 @@ * @param dsa_key The DSA hostkey, may be NULL * @param rsa_key The RSA hostkey, may be NULL */ - public ServerConnection(Socket s, DSAPrivateKey dsa_key, RSAPrivateKey rsa_key) + public ServerConnection(Socket s, KeyPair dsa_key, KeyPair rsa_key) { state.s = s; state.softwareversion = softwareversion; @@ -208,7 +208,7 @@ * * @param dsa_hostkey */ - public synchronized void setDsaHostKey(DSAPrivateKey dsa_hostkey) + public synchronized void setDsaHostKey(KeyPair dsa_hostkey) { synchronized (state) { @@ -230,7 +230,7 @@ * * @param rsa_hostkey */ - public synchronized void setRsaHostKey(RSAPrivateKey rsa_hostkey) + public synchronized void setRsaHostKey(KeyPair rsa_hostkey) { synchronized (state) { @@ -252,7 +252,7 @@ */ public void setPEMHostKey(char[] pemdata, String password) throws IOException { - Object key = PEMDecoder.decode(pemdata, password); + PrivateKey key = PEMDecoder.decode(pemdata, password).getPrivate(); if (key instanceof DSAPrivateKey) setDsaHostKey((DSAPrivateKey) key); diff -r 4656869af8fe -r db9b028016de src/ch/ethz/ssh2/Session.java --- a/src/ch/ethz/ssh2/Session.java Fri Jul 18 19:26:29 2014 -0700 +++ b/src/ch/ethz/ssh2/Session.java Fri Jul 18 19:52:08 2014 -0700 @@ -336,6 +336,26 @@ cm.requestSubSystem(cn, name); } + /** + * Request authentication agent forwarding. + * @param agent object that implements the callbacks + * + * @throws IOException in case of any problem or when the session is closed + */ + + public synchronized boolean requestAuthAgentForwarding(AuthAgentCallback agent) throws IOException { + synchronized (this) { + /* + * The following is just a nicer error, we would catch it anyway + * later in the channel code + */ + if (flag_closed) + throw new IOException("This session is closed."); + } + + return cm.requestChannelAgentForwarding(cn, agent); + } + public int getState() { return cn.getState(); diff -r 4656869af8fe -r db9b028016de src/ch/ethz/ssh2/signature/RSASHA1Verify.java --- a/src/ch/ethz/ssh2/signature/RSASHA1Verify.java Fri Jul 18 19:26:29 2014 -0700 +++ b/src/ch/ethz/ssh2/signature/RSASHA1Verify.java Fri Jul 18 19:52:08 2014 -0700 @@ -84,7 +84,7 @@ throw new IOException("Error in RSA signature, S is empty."); if (log.isEnabled()) { - log.info(80, "Decoding ssh-rsa signature string (length: " + s.length + ")"); + log.info("Decoding ssh-rsa signature string (length: " + s.length + ")"); } if (tr.remain() != 0) diff -r 4656869af8fe -r db9b028016de src/ch/ethz/ssh2/transport/ClientKexManager.java --- a/src/ch/ethz/ssh2/transport/ClientKexManager.java Fri Jul 18 19:26:29 2014 -0700 +++ b/src/ch/ethz/ssh2/transport/ClientKexManager.java Fri Jul 18 19:52:08 2014 -0700 @@ -58,7 +58,7 @@ if (kxs.np.server_host_key_algo.startsWith("ecdsa-sha2-")) { byte[] rs = ECDSASHA2Verify.decodeSSHECDSASignature(sig); ECPublicKey epk = ECDSASHA2Verify.decodeSSHECDSAPublicKey(hostkey); - log.debug(50, "Verifying ecdsa signature"); + log.debug("Verifying ecdsa signature"); return ECDSASHA2Verify.verifySignature(kxs.H, rs, epk); } if (kxs.np.server_host_key_algo.equals("ssh-rsa")) { diff -r 4656869af8fe -r db9b028016de src/ch/ethz/ssh2/transport/ServerKexManager.java --- a/src/ch/ethz/ssh2/transport/ServerKexManager.java Fri Jul 18 19:26:29 2014 -0700 +++ b/src/ch/ethz/ssh2/transport/ServerKexManager.java Fri Jul 18 19:52:08 2014 -0700 @@ -6,7 +6,15 @@ import java.io.IOException; import java.security.DigestException; - +import java.security.KeyPair; +import java.security.PublicKey; +import java.security.SecureRandom; +import java.security.interfaces.DSAPrivateKey; +import java.security.interfaces.DSAPublicKey; +import java.security.interfaces.ECPrivateKey; +import java.security.interfaces.ECPublicKey; +import java.security.interfaces.RSAPrivateKey; +import java.security.interfaces.RSAPublicKey; import ch.ethz.ssh2.ConnectionInfo; import ch.ethz.ssh2.PacketTypeException; import ch.ethz.ssh2.auth.ServerAuthenticationManager;