diff src/ch/ethz/ssh2/Connection.java @ 344:b40bc65fa09a

compensate for SecureRandom bug on older devices
author Carl Byington <carl@five-ten-sg.com>
date Thu, 31 Jul 2014 18:39:36 -0700
parents cd1d87edcbf6
children 145ec135804f
line wrap: on
line diff
--- a/src/ch/ethz/ssh2/Connection.java	Thu Jul 31 17:30:36 2014 -0700
+++ b/src/ch/ethz/ssh2/Connection.java	Thu Jul 31 18:39:36 2014 -0700
@@ -13,7 +13,6 @@
 import java.net.Socket;
 import java.net.SocketTimeoutException;
 import java.security.KeyPair;
-import java.security.SecureRandom;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
@@ -23,14 +22,15 @@
 import ch.ethz.ssh2.channel.ChannelManager;
 import ch.ethz.ssh2.compression.CompressionFactory;
 import ch.ethz.ssh2.crypto.CryptoWishList;
+import ch.ethz.ssh2.crypto.SecureRandomFix;
 import ch.ethz.ssh2.crypto.cipher.BlockCipherFactory;
 import ch.ethz.ssh2.crypto.digest.MAC;
 import ch.ethz.ssh2.packets.PacketIgnore;
 import ch.ethz.ssh2.transport.ClientTransportManager;
 import ch.ethz.ssh2.transport.HTTPProxyClientTransportManager;
 import ch.ethz.ssh2.transport.KexManager;
+import ch.ethz.ssh2.util.TimeoutService.TimeoutToken;
 import ch.ethz.ssh2.util.TimeoutService;
-import ch.ethz.ssh2.util.TimeoutService.TimeoutToken;
 
 /**
  * A <code>Connection</code> is used to establish an encrypted TCP/IP
@@ -64,7 +64,7 @@
      * Note: SecureRandom.nextBytes() is thread safe.
      */
 
-    private SecureRandom generator;
+    private SecureRandomFix generator;
 
     /**
      * Unless you know what you are doing, you will never need this.
@@ -1162,9 +1162,9 @@
         return false;
     }
 
-    private SecureRandom getOrCreateSecureRND() {
+    private SecureRandomFix getOrCreateSecureRND() {
         if (generator == null) {
-            generator = new SecureRandom();
+            generator = new SecureRandomFix();
         }
 
         return generator;
@@ -1194,7 +1194,7 @@
      */
 
     public synchronized void sendIgnorePacket() throws IOException {
-        SecureRandom rnd = getOrCreateSecureRND();
+        SecureRandomFix rnd = getOrCreateSecureRND();
         byte[] data = new byte[rnd.nextInt(16)];
         rnd.nextBytes(data);
         sendIgnorePacket(data);
@@ -1424,7 +1424,7 @@
      * @param rnd a SecureRandom instance
      */
 
-    public synchronized void setSecureRandom(SecureRandom rnd) {
+    public synchronized void setSecureRandom(SecureRandomFix rnd) {
         if (rnd == null) {
             throw new IllegalArgumentException();
         }