src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/HotSpotCryptoSubstitutionTest.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/HotSpotCryptoSubstitutionTest.java

Print this page




  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package org.graalvm.compiler.hotspot.test;
  24 
  25 import java.io.ByteArrayOutputStream;
  26 import java.io.DataInputStream;
  27 import java.io.IOException;
  28 import java.io.InputStream;
  29 import java.security.AlgorithmParameters;
  30 import java.security.SecureRandom;
  31 
  32 import javax.crypto.Cipher;
  33 import javax.crypto.KeyGenerator;
  34 import javax.crypto.SecretKey;
  35 
  36 import org.junit.Assert;
  37 import org.junit.Test;
  38 
  39 import org.graalvm.compiler.code.CompilationResult;

  40 import org.graalvm.compiler.hotspot.meta.HotSpotGraphBuilderPlugins;
  41 
  42 import jdk.vm.ci.code.InstalledCode;
  43 import jdk.vm.ci.meta.ResolvedJavaMethod;
  44 
  45 /**
  46  * Tests the intrinsification of certain crypto methods.
  47  */
  48 public class HotSpotCryptoSubstitutionTest extends HotSpotGraalCompilerTest {
  49 
  50     @Override
  51     protected InstalledCode addMethod(ResolvedJavaMethod method, CompilationResult compResult) {
  52         return getBackend().createDefaultInstalledCode(method, compResult);
  53     }
  54 
  55     SecretKey aesKey;
  56     SecretKey desKey;
  57     byte[] input;
  58     ByteArrayOutputStream aesExpected = new ByteArrayOutputStream();
  59     ByteArrayOutputStream desExpected = new ByteArrayOutputStream();
  60 
  61     public HotSpotCryptoSubstitutionTest() throws Exception {
  62         byte[] seed = {0x4, 0x7, 0x1, 0x1};
  63         SecureRandom random = new SecureRandom(seed);
  64         KeyGenerator aesKeyGen = KeyGenerator.getInstance("AES");
  65         KeyGenerator desKeyGen = KeyGenerator.getInstance("DESede");
  66         aesKeyGen.init(128, random);
  67         desKeyGen.init(168, random);
  68         aesKey = aesKeyGen.generateKey();
  69         desKey = desKeyGen.generateKey();
  70         input = readClassfile16(getClass());
  71 
  72         aesExpected.write(runEncryptDecrypt(aesKey, "AES/CBC/NoPadding"));




  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package org.graalvm.compiler.hotspot.test;
  24 
  25 import java.io.ByteArrayOutputStream;
  26 import java.io.DataInputStream;
  27 import java.io.IOException;
  28 import java.io.InputStream;
  29 import java.security.AlgorithmParameters;
  30 import java.security.SecureRandom;
  31 
  32 import javax.crypto.Cipher;
  33 import javax.crypto.KeyGenerator;
  34 import javax.crypto.SecretKey;
  35 
  36 import org.junit.Assert;
  37 import org.junit.Test;
  38 
  39 import org.graalvm.compiler.code.CompilationResult;
  40 import org.graalvm.compiler.debug.DebugContext;
  41 import org.graalvm.compiler.hotspot.meta.HotSpotGraphBuilderPlugins;
  42 
  43 import jdk.vm.ci.code.InstalledCode;
  44 import jdk.vm.ci.meta.ResolvedJavaMethod;
  45 
  46 /**
  47  * Tests the intrinsification of certain crypto methods.
  48  */
  49 public class HotSpotCryptoSubstitutionTest extends HotSpotGraalCompilerTest {
  50 
  51     @Override
  52     protected InstalledCode addMethod(DebugContext debug, ResolvedJavaMethod method, CompilationResult compResult) {
  53         return getBackend().createDefaultInstalledCode(debug, method, compResult);
  54     }
  55 
  56     SecretKey aesKey;
  57     SecretKey desKey;
  58     byte[] input;
  59     ByteArrayOutputStream aesExpected = new ByteArrayOutputStream();
  60     ByteArrayOutputStream desExpected = new ByteArrayOutputStream();
  61 
  62     public HotSpotCryptoSubstitutionTest() throws Exception {
  63         byte[] seed = {0x4, 0x7, 0x1, 0x1};
  64         SecureRandom random = new SecureRandom(seed);
  65         KeyGenerator aesKeyGen = KeyGenerator.getInstance("AES");
  66         KeyGenerator desKeyGen = KeyGenerator.getInstance("DESede");
  67         aesKeyGen.init(128, random);
  68         desKeyGen.init(168, random);
  69         aesKey = aesKeyGen.generateKey();
  70         desKey = desKeyGen.generateKey();
  71         input = readClassfile16(getClass());
  72 
  73         aesExpected.write(runEncryptDecrypt(aesKey, "AES/CBC/NoPadding"));


src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/HotSpotCryptoSubstitutionTest.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File