1 /* 2 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 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 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 /** 26 * @test 27 * @bug 7184394 28 * @key stress 29 * @summary add intrinsics to use AES instructions 30 * @library /testlibrary / 31 * @modules java.base/jdk.internal.misc 32 * java.management 33 * 34 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC 35 * compiler.codegen.aes.TestAESMain 36 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencInputOffset=1 37 * compiler.codegen.aes.TestAESMain 38 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencOutputOffset=1 39 * compiler.codegen.aes.TestAESMain 40 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DdecOutputOffset=1 41 * compiler.codegen.aes.TestAESMain 42 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencInputOffset=1 -DencOutputOffset=1 43 * compiler.codegen.aes.TestAESMain 44 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 45 * compiler.codegen.aes.TestAESMain 46 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 -DpaddingStr=NoPadding -DmsgSize=640 47 * compiler.codegen.aes.TestAESMain 48 * 49 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB 50 * compiler.codegen.aes.TestAESMain 51 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DencInputOffset=1 52 * compiler.codegen.aes.TestAESMain 53 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DencOutputOffset= 54 * compiler.codegen.aes.TestAESMain 55 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DdecOutputOffset=1 56 * compiler.codegen.aes.TestAESMain 57 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DencInputOffset=1 -DencOutputOffset=1 58 * compiler.codegen.aes.TestAESMain 59 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 60 * compiler.codegen.aes.TestAESMain 61 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 -DpaddingStr=NoPadding -DmsgSize=640 62 * compiler.codegen.aes.TestAESMain 63 * 64 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=GCM 65 * compiler.codegen.aes.TestAESMain 66 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=GCM -DencInputOffset=1 67 * compiler.codegen.aes.TestAESMain 68 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=GCM -DencOutputOffset=1 69 * compiler.codegen.aes.TestAESMain 70 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=GCM -DdecOutputOffset=1 71 * compiler.codegen.aes.TestAESMain 72 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=GCM -DencInputOffset=1 -DencOutputOffset=1 73 * compiler.codegen.aes.TestAESMain 74 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=GCM -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 75 * compiler.codegen.aes.TestAESMain 76 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=GCM -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 -DpaddingStr=NoPadding -DmsgSize=640 77 * compiler.codegen.aes.TestAESMain 78 * 79 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR 80 * compiler.codegen.aes.TestAESMain 81 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR -DencInputOffset=1 82 * compiler.codegen.aes.TestAESMain 83 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR -DencOutputOffset=1 84 * compiler.codegen.aes.TestAESMain 85 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR -DdecOutputOffset=1 86 * compiler.codegen.aes.TestAESMain 87 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR -DencInputOffset=1 -DencOutputOffset=1 88 * compiler.codegen.aes.TestAESMain 89 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 90 * compiler.codegen.aes.TestAESMain 91 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 -DpaddingStr=NoPadding -DmsgSize=640 92 * compiler.codegen.aes.TestAESMain 93 * 94 * @author Tom Deneau 95 */ 96 97 package compiler.codegen.aes; 98 99 public class TestAESMain { 100 public static void main(String[] args) { 101 int iters = (args.length > 0 ? Integer.valueOf(args[0]) : 1000000); 102 int warmupIters = (args.length > 1 ? Integer.valueOf(args[1]) : 20000); 103 System.out.println(iters + " iterations"); 104 TestAESEncode etest = new TestAESEncode(); 105 etest.prepare(); 106 // warm-up 107 System.out.println("Starting encryption warm-up"); 108 for (int i = 0; i < warmupIters; i++) { 109 etest.run(); 110 } 111 System.out.println("Finished encryption warm-up"); 112 long start = System.nanoTime(); 113 for (int i = 0; i < iters; i++) { 114 etest.run(); 115 } 116 long end = System.nanoTime(); 117 System.out.println("TestAESEncode runtime was " + (double) ((end - start) / 1000000.0) + " ms"); 118 119 TestAESDecode dtest = new TestAESDecode(); 120 dtest.prepare(); 121 // warm-up 122 System.out.println("Starting decryption warm-up"); 123 for (int i = 0; i < warmupIters; i++) { 124 dtest.run(); 125 } 126 System.out.println("Finished decryption warm-up"); 127 start = System.nanoTime(); 128 for (int i = 0; i < iters; i++) { 129 dtest.run(); 130 } 131 end = System.nanoTime(); 132 System.out.println("TestAESDecode runtime was " + (double) ((end - start) / 1000000.0) + " ms"); 133 } 134 }