aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/com/trilead/ssh2
diff options
context:
space:
mode:
authorKenny Root <kenny@the-b.org>2015-04-03 06:51:45 +0200
committerKenny Root <kenny@the-b.org>2015-04-03 06:51:45 +0200
commita1c3e4f005ec269281c2ff1f821346b7242cef61 (patch)
tree0d10d051b85d3bf411dcc399ce8f6e4483c911e9 /app/src/main/java/com/trilead/ssh2
parentfa4b418e881d9e418ef10b9dcdad0b09f11f9907 (diff)
parent632e4495715fbc77d129268e91da2cf513580d08 (diff)
downloadconnectbot-a1c3e4f005ec269281c2ff1f821346b7242cef61.tar.gz
connectbot-a1c3e4f005ec269281c2ff1f821346b7242cef61.tar.bz2
connectbot-a1c3e4f005ec269281c2ff1f821346b7242cef61.zip
Merge branch 'master' into gradle-conversion
Diffstat (limited to 'app/src/main/java/com/trilead/ssh2')
-rw-r--r--app/src/main/java/com/trilead/ssh2/transport/KexManager.java30
1 files changed, 24 insertions, 6 deletions
diff --git a/app/src/main/java/com/trilead/ssh2/transport/KexManager.java b/app/src/main/java/com/trilead/ssh2/transport/KexManager.java
index cd26530..2476b76 100644
--- a/app/src/main/java/com/trilead/ssh2/transport/KexManager.java
+++ b/app/src/main/java/com/trilead/ssh2/transport/KexManager.java
@@ -2,6 +2,8 @@
package com.trilead.ssh2.transport;
import java.io.IOException;
+import java.security.KeyFactory;
+import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.interfaces.DSAPublicKey;
import java.security.interfaces.ECPublicKey;
@@ -47,20 +49,36 @@ public class KexManager
{
private static final Logger log = Logger.getLogger(KexManager.class);
+ private static final boolean supportsEc;
+ static {
+ KeyFactory keyFact;
+ try {
+ keyFact = KeyFactory.getInstance("EC");
+ } catch (NoSuchAlgorithmException ignored) {
+ keyFact = null;
+ log.log(10, "Disabling EC support due to lack of KeyFactory");
+ }
+ supportsEc = keyFact != null;
+ }
+
private static final Set<String> HOSTKEY_ALGS = new TreeSet<String>();
static {
- HOSTKEY_ALGS.add("ecdsa-sha2-nistp256");
- HOSTKEY_ALGS.add("ecdsa-sha2-nistp384");
- HOSTKEY_ALGS.add("ecdsa-sha2-nistp521");
+ if (supportsEc) {
+ HOSTKEY_ALGS.add("ecdsa-sha2-nistp256");
+ HOSTKEY_ALGS.add("ecdsa-sha2-nistp384");
+ HOSTKEY_ALGS.add("ecdsa-sha2-nistp521");
+ }
HOSTKEY_ALGS.add("ssh-rsa");
HOSTKEY_ALGS.add("ssh-dsa");
}
private static final Set<String> KEX_ALGS = new TreeSet<String>();
static {
- KEX_ALGS.add("ecdh-sha2-nistp256");
- KEX_ALGS.add("ecdh-sha2-nistp384");
- KEX_ALGS.add("ecdh-sha2-nistp521");
+ if (supportsEc) {
+ KEX_ALGS.add("ecdh-sha2-nistp256");
+ KEX_ALGS.add("ecdh-sha2-nistp384");
+ KEX_ALGS.add("ecdh-sha2-nistp521");
+ }
KEX_ALGS.add("diffie-hellman-group-exchange-sha256");
KEX_ALGS.add("diffie-hellman-group-exchange-sha1");
KEX_ALGS.add("diffie-hellman-group14-sha1");