提交 026bdda3 编写于 作者: K kvn

8035936: SIGBUS in StubRoutines::aesencryptBlock, solaris-sparc

Summary: Fix the arbitrary alignment issue in SPARC AES crypto stub routines.
Reviewed-by: kvn, iveresov
Contributed-by: shrinivas.joshi@oracle.com
上级 2c19f0f1
/* /*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -123,8 +123,13 @@ class Assembler : public AbstractAssembler { ...@@ -123,8 +123,13 @@ class Assembler : public AbstractAssembler {
fpop2_op3 = 0x35, fpop2_op3 = 0x35,
impdep1_op3 = 0x36, impdep1_op3 = 0x36,
aes3_op3 = 0x36, aes3_op3 = 0x36,
alignaddr_op3 = 0x36,
faligndata_op3 = 0x36,
flog3_op3 = 0x36, flog3_op3 = 0x36,
edge_op3 = 0x36,
fsrc_op3 = 0x36,
impdep2_op3 = 0x37, impdep2_op3 = 0x37,
stpartialf_op3 = 0x37,
jmpl_op3 = 0x38, jmpl_op3 = 0x38,
rett_op3 = 0x39, rett_op3 = 0x39,
trap_op3 = 0x3a, trap_op3 = 0x3a,
...@@ -175,17 +180,23 @@ class Assembler : public AbstractAssembler { ...@@ -175,17 +180,23 @@ class Assembler : public AbstractAssembler {
enum opfs { enum opfs {
// selected opfs // selected opfs
edge8n_opf = 0x01,
fmovs_opf = 0x01, fmovs_opf = 0x01,
fmovd_opf = 0x02, fmovd_opf = 0x02,
fnegs_opf = 0x05, fnegs_opf = 0x05,
fnegd_opf = 0x06, fnegd_opf = 0x06,
alignaddr_opf = 0x18,
fadds_opf = 0x41, fadds_opf = 0x41,
faddd_opf = 0x42, faddd_opf = 0x42,
fsubs_opf = 0x45, fsubs_opf = 0x45,
fsubd_opf = 0x46, fsubd_opf = 0x46,
faligndata_opf = 0x48,
fmuls_opf = 0x49, fmuls_opf = 0x49,
fmuld_opf = 0x4a, fmuld_opf = 0x4a,
fdivs_opf = 0x4d, fdivs_opf = 0x4d,
...@@ -348,6 +359,8 @@ class Assembler : public AbstractAssembler { ...@@ -348,6 +359,8 @@ class Assembler : public AbstractAssembler {
ASI_PRIMARY = 0x80, ASI_PRIMARY = 0x80,
ASI_PRIMARY_NOFAULT = 0x82, ASI_PRIMARY_NOFAULT = 0x82,
ASI_PRIMARY_LITTLE = 0x88, ASI_PRIMARY_LITTLE = 0x88,
// 8x8-bit partial store
ASI_PST8_PRIMARY = 0xC0,
// Block initializing store // Block initializing store
ASI_ST_BLKINIT_PRIMARY = 0xE2, ASI_ST_BLKINIT_PRIMARY = 0xE2,
// Most-Recently-Used (MRU) BIS variant // Most-Recently-Used (MRU) BIS variant
...@@ -585,6 +598,9 @@ class Assembler : public AbstractAssembler { ...@@ -585,6 +598,9 @@ class Assembler : public AbstractAssembler {
// instruction only in VIS1 // instruction only in VIS1
static void vis1_only() { assert( VM_Version::has_vis1(), "This instruction only works on SPARC with VIS1"); } static void vis1_only() { assert( VM_Version::has_vis1(), "This instruction only works on SPARC with VIS1"); }
// instruction only in VIS2
static void vis2_only() { assert( VM_Version::has_vis2(), "This instruction only works on SPARC with VIS2"); }
// instruction only in VIS3 // instruction only in VIS3
static void vis3_only() { assert( VM_Version::has_vis3(), "This instruction only works on SPARC with VIS3"); } static void vis3_only() { assert( VM_Version::has_vis3(), "This instruction only works on SPARC with VIS3"); }
...@@ -1164,6 +1180,20 @@ public: ...@@ -1164,6 +1180,20 @@ public:
inline void wrfprs( Register d) { v9_only(); emit_int32( op(arith_op) | rs1(d) | op3(wrreg_op3) | u_field(6, 29, 25)); } inline void wrfprs( Register d) { v9_only(); emit_int32( op(arith_op) | rs1(d) | op3(wrreg_op3) | u_field(6, 29, 25)); }
// VIS1 instructions
void alignaddr( Register s1, Register s2, Register d ) { vis1_only(); emit_int32( op(arith_op) | rd(d) | op3(alignaddr_op3) | rs1(s1) | opf(alignaddr_opf) | rs2(s2)); }
void faligndata( FloatRegister s1, FloatRegister s2, FloatRegister d ) { vis1_only(); emit_int32( op(arith_op) | fd(d, FloatRegisterImpl::D) | op3(faligndata_op3) | fs1(s1, FloatRegisterImpl::D) | opf(faligndata_opf) | fs2(s2, FloatRegisterImpl::D)); }
void fsrc2( FloatRegisterImpl::Width w, FloatRegister s2, FloatRegister d ) { vis1_only(); emit_int32( op(arith_op) | fd(d, w) | op3(fsrc_op3) | opf(0x7A - w) | fs2(s2, w)); }
void stpartialf( Register s1, Register s2, FloatRegister d, int ia = -1 ) { vis1_only(); emit_int32( op(ldst_op) | fd(d, FloatRegisterImpl::D) | op3(stpartialf_op3) | rs1(s1) | imm_asi(ia) | rs2(s2)); }
// VIS2 instructions
void edge8n( Register s1, Register s2, Register d ) { vis2_only(); emit_int32( op(arith_op) | rd(d) | op3(edge_op3) | rs1(s1) | opf(edge8n_opf) | rs2(s2)); }
// VIS3 instructions // VIS3 instructions
void movstosw( FloatRegister s, Register d ) { vis3_only(); emit_int32( op(arith_op) | rd(d) | op3(mftoi_op3) | opf(mstosw_opf) | fs2(s, FloatRegisterImpl::S)); } void movstosw( FloatRegister s, Register d ) { vis3_only(); emit_int32( op(arith_op) | rd(d) | op3(mftoi_op3) | opf(mstosw_opf) | fs2(s, FloatRegisterImpl::S)); }
......
...@@ -41,7 +41,7 @@ static bool returns_to_call_stub(address return_pc) { ...@@ -41,7 +41,7 @@ static bool returns_to_call_stub(address return_pc) {
enum /* platform_dependent_constants */ { enum /* platform_dependent_constants */ {
// %%%%%%%% May be able to shrink this a lot // %%%%%%%% May be able to shrink this a lot
code_size1 = 20000, // simply increase if too small (assembler will crash if too small) code_size1 = 20000, // simply increase if too small (assembler will crash if too small)
code_size2 = 20000 // simply increase if too small (assembler will crash if too small) code_size2 = 22000 // simply increase if too small (assembler will crash if too small)
}; };
class Sparc { class Sparc {
......
/* /*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -266,9 +266,9 @@ void VM_Version::initialize() { ...@@ -266,9 +266,9 @@ void VM_Version::initialize() {
if (!has_vis1()) // Drop to 0 if no VIS1 support if (!has_vis1()) // Drop to 0 if no VIS1 support
UseVIS = 0; UseVIS = 0;
// T2 and above should have support for AES instructions // SPARC T4 and above should have support for AES instructions
if (has_aes()) { if (has_aes()) {
if (UseVIS > 0) { // AES intrinsics use FXOR instruction which is VIS1 if (UseVIS > 2) { // AES intrinsics use MOVxTOd/MOVdTOx which are VIS3
if (FLAG_IS_DEFAULT(UseAES)) { if (FLAG_IS_DEFAULT(UseAES)) {
FLAG_SET_DEFAULT(UseAES, true); FLAG_SET_DEFAULT(UseAES, true);
} }
...@@ -282,7 +282,7 @@ void VM_Version::initialize() { ...@@ -282,7 +282,7 @@ void VM_Version::initialize() {
} }
} else { } else {
if (UseAES || UseAESIntrinsics) { if (UseAES || UseAESIntrinsics) {
warning("SPARC AES intrinsics require VIS1 instruction support. Intrinsics will be disabled."); warning("SPARC AES intrinsics require VIS3 instruction support. Intrinsics will be disabled.");
if (UseAES) { if (UseAES) {
FLAG_SET_DEFAULT(UseAES, false); FLAG_SET_DEFAULT(UseAES, false);
} }
......
...@@ -774,7 +774,7 @@ ...@@ -774,7 +774,7 @@
/* java/lang/ref/Reference */ \ /* java/lang/ref/Reference */ \
do_intrinsic(_Reference_get, java_lang_ref_Reference, get_name, void_object_signature, F_R) \ do_intrinsic(_Reference_get, java_lang_ref_Reference, get_name, void_object_signature, F_R) \
\ \
/* support for com.sum.crypto.provider.AESCrypt and some of its callers */ \ /* support for com.sun.crypto.provider.AESCrypt and some of its callers */ \
do_class(com_sun_crypto_provider_aescrypt, "com/sun/crypto/provider/AESCrypt") \ do_class(com_sun_crypto_provider_aescrypt, "com/sun/crypto/provider/AESCrypt") \
do_intrinsic(_aescrypt_encryptBlock, com_sun_crypto_provider_aescrypt, encryptBlock_name, byteArray_int_byteArray_int_signature, F_R) \ do_intrinsic(_aescrypt_encryptBlock, com_sun_crypto_provider_aescrypt, encryptBlock_name, byteArray_int_byteArray_int_signature, F_R) \
do_intrinsic(_aescrypt_decryptBlock, com_sun_crypto_provider_aescrypt, decryptBlock_name, byteArray_int_byteArray_int_signature, F_R) \ do_intrinsic(_aescrypt_decryptBlock, com_sun_crypto_provider_aescrypt, decryptBlock_name, byteArray_int_byteArray_int_signature, F_R) \
......
/* /*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -870,7 +870,7 @@ const TypeFunc* OptoRuntime::updateBytesCRC32_Type() { ...@@ -870,7 +870,7 @@ const TypeFunc* OptoRuntime::updateBytesCRC32_Type() {
return TypeFunc::make(domain, range); return TypeFunc::make(domain, range);
} }
// for cipherBlockChaining calls of aescrypt encrypt/decrypt, four pointers and a length, returning void // for cipherBlockChaining calls of aescrypt encrypt/decrypt, four pointers and a length, returning int
const TypeFunc* OptoRuntime::cipherBlockChaining_aescrypt_Type() { const TypeFunc* OptoRuntime::cipherBlockChaining_aescrypt_Type() {
// create input type (domain) // create input type (domain)
int num_args = 5; int num_args = 5;
......
/* /*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -40,9 +40,20 @@ abstract public class TestAESBase { ...@@ -40,9 +40,20 @@ abstract public class TestAESBase {
int msgSize = Integer.getInteger("msgSize", 646); int msgSize = Integer.getInteger("msgSize", 646);
boolean checkOutput = Boolean.getBoolean("checkOutput"); boolean checkOutput = Boolean.getBoolean("checkOutput");
boolean noReinit = Boolean.getBoolean("noReinit"); boolean noReinit = Boolean.getBoolean("noReinit");
boolean testingMisalignment;
private static final int ALIGN = 8;
int encInputOffset = Integer.getInteger("encInputOffset", 0) % ALIGN;
int encOutputOffset = Integer.getInteger("encOutputOffset", 0) % ALIGN;
int decOutputOffset = Integer.getInteger("decOutputOffset", 0) % ALIGN;
int lastChunkSize = Integer.getInteger("lastChunkSize", 32);
int keySize = Integer.getInteger("keySize", 128); int keySize = Integer.getInteger("keySize", 128);
int inputLength;
int encodeLength;
int decodeLength;
int decodeMsgSize;
String algorithm = System.getProperty("algorithm", "AES"); String algorithm = System.getProperty("algorithm", "AES");
String mode = System.getProperty("mode", "CBC"); String mode = System.getProperty("mode", "CBC");
String paddingStr = System.getProperty("paddingStr", "PKCS5Padding");
byte[] input; byte[] input;
byte[] encode; byte[] encode;
byte[] expectedEncode; byte[] expectedEncode;
...@@ -51,7 +62,6 @@ abstract public class TestAESBase { ...@@ -51,7 +62,6 @@ abstract public class TestAESBase {
Random random = new Random(0); Random random = new Random(0);
Cipher cipher; Cipher cipher;
Cipher dCipher; Cipher dCipher;
String paddingStr = "PKCS5Padding";
AlgorithmParameters algParams; AlgorithmParameters algParams;
SecretKey key; SecretKey key;
...@@ -67,7 +77,10 @@ abstract public class TestAESBase { ...@@ -67,7 +77,10 @@ abstract public class TestAESBase {
public void prepare() { public void prepare() {
try { try {
System.out.println("\nalgorithm=" + algorithm + ", mode=" + mode + ", msgSize=" + msgSize + ", keySize=" + keySize + ", noReinit=" + noReinit + ", checkOutput=" + checkOutput); 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 );
if (encInputOffset % ALIGN != 0 || encOutputOffset % ALIGN != 0 || decOutputOffset % ALIGN !=0 )
testingMisalignment = true;
int keyLenBytes = (keySize == 0 ? 16 : keySize/8); int keyLenBytes = (keySize == 0 ? 16 : keySize/8);
byte keyBytes[] = new byte[keyLenBytes]; byte keyBytes[] = new byte[keyLenBytes];
...@@ -81,10 +94,6 @@ abstract public class TestAESBase { ...@@ -81,10 +94,6 @@ abstract public class TestAESBase {
System.out.println("Algorithm: " + key.getAlgorithm() + "(" System.out.println("Algorithm: " + key.getAlgorithm() + "("
+ key.getEncoded().length * 8 + "bit)"); + key.getEncoded().length * 8 + "bit)");
} }
input = new byte[msgSize];
for (int i=0; i<input.length; i++) {
input[i] = (byte) (i & 0xff);
}
cipher = Cipher.getInstance(algorithm + "/" + mode + "/" + paddingStr, "SunJCE"); cipher = Cipher.getInstance(algorithm + "/" + mode + "/" + paddingStr, "SunJCE");
dCipher = Cipher.getInstance(algorithm + "/" + mode + "/" + paddingStr, "SunJCE"); dCipher = Cipher.getInstance(algorithm + "/" + mode + "/" + paddingStr, "SunJCE");
...@@ -103,10 +112,35 @@ abstract public class TestAESBase { ...@@ -103,10 +112,35 @@ abstract public class TestAESBase {
childShowCipher(); childShowCipher();
} }
inputLength = msgSize + encInputOffset;
if (testingMisalignment) {
encodeLength = cipher.getOutputSize(msgSize - lastChunkSize) + encOutputOffset;
encodeLength += cipher.getOutputSize(lastChunkSize);
decodeLength = dCipher.getOutputSize(encodeLength - lastChunkSize) + decOutputOffset;
decodeLength += dCipher.getOutputSize(lastChunkSize);
} else {
encodeLength = cipher.getOutputSize(msgSize) + encOutputOffset;
decodeLength = dCipher.getOutputSize(encodeLength) + decOutputOffset;
}
input = new byte[inputLength];
for (int i=encInputOffset, j=0; i<inputLength; i++, j++) {
input[i] = (byte) (j & 0xff);
}
// do one encode and decode in preparation // do one encode and decode in preparation
// this will also create the encode buffer and decode buffer encode = new byte[encodeLength];
encode = cipher.doFinal(input); decode = new byte[decodeLength];
decode = dCipher.doFinal(encode); if (testingMisalignment) {
decodeMsgSize = cipher.update(input, encInputOffset, (msgSize - lastChunkSize), encode, encOutputOffset);
decodeMsgSize += cipher.doFinal(input, (encInputOffset + msgSize - lastChunkSize), lastChunkSize, encode, (encOutputOffset + decodeMsgSize));
int tempSize = dCipher.update(encode, encOutputOffset, (decodeMsgSize - lastChunkSize), decode, decOutputOffset);
dCipher.doFinal(encode, (encOutputOffset + decodeMsgSize - lastChunkSize), lastChunkSize, decode, (decOutputOffset + tempSize));
} else {
decodeMsgSize = cipher.doFinal(input, encInputOffset, msgSize, encode, encOutputOffset);
dCipher.doFinal(encode, encOutputOffset, decodeMsgSize, decode, decOutputOffset);
}
if (checkOutput) { if (checkOutput) {
expectedEncode = (byte[]) encode.clone(); expectedEncode = (byte[]) encode.clone();
expectedDecode = (byte[]) decode.clone(); expectedDecode = (byte[]) decode.clone();
......
/* /*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -33,14 +33,15 @@ public class TestAESDecode extends TestAESBase { ...@@ -33,14 +33,15 @@ public class TestAESDecode extends TestAESBase {
public void run() { public void run() {
try { try {
if (!noReinit) dCipher.init(Cipher.DECRYPT_MODE, key, algParams); if (!noReinit) dCipher.init(Cipher.DECRYPT_MODE, key, algParams);
decode = new byte[decodeLength];
if (testingMisalignment) {
int tempSize = dCipher.update(encode, encOutputOffset, (decodeMsgSize - lastChunkSize), decode, decOutputOffset);
dCipher.doFinal(encode, (encOutputOffset + decodeMsgSize - lastChunkSize), lastChunkSize, decode, (decOutputOffset + tempSize));
} else {
dCipher.doFinal(encode, encOutputOffset, decodeMsgSize, decode, decOutputOffset);
}
if (checkOutput) { if (checkOutput) {
// checked version creates new output buffer each time
decode = dCipher.doFinal(encode, 0, encode.length);
compareArrays(decode, expectedDecode); compareArrays(decode, expectedDecode);
} else {
// non-checked version outputs to existing encode buffer for maximum speed
decode = new byte[dCipher.getOutputSize(encode.length)];
dCipher.doFinal(encode, 0, encode.length, decode);
} }
} }
catch (Exception e) { catch (Exception e) {
......
/* /*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -33,14 +33,15 @@ public class TestAESEncode extends TestAESBase { ...@@ -33,14 +33,15 @@ public class TestAESEncode extends TestAESBase {
public void run() { public void run() {
try { try {
if (!noReinit) cipher.init(Cipher.ENCRYPT_MODE, key, algParams); if (!noReinit) cipher.init(Cipher.ENCRYPT_MODE, key, algParams);
encode = new byte[encodeLength];
if (testingMisalignment) {
int tempSize = cipher.update(input, encInputOffset, (msgSize - lastChunkSize), encode, encOutputOffset);
cipher.doFinal(input, (encInputOffset + msgSize - lastChunkSize), lastChunkSize, encode, (encOutputOffset + tempSize));
} else {
cipher.doFinal(input, encInputOffset, msgSize, encode, encOutputOffset);
}
if (checkOutput) { if (checkOutput) {
// checked version creates new output buffer each time
encode = cipher.doFinal(input, 0, msgSize);
compareArrays(encode, expectedEncode); compareArrays(encode, expectedEncode);
} else {
// non-checked version outputs to existing encode buffer for maximum speed
encode = new byte[cipher.getOutputSize(msgSize)];
cipher.doFinal(input, 0, msgSize, encode);
} }
} }
catch (Exception e) { catch (Exception e) {
......
/* /*
* Copyright (c) 2012, 2014 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -28,7 +28,19 @@ ...@@ -28,7 +28,19 @@
* @summary add intrinsics to use AES instructions * @summary add intrinsics to use AES instructions
* *
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC TestAESMain * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC TestAESMain
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencInputOffset=1 TestAESMain
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencOutputOffset=1 TestAESMain
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DdecOutputOffset=1 TestAESMain
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencInputOffset=1 -DencOutputOffset=1 TestAESMain
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 TestAESMain
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 -DpaddingStr=NoPadding TestAESMain
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB TestAESMain * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB TestAESMain
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DencInputOffset=1 TestAESMain
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DencOutputOffset=1 TestAESMain
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DdecOutputOffset=1 TestAESMain
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DencInputOffset=1 -DencOutputOffset=1 TestAESMain
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 TestAESMain
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 -DpaddingStr=NoPadding TestAESMain
* *
* @author Tom Deneau * @author Tom Deneau
*/ */
...@@ -36,12 +48,13 @@ ...@@ -36,12 +48,13 @@
public class TestAESMain { public class TestAESMain {
public static void main(String[] args) { public static void main(String[] args) {
int iters = (args.length > 0 ? Integer.valueOf(args[0]) : 1000000); int iters = (args.length > 0 ? Integer.valueOf(args[0]) : 1000000);
int warmupIters = (args.length > 1 ? Integer.valueOf(args[1]) : 20000);
System.out.println(iters + " iterations"); System.out.println(iters + " iterations");
TestAESEncode etest = new TestAESEncode(); TestAESEncode etest = new TestAESEncode();
etest.prepare(); etest.prepare();
// warm-up for 20K iterations // warm-up
System.out.println("Starting encryption warm-up"); System.out.println("Starting encryption warm-up");
for (int i=0; i<20000; i++) { for (int i=0; i<warmupIters; i++) {
etest.run(); etest.run();
} }
System.out.println("Finished encryption warm-up"); System.out.println("Finished encryption warm-up");
...@@ -54,9 +67,9 @@ public class TestAESMain { ...@@ -54,9 +67,9 @@ public class TestAESMain {
TestAESDecode dtest = new TestAESDecode(); TestAESDecode dtest = new TestAESDecode();
dtest.prepare(); dtest.prepare();
// warm-up for 20K iterations // warm-up
System.out.println("Starting decryption warm-up"); System.out.println("Starting decryption warm-up");
for (int i=0; i<20000; i++) { for (int i=0; i<warmupIters; i++) {
dtest.run(); dtest.run();
} }
System.out.println("Finished decryption warm-up"); System.out.println("Finished decryption warm-up");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册