Mercurial > 510Connectbot
comparison src/com/five_ten_sg/connectbot/transport/SSH.java @ 342:175c7d68f3c4
merge ganymed into mainline
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Thu, 31 Jul 2014 16:33:38 -0700 |
parents | 5351641c8a46 |
children |
comparison
equal
deleted
inserted
replaced
272:ce2f4e397703 | 342:175c7d68f3c4 |
---|---|
29 import java.security.NoSuchAlgorithmException; | 29 import java.security.NoSuchAlgorithmException; |
30 import java.security.PrivateKey; | 30 import java.security.PrivateKey; |
31 import java.security.PublicKey; | 31 import java.security.PublicKey; |
32 import java.security.interfaces.DSAPrivateKey; | 32 import java.security.interfaces.DSAPrivateKey; |
33 import java.security.interfaces.DSAPublicKey; | 33 import java.security.interfaces.DSAPublicKey; |
34 import java.security.interfaces.ECPrivateKey; | |
35 import java.security.interfaces.ECPublicKey; | |
34 import java.security.interfaces.RSAPrivateKey; | 36 import java.security.interfaces.RSAPrivateKey; |
35 import java.security.interfaces.RSAPublicKey; | 37 import java.security.interfaces.RSAPublicKey; |
36 import java.security.spec.InvalidKeySpecException; | 38 import java.security.spec.InvalidKeySpecException; |
37 import java.util.Arrays; | 39 import java.util.Arrays; |
38 import java.util.HashMap; | 40 import java.util.HashMap; |
57 import android.content.Context; | 59 import android.content.Context; |
58 import android.net.Uri; | 60 import android.net.Uri; |
59 import android.os.Environment; | 61 import android.os.Environment; |
60 import android.util.Log; | 62 import android.util.Log; |
61 | 63 |
62 import com.trilead.ssh2.AuthAgentCallback; | 64 import ch.ethz.ssh2.AuthAgentCallback; |
63 import com.trilead.ssh2.ChannelCondition; | 65 import ch.ethz.ssh2.ChannelCondition; |
64 import com.trilead.ssh2.Connection; | 66 import ch.ethz.ssh2.Connection; |
65 import com.trilead.ssh2.ConnectionInfo; | 67 import ch.ethz.ssh2.ConnectionInfo; |
66 import com.trilead.ssh2.ConnectionMonitor; | 68 import ch.ethz.ssh2.ConnectionMonitor; |
67 import com.trilead.ssh2.DynamicPortForwarder; | 69 import ch.ethz.ssh2.DynamicPortForwarder; |
68 import com.trilead.ssh2.InteractiveCallback; | 70 import ch.ethz.ssh2.InteractiveCallback; |
69 import com.trilead.ssh2.KnownHosts; | 71 import ch.ethz.ssh2.KnownHosts; |
70 import com.trilead.ssh2.LocalPortForwarder; | 72 import ch.ethz.ssh2.LocalPortForwarder; |
71 import com.trilead.ssh2.SCPClient; | 73 import ch.ethz.ssh2.SCPClient; |
72 import com.trilead.ssh2.ServerHostKeyVerifier; | 74 import ch.ethz.ssh2.ServerHostKeyVerifier; |
73 import com.trilead.ssh2.Session; | 75 import ch.ethz.ssh2.Session; |
74 import com.trilead.ssh2.HTTPProxyData; | 76 import ch.ethz.ssh2.HTTPProxyData; |
75 import com.trilead.ssh2.HTTPProxyException; | 77 import ch.ethz.ssh2.HTTPProxyException; |
76 import com.trilead.ssh2.crypto.PEMDecoder; | 78 import ch.ethz.ssh2.crypto.PEMDecoder; |
77 import com.trilead.ssh2.signature.DSASHA1Verify; | 79 import ch.ethz.ssh2.signature.DSASHA1Verify; |
78 import com.trilead.ssh2.signature.RSASHA1Verify; | 80 import ch.ethz.ssh2.signature.ECDSASHA2Verify; |
81 import ch.ethz.ssh2.signature.RSASHA1Verify; | |
79 | 82 |
80 /** | 83 /** |
81 * @author Kenny Root | 84 * @author Kenny Root |
82 * | 85 * |
83 */ | 86 */ |
142 | 145 |
143 if ("ssh-rsa".equals(serverHostKeyAlgorithm)) | 146 if ("ssh-rsa".equals(serverHostKeyAlgorithm)) |
144 algorithmName = "RSA"; | 147 algorithmName = "RSA"; |
145 else if ("ssh-dss".equals(serverHostKeyAlgorithm)) | 148 else if ("ssh-dss".equals(serverHostKeyAlgorithm)) |
146 algorithmName = "DSA"; | 149 algorithmName = "DSA"; |
147 else if (serverHostKeyAlgorithm.startsWith("ecdsa-")) | 150 else if (serverHostKeyAlgorithm.startsWith("ecdsa-sha2-")) |
148 algorithmName = "EC"; | 151 algorithmName = "EC"; |
149 else | 152 else |
150 algorithmName = serverHostKeyAlgorithm; | 153 algorithmName = serverHostKeyAlgorithm; |
151 | 154 |
152 switch (hosts.verifyHostkey(matchName, serverHostKeyAlgorithm, serverHostKey)) { | 155 switch (hosts.verifyHostkey(matchName, serverHostKeyAlgorithm, serverHostKey)) { |
560 return; | 563 return; |
561 } | 564 } |
562 catch (IOException e) { | 565 catch (IOException e) { |
563 Log.e(TAG, "Problem in SSH connection thread during authentication", e); | 566 Log.e(TAG, "Problem in SSH connection thread during authentication", e); |
564 // Display the reason in the text. | 567 // Display the reason in the text. |
565 bridge.outputLine(e.getCause().getMessage()); | 568 Throwable t = e.getCause(); |
569 String m = (t == null) ? e.getMessage() : t.getMessage(); | |
570 bridge.outputLine(m); | |
566 onDisconnect(); | 571 onDisconnect(); |
567 return; | 572 return; |
568 } | 573 } |
569 | 574 |
570 try { | 575 try { |
1059 pubKeys.put(entry.getKey(), RSASHA1Verify.encodeSSHRSAPublicKey(pubkey)); | 1064 pubKeys.put(entry.getKey(), RSASHA1Verify.encodeSSHRSAPublicKey(pubkey)); |
1060 } | 1065 } |
1061 else if (privKey instanceof DSAPrivateKey) { | 1066 else if (privKey instanceof DSAPrivateKey) { |
1062 DSAPublicKey pubkey = (DSAPublicKey) pair.getPublic(); | 1067 DSAPublicKey pubkey = (DSAPublicKey) pair.getPublic(); |
1063 pubKeys.put(entry.getKey(), DSASHA1Verify.encodeSSHDSAPublicKey(pubkey)); | 1068 pubKeys.put(entry.getKey(), DSASHA1Verify.encodeSSHDSAPublicKey(pubkey)); |
1069 } | |
1070 else if (privKey instanceof ECPrivateKey) { | |
1071 ECPublicKey pubkey = (ECPublicKey) pair.getPublic(); | |
1072 pubKeys.put(entry.getKey(), ECDSASHA2Verify.encodeSSHECDSAPublicKey(pubkey)); | |
1064 } | 1073 } |
1065 else | 1074 else |
1066 continue; | 1075 continue; |
1067 } | 1076 } |
1068 catch (IOException e) { | 1077 catch (IOException e) { |