Free.util
Class AuthSys

java.lang.Object
  |
  +--Free.util.AuthSys

public class AuthSys
extends java.lang.Object

The AuthSys Class implements a Message Authentication Code system (MAC). AuthSys creates its MAC based on the SHA-1 algorithm included as part of java.security which comes with all Java implementations and is not subject to restrictions. Essentially a message digest of a packet's data portion is created. Then a new message digest of the previous digest concatenated with a passphrase is created. This is returned to be added to packets elsewhere.

Version:
0.7 29 August 2001
Author:
Jason Kitcat

Constructor Summary
AuthSys()
           
 
Method Summary
static boolean checkDigest(Packet pack)
          analyses MAC to ensure packets haven't been tampered.
static boolean checkHMAC(Packet pack, java.lang.String key, int seq_no)
          analyses HMAC to ensure packets haven't been tampered.
static java.lang.String makeDigest(java.lang.String data)
          creates a MAC to detect tampering
static java.lang.String makeHMAC(java.lang.String data, java.lang.String key, int seq_no)
          creates a HMAC to detect tampering.
static java.lang.String seedToKey(java.lang.String seed)
          Turns seed into a key for HMAC
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AuthSys

public AuthSys()
Method Detail

makeDigest

public static java.lang.String makeDigest(java.lang.String data)
                                   throws java.lang.Exception
creates a MAC to detect tampering
Parameters:
data - The data being sent in the packet
Returns:
A string containing the MAC

checkDigest

public static boolean checkDigest(Packet pack)
                           throws java.lang.Exception
analyses MAC to ensure packets haven't been tampered. Simply calls makeDigest and compares the result with the digest portion of the Packet supplied.
Parameters:
pack - The packet, including message digest
Returns:
A boolean depending on whether the packet is ok.

makeHMAC

public static java.lang.String makeHMAC(java.lang.String data,
                                        java.lang.String key,
                                        int seq_no)
                                 throws java.lang.Exception
creates a HMAC to detect tampering.
Parameters:
data - The data being sent in the packet
key - Key to be used in creating the HMAC
seq_no - Sequence number of the packet
Returns:
A string containing the HMAC

checkHMAC

public static boolean checkHMAC(Packet pack,
                                java.lang.String key,
                                int seq_no)
                         throws java.lang.Exception
analyses HMAC to ensure packets haven't been tampered. Simply calls makeHMAC and compares the result with the digest portion of the Packet supplied.
Parameters:
pack - The packet, including message digest
key - Key used in making the HMAC
seq_no - Sequence number of the packet
Returns:
A boolean depending on whether the packet is ok.

seedToKey

public static java.lang.String seedToKey(java.lang.String seed)
                                  throws java.lang.Exception
Turns seed into a key for HMAC
Parameters:
seed - String holding the seed-value
Returns:
A string holding the HMAC key