1 /* |
1 /* |
2 * Copyright (c) 2003, 2011, 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 4898468 6994008 |
26 * @bug 4898468 6994008 |
27 * @summary basic test for RSA cipher |
27 * @summary basic test for RSA cipher |
28 * @author Andreas Sterbenz |
28 * @author Andreas Sterbenz |
29 * @library .. |
29 * @library .. |
30 * @key randomness |
30 * @key randomness |
|
31 * @run main/othervm TestRSACipher |
|
32 * @run main/othervm TestRSACipher sm |
31 */ |
33 */ |
32 |
34 |
33 import java.io.*; |
35 import java.security.GeneralSecurityException; |
34 import java.util.*; |
36 import java.security.KeyPair; |
35 |
37 import java.security.KeyPairGenerator; |
36 import java.security.*; |
38 import java.security.PrivateKey; |
37 |
39 import java.security.Provider; |
38 import javax.crypto.*; |
40 import java.security.PublicKey; |
|
41 import java.util.Arrays; |
|
42 import java.util.Random; |
|
43 import javax.crypto.BadPaddingException; |
|
44 import javax.crypto.Cipher; |
|
45 import javax.crypto.IllegalBlockSizeException; |
39 |
46 |
40 public class TestRSACipher extends PKCS11Test { |
47 public class TestRSACipher extends PKCS11Test { |
41 |
48 |
42 private static final String[] RSA_ALGOS = |
49 private static final String[] RSA_ALGOS = |
43 { "RSA/ECB/PKCS1Padding", "RSA" }; |
50 { "RSA/ECB/PKCS1Padding", "RSA" }; |
44 |
51 |
|
52 @Override |
45 public void main(Provider p) throws Exception { |
53 public void main(Provider p) throws Exception { |
46 try { |
54 try { |
47 Cipher.getInstance(RSA_ALGOS[0], p); |
55 Cipher.getInstance(RSA_ALGOS[0], p); |
48 } catch (GeneralSecurityException e) { |
56 } catch (GeneralSecurityException e) { |
49 System.out.println("Not supported by provider, skipping"); |
57 System.out.println("Not supported by provider, skipping"); |