jdk/test/sun/security/pkcs11/ec/TestKeyFactory.java
changeset 35379 1e8e336ef66b
parent 21596 0e3a39f29dbc
child 40975 680639c9b307
equal deleted inserted replaced
35378:7e19fa0e4e5b 35379:1e8e336ef66b
     1 /*
     1 /*
     2  * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2006, 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.
    25  * @test
    25  * @test
    26  * @bug 6405536
    26  * @bug 6405536
    27  * @summary Test the P11ECKeyFactory
    27  * @summary Test the P11ECKeyFactory
    28  * @author Andreas Sterbenz
    28  * @author Andreas Sterbenz
    29  * @library ..
    29  * @library ..
       
    30  * @run main/othervm TestKeyFactory
       
    31  * @run main/othervm TestKeyFactory sm
    30  */
    32  */
    31 
    33 
    32 import java.io.*;
    34 import java.security.Key;
    33 import java.util.*;
    35 import java.security.KeyFactory;
    34 
    36 import java.security.KeyPair;
    35 import java.security.*;
    37 import java.security.KeyPairGenerator;
    36 import java.security.interfaces.*;
    38 import java.security.PrivateKey;
    37 import java.security.spec.*;
    39 import java.security.Provider;
       
    40 import java.security.PublicKey;
       
    41 import java.security.spec.ECPrivateKeySpec;
       
    42 import java.security.spec.ECPublicKeySpec;
       
    43 import java.security.spec.KeySpec;
       
    44 import java.security.spec.PKCS8EncodedKeySpec;
       
    45 import java.security.spec.X509EncodedKeySpec;
       
    46 import java.util.Arrays;
    38 
    47 
    39 public class TestKeyFactory extends PKCS11Test {
    48 public class TestKeyFactory extends PKCS11Test {
    40 
    49 
    41     /**
    50     /**
    42      * Test that key1 (reference key) and key2 (key to be tested) are
    51      * Test that key1 (reference key) and key2 (key to be tested) are
   109             testPrivate(kf, (PrivateKey)key);
   118             testPrivate(kf, (PrivateKey)key);
   110         }
   119         }
   111     }
   120     }
   112 
   121 
   113     public static void main(String[] args) throws Exception {
   122     public static void main(String[] args) throws Exception {
   114         main(new TestKeyFactory());
   123         main(new TestKeyFactory(), args);
   115     }
   124     }
   116 
   125 
       
   126     @Override
   117     public void main(Provider p) throws Exception {
   127     public void main(Provider p) throws Exception {
   118         if (p.getService("KeyFactory", "EC") == null) {
   128         if (p.getService("KeyFactory", "EC") == null) {
   119             System.out.println("Provider does not support EC, skipping");
   129             System.out.println("Provider does not support EC, skipping");
   120             return;
   130             return;
   121         }
   131         }