7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* @test 25 * @bug 4102896 26 * @summary Make sure that a SecureRandom object can be serialized 27 */ 28 29 import java.security.*; 30 import java.io.*; 31 32 public class Serialize { 33 34 public static void main(String args[]) throws Exception { 35 for (String alg: new String[]{ 36 "SHA1PRNG", "DRBG", "Hash_DRBG", "HMAC_DRBG", "CTR_DRBG", 37 "Hash_DRBG,SHA-512,192,pr_and_reseed"}) { 38 39 System.out.println("Testing " + alg); 40 SecureRandom s1; 41 42 // A SecureRandom can be s11ned and des11ned at any time. 43 44 // Brand new. 45 s1 = getInstance(alg); 46 revive(s1).nextInt(); 47 if (alg.contains("DRBG")) { 48 revive(s1).reseed(); 49 } 50 51 // Used 52 s1 = getInstance(alg); 53 s1.nextInt(); // state set 54 revive(s1).nextInt(); | 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* @test 25 * @bug 4102896 26 * @summary Make sure that a SecureRandom object can be serialized 27 * @run main/othervm Serialize 28 */ 29 30 import java.security.*; 31 import java.io.*; 32 33 public class Serialize { 34 35 public static void main(String args[]) throws Exception { 36 System.setProperty("java.security.egd", "file:/dev/urandom"); 37 38 for (String alg: new String[]{ 39 "SHA1PRNG", "DRBG", "Hash_DRBG", "HMAC_DRBG", "CTR_DRBG", 40 "Hash_DRBG,SHA-512,192,pr_and_reseed"}) { 41 42 System.out.println("Testing " + alg); 43 SecureRandom s1; 44 45 // A SecureRandom can be s11ned and des11ned at any time. 46 47 // Brand new. 48 s1 = getInstance(alg); 49 revive(s1).nextInt(); 50 if (alg.contains("DRBG")) { 51 revive(s1).reseed(); 52 } 53 54 // Used 55 s1 = getInstance(alg); 56 s1.nextInt(); // state set 57 revive(s1).nextInt(); |