Class MD4
java.lang.Object
java.security.MessageDigestSpi
java.security.MessageDigest
com.hierynomus.security.jce.messagedigest.MD4
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
The four registers initialized with the above IVs.private static final int
The initial values of the four registers.private int
private static final int
private final byte[]
The internal buffer isinvalid reference
BLOCK_LENGTH
static final int
The MD4 algorithm block length is 64 bytes wide.static final int
The MD4 algorithm message digest length is 16 bytes wide.private int
private static final int
private int
private static final int
private long
Counts the total length of the data being digested. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected byte[]
protected int
engineDigest
(byte[] buf, int offset, int len) protected int
Returns the digest length in bytes.protected void
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.Methods inherited from class java.security.MessageDigest
clone, digest, digest, digest, getAlgorithm, getDigestLength, getInstance, getInstance, getInstance, getProvider, isEqual, reset, toString, update, update, update, update
Methods inherited from class java.security.MessageDigestSpi
engineUpdate
-
Field Details
-
BYTE_DIGEST_LENGTH
public static final int BYTE_DIGEST_LENGTHThe MD4 algorithm message digest length is 16 bytes wide.- See Also:
-
BYTE_BLOCK_LENGTH
public static final int BYTE_BLOCK_LENGTHThe MD4 algorithm block length is 64 bytes wide.- See Also:
-
A
private static final int AThe initial values of the four registers. RFC gives the values in LE so we converted it as JAVA uses BE endianness.- See Also:
-
B
private static final int B- See Also:
-
C
private static final int C- See Also:
-
D
private static final int D- See Also:
-
a
private int aThe four registers initialized with the above IVs. -
b
private int b -
c
private int c -
d
private int d -
msgLength
private long msgLengthCounts the total length of the data being digested. -
buffer
private final byte[] bufferThe internal buffer isinvalid reference
BLOCK_LENGTH
-
-
Constructor Details
-
MD4
public MD4()Default constructor.
-
-
Method Details
-
engineGetDigestLength
protected int engineGetDigestLength()Returns the digest length in bytes.- Overrides:
engineGetDigestLength
in classMessageDigestSpi
- Returns:
- the digest length in bytes.
-
engineUpdate
protected void engineUpdate(byte b) - Specified by:
engineUpdate
in classMessageDigestSpi
-
engineUpdate
protected void engineUpdate(byte[] b, int offset, int len) - Specified by:
engineUpdate
in classMessageDigestSpi
-
engineDigest
protected byte[] engineDigest()- Specified by:
engineDigest
in classMessageDigestSpi
-
engineDigest
- Overrides:
engineDigest
in classMessageDigestSpi
- Throws:
DigestException
-
engineReset
protected void engineReset()- Specified by:
engineReset
in classMessageDigestSpi
-
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:
-
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
-