Hi, Am 10.02.2016 um 09:38 schrieb Vladimir Kvashin:
> - does jsch accept contributions? if yes, I can try fixing this > and propose a patch I asked this question as well in the past and have never received an answer. > - are there any plans to fix it? FWIW, here is a patch, that should fix the issue. The Digester instance in KnownHost is used in a global way and needed quite some synchronization. I changed it to a new instance every time the digester is retrieved, making the synchronization as a whole unnecessary. Cheers, Lothar --------------- snip ### Eclipse Workspace Patch 1.0 #P JSCH_EBD Index: src/main/java/com/jcraft/jsch/KnownHosts.java =================================================================== --- src/main/java/com/jcraft/jsch/KnownHosts.java (revision 24760) +++ src/main/java/com/jcraft/jsch/KnownHosts.java (working copy) @@ -39,7 +39,7 @@ private String known_hosts=null; private java.util.Vector pool=null; - private MAC hmacsha1=null; + private Class hmacsha1_class = null; KnownHosts(JSch jsch){ super(); @@ -482,17 +482,18 @@ return hosts; } - private synchronized MAC getHMACSHA1(){ - if(hmacsha1==null){ + private MAC getHMACSHA1(){ try{ - Class c=Class.forName(jsch.getConfig("hmac-sha1")); - hmacsha1=(MAC)(c.newInstance()); + if (hmacsha1_class == null){ + String hmacsha1_classname = JSch.getConfig("hmac-sha1"); + hmacsha1_class = Class.forName(hmacsha1_classname); + } + return (MAC) hmacsha1_class.newInstance(); } catch(Exception e){ System.err.println("hmacsha1: "+e); } - } - return hmacsha1; + return null; } HostKey createHashedHostKey(String host, byte[]key) throws JSchException { @@ -539,14 +540,12 @@ } MAC macsha1=getHMACSHA1(); try{ - synchronized(macsha1){ macsha1.init(salt); byte[] foo=Util.str2byte(_host); macsha1.update(foo, 0, foo.length); byte[] bar=new byte[macsha1.getBlockSize()]; macsha1.doFinal(bar, 0); return Util.array_equals(hash, bar); - } } catch(Exception e){ System.out.println(e); @@ -570,13 +569,11 @@ } } try{ - synchronized(macsha1){ macsha1.init(salt); byte[] foo=Util.str2byte(host); macsha1.update(foo, 0, foo.length); hash=new byte[macsha1.getBlockSize()]; macsha1.doFinal(hash, 0); - } } catch(Exception e){ } --------------- snip ------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 _______________________________________________ JSch-users mailing list JSch-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jsch-users