20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 import java.security.InvalidKeyException;
25 import java.security.NoSuchAlgorithmException;
26 import java.security.NoSuchProviderException;
27 import java.security.Provider;
28 import java.security.SecureRandom;
29 import java.util.List;
30 import javax.crypto.Mac;
31 import javax.crypto.spec.SecretKeySpec;
32
33 /**
34 * @test
35 * @bug 8048603
36 * @summary Check if doFinal and update operation result in same Mac
37 * @author Yu-Ching Valerie Peng, Bill Situ, Alexander Fomin
38 * @library ..
39 * @run main MacSameTest
40 */
41 public class MacSameTest extends PKCS11Test {
42
43 private static final int MESSAGE_SIZE = 25;
44 private static final int OFFSET = 5;
45 private static final int KEY_SIZE = 70;
46
47 /**
48 * Initialize a message, instantiate a Mac object,
49 * initialize the object with a SecretKey,
50 * feed the message into the Mac object
51 * all at once and get the output MAC as result1.
52 * Reset the Mac object, chop the message into three pieces,
53 * feed into the Mac object sequentially, and get the output MAC as result2.
54 * Finally, compare result1 and result2 and see if they are the same.
55 *
56 * @param args the command line arguments
57 */
58 public static void main(String[] args) throws Exception {
59 main(new MacSameTest());
|
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 import java.security.InvalidKeyException;
25 import java.security.NoSuchAlgorithmException;
26 import java.security.NoSuchProviderException;
27 import java.security.Provider;
28 import java.security.SecureRandom;
29 import java.util.List;
30 import javax.crypto.Mac;
31 import javax.crypto.spec.SecretKeySpec;
32
33 /**
34 * @test
35 * @bug 8048603
36 * @summary Check if doFinal and update operation result in same Mac
37 * @author Yu-Ching Valerie Peng, Bill Situ, Alexander Fomin
38 * @library ..
39 * @run main MacSameTest
40 * @key randomness
41 */
42 public class MacSameTest extends PKCS11Test {
43
44 private static final int MESSAGE_SIZE = 25;
45 private static final int OFFSET = 5;
46 private static final int KEY_SIZE = 70;
47
48 /**
49 * Initialize a message, instantiate a Mac object,
50 * initialize the object with a SecretKey,
51 * feed the message into the Mac object
52 * all at once and get the output MAC as result1.
53 * Reset the Mac object, chop the message into three pieces,
54 * feed into the Mac object sequentially, and get the output MAC as result2.
55 * Finally, compare result1 and result2 and see if they are the same.
56 *
57 * @param args the command line arguments
58 */
59 public static void main(String[] args) throws Exception {
60 main(new MacSameTest());
|