From ebec6db1083652b898b1e382712b59fe1e99e5f4 Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Mon, 4 Feb 2013 23:38:41 -0800 Subject: Use RSA CRT keys for speed --- .../com/trilead/ssh2/channel/AuthAgentForwardThread.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/src/main/java/com/trilead/ssh2/channel/AuthAgentForwardThread.java b/lib/src/main/java/com/trilead/ssh2/channel/AuthAgentForwardThread.java index f04c412..c6831e6 100644 --- a/lib/src/main/java/com/trilead/ssh2/channel/AuthAgentForwardThread.java +++ b/lib/src/main/java/com/trilead/ssh2/channel/AuthAgentForwardThread.java @@ -37,7 +37,7 @@ import java.security.spec.ECPrivateKeySpec; import java.security.spec.ECPublicKeySpec; import java.security.spec.InvalidKeySpecException; import java.security.spec.KeySpec; -import java.security.spec.RSAPrivateKeySpec; +import java.security.spec.RSAPrivateCrtKeySpec; import java.security.spec.RSAPublicKeySpec; import java.util.Map; import java.util.Map.Entry; @@ -293,13 +293,17 @@ public class AuthAgentForwardThread extends Thread implements IChannelWorkerThre BigInteger n = tr.readMPINT(); BigInteger e = tr.readMPINT(); BigInteger d = tr.readMPINT(); - tr.readMPINT(); // iqmp - tr.readMPINT(); // p - tr.readMPINT(); // q + BigInteger iqmp = tr.readMPINT(); + BigInteger p = tr.readMPINT(); + BigInteger q = tr.readMPINT(); comment = tr.readString(); + // Derive the extra values Java needs. + BigInteger dmp1 = d.mod(p.subtract(BigInteger.ONE)); + BigInteger dmq1 = d.mod(q.subtract(BigInteger.ONE)); + pubSpec = new RSAPublicKeySpec(n, e); - privSpec = new RSAPrivateKeySpec(n, d); + privSpec = new RSAPrivateCrtKeySpec(n, e, d, p, q, dmp1, dmq1, iqmp); } else if (type.equals("ssh-dss")) { keyType = "DSA"; -- cgit v1.2.3