src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/HotSpotCryptoSubstitutionTest.java
equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2013, 2019, 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. |
33 |
33 |
34 import javax.crypto.Cipher; |
34 import javax.crypto.Cipher; |
35 import javax.crypto.KeyGenerator; |
35 import javax.crypto.KeyGenerator; |
36 import javax.crypto.SecretKey; |
36 import javax.crypto.SecretKey; |
37 |
37 |
38 import org.junit.Assert; |
|
39 import org.junit.Test; |
|
40 |
|
41 import org.graalvm.compiler.code.CompilationResult; |
38 import org.graalvm.compiler.code.CompilationResult; |
42 import org.graalvm.compiler.debug.DebugContext; |
39 import org.graalvm.compiler.debug.DebugContext; |
43 import org.graalvm.compiler.hotspot.meta.HotSpotGraphBuilderPlugins; |
40 import org.graalvm.compiler.hotspot.meta.HotSpotGraphBuilderPlugins; |
|
41 import org.junit.Assert; |
|
42 import org.junit.Test; |
44 |
43 |
45 import jdk.vm.ci.code.InstalledCode; |
44 import jdk.vm.ci.code.InstalledCode; |
46 import jdk.vm.ci.meta.ResolvedJavaMethod; |
45 import jdk.vm.ci.meta.ResolvedJavaMethod; |
47 |
46 |
48 /** |
47 /** |
89 } |
88 } |
90 } |
89 } |
91 |
90 |
92 @Test |
91 @Test |
93 public void testCipherBlockChainingIntrinsics() throws Exception { |
92 public void testCipherBlockChainingIntrinsics() throws Exception { |
94 if (compileAndInstall("com.sun.crypto.provider.CipherBlockChaining", HotSpotGraphBuilderPlugins.cbcEncryptName, HotSpotGraphBuilderPlugins.cbcDecryptName)) { |
93 boolean implNames = HotSpotGraphBuilderPlugins.cbcUsesImplNames(runtime().getVMConfig()); |
|
94 String cbcEncryptName = implNames ? "implEncrypt" : "encrypt"; |
|
95 String cbcDecryptName = implNames ? "implDecrypt" : "decrypt"; |
|
96 if (compileAndInstall("com.sun.crypto.provider.CipherBlockChaining", cbcEncryptName, cbcDecryptName)) { |
95 ByteArrayOutputStream actual = new ByteArrayOutputStream(); |
97 ByteArrayOutputStream actual = new ByteArrayOutputStream(); |
96 actual.write(runEncryptDecrypt(aesKey, "AES/CBC/NoPadding")); |
98 actual.write(runEncryptDecrypt(aesKey, "AES/CBC/NoPadding")); |
97 actual.write(runEncryptDecrypt(aesKey, "AES/CBC/PKCS5Padding")); |
99 actual.write(runEncryptDecrypt(aesKey, "AES/CBC/PKCS5Padding")); |
98 Assert.assertArrayEquals(aesExpected.toByteArray(), actual.toByteArray()); |
100 Assert.assertArrayEquals(aesExpected.toByteArray(), actual.toByteArray()); |
99 |
101 |