test/compiler/7184394/TestAESBase.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff test/compiler/7184394

test/compiler/7184394/TestAESBase.java

Print this page
rev 7259 : 8044186: Introduce a reproducible random generator
Reviewed-by: iignatyev
Contributed-by: sergei.kovalev@oracle.com


   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  * @author Tom Deneau
  27  */
  28 



  29 import javax.crypto.Cipher;
  30 import javax.crypto.KeyGenerator;
  31 import javax.crypto.SecretKey;
  32 import javax.crypto.spec.IvParameterSpec;
  33 import javax.crypto.spec.SecretKeySpec;
  34 import java.security.AlgorithmParameters;
  35 
  36 import java.util.Random;
  37 import java.util.Arrays;
  38 
  39 abstract public class TestAESBase {
  40   int msgSize = Integer.getInteger("msgSize", 646);
  41   boolean checkOutput = Boolean.getBoolean("checkOutput");
  42   boolean noReinit = Boolean.getBoolean("noReinit");
  43   boolean testingMisalignment;
  44   private static final int ALIGN = 8;
  45   int encInputOffset = Integer.getInteger("encInputOffset", 0) % ALIGN;
  46   int encOutputOffset = Integer.getInteger("encOutputOffset", 0) % ALIGN;
  47   int decOutputOffset = Integer.getInteger("decOutputOffset", 0) % ALIGN;
  48   int lastChunkSize = Integer.getInteger("lastChunkSize", 32);
  49   int keySize = Integer.getInteger("keySize", 128);
  50   int inputLength;
  51   int encodeLength;
  52   int decodeLength;
  53   int decodeMsgSize;
  54   String algorithm = System.getProperty("algorithm", "AES");
  55   String mode = System.getProperty("mode", "CBC");
  56   String paddingStr = System.getProperty("paddingStr", "PKCS5Padding");
  57   byte[] input;
  58   byte[] encode;
  59   byte[] expectedEncode;
  60   byte[] decode;
  61   byte[] expectedDecode;
  62   Random random = new Random(0);
  63   Cipher cipher;
  64   Cipher dCipher;
  65   AlgorithmParameters algParams;
  66   SecretKey key;
  67 
  68   static int numThreads = 0;
  69   int  threadId;
  70   static synchronized int getThreadId() {
  71     int id = numThreads;
  72     numThreads++;
  73     return id;
  74   }
  75 
  76   abstract public void run();
  77 
  78   public void prepare() {
  79     try {
  80     System.out.println("\nalgorithm=" + algorithm + ", mode=" + mode + ", paddingStr=" + paddingStr + ", msgSize=" + msgSize + ", keySize=" + keySize + ", noReinit=" + noReinit + ", checkOutput=" + checkOutput + ", encInputOffset=" + encInputOffset + ", encOutputOffset=" + encOutputOffset + ", decOutputOffset=" + decOutputOffset + ", lastChunkSize=" +lastChunkSize );
  81 
  82       if (encInputOffset % ALIGN != 0 || encOutputOffset % ALIGN != 0 || decOutputOffset % ALIGN !=0 )




   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  * @author Tom Deneau
  27  */
  28 
  29 import com.oracle.java.testlibrary.Utils;
  30 import java.security.AlgorithmParameters;
  31 import java.util.Random;
  32 import javax.crypto.Cipher;

  33 import javax.crypto.SecretKey;
  34 import javax.crypto.spec.IvParameterSpec;
  35 import javax.crypto.spec.SecretKeySpec;




  36 
  37 abstract public class TestAESBase {
  38   int msgSize = Integer.getInteger("msgSize", 646);
  39   boolean checkOutput = Boolean.getBoolean("checkOutput");
  40   boolean noReinit = Boolean.getBoolean("noReinit");
  41   boolean testingMisalignment;
  42   private static final int ALIGN = 8;
  43   int encInputOffset = Integer.getInteger("encInputOffset", 0) % ALIGN;
  44   int encOutputOffset = Integer.getInteger("encOutputOffset", 0) % ALIGN;
  45   int decOutputOffset = Integer.getInteger("decOutputOffset", 0) % ALIGN;
  46   int lastChunkSize = Integer.getInteger("lastChunkSize", 32);
  47   int keySize = Integer.getInteger("keySize", 128);
  48   int inputLength;
  49   int encodeLength;
  50   int decodeLength;
  51   int decodeMsgSize;
  52   String algorithm = System.getProperty("algorithm", "AES");
  53   String mode = System.getProperty("mode", "CBC");
  54   String paddingStr = System.getProperty("paddingStr", "PKCS5Padding");
  55   byte[] input;
  56   byte[] encode;
  57   byte[] expectedEncode;
  58   byte[] decode;
  59   byte[] expectedDecode;
  60   final Random random = Utils.getRandomInstance();
  61   Cipher cipher;
  62   Cipher dCipher;
  63   AlgorithmParameters algParams;
  64   SecretKey key;
  65 
  66   static int numThreads = 0;
  67   int  threadId;
  68   static synchronized int getThreadId() {
  69     int id = numThreads;
  70     numThreads++;
  71     return id;
  72   }
  73 
  74   abstract public void run();
  75 
  76   public void prepare() {
  77     try {
  78     System.out.println("\nalgorithm=" + algorithm + ", mode=" + mode + ", paddingStr=" + paddingStr + ", msgSize=" + msgSize + ", keySize=" + keySize + ", noReinit=" + noReinit + ", checkOutput=" + checkOutput + ", encInputOffset=" + encInputOffset + ", encOutputOffset=" + encOutputOffset + ", decOutputOffset=" + decOutputOffset + ", lastChunkSize=" +lastChunkSize );
  79 
  80       if (encInputOffset % ALIGN != 0 || encOutputOffset % ALIGN != 0 || decOutputOffset % ALIGN !=0 )


test/compiler/7184394/TestAESBase.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File