test/java/math/BigInteger/ModPow65537.java
Print this page
rev 11823 : 8078672: Print and allow setting by Java property seeds used to initialize Random instances in java.lang numerics tests
Summary: Add ability to initial the random number generator from the system property "seed" and print to STDOUT the seed value actually used.
Reviewed-by: XXX
*** 21,41 ****
* questions.
*/
/*
* @test
! * @library ..
! * @bug 4891312 8074460
* @summary verify that modPow() not broken by the special case for 65537 (use -Dseed=X to set PRNG seed)
* @author Andreas Sterbenz
* @key randomness
*/
import java.math.BigInteger;
import java.security.*;
import java.security.spec.*;
public class ModPow65537 {
public static void main(String[] args) throws Exception {
// SunRsaSign uses BigInteger internally
--- 21,44 ----
* questions.
*/
/*
* @test
! * @library /lib/testlibrary/
! * @build jdk.testlibrary.*
! * @run main ModPow65537
! * @bug 4891312 8074460 8078672
* @summary verify that modPow() not broken by the special case for 65537 (use -Dseed=X to set PRNG seed)
* @author Andreas Sterbenz
* @key randomness
*/
import java.math.BigInteger;
import java.security.*;
import java.security.spec.*;
+ import java.util.Random;
public class ModPow65537 {
public static void main(String[] args) throws Exception {
// SunRsaSign uses BigInteger internally
*** 77,89 ****
}
private static void testSigning(KeyPair kp) throws Exception {
System.out.println(kp.getPublic());
byte[] data = new byte[1024];
! RandomSeed rndSeed = new RandomSeed(false);
! System.out.println("Random number generator seed = " + rndSeed.getSeed());
! rndSeed.getRandom().nextBytes(data);
Signature sig = Signature.getInstance("SHA1withRSA", "SunRsaSign");
sig.initSign(kp.getPrivate());
sig.update(data);
byte[] sigBytes = sig.sign();
--- 80,91 ----
}
private static void testSigning(KeyPair kp) throws Exception {
System.out.println(kp.getPublic());
byte[] data = new byte[1024];
! Random random = RandomFactory.getRandom();
! random.nextBytes(data);
Signature sig = Signature.getInstance("SHA1withRSA", "SunRsaSign");
sig.initSign(kp.getPrivate());
sig.update(data);
byte[] sigBytes = sig.sign();