Cryptography Reference
In-Depth Information
H
0
y
1
) OR A)
257
F
1
((
((0000000000000000
1111101111110100) OR
1111000000000000)
100000001
(1111101111110100 OR 1111000000000000)
100000001
1111101111110100
100000001
101011011010010100101011 (mod
10110111001001010111011101).
G
1
is taken to be the 16 rightmost bits of
F
1
; so
G
1
= 1010010100101011.
We take
H
1
by computing
H
1
=
G
1
H
0
= 1010010100101011.
H
2
in the same way:
F
2
((
H
1
y
2
) OR A)
257
We compute
((1010010100101011
1010000010100110) OR
1111000000000000)
100000001
(0000010110001101 OR 1111000000000000)
100000001
1111010110001101
100000001
10001000101100100000010111 (mod
10110111001001010111011101).
G
2
= 1100100000010111
H
2
=
G
2
H
1
= 1100100000010111
1010010100101011 = 0110110100111100.
The final digest value is 0110110100111100.
Of course, this was a lot to go through for such a tiny message; in fact, in this case, the
digest is larger than the message! Of course, we could have used a message up to 2
8
1 =
255 bits in length for this example.
The MASH2 Class
I have designed a class to generate digests of messages using the
MASH-2 algorithm. The digestOf() method accepts a message as a byte array, and returns
the digest as a byte array.
import java.math.*;
import java.security.*;
public class MASH2 {
//Define some handy values
static BigInteger two=BigInteger.valueOf(2);
static BigInteger ten=BigInteger.valueOf(10);//=binary 1010
static BigInteger fifteen=BigInteger.valueOf(15);//=binary 1111
static BigInteger sixteen=BigInteger.valueOf(16);
static BigInteger exp=BigInteger.valueOf(257);
BigInteger modulus;
public MASH2(BigInteger modulus) {
this.modulus=modulus;
}
Search WWH ::
Custom Search