/[classpath]/classpath/java/security/SecureRandom.java
ViewVC logotype

Diff of /classpath/java/security/SecureRandom.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.14 by tromey, Fri Apr 23 20:34:11 2004 UTC revision 1.14.2.1 by gnu_andrew, Sat Jan 15 17:02:08 2005 UTC
# Line 87  public class SecureRandom extends Random Line 87  public class SecureRandom extends Random
87     */     */
88    public SecureRandom()    public SecureRandom()
89    {    {
90      Provider p[] = Security.getProviders();      Provider[] p = Security.getProviders();
91    
92      //Format of Key: SecureRandom.algname      //Format of Key: SecureRandom.algname
93      String key;      String key;
# Line 112  public class SecureRandom extends Random Line 112  public class SecureRandom extends Random
112                          provider = p[i];                          provider = p[i];
113                          return;                          return;
114                        }                        }
115                      catch (Throwable ignore) { }                      catch (Throwable t)
116                          {
117                            // Ignore.
118                          }
119                    }                    }
120                }                }
121            }            }
# Line 167  public class SecureRandom extends Random Line 170  public class SecureRandom extends Random
170     * @throws NoSuchAlgorithmException If no installed provider implements     * @throws NoSuchAlgorithmException If no installed provider implements
171     *         the given algorithm.     *         the given algorithm.
172     */     */
173    public static SecureRandom getInstance(String algorithm) throws    public static SecureRandom getInstance(String algorithm)
174      NoSuchAlgorithmException      throws NoSuchAlgorithmException
175    {    {
176      Provider p[] = Security.getProviders();      Provider[] p = Security.getProviders();
177        
178      for (int i = 0; i < p.length; i++)      for (int i = 0; i < p.length; i++)
179        {        {
180          try          try
181            {            {
182              return getInstance(algorithm, p[i]);              return getInstance(algorithm, p[i]);
183            }            }
184          catch (NoSuchAlgorithmException ignored)          catch (NoSuchAlgorithmException e)
185            {            {
186                // Ignore.
187            }            }
188        }        }
189    
# Line 284  public class SecureRandom extends Random Line 289  public class SecureRandom extends Random
289      // Therefore we test.      // Therefore we test.
290      if (secureRandomSpi != null)      if (secureRandomSpi != null)
291        {        {
292          byte tmp[] = { (byte) (0xff & (seed >> 56)),          byte[] tmp = { (byte) (0xff & (seed >> 56)),
293                         (byte) (0xff & (seed >> 48)),                         (byte) (0xff & (seed >> 48)),
294                         (byte) (0xff & (seed >> 40)),                         (byte) (0xff & (seed >> 40)),
295                         (byte) (0xff & (seed >> 32)),                         (byte) (0xff & (seed >> 32)),
# Line 324  public class SecureRandom extends Random Line 329  public class SecureRandom extends Random
329      if (numBits == 0)      if (numBits == 0)
330        return 0;        return 0;
331    
332      byte tmp[] = new byte[numBits / 8 + (1 * (numBits % 8))];      byte[] tmp = new byte[numBits / 8 + (1 * (numBits % 8))];
333    
334      secureRandomSpi.engineNextBytes(tmp);      secureRandomSpi.engineNextBytes(tmp);
335      randomBytesUsed += tmp.length;      randomBytesUsed += tmp.length;
# Line 349  public class SecureRandom extends Random Line 354  public class SecureRandom extends Random
354     */     */
355    public static byte[] getSeed(int numBytes)    public static byte[] getSeed(int numBytes)
356    {    {
357      byte tmp[] = new byte[numBytes];      byte[] tmp = new byte[numBytes];
358    
359      new Random().nextBytes(tmp);      new Random().nextBytes(tmp);
360      return tmp;      return tmp;

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.14.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26