re PR libgcj/9271 (Severe bias in java.security.SecureRandom)
2003-02-13 Casey Marshall <rsdio@metastatic.org> PR libgcj/9271: * java/security/SecureRandom.java (next): Avoid bias in results. From-SVN: r62851
This commit is contained in:
parent
06b5f09133
commit
894c84e4d9
2 changed files with 10 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
/* SecureRandom.java --- Secure Random class implmentation
|
||||
Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -36,6 +36,7 @@ obligated to do so. If you do not wish to do so, delete this
|
|||
exception statement from your version. */
|
||||
|
||||
package java.security;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Random;
|
||||
import java.util.Enumeration;
|
||||
|
@ -358,9 +359,10 @@ public class SecureRandom extends Random
|
|||
int ret = 0;
|
||||
|
||||
for (int i = 0; i < tmp.length; i++)
|
||||
ret |= tmp[i] << (8 * i);
|
||||
ret |= (tmp[i] & 0xFF) << (8 * i);
|
||||
|
||||
return ret;
|
||||
long mask = (1L << numBits) - 1;
|
||||
return (int) (ret & mask);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue