aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenny Root <kenny@the-b.org>2015-04-04 23:09:34 -0700
committerKenny Root <kenny@the-b.org>2015-04-05 16:00:27 -0700
commitc7032050b30cd7e4bbb7323a821cf236d2b64cf1 (patch)
tree8c400eecabe469baecfad32af27c38db64df5641
parent448addf10d132a410b7d280674fef5ed04463ed2 (diff)
downloadconnectbot-c7032050b30cd7e4bbb7323a821cf236d2b64cf1.tar.gz
connectbot-c7032050b30cd7e4bbb7323a821cf236d2b64cf1.tar.bz2
connectbot-c7032050b30cd7e4bbb7323a821cf236d2b64cf1.zip
Keep order for crypto wishlist
Switch from TreeSet to LinkedHashMap since the preference is determined by iterating over the Set for both KEX_ALGS and HOST_KEY_ALGS. The order before was based on string comparisons(!) Change-Id: Ia4573d67f35a5371eb8c70dde631085d61570fe9
-rw-r--r--CHANGELOG.md3
-rw-r--r--src/com/trilead/ssh2/transport/KexManager.java5
2 files changed, 6 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 665105b..895d821 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,3 +3,6 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased][unreleased]
+### Fixed
+- Key exchange and host key algorithm preference order was not being
+ respected.
diff --git a/src/com/trilead/ssh2/transport/KexManager.java b/src/com/trilead/ssh2/transport/KexManager.java
index 2476b76..acf2812 100644
--- a/src/com/trilead/ssh2/transport/KexManager.java
+++ b/src/com/trilead/ssh2/transport/KexManager.java
@@ -8,6 +8,7 @@ import java.security.SecureRandom;
import java.security.interfaces.DSAPublicKey;
import java.security.interfaces.ECPublicKey;
import java.security.interfaces.RSAPublicKey;
+import java.util.LinkedHashSet;
import java.util.Set;
import java.util.TreeSet;
@@ -61,7 +62,7 @@ public class KexManager
supportsEc = keyFact != null;
}
- private static final Set<String> HOSTKEY_ALGS = new TreeSet<String>();
+ private static final Set<String> HOSTKEY_ALGS = new LinkedHashSet<String>();
static {
if (supportsEc) {
HOSTKEY_ALGS.add("ecdsa-sha2-nistp256");
@@ -72,7 +73,7 @@ public class KexManager
HOSTKEY_ALGS.add("ssh-dsa");
}
- private static final Set<String> KEX_ALGS = new TreeSet<String>();
+ private static final Set<String> KEX_ALGS = new LinkedHashSet<String>();
static {
if (supportsEc) {
KEX_ALGS.add("ecdh-sha2-nistp256");