author | redestad |
Mon, 18 Apr 2016 16:48:12 +0200 | |
changeset 37370 | 4dcebdd2bbc0 |
parent 28240 | 0d15a67e8085 |
permissions | -rw-r--r-- |
28240
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
1 |
/* |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
4 |
* |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
8 |
* |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
13 |
* accompanied this code). |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
14 |
* |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
18 |
* |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
21 |
* questions. |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
22 |
*/ |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
23 |
|
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
24 |
/* |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
25 |
* @test |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
26 |
* @bug 8043349 |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
27 |
* @summary Ensure the cipher aliases of AES and RSA works correctly |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
28 |
*/ |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
29 |
import java.io.*; |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
30 |
import java.security.*; |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
31 |
import java.security.spec.*; |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
32 |
import java.util.*; |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
33 |
import javax.crypto.*; |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
34 |
import javax.crypto.spec.*; |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
35 |
|
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
36 |
public class TestAlias extends UcryptoTest { |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
37 |
|
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
38 |
private static final String[] CIPHER_ALGOS = { |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
39 |
"AES/ECB/PKCS5Padding", |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
40 |
"AES", |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
41 |
"RSA/ECB/PKCS1Padding", |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
42 |
"RSA", |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
43 |
}; |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
44 |
|
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
45 |
public static void main(String[] args) throws Exception { |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
46 |
main(new TestAlias(), null); |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
47 |
} |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
48 |
|
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
49 |
public void doTest(Provider prov) throws Exception { |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
50 |
Cipher c; |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
51 |
for (int i = 0; i < (CIPHER_ALGOS.length - 1); i+=2) { |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
52 |
String fullTransformation = CIPHER_ALGOS[i]; |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
53 |
try { |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
54 |
c = Cipher.getInstance(fullTransformation, prov); |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
55 |
} catch (NoSuchAlgorithmException nsae) { |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
56 |
System.out.println("Skip unsupported algo: " + fullTransformation); |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
57 |
continue; |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
58 |
} |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
59 |
c = Cipher.getInstance(CIPHER_ALGOS[i+1], prov); |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
60 |
} |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
61 |
|
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
62 |
System.out.println("Test Passed"); |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
63 |
} |
0d15a67e8085
8043349: Consider adding aliases for Ucrypto algorithm-only Cipher transformations.
valeriep
parents:
diff
changeset
|
64 |
} |