Package gnu.javax.crypto.mac

Examples of gnu.javax.crypto.mac.TMMH16


        attributes.clear();
        keystream = new DummyKeystream();
        keystream.init(null);

        output = new byte[] { (byte) 0x9d, (byte) 0x6a };
        mac = new TMMH16();
        attributes.put(TMMH16.KEYSTREAM, keystream);
        attributes.put(TMMH16.TAG_LENGTH, new Integer(2));
        mac.init(attributes);
        message = new byte[] { (byte) 0xca, (byte) 0xfe, (byte) 0xba,
                              (byte) 0xbe, (byte) 0xba, (byte) 0xde };
        for (int i = 0; i < message.length; i++)
          {
            mac.update(message[i]);
          }
        result = mac.digest();
        harness.check(Arrays.equals(result, output), "testVector1");
      }
    catch (Exception x)
      {
        harness.debug(x);
        harness.fail("TestOfTMMH16.testVector1");
      }

    /*
     KEY_LENGTH: 10
     TAG_LENGTH: 2
     key: { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc }
     message: { 0xca, 0xfe, 0xba }
     output: { 0xc8, 0x8e }
     */
    try
      {
        attributes.clear();
        keystream = new DummyKeystream();
        keystream.init(null);

        output = new byte[] { (byte) 0xc8, (byte) 0x8e };
        mac = new TMMH16();
        attributes.put(TMMH16.KEYSTREAM, keystream);
        attributes.put(TMMH16.TAG_LENGTH, new Integer(2));
        mac.init(attributes);
        message = new byte[] { (byte) 0xca, (byte) 0xfe, (byte) 0xba };
        for (int i = 0; i < message.length; i++)
          {
            mac.update(message[i]);
          }
        result = mac.digest();
        harness.check(Arrays.equals(result, output), "testVector2");
      }
    catch (Exception x)
      {
        harness.debug(x);
        harness.fail("TestOfTMMH16.testVector2");
      }

    /*
     KEY_LENGTH: 10
     TAG_LENGTH: 4
     key: { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc }
     message: { 0xca, 0xfe, 0xba, 0xbe, 0xba, 0xde }
     output: { 0x9d, 0x6a, 0xc0, 0xd3 }
     */
    try
      {
        attributes.clear();
        keystream = new DummyKeystream();
        keystream.init(null);

        output = new byte[] { (byte) 0x9d, (byte) 0x6a, (byte) 0xc0,
                             (byte) 0xd3 };
        mac = new TMMH16();
        attributes.put(TMMH16.KEYSTREAM, keystream);
        attributes.put(TMMH16.TAG_LENGTH, new Integer(4));
        mac.init(attributes);
        message = new byte[] { (byte) 0xca, (byte) 0xfe, (byte) 0xba,
                              (byte) 0xbe, (byte) 0xba, (byte) 0xde };
View Full Code Here

TOP

Related Classes of gnu.javax.crypto.mac.TMMH16

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.