< prev index next >

test/com/sun/crypto/provider/Mac/MacSameTest.java

Print this page




  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 import java.security.InvalidKeyException;
  25 import java.security.NoSuchAlgorithmException;
  26 import java.security.NoSuchProviderException;
  27 import java.security.SecureRandom;
  28 import javax.crypto.Mac;
  29 import javax.crypto.spec.SecretKeySpec;
  30 
  31 /**
  32  * @test
  33  * @bug 8048603
  34  * @summary Check if doFinal and update operation result in same Mac
  35  * @author Yu-Ching Valerie Peng, Bill Situ, Alexander Fomin
  36  * @build Utils
  37  * @run main MacSameTest

  38  */
  39 public class MacSameTest implements MacTest {
  40 
  41     private static final int MESSAGE_SIZE = 25;
  42     private static final int OFFSET = 5;
  43     private static final int KEY_SIZE = 70;
  44 
  45     /**
  46      * Initialize a message, instantiate a Mac object,
  47      * initialize the object with a SecretKey,
  48      * feed the message into the Mac object
  49      * all at once and get the output MAC as result1.
  50      * Reset the Mac object, chop the message into three pieces,
  51      * feed into the Mac object sequentially, and get the output MAC as result2.
  52      * Finally, compare result1 and result2 and see if they are the same.
  53      *
  54      * @param args the command line arguments
  55      */
  56     public static void main(String[] args) {
  57         Utils.runTests(new MacSameTest());




  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 import java.security.InvalidKeyException;
  25 import java.security.NoSuchAlgorithmException;
  26 import java.security.NoSuchProviderException;
  27 import java.security.SecureRandom;
  28 import javax.crypto.Mac;
  29 import javax.crypto.spec.SecretKeySpec;
  30 
  31 /**
  32  * @test
  33  * @bug 8048603
  34  * @summary Check if doFinal and update operation result in same Mac
  35  * @author Yu-Ching Valerie Peng, Bill Situ, Alexander Fomin
  36  * @build Utils
  37  * @run main MacSameTest
  38  * @key randomness
  39  */
  40 public class MacSameTest implements MacTest {
  41 
  42     private static final int MESSAGE_SIZE = 25;
  43     private static final int OFFSET = 5;
  44     private static final int KEY_SIZE = 70;
  45 
  46     /**
  47      * Initialize a message, instantiate a Mac object,
  48      * initialize the object with a SecretKey,
  49      * feed the message into the Mac object
  50      * all at once and get the output MAC as result1.
  51      * Reset the Mac object, chop the message into three pieces,
  52      * feed into the Mac object sequentially, and get the output MAC as result2.
  53      * Finally, compare result1 and result2 and see if they are the same.
  54      *
  55      * @param args the command line arguments
  56      */
  57     public static void main(String[] args) {
  58         Utils.runTests(new MacSameTest());


< prev index next >