aboutsummaryrefslogtreecommitdiffstats
path: root/lib/src/main/java/com/trilead/ssh2/crypto/KeyMaterial.java
diff options
context:
space:
mode:
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);