aboutsummaryrefslogtreecommitdiffstats
path: root/lib/src/main/java/com/trilead/ssh2/crypto/KeyMaterial.java
diff options
context:
space:
mode:
authorKenny Root <kenny@the-b.org>2013-04-10 18:43:35 -0700
committerKenny Root <kenny@the-b.org>2013-04-10 20:14:43 -0700
commit8e00d2fc37bc277a50c495938cc1ec7ab32aef66 (patch)
treeb821012175ee2a4afb5faa5d16632be4f609301d /lib/src/main/java/com/trilead/ssh2/crypto/KeyMaterial.java
parent1ad1f57886747362abb2e6f7eb91a221369eed35 (diff)
downloadsshlib-8e00d2fc37bc277a50c495938cc1ec7ab32aef66.tar.gz
sshlib-8e00d2fc37bc277a50c495938cc1ec7ab32aef66.tar.bz2
sshlib-8e00d2fc37bc277a50c495938cc1ec7ab32aef66.zip
Add ECDH support
Add support for the ECDH methods required by RFC 5656 ecdh-sha2-nistp256 ecdh-sha2-nistp384 ecdh-sha2-nistp521
Diffstat (limited to 'lib/src/main/java/com/trilead/ssh2/crypto/KeyMaterial.java')
-rw-r--r--lib/src/main/java/com/trilead/ssh2/crypto/KeyMaterial.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/src/main/java/com/trilead/ssh2/crypto/KeyMaterial.java b/lib/src/main/java/com/trilead/ssh2/crypto/KeyMaterial.java
index 5dfb55e..035717d 100644
--- a/lib/src/main/java/com/trilead/ssh2/crypto/KeyMaterial.java
+++ b/lib/src/main/java/com/trilead/ssh2/crypto/KeyMaterial.java
@@ -3,6 +3,8 @@ package com.trilead.ssh2.crypto;
import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
import com.trilead.ssh2.crypto.digest.HashForSSH2Types;
@@ -66,13 +68,18 @@ public class KeyMaterial
return res;
}
- public static KeyMaterial create(String hashType, byte[] H, BigInteger K, byte[] SessionID, int keyLengthCS,
+ public static KeyMaterial create(String hashAlgo, byte[] H, BigInteger K, byte[] SessionID, int keyLengthCS,
int blockSizeCS, int macLengthCS, int keyLengthSC, int blockSizeSC, int macLengthSC)
throws IllegalArgumentException
{
KeyMaterial km = new KeyMaterial();
- HashForSSH2Types sh = new HashForSSH2Types(hashType);
+ HashForSSH2Types sh;
+ try {
+ sh = new HashForSSH2Types(MessageDigest.getInstance(hashAlgo));
+ } catch (NoSuchAlgorithmException e) {
+ throw new IllegalArgumentException(e);
+ }
km.initial_iv_client_to_server = calculateKey(sh, K, H, (byte) 'A', SessionID, blockSizeCS);