jdk/src/java.base/share/classes/java/security/SecureRandom.java
changeset 32649 2ee9017c7597
parent 31538 0981099a3e54
child 33241 27eb2d6abda9
equal deleted inserted replaced
32648:1fa861caf840 32649:2ee9017c7597
   422      *
   422      *
   423      * @param seed the seed.
   423      * @param seed the seed.
   424      *
   424      *
   425      * @see #getSeed
   425      * @see #getSeed
   426      */
   426      */
   427     synchronized public void setSeed(byte[] seed) {
   427     public synchronized void setSeed(byte[] seed) {
   428         secureRandomSpi.engineSetSeed(seed);
   428         secureRandomSpi.engineSetSeed(seed);
   429     }
   429     }
   430 
   430 
   431     /**
   431     /**
   432      * Reseeds this random object, using the eight bytes contained
   432      * Reseeds this random object, using the eight bytes contained
   463      * {@code setSeed} was previously called.
   463      * {@code setSeed} was previously called.
   464      *
   464      *
   465      * @param bytes the array to be filled in with random bytes.
   465      * @param bytes the array to be filled in with random bytes.
   466      */
   466      */
   467     @Override
   467     @Override
   468     synchronized public void nextBytes(byte[] bytes) {
   468     public synchronized void nextBytes(byte[] bytes) {
   469         secureRandomSpi.engineNextBytes(bytes);
   469         secureRandomSpi.engineNextBytes(bytes);
   470     }
   470     }
   471 
   471 
   472     /**
   472     /**
   473      * Generates an integer containing the user-specified number of
   473      * Generates an integer containing the user-specified number of
   482      *
   482      *
   483      * @return an {@code int} containing the user-specified number
   483      * @return an {@code int} containing the user-specified number
   484      * of pseudo-random bits (right justified, with leading zeros).
   484      * of pseudo-random bits (right justified, with leading zeros).
   485      */
   485      */
   486     @Override
   486     @Override
   487     final protected int next(int numBits) {
   487     protected final int next(int numBits) {
   488         int numBytes = (numBits+7)/8;
   488         int numBytes = (numBits+7)/8;
   489         byte[] b = new byte[numBytes];
   489         byte[] b = new byte[numBytes];
   490         int next = 0;
   490         int next = 0;
   491 
   491 
   492         nextBytes(b);
   492         nextBytes(b);