22 */
23
24 /*
25 * @test
26 * @bug 7088989 8014374 8167512 8173708
27 * @summary Ensure the AES ciphers of OracleUcrypto provider works correctly
28 * @key randomness
29 * @library /test/lib
30 * @build jdk.test.lib.Platform
31 * jdk.test.lib.Utils
32 * @run main TestAES
33 * @run main/othervm -Dpolicy=empty.policy TestAES
34 */
35
36 import java.security.*;
37 import java.security.spec.*;
38 import java.util.*;
39 import javax.crypto.*;
40 import javax.crypto.spec.*;
41
42 import jdk.test.lib.Platform;
43 import jdk.test.lib.Utils;
44
45 public class TestAES extends UcryptoTest {
46
47 private static final String[] PADDEDCIPHER_ALGOS = {
48 "AES/ECB/PKCS5Padding",
49 "AES/CBC/PKCS5Padding",
50 "AES/CFB128/PKCS5Padding"
51 };
52
53 private static final String[] CIPHER_ALGOS = {
54 "AES/ECB/NoPadding",
55 "AES/CBC/NoPadding",
56 "AES/CFB128/NoPadding",
57 "AES/CTR/NoPadding",
58 };
59
60 private static final SecretKey CIPHER_KEY =
61 new SecretKeySpec(new byte[16], "AES");
359 return equal;
360 }
361
362 private static boolean checkKeys(Key k1, Key k2) {
363 boolean equal = true;
364 if (!k1.getAlgorithm().equalsIgnoreCase(k2.getAlgorithm())) {
365 System.out.println("DIFFERENT Key Algorithm");
366 equal = false;
367 } else if (!k1.getFormat().equalsIgnoreCase(k2.getFormat())) {
368 System.out.println("DIFFERENT Key Format");
369 equal = false;
370 } else if (!Arrays.equals(k1.getEncoded(), k2.getEncoded())) {
371 System.out.println("DIFFERENT Key Encoding");
372 equal = false;
373 }
374 return equal;
375 }
376
377 // The cases on CFB128 mode have to be skipped on pre-S11.3.
378 private static boolean isBadSolaris() {
379 return Platform.isSolaris()
380 && Platform.getOsVersionMajor() <= 5
381 && Platform.getOsVersionMinor() <= 11
382 && Utils.distro().compareTo("11.3") < 0;
383 }
384 }
|
22 */
23
24 /*
25 * @test
26 * @bug 7088989 8014374 8167512 8173708
27 * @summary Ensure the AES ciphers of OracleUcrypto provider works correctly
28 * @key randomness
29 * @library /test/lib
30 * @build jdk.test.lib.Platform
31 * jdk.test.lib.Utils
32 * @run main TestAES
33 * @run main/othervm -Dpolicy=empty.policy TestAES
34 */
35
36 import java.security.*;
37 import java.security.spec.*;
38 import java.util.*;
39 import javax.crypto.*;
40 import javax.crypto.spec.*;
41
42 import jdk.test.lib.OSVersion;
43 import jdk.test.lib.Platform;
44 import jdk.test.lib.Utils;
45
46 public class TestAES extends UcryptoTest {
47
48 private static final String[] PADDEDCIPHER_ALGOS = {
49 "AES/ECB/PKCS5Padding",
50 "AES/CBC/PKCS5Padding",
51 "AES/CFB128/PKCS5Padding"
52 };
53
54 private static final String[] CIPHER_ALGOS = {
55 "AES/ECB/NoPadding",
56 "AES/CBC/NoPadding",
57 "AES/CFB128/NoPadding",
58 "AES/CTR/NoPadding",
59 };
60
61 private static final SecretKey CIPHER_KEY =
62 new SecretKeySpec(new byte[16], "AES");
360 return equal;
361 }
362
363 private static boolean checkKeys(Key k1, Key k2) {
364 boolean equal = true;
365 if (!k1.getAlgorithm().equalsIgnoreCase(k2.getAlgorithm())) {
366 System.out.println("DIFFERENT Key Algorithm");
367 equal = false;
368 } else if (!k1.getFormat().equalsIgnoreCase(k2.getFormat())) {
369 System.out.println("DIFFERENT Key Format");
370 equal = false;
371 } else if (!Arrays.equals(k1.getEncoded(), k2.getEncoded())) {
372 System.out.println("DIFFERENT Key Encoding");
373 equal = false;
374 }
375 return equal;
376 }
377
378 // The cases on CFB128 mode have to be skipped on pre-S11.3.
379 private static boolean isBadSolaris() {
380 return Platform.isSolaris() && OSVersion.current().compareTo(new OSVersion(11, 3)) < 0;
381 }
382 }
|