Class MD4

All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
BrokenMD4

public class MD4 extends MessageDigestSpi implements Cloneable

An implementation of Ron Rivest's MD4 message digest algorithm. MD4 was the precursor to the stronger MD5 algorithm, and while not considered cryptograpically secure itself, MD4 is in use in various applications. It is slightly faster than MD5.

This implementation is derived from the version of MD4 in GNU Crypto.

References:

  1. The MD4 Message- Digest Algorithm.
    R. Rivest.
Version:
$Revision: 1.9 $
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int
     
    protected static final int
     
    protected int
     
    protected static final int
     
    static final int
    The MD4 algorithm operates on 512-bit blocks, or 64 bytes.
    protected final byte[]
     
    protected int
     
    protected static final int
     
    protected long
     
    protected int
     
    protected static final int
     
    static final int
    An MD4 message digest is always 128-bits long, or 16 bytes.
  • Constructor Summary

    Constructors
    Constructor
    Description
    MD4()
    Trivial zero-argument constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    protected byte[]
    Pack the four chaining variables into a byte array.
    protected int
    engineDigest(byte[] out, int off, int len)
     
    protected int
     
    protected void
    Reset the four chaining variables.
    void
    engineUpdate(byte b)
     
    protected void
    engineUpdate(byte[] b, int offset, int len)
     
    protected byte[]
    Pad the buffer by appending the byte 0x80, then as many zero bytes to fill the buffer 8 bytes shy of being a multiple of 64 bytes, then append the length of the buffer, in bits, before padding.
    protected void
    transform(byte[] in, int offset)
    Transform a 64-byte block.

    Methods inherited from class java.security.MessageDigestSpi

    engineUpdate

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DIGEST_LENGTH

      public static final int DIGEST_LENGTH
      An MD4 message digest is always 128-bits long, or 16 bytes.
      See Also:
    • BLOCK_LENGTH

      public static final int BLOCK_LENGTH
      The MD4 algorithm operates on 512-bit blocks, or 64 bytes.
      See Also:
    • A

      protected static final int A
      See Also:
    • B

      protected static final int B
      See Also:
    • C

      protected static final int C
      See Also:
    • D

      protected static final int D
      See Also:
    • a

      protected int a
    • b

      protected int b
    • c

      protected int c
    • d

      protected int d
    • count

      protected long count
    • buffer

      protected final byte[] buffer
  • Constructor Details

    • MD4

      public MD4()
      Trivial zero-argument constructor.
  • Method Details

    • clone

      public Object clone()
      Overrides:
      clone in class MessageDigestSpi
    • engineGetDigestLength

      protected int engineGetDigestLength()
      Overrides:
      engineGetDigestLength in class MessageDigestSpi
    • engineUpdate

      public void engineUpdate(byte b)
      Specified by:
      engineUpdate in class MessageDigestSpi
    • engineUpdate

      protected void engineUpdate(byte[] b, int offset, int len)
      Specified by:
      engineUpdate in class MessageDigestSpi
    • engineDigest

      protected byte[] engineDigest()
      Pack the four chaining variables into a byte array.
      Specified by:
      engineDigest in class MessageDigestSpi
    • engineDigest

      protected int engineDigest(byte[] out, int off, int len) throws DigestException
      Overrides:
      engineDigest in class MessageDigestSpi
      Throws:
      DigestException
    • engineReset

      protected void engineReset()
      Reset the four chaining variables.
      Specified by:
      engineReset in class MessageDigestSpi
    • padBuffer

      protected byte[] padBuffer()
      Pad the buffer by appending the byte 0x80, then as many zero bytes to fill the buffer 8 bytes shy of being a multiple of 64 bytes, then append the length of the buffer, in bits, before padding.
    • transform

      protected void transform(byte[] in, int offset)
      Transform a 64-byte block.