Class MD4
- java.lang.Object
-
- java.security.MessageDigestSpi
-
- java.security.MessageDigest
-
- com.hierynomus.security.jce.messagedigest.MD4
-
public class MD4 extends java.security.MessageDigest
MD4.java - An implementation of Ron Rivest's MD4 message digest algorithm. The MD4 algorithm is designed to be quite fast on 32-bit machines. In addition, the MD4 algorithm does not require any large substitution tables.- Since:
- MINA 2.0.0-M3
- See Also:
MD4 Message- Digest Algorithm by R. Rivest.
-
-
Field Summary
Fields Modifier and Type Field Description private int
a
The four registers initialized with the above IVs.private static int
A
The initial values of the four registers.private int
b
private static int
B
private byte[]
buffer
The internal buffer isBLOCK_LENGTH
wide.static int
BYTE_BLOCK_LENGTH
The MD4 algorithm block length is 64 bytes wide.static int
BYTE_DIGEST_LENGTH
The MD4 algorithm message digest length is 16 bytes wide.private int
c
private static int
C
private int
d
private static int
D
private long
msgLength
Counts the total length of the data being digested.
-
Constructor Summary
Constructors Constructor Description MD4()
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected byte[]
engineDigest()
protected int
engineDigest(byte[] buf, int offset, int len)
protected int
engineGetDigestLength()
Returns the digest length in bytes.protected void
engineReset()
protected void
engineUpdate(byte b)
protected void
engineUpdate(byte[] b, int offset, int len)
private byte[]
pad()
Pads the buffer by appending the byte 0x80, then append as many zero bytes as necessary to make the buffer length a multiple of 64 bytes.private void
process(byte[] in, int offset)
Process one 64-byte block.
-
-
-
Field Detail
-
BYTE_DIGEST_LENGTH
public static final int BYTE_DIGEST_LENGTH
The MD4 algorithm message digest length is 16 bytes wide.- See Also:
- Constant Field Values
-
BYTE_BLOCK_LENGTH
public static final int BYTE_BLOCK_LENGTH
The MD4 algorithm block length is 64 bytes wide.- See Also:
- Constant Field Values
-
A
private static final int A
The initial values of the four registers. RFC gives the values in LE so we converted it as JAVA uses BE endianness.- See Also:
- Constant Field Values
-
B
private static final int B
- See Also:
- Constant Field Values
-
C
private static final int C
- See Also:
- Constant Field Values
-
D
private static final int D
- See Also:
- Constant Field Values
-
a
private int a
The four registers initialized with the above IVs.
-
b
private int b
-
c
private int c
-
d
private int d
-
msgLength
private long msgLength
Counts the total length of the data being digested.
-
buffer
private final byte[] buffer
The internal buffer isBLOCK_LENGTH
wide.
-
-
Method Detail
-
engineGetDigestLength
protected int engineGetDigestLength()
Returns the digest length in bytes.- Overrides:
engineGetDigestLength
in classjava.security.MessageDigestSpi
- Returns:
- the digest length in bytes.
-
engineUpdate
protected void engineUpdate(byte b)
- Specified by:
engineUpdate
in classjava.security.MessageDigestSpi
-
engineUpdate
protected void engineUpdate(byte[] b, int offset, int len)
- Specified by:
engineUpdate
in classjava.security.MessageDigestSpi
-
engineDigest
protected byte[] engineDigest()
- Specified by:
engineDigest
in classjava.security.MessageDigestSpi
-
engineDigest
protected int engineDigest(byte[] buf, int offset, int len) throws java.security.DigestException
- Overrides:
engineDigest
in classjava.security.MessageDigestSpi
- Throws:
java.security.DigestException
-
engineReset
protected void engineReset()
- Specified by:
engineReset
in classjava.security.MessageDigestSpi
-
pad
private byte[] pad()
Pads the buffer by appending the byte 0x80, then append as many zero bytes as necessary to make the buffer length a multiple of 64 bytes. The last 8 bytes will be filled with the length of the buffer in bits. If there's no room to store the length in bits in the block i.e the block is larger than 56 bytes then an additionnal 64-bytes block is appended.- Returns:
- the pad byte array
- See Also:
3.1 3.2 of the RFC 1320.
-
process
private void process(byte[] in, int offset)
Process one 64-byte block. Algorithm is constituted by three rounds. Note that F, G and H functions were inlined for improved performance.- Parameters:
in
- the byte array to processoffset
- the offset at which the 64-byte block is stored
-
-