jdk/test/java/math/BigInteger/ModPow65537.java
changeset 29371 6f7f029a6b63
parent 5506 202f599c92aa
child 30046 cf2c86e1819e
equal deleted inserted replaced
29370:1ca08334b821 29371:6f7f029a6b63
     1 /*
     1 /*
     2  * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 /*
    24 /*
    25  * @test
    25  * @test
    26  * @bug 4891312
    26  * @library ..
    27  * @summary verify that modPow() not broken by the special case for 65537
    27  * @bug 4891312 8074460
       
    28  * @summary verify that modPow() not broken by the special case for 65537 (use -Dseed=X to set PRNG seed)
    28  * @author Andreas Sterbenz
    29  * @author Andreas Sterbenz
    29  */
    30  */
    30 
    31 
    31 import java.math.BigInteger;
    32 import java.math.BigInteger;
    32 import java.util.*;
       
    33 
    33 
    34 import java.security.*;
    34 import java.security.*;
    35 import java.security.spec.*;
    35 import java.security.spec.*;
    36 
    36 
    37 public class ModPow65537 {
    37 public class ModPow65537 {
    76     }
    76     }
    77 
    77 
    78     private static void testSigning(KeyPair kp) throws Exception {
    78     private static void testSigning(KeyPair kp) throws Exception {
    79         System.out.println(kp.getPublic());
    79         System.out.println(kp.getPublic());
    80         byte[] data = new byte[1024];
    80         byte[] data = new byte[1024];
    81         new Random().nextBytes(data);
    81         RandomSeed rndSeed = new RandomSeed(false);
       
    82         System.out.println("Random number generator seed = " + rndSeed.getSeed());
       
    83         rndSeed.getRandom().nextBytes(data);
    82 
    84 
    83         Signature sig = Signature.getInstance("SHA1withRSA", "SunRsaSign");
    85         Signature sig = Signature.getInstance("SHA1withRSA", "SunRsaSign");
    84         sig.initSign(kp.getPrivate());
    86         sig.initSign(kp.getPrivate());
    85         sig.update(data);
    87         sig.update(data);
    86         byte[] sigBytes = sig.sign();
    88         byte[] sigBytes = sig.sign();