Mercurial > 510Connectbot
changeset 287:db9b028016de ganymed
start conversion from trilead to ganymed
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Fri, 18 Jul 2014 19:52:08 -0700 |
parents | 4656869af8fe |
children | 5824a1475be4 |
files | src/ch/ethz/ssh2/Connection.java src/ch/ethz/ssh2/KnownHosts.java src/ch/ethz/ssh2/ServerConnection.java src/ch/ethz/ssh2/Session.java src/ch/ethz/ssh2/signature/RSASHA1Verify.java src/ch/ethz/ssh2/transport/ClientKexManager.java src/ch/ethz/ssh2/transport/ServerKexManager.java |
diffstat | 7 files changed, 57 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- 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. + * <p> + * 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
--- 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); }
--- 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 <code>NULL</code> * @param rsa_key The RSA hostkey, may be <code>NULL</code> */ - 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);
--- 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();
--- 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)
--- 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")) {
--- 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;