Mercurial > 510Connectbot
comparison src/ch/ethz/ssh2/KnownHosts.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 | 071eccdff8ea |
children |
comparison
equal
deleted
inserted
replaced
343:df13118e8e79 | 344:b40bc65fa09a |
---|---|
13 import java.io.IOException; | 13 import java.io.IOException; |
14 import java.io.RandomAccessFile; | 14 import java.io.RandomAccessFile; |
15 import java.net.InetAddress; | 15 import java.net.InetAddress; |
16 import java.net.UnknownHostException; | 16 import java.net.UnknownHostException; |
17 import java.security.DigestException; | 17 import java.security.DigestException; |
18 import java.security.SecureRandom; | |
19 import java.util.ArrayList; | 18 import java.util.ArrayList; |
20 import java.util.LinkedList; | 19 import java.util.LinkedList; |
21 import java.util.List; | 20 import java.util.List; |
22 | 21 |
23 import ch.ethz.ssh2.crypto.Base64; | 22 import ch.ethz.ssh2.crypto.Base64; |
23 import ch.ethz.ssh2.crypto.SecureRandomFix; | |
24 import ch.ethz.ssh2.crypto.digest.Digest; | 24 import ch.ethz.ssh2.crypto.digest.Digest; |
25 import ch.ethz.ssh2.crypto.digest.HMAC; | 25 import ch.ethz.ssh2.crypto.digest.HMAC; |
26 import ch.ethz.ssh2.crypto.digest.MD5; | 26 import ch.ethz.ssh2.crypto.digest.MD5; |
27 import ch.ethz.ssh2.crypto.digest.SHA1; | 27 import ch.ethz.ssh2.crypto.digest.SHA1; |
28 | |
28 import java.security.KeyPair; | 29 import java.security.KeyPair; |
29 import java.security.PrivateKey; | 30 import java.security.PrivateKey; |
30 import java.security.PublicKey; | 31 import java.security.PublicKey; |
31 import java.security.interfaces.DSAPublicKey; | 32 import java.security.interfaces.DSAPublicKey; |
32 import java.security.interfaces.ECPublicKey; | 33 import java.security.interfaces.ECPublicKey; |
154 * @return the hashed representation, e.g., "|1|cDhrv7zwEUV3k71CEPHnhHZezhA=|Xo+2y6rUXo2OIWRAYhBOIijbJMA=" | 155 * @return the hashed representation, e.g., "|1|cDhrv7zwEUV3k71CEPHnhHZezhA=|Xo+2y6rUXo2OIWRAYhBOIijbJMA=" |
155 */ | 156 */ |
156 public static String createHashedHostname(String hostname) throws IOException { | 157 public static String createHashedHostname(String hostname) throws IOException { |
157 SHA1 sha1 = new SHA1(); | 158 SHA1 sha1 = new SHA1(); |
158 byte[] salt = new byte[sha1.getDigestLength()]; | 159 byte[] salt = new byte[sha1.getDigestLength()]; |
159 new SecureRandom().nextBytes(salt); | 160 new SecureRandomFix().nextBytes(salt); |
160 byte[] hash; | 161 byte[] hash; |
161 | 162 |
162 try { | 163 try { |
163 hash = hmacSha1Hash(salt, hostname); | 164 hash = hmacSha1Hash(salt, hostname); |
164 } | 165 } |