demo.md
Class HMac

java.lang.Object
  |
  +--demo.md.HMac

public class HMac
extends Object

This class tests HMac implementation using MD5 as hash algorithm as specified in RFC 2104.

Version:
File Revision 18

Constructor Summary
HMac()
          Default Constructor.
 
Method Summary
 boolean hmac(String algorithm, byte[] key, byte[] data, byte[] correct)
          Computes the HMAC on the given data using the given key, and compares the result with the given pre-computed correct value.
 boolean hmac(String algorithm, byte[] data, int keyLength)
          Repeatetly computes a HMAC on the given data and compares if the result is always the same.
 boolean hmacAll()
          Tests the HMAC algorithm for several hash algorithms.
 boolean hmacMd5()
          Tests the HMAC algorithm using Md5 for hash computation.
static void main(String[] arg)
          Performs some tests for HMAC.
 void start()
          Tests the HMAC algorithm using Md5 for hash computation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HMac

public HMac()
Default Constructor.
Method Detail

hmac

public boolean hmac(String algorithm,
                    byte[] key,
                    byte[] data,
                    byte[] correct)
             throws Exception
Computes the HMAC on the given data using the given key, and compares the result with the given pre-computed correct value.
Parameters:
algorithm - the HMAC algorithm to be used, e.g. "HMAC/MD5"
key - the key data to be used for generating a secret key necessary for MAC computation
data - the data on which the MAC shall be computed
correct - the pre-computed correct value for verifying the rseult of the MAC computation
Returns:
true if the MAC computation yields the correct result false otherwise

hmac

public boolean hmac(String algorithm,
                    byte[] data,
                    int keyLength)
             throws Exception
Repeatetly computes a HMAC on the given data and compares if the result is always the same.
Parameters:
algorithm - the HMAC algorithm to be used, e.g. "HMAC/MD5"
data - the data on which the MAC shall be computed
keyLength - the length of the key to be used
Returns:
true if the test succeeds, false otherwise

start

public void start()
Tests the HMAC algorithm using Md5 for hash computation.
Returns:
true if the test yields the correct result, false otherwise

hmacMd5

public boolean hmacMd5()
                throws Exception
Tests the HMAC algorithm using Md5 for hash computation.
Returns:
true if the test yields the correct result, false otherwise

hmacAll

public boolean hmacAll()
                throws Exception
Tests the HMAC algorithm for several hash algorithms.
Returns:
true if the test yields the correct result, false otherwise

main

public static void main(String[] arg)
                 throws IOException
Performs some tests for HMAC.

This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note).

IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK