jdk/test/sun/security/pkcs11/Signature/ReinitSignature.java
changeset 32138 23830562d3d1
parent 30046 cf2c86e1819e
child 40975 680639c9b307
equal deleted inserted replaced
32137:335cf1796fcd 32138:23830562d3d1
     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.
    26  * @bug 4856966
    26  * @bug 4856966
    27  * @summary test that reinitializing Signatures works correctly
    27  * @summary test that reinitializing Signatures works correctly
    28  * @author Andreas Sterbenz
    28  * @author Andreas Sterbenz
    29  * @library ..
    29  * @library ..
    30  * @key randomness
    30  * @key randomness
       
    31  * @run main ReinitSignature
       
    32  * @run main ReinitSignature
       
    33  * @run main ReinitSignature
       
    34  * @run main ReinitSignature
       
    35  * @run main ReinitSignature
       
    36  * @run main ReinitSignature
       
    37  * @run main ReinitSignature
       
    38  * @run main ReinitSignature
       
    39  * @run main ReinitSignature
       
    40  * @run main ReinitSignature
       
    41  * @run main ReinitSignature
       
    42  * @run main ReinitSignature
       
    43  * @run main ReinitSignature
       
    44  * @run main ReinitSignature
       
    45  * @run main ReinitSignature
       
    46  * @run main ReinitSignature
       
    47  * @run main ReinitSignature
       
    48  * @run main ReinitSignature
       
    49  * @run main ReinitSignature
       
    50  * @run main ReinitSignature
       
    51  * @run main ReinitSignature
       
    52  * @run main ReinitSignature
       
    53  * @run main ReinitSignature
       
    54  * @run main ReinitSignature
       
    55  * @run main ReinitSignature
       
    56  * @run main ReinitSignature
       
    57  * @run main ReinitSignature
       
    58  * @run main ReinitSignature
       
    59  * @run main ReinitSignature
       
    60  * @run main ReinitSignature
       
    61  * @run main ReinitSignature
       
    62  * @run main ReinitSignature
       
    63  * @run main ReinitSignature
       
    64  * @run main ReinitSignature
       
    65  * @run main ReinitSignature
       
    66  * @run main ReinitSignature
       
    67  * @run main ReinitSignature
       
    68  * @run main ReinitSignature
       
    69  * @run main ReinitSignature
       
    70  * @run main ReinitSignature
       
    71  * @run main ReinitSignature
       
    72  * @run main ReinitSignature
       
    73  * @run main ReinitSignature
       
    74  * @run main ReinitSignature
       
    75  * @run main ReinitSignature
       
    76  * @run main ReinitSignature
       
    77  * @run main ReinitSignature
       
    78  * @run main ReinitSignature
       
    79  * @run main ReinitSignature
       
    80  * @run main ReinitSignature
       
    81  * @run main ReinitSignature
       
    82  * @run main ReinitSignature
       
    83  * @run main ReinitSignature
       
    84  * @run main ReinitSignature
       
    85  * @run main ReinitSignature
       
    86  * @run main ReinitSignature
       
    87  * @run main ReinitSignature
       
    88  * @run main ReinitSignature
       
    89  * @run main ReinitSignature
       
    90  * @run main ReinitSignature
       
    91  * @run main ReinitSignature
       
    92  * @run main ReinitSignature
       
    93  * @run main ReinitSignature
       
    94  * @run main ReinitSignature
       
    95  * @run main ReinitSignature
       
    96  * @run main ReinitSignature
       
    97  * @run main ReinitSignature
       
    98  * @run main ReinitSignature
       
    99  * @run main ReinitSignature
       
   100  * @run main ReinitSignature
       
   101  * @run main ReinitSignature
       
   102  * @run main ReinitSignature
       
   103  * @run main ReinitSignature
       
   104  * @run main ReinitSignature
       
   105  * @run main ReinitSignature
       
   106  * @run main ReinitSignature
       
   107  * @run main ReinitSignature
       
   108  * @run main ReinitSignature
       
   109  * @run main ReinitSignature
       
   110  * @run main ReinitSignature
       
   111  * @run main ReinitSignature
       
   112  * @run main ReinitSignature
       
   113  * @run main ReinitSignature
       
   114  * @run main ReinitSignature
       
   115  * @run main ReinitSignature
       
   116  * @run main ReinitSignature
       
   117  * @run main ReinitSignature
       
   118  * @run main ReinitSignature
       
   119  * @run main ReinitSignature
       
   120  * @run main ReinitSignature
       
   121  * @run main ReinitSignature
       
   122  * @run main ReinitSignature
       
   123  * @run main ReinitSignature
       
   124  * @run main ReinitSignature
       
   125  * @run main ReinitSignature
       
   126  * @run main ReinitSignature
       
   127  * @run main ReinitSignature
       
   128  * @run main ReinitSignature
       
   129  * @run main ReinitSignature
       
   130  * @run main ReinitSignature
       
   131  * @run main ReinitSignature
       
   132  * @run main ReinitSignature
       
   133  * @run main ReinitSignature
       
   134  * @run main ReinitSignature
       
   135  * @run main ReinitSignature
       
   136  * @run main ReinitSignature
       
   137  * @run main ReinitSignature
       
   138  * @run main ReinitSignature
       
   139  * @run main ReinitSignature
       
   140  * @run main ReinitSignature
       
   141  * @run main ReinitSignature
       
   142  * @run main ReinitSignature
       
   143  * @run main ReinitSignature
       
   144  * @run main ReinitSignature
       
   145  * @run main ReinitSignature
       
   146  * @run main ReinitSignature
       
   147  * @run main ReinitSignature
       
   148  * @run main ReinitSignature
       
   149  * @run main ReinitSignature
       
   150  * @run main ReinitSignature
       
   151  * @run main ReinitSignature
       
   152  * @run main ReinitSignature
       
   153  * @run main ReinitSignature
       
   154  * @run main ReinitSignature
       
   155  * @run main ReinitSignature
       
   156  * @run main ReinitSignature
       
   157  * @run main ReinitSignature
       
   158  * @run main ReinitSignature
       
   159  * @run main ReinitSignature
       
   160  * @run main ReinitSignature
       
   161  * @run main ReinitSignature
       
   162  * @run main ReinitSignature
       
   163  * @run main ReinitSignature
       
   164  * @run main ReinitSignature
       
   165  * @run main ReinitSignature
       
   166  * @run main ReinitSignature
       
   167  * @run main ReinitSignature
       
   168  * @run main ReinitSignature
       
   169  * @run main ReinitSignature
       
   170  * @run main ReinitSignature
       
   171  * @run main ReinitSignature
       
   172  * @run main ReinitSignature
       
   173  * @run main ReinitSignature
       
   174  * @run main ReinitSignature
       
   175  * @run main ReinitSignature
       
   176  * @run main ReinitSignature
       
   177  * @run main ReinitSignature
       
   178  * @run main ReinitSignature
       
   179  * @run main ReinitSignature
       
   180  * @run main ReinitSignature
       
   181  * @run main ReinitSignature
       
   182  * @run main ReinitSignature
       
   183  * @run main ReinitSignature
       
   184  * @run main ReinitSignature
       
   185  * @run main ReinitSignature
       
   186  * @run main ReinitSignature
       
   187  * @run main ReinitSignature
       
   188  * @run main ReinitSignature
       
   189  * @run main ReinitSignature
       
   190  * @run main ReinitSignature
       
   191  * @run main ReinitSignature
       
   192  * @run main ReinitSignature
       
   193  * @run main ReinitSignature
       
   194  * @run main ReinitSignature
       
   195  * @run main ReinitSignature
       
   196  * @run main ReinitSignature
       
   197  * @run main ReinitSignature
       
   198  * @run main ReinitSignature
       
   199  * @run main ReinitSignature
       
   200  * @run main ReinitSignature
       
   201  * @run main ReinitSignature
       
   202  * @run main ReinitSignature
       
   203  * @run main ReinitSignature
       
   204  * @run main ReinitSignature
       
   205  * @run main ReinitSignature
       
   206  * @run main ReinitSignature
       
   207  * @run main ReinitSignature
       
   208  * @run main ReinitSignature
       
   209  * @run main ReinitSignature
       
   210  * @run main ReinitSignature
       
   211  * @run main ReinitSignature
       
   212  * @run main ReinitSignature
       
   213  * @run main ReinitSignature
       
   214  * @run main ReinitSignature
       
   215  * @run main ReinitSignature
       
   216  * @run main ReinitSignature
       
   217  * @run main ReinitSignature
       
   218  * @run main ReinitSignature
       
   219  * @run main ReinitSignature
       
   220  * @run main ReinitSignature
       
   221  * @run main ReinitSignature
       
   222  * @run main ReinitSignature
       
   223  * @run main ReinitSignature
       
   224  * @run main ReinitSignature
       
   225  * @run main ReinitSignature
       
   226  * @run main ReinitSignature
       
   227  * @run main ReinitSignature
       
   228  * @run main ReinitSignature
       
   229  * @run main ReinitSignature
       
   230  * @run main ReinitSignature
       
   231  * @run main ReinitSignature
       
   232  * @run main ReinitSignature
       
   233  * @run main ReinitSignature
       
   234  * @run main ReinitSignature
       
   235  * @run main ReinitSignature
       
   236  * @run main ReinitSignature
       
   237  * @run main ReinitSignature
       
   238  * @run main ReinitSignature
       
   239  * @run main ReinitSignature
       
   240  * @run main ReinitSignature
       
   241  * @run main ReinitSignature
       
   242  * @run main ReinitSignature
       
   243  * @run main ReinitSignature
       
   244  * @run main ReinitSignature
       
   245  * @run main ReinitSignature
       
   246  * @run main ReinitSignature
       
   247  * @run main ReinitSignature
       
   248  * @run main ReinitSignature
       
   249  * @run main ReinitSignature
       
   250  * @run main ReinitSignature
       
   251  * @run main ReinitSignature
       
   252  * @run main ReinitSignature
       
   253  * @run main ReinitSignature
       
   254  * @run main ReinitSignature
       
   255  * @run main ReinitSignature
       
   256  * @run main ReinitSignature
       
   257  * @run main ReinitSignature
       
   258  * @run main ReinitSignature
       
   259  * @run main ReinitSignature
       
   260  * @run main ReinitSignature
       
   261  * @run main ReinitSignature
       
   262  * @run main ReinitSignature
       
   263  * @run main ReinitSignature
       
   264  * @run main ReinitSignature
       
   265  * @run main ReinitSignature
       
   266  * @run main ReinitSignature
       
   267  * @run main ReinitSignature
       
   268  * @run main ReinitSignature
       
   269  * @run main ReinitSignature
       
   270  * @run main ReinitSignature
       
   271  * @run main ReinitSignature
       
   272  * @run main ReinitSignature
       
   273  * @run main ReinitSignature
       
   274  * @run main ReinitSignature
       
   275  * @run main ReinitSignature
       
   276  * @run main ReinitSignature
       
   277  * @run main ReinitSignature
       
   278  * @run main ReinitSignature
       
   279  * @run main ReinitSignature
       
   280  * @run main ReinitSignature
       
   281  * @run main ReinitSignature
       
   282  * @run main ReinitSignature
       
   283  * @run main ReinitSignature
       
   284  * @run main ReinitSignature
       
   285  * @run main ReinitSignature
       
   286  * @run main ReinitSignature
       
   287  * @run main ReinitSignature
       
   288  * @run main ReinitSignature
       
   289  * @run main ReinitSignature
       
   290  * @run main ReinitSignature
       
   291  * @run main ReinitSignature
       
   292  * @run main ReinitSignature
       
   293  * @run main ReinitSignature
       
   294  * @run main ReinitSignature
       
   295  * @run main ReinitSignature
       
   296  * @run main ReinitSignature
       
   297  * @run main ReinitSignature
       
   298  * @run main ReinitSignature
       
   299  * @run main ReinitSignature
       
   300  * @run main ReinitSignature
       
   301  * @run main ReinitSignature
       
   302  * @run main ReinitSignature
       
   303  * @run main ReinitSignature
       
   304  * @run main ReinitSignature
       
   305  * @run main ReinitSignature
       
   306  * @run main ReinitSignature
       
   307  * @run main ReinitSignature
       
   308  * @run main ReinitSignature
       
   309  * @run main ReinitSignature
       
   310  * @run main ReinitSignature
       
   311  * @run main ReinitSignature
       
   312  * @run main ReinitSignature
       
   313  * @run main ReinitSignature
       
   314  * @run main ReinitSignature
       
   315  * @run main ReinitSignature
       
   316  * @run main ReinitSignature
       
   317  * @run main ReinitSignature
       
   318  * @run main ReinitSignature
       
   319  * @run main ReinitSignature
       
   320  * @run main ReinitSignature
       
   321  * @run main ReinitSignature
       
   322  * @run main ReinitSignature
       
   323  * @run main ReinitSignature
       
   324  * @run main ReinitSignature
       
   325  * @run main ReinitSignature
       
   326  * @run main ReinitSignature
       
   327  * @run main ReinitSignature
       
   328  * @run main ReinitSignature
       
   329  * @run main ReinitSignature
       
   330  * @run main ReinitSignature
    31  */
   331  */
    32 
   332 
    33 import java.util.*;
   333 import java.util.*;
    34 
   334 
    35 import java.security.*;
   335 import java.security.*;
    39     public static void main(String[] args) throws Exception {
   339     public static void main(String[] args) throws Exception {
    40         main(new ReinitSignature());
   340         main(new ReinitSignature());
    41     }
   341     }
    42 
   342 
    43     public void main(Provider p) throws Exception {
   343     public void main(Provider p) throws Exception {
       
   344 
       
   345         /*
       
   346          * Use Solaris SPARC 11.2 or later to avoid an intermittent failure
       
   347          * when running SunPKCS11-Solaris (8044554)
       
   348          */
       
   349         if (p.getName().equals("SunPKCS11-Solaris") &&
       
   350             System.getProperty("os.name").equals("SunOS") &&
       
   351             System.getProperty("os.arch").equals("sparcv9") &&
       
   352             System.getProperty("os.version").compareTo("5.11") <= 0 &&
       
   353             getDistro().compareTo("11.2") < 0) {
       
   354 
       
   355             System.out.println("SunPKCS11-Solaris provider requires " +
       
   356                 "Solaris SPARC 11.2 or later, skipping");
       
   357             return;
       
   358         }
       
   359 
    44         KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", p);
   360         KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", p);
    45         kpg.initialize(512);
   361         kpg.initialize(512);
    46         KeyPair kp = kpg.generateKeyPair();
   362         KeyPair kp = kpg.generateKeyPair();
    47         PrivateKey privateKey = kp.getPrivate();
   363         PrivateKey privateKey = kp.getPrivate();
    48         PublicKey publicKey = kp.getPublic();
   364         PublicKey publicKey = kp.getPublic();