Class HashMD5

java.lang.Object
   |
   +----HashMD5

public class HashMD5
extends Object

NetRand Project

Software Engineering - CS536

University of Wisconsin - Milwaukee

Authors:


File: HashMD5.java

HashMD5 implements the MD5 one-way hash function designed by Ron Rivest


Variable Index

 o A
 o a
 o b
 o B
 o C
 o c
 o D
 o d
 o msgBlock

Constructor Index

 o HashMD5()

Method Index

 o divideIntoSubBlocks(byte[])
divides the input block into 16 sub-blocks and copies the sub-blocks into the classes input[] byte array
 o doHash(byte[])
performs the MD5 hash on a 512-bit input block
 o F(int, int, int)
hashing function used during round 1
 o FF(int, int, int, int, int, int, int)
 o G(int, int, int)
hashing function used during round 2
 o GG(int, int, int, int, int, int, int)
 o H(int, int, int)
hashing function used during round 3
 o HH(int, int, int, int, int, int, int)
 o I(int, int, int)
hashing function used during round 4
 o II(int, int, int, int, int, int, int)
 o initHashMD5()
initializes the chainging variables before hash is performed
 o leftCirShift(int, int)
performed a left circle shift on a 32-bit integer value
 o numberOutputBytes()
 o requiredInputBytes()
 o RoundFour()
round 4 of 4
 o RoundOne()
round 1 of 4
 o RoundThree()
round 3 of 4
 o RoundTwo()
round 2 of 4

Variables

 o msgBlock
 private static int msgBlock[]
 o A
 private static int A
 o B
 private static int B
 o C
 private static int C
 o D
 private static int D
 o a
 private static int a
 o b
 private static int b
 o c
 private static int c
 o d
 private static int d

Constructors

 o HashMD5
 public HashMD5()

Methods

 o initHashMD5
 private static void initHashMD5()
initializes the chainging variables before hash is performed

 o requiredInputBytes
 public static int requiredInputBytes()
Returns:
the number of bytes the MD5 hash function takes as input = 64
 o numberOutputBytes
 public static int numberOutputBytes()
Returns:
the number of bytes the MD5 hash function outputs = 16
 o doHash
 public static byte[] doHash(byte block[]) throws IllegalArgumentException
performs the MD5 hash on a 512-bit input block

Parameters:
block - - the input block to hash
Returns:
128-bit hash value of the input block
Throws: IllegalArgumentException
if the input block size != 512-bits
 o divideIntoSubBlocks
 private static boolean divideIntoSubBlocks(byte block[])
divides the input block into 16 sub-blocks and copies the sub-blocks into the classes input[] byte array

Parameters:
block - - the input block to hash
Returns:
true iff the input block has been divided into sub-blocks, otherwise false is returned
 o RoundOne
 private static void RoundOne()
round 1 of 4

 o RoundTwo
 private static void RoundTwo()
round 2 of 4

 o RoundThree
 private static void RoundThree()
round 3 of 4

 o RoundFour
 private static void RoundFour()
round 4 of 4

 o F
 private static int F(int X,
                      int Y,
                      int Z)
hashing function used during round 1

 o FF
 private static int FF(int a,
                       int b,
                       int c,
                       int d,
                       int M,
                       int s,
                       int constant)
 o G
 private static int G(int X,
                      int Y,
                      int Z)
hashing function used during round 2

 o GG
 private static int GG(int a,
                       int b,
                       int c,
                       int d,
                       int M,
                       int s,
                       int constant)
 o H
 private static int H(int X,
                      int Y,
                      int Z)
hashing function used during round 3

 o HH
 private static int HH(int a,
                       int b,
                       int c,
                       int d,
                       int M,
                       int s,
                       int constant)
 o I
 private static int I(int X,
                      int Y,
                      int Z)
hashing function used during round 4

 o II
 private static int II(int a,
                       int b,
                       int c,
                       int d,
                       int M,
                       int s,
                       int constant)
 o leftCirShift
 private static int leftCirShift(int num,
                                 int nshift)
performed a left circle shift on a 32-bit integer value

Parameters:
num - - the integer value to perform the shift on
nshift - - the number of circle shifts to perform
Returns:
the resulting integer value after the shit is performed