< prev index next >
test/com/sun/crypto/provider/Cipher/AES/TestGHASH.java
Print this page
@@ -1,7 +1,8 @@
/*
* Copyright (c) 2015, Red Hat, Inc.
+ * Copyright (c) 2015, Oracle, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -22,11 +23,18 @@
*/
/*
* @test
* @bug 8069072
- * @summary Test vectors for com.sun.crypto.provider.GHASH
+ * @summary Test vectors for com.sun.crypto.provider.GHASH.
+ *
+ * Single iteration to verify software-only GHASH algorithm.
+ * @run main TestGHASH
+ *
+ * Multi-iteration to verify test intrinsics GHASH, if available.
+ * Many iterations are needed so we are sure hotspot will use intrinsic
+ * @run main TestGHASH -n 10000
*/
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.nio.ByteBuffer;
@@ -122,20 +130,30 @@
}
}
public static void main(String[] args) throws Exception {
TestGHASH test;
- if (args.length == 0) {
- test = new TestGHASH("com.sun.crypto.provider.GHASH");
- } else {
- test = new TestGHASH(args[0]);
- }
+ String test_class = "com.sun.crypto.provider.GHASH";
+ int i = 0;
+ int num_of_loops = 1;
+ while (args.length > i) {
+ if (args[i].compareTo("-c") == 0) {
+ test_class = args[++i];
+ } else if (args[i].compareTo("-n") == 0) {
+ num_of_loops = Integer.parseInt(args[++i]);
+ }
+ i++;
+ }
+
+ System.out.println("Running " + num_of_loops + " iterations.");
+ test = new TestGHASH(test_class);
+ i = 0;
+ while (num_of_loops > i) {
// Test vectors from David A. McGrew, John Viega,
// "The Galois/Counter Mode of Operation (GCM)", 2005.
// <http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/gcm/gcm-revised-spec.pdf>
-
test.check(1, "66e94bd4ef8a2c3b884cfa59ca342b2e", "", "",
"00000000000000000000000000000000");
test.check(2,
"66e94bd4ef8a2c3b884cfa59ca342b2e", "",
"0388dace60b6a392f328c2b971b2fe78",
@@ -160,7 +178,9 @@
"61353b4c2806934a777ff51fa22a4755" +
"699b2a714fcdc6f83766e5f97b6c7423" +
"73806900e49f24b22b097544d4896b42" +
"4989b5e1ebac0f07c23f4598",
"df586bb4c249b92cb6922877e444d37b");
+ i++;
+ }
}
}
< prev index next >