aboutsummaryrefslogtreecommitdiffstats
path: root/lib/src/main/java/com/trilead/ssh2/KnownHosts.java
diff options
context:
space:
mode:
authorKenny Root <kenny@the-b.org>2013-02-04 23:38:07 -0800
committerKenny Root <kenny@the-b.org>2013-02-04 23:43:45 -0800
commitadabbacc18acd44182702d74aa7a4eac338fc43d (patch)
tree2e9d0acd72df141e27e79c384ff8ce1f4a66de8b /lib/src/main/java/com/trilead/ssh2/KnownHosts.java
parent4271e2ed172a016e9455f0e43b628a744907ce63 (diff)
downloadsshlib-adabbacc18acd44182702d74aa7a4eac338fc43d.tar.gz
sshlib-adabbacc18acd44182702d74aa7a4eac338fc43d.tar.bz2
sshlib-adabbacc18acd44182702d74aa7a4eac338fc43d.zip
Add ECDSA support
Diffstat (limited to 'lib/src/main/java/com/trilead/ssh2/KnownHosts.java')
-rw-r--r--lib/src/main/java/com/trilead/ssh2/KnownHosts.java19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/src/main/java/com/trilead/ssh2/KnownHosts.java b/lib/src/main/java/com/trilead/ssh2/KnownHosts.java
index c68b852..b88c1b9 100644
--- a/lib/src/main/java/com/trilead/ssh2/KnownHosts.java
+++ b/lib/src/main/java/com/trilead/ssh2/KnownHosts.java
@@ -17,6 +17,7 @@ import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.interfaces.DSAPublicKey;
+import java.security.interfaces.ECPublicKey;
import java.security.interfaces.RSAPublicKey;
import java.util.Iterator;
import java.util.LinkedList;
@@ -28,6 +29,7 @@ import javax.crypto.spec.SecretKeySpec;
import com.trilead.ssh2.crypto.Base64;
import com.trilead.ssh2.signature.DSASHA1Verify;
+import com.trilead.ssh2.signature.ECDSASHA2Verify;
import com.trilead.ssh2.signature.RSASHA1Verify;
@@ -115,6 +117,14 @@ public class KnownHosts
publicKeys.add(new KnownHostsEntry(hostnames, dpk));
}
}
+ else if ("ecdsa-sha2-nistp256".equals(serverHostKeyAlgorithm))
+ {
+ ECPublicKey epk = ECDSASHA2Verify.decodeSSHECDSAPublicKey(serverHostKey);
+
+ synchronized (publicKeys) {
+ publicKeys.add(new KnownHostsEntry(hostnames, epk));
+ }
+ }
else
throw new IOException("Unknwon host key type (" + serverHostKeyAlgorithm + ")");
}
@@ -590,6 +600,10 @@ public class KnownHosts
{
remoteKey = DSASHA1Verify.decodeSSHDSAPublicKey(serverHostKey);
}
+ else if ("ecdsa-sha2-nistp256".equals(serverHostKeyAlgorithm))
+ {
+ remoteKey = ECDSASHA2Verify.decodeSSHECDSAPublicKey(serverHostKey);
+ }
else
throw new IllegalArgumentException("Unknown hostkey type " + serverHostKeyAlgorithm);
@@ -705,7 +719,10 @@ public class KnownHosts
throw new IllegalArgumentException("Unknown hash type " + type);
}
- if ("ssh-rsa".equals(keyType))
+ if ("ecdsa-sha2-nistp256".equals(keyType))
+ {
+ }
+ else if ("ssh-rsa".equals(keyType))
{
}
else if ("ssh-dss".equals(keyType))