jdk/test/sun/security/pkcs11/Signature/TestDSA.java
changeset 35379 1e8e336ef66b
parent 32138 23830562d3d1
child 40975 680639c9b307
equal deleted inserted replaced
35378:7e19fa0e4e5b 35379:1e8e336ef66b
     1 /*
     1 /*
     2  * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2016, 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 basic test of SHA1withDSA and RawDSA signing/verifying
    27  * @summary basic test of SHA1withDSA and RawDSA signing/verifying
    28  * @author Andreas Sterbenz
    28  * @author Andreas Sterbenz
    29  * @library ..
    29  * @library ..
    30  * @key randomness
    30  * @key randomness
       
    31  * @run main/othervm TestDSA
       
    32  * @run main/othervm TestDSA sm
    31  */
    33  */
    32 
    34 
    33 import java.io.*;
    35 import java.io.ByteArrayOutputStream;
    34 import java.util.*;
    36 import java.io.IOException;
       
    37 import java.io.StringReader;
    35 import java.math.BigInteger;
    38 import java.math.BigInteger;
    36 
    39 import java.security.KeyFactory;
    37 import java.security.*;
    40 import java.security.MessageDigest;
    38 import java.security.spec.*;
    41 import java.security.PrivateKey;
       
    42 import java.security.Provider;
       
    43 import java.security.PublicKey;
       
    44 import java.security.Signature;
       
    45 import java.security.SignatureException;
       
    46 import java.security.spec.DSAPrivateKeySpec;
       
    47 import java.security.spec.DSAPublicKeySpec;
       
    48 import java.util.Random;
    39 
    49 
    40 public class TestDSA extends PKCS11Test {
    50 public class TestDSA extends PKCS11Test {
    41 
    51 
    42     // values of the keys we use for the tests
    52     // values of the keys we use for the tests
    43 
    53 
   100         }
   110         }
   101         System.out.println("Passed");
   111         System.out.println("Passed");
   102     }
   112     }
   103 
   113 
   104     public static void main(String[] args) throws Exception {
   114     public static void main(String[] args) throws Exception {
   105         main(new TestDSA());
   115         main(new TestDSA(), args);
   106     }
   116     }
   107 
   117 
       
   118     @Override
   108     public void main(Provider provider) throws Exception {
   119     public void main(Provider provider) throws Exception {
   109         long start = System.currentTimeMillis();
   120         long start = System.currentTimeMillis();
   110 
   121 
   111         System.out.println("Testing provider " + provider + "...");
   122         System.out.println("Testing provider " + provider + "...");
   112 
   123 
   113         /*
   124         /*
   114          * Use Solaris SPARC 11.2 or later to avoid an intermittent failure
   125          * Use Solaris SPARC 11.2 or later to avoid an intermittent failure
   115          * when running SunPKCS11-Solaris (8044554)
   126          * when running SunPKCS11-Solaris (8044554)
   116          */
   127          */
   117         if (provider.getName().equals("SunPKCS11-Solaris") &&
   128         if (provider.getName().equals("SunPKCS11-Solaris") &&
   118             System.getProperty("os.name").equals("SunOS") &&
   129             props.getProperty("os.name").equals("SunOS") &&
   119             System.getProperty("os.arch").equals("sparcv9") &&
   130             props.getProperty("os.arch").equals("sparcv9") &&
   120             System.getProperty("os.version").compareTo("5.11") <= 0 &&
   131             props.getProperty("os.version").compareTo("5.11") <= 0 &&
   121             getDistro().compareTo("11.2") < 0) {
   132             getDistro().compareTo("11.2") < 0) {
   122 
   133 
   123             System.out.println("SunPKCS11-Solaris provider requires " +
   134             System.out.println("SunPKCS11-Solaris provider requires " +
   124                 "Solaris SPARC 11.2 or later, skipping");
   135                 "Solaris SPARC 11.2 or later, skipping");
   125             return;
   136             return;