equal
deleted
inserted
replaced
21 * questions. |
21 * questions. |
22 */ |
22 */ |
23 |
23 |
24 /* |
24 /* |
25 * @test |
25 * @test |
26 * @library .. |
26 * @library /lib/testlibrary/ |
27 * @bug 4891312 8074460 |
27 * @build jdk.testlibrary.* |
|
28 * @run main ModPow65537 |
|
29 * @bug 4891312 8074460 8078672 |
28 * @summary verify that modPow() not broken by the special case for 65537 (use -Dseed=X to set PRNG seed) |
30 * @summary verify that modPow() not broken by the special case for 65537 (use -Dseed=X to set PRNG seed) |
29 * @author Andreas Sterbenz |
31 * @author Andreas Sterbenz |
30 * @key randomness |
32 * @key randomness |
31 */ |
33 */ |
32 |
34 |
33 import java.math.BigInteger; |
35 import java.math.BigInteger; |
34 |
36 |
35 import java.security.*; |
37 import java.security.*; |
36 import java.security.spec.*; |
38 import java.security.spec.*; |
|
39 import java.util.Random; |
37 |
40 |
38 public class ModPow65537 { |
41 public class ModPow65537 { |
39 |
42 |
40 public static void main(String[] args) throws Exception { |
43 public static void main(String[] args) throws Exception { |
41 // SunRsaSign uses BigInteger internally |
44 // SunRsaSign uses BigInteger internally |
77 } |
80 } |
78 |
81 |
79 private static void testSigning(KeyPair kp) throws Exception { |
82 private static void testSigning(KeyPair kp) throws Exception { |
80 System.out.println(kp.getPublic()); |
83 System.out.println(kp.getPublic()); |
81 byte[] data = new byte[1024]; |
84 byte[] data = new byte[1024]; |
82 RandomSeed rndSeed = new RandomSeed(false); |
85 Random random = RandomFactory.getRandom(); |
83 System.out.println("Random number generator seed = " + rndSeed.getSeed()); |
86 random.nextBytes(data); |
84 rndSeed.getRandom().nextBytes(data); |
|
85 |
87 |
86 Signature sig = Signature.getInstance("SHA1withRSA", "SunRsaSign"); |
88 Signature sig = Signature.getInstance("SHA1withRSA", "SunRsaSign"); |
87 sig.initSign(kp.getPrivate()); |
89 sig.initSign(kp.getPrivate()); |
88 sig.update(data); |
90 sig.update(data); |
89 byte[] sigBytes = sig.sign(); |
91 byte[] sigBytes = sig.sign(); |