1 /* |
1 /* |
2 * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2008, 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 6572331 6994008 |
26 * @bug 6572331 6994008 |
27 * @summary basic test for RSA cipher key wrapping functionality |
27 * @summary basic test for RSA cipher key wrapping functionality |
28 * @author Valerie Peng |
28 * @author Valerie Peng |
29 * @library .. |
29 * @library .. |
|
30 * @run main/othervm TestRSACipherWrap |
|
31 * @run main/othervm TestRSACipherWrap sm |
30 */ |
32 */ |
31 import java.io.*; |
|
32 import java.util.*; |
|
33 |
33 |
34 import java.security.*; |
34 import java.security.GeneralSecurityException; |
35 |
35 import java.security.InvalidParameterException; |
36 import javax.crypto.*; |
36 import java.security.Key; |
|
37 import java.security.KeyPair; |
|
38 import java.security.KeyPairGenerator; |
|
39 import java.security.Provider; |
|
40 import java.util.Arrays; |
|
41 import javax.crypto.Cipher; |
|
42 import javax.crypto.KeyGenerator; |
|
43 import javax.crypto.SecretKey; |
37 import javax.crypto.spec.SecretKeySpec; |
44 import javax.crypto.spec.SecretKeySpec; |
38 |
45 |
39 public class TestRSACipherWrap extends PKCS11Test { |
46 public class TestRSACipherWrap extends PKCS11Test { |
40 |
47 |
41 private static final String[] RSA_ALGOS = |
48 private static final String[] RSA_ALGOS = |
42 { "RSA/ECB/PKCS1Padding", "RSA" }; |
49 { "RSA/ECB/PKCS1Padding", "RSA" }; |
43 |
50 |
|
51 @Override |
44 public void main(Provider p) throws Exception { |
52 public void main(Provider p) throws Exception { |
45 try { |
53 try { |
46 Cipher.getInstance(RSA_ALGOS[0], p); |
54 Cipher.getInstance(RSA_ALGOS[0], p); |
47 } catch (GeneralSecurityException e) { |
55 } catch (GeneralSecurityException e) { |
48 System.out.println(RSA_ALGOS[0] + " unsupported, skipping"); |
56 System.out.println(RSA_ALGOS[0] + " unsupported, skipping"); |