MD4 hash

 

About MD4 hash

MD4 (Message Digest Algorithm 4) is a cryptographic hash function designed by Ronald Rivest in 1990. It is part of the MD (Message Digest) family of hash functions, which also includes MD2, MD5, and others. MD4 was designed to provide a way to produce a fixed-size hash value (or message digest) from an arbitrary length input.

Characteristics of MD4

  1. Fixed-Length Output:

    • MD4 produces a fixed-length output of 128 bits (16 bytes), regardless of the size of the input data.
  2. Input Padding:

    • The input message is padded to ensure its length is congruent to 448 modulo 512. Padding is done by appending a single '1' bit, followed by enough '0' bits to make the message length 64 bits short of a multiple of 512. The length of the original message (before padding) is then appended as a 64-bit integer.
  3. Processing in Blocks:

    • MD4 processes the message in 512-bit (64-byte) blocks.
  4. Initialization Vector (IV):

    • MD4 starts with a predefined initial state composed of four 32-bit words:
      • A = 0x67452301
      • B = 0xEFCDAB89
      • C = 0x98BADCFE
      • D = 0x10325476
  5. Compression Function:

    • MD4's core consists of three rounds of operations on each 512-bit block. Each round involves non-linear functions, modular addition, and bitwise operations (shifts and rotations).
      • Round 1: Uses the function F(X, Y, Z) = (X & Y) | (~X & Z)
      • Round 2: Uses the function G(X, Y, Z) = (X & Y) | (X & Z) | (Y & Z)
      • Round 3: Uses the function H(X, Y, Z) = X ^ Y ^ Z
  6. Finalization:

    • After processing all the message blocks, the output of the final block is concatenated to produce the final 128-bit hash value.

Algorithm Steps

  1. Initialization:

    • Initialize the state variables (A, B, C, D) to the predefined values.
  2. Padding:

    • Pad the message according to the specified padding rules.
  3. Processing:

    • Divide the padded message into 512-bit blocks.
    • For each block, perform the three rounds of operations, updating the state variables.
  4. Output:

    • Concatenate the state variables to form the final 128-bit hash value.

Security and Usage

  • Security:

    • MD4 was designed to be efficient on 32-bit machines and was one of the fastest hash functions at the time of its creation. However, MD4 has significant vulnerabilities:
      • It is susceptible to collision attacks, where two different inputs produce the same hash output.
      • It is also vulnerable to preimage and second-preimage attacks, making it insecure for most cryptographic purposes.
    • These vulnerabilities have led to its deprecation in favor of more secure hash functions like SHA-256 (part of the SHA-2 family) and SHA-3.
  • Usage:

    • MD4 is mostly obsolete today and is not recommended for any new applications. However, it might still be found in some legacy systems or protocols that were designed before its vulnerabilities were discovered.

Summary

MD4 is an early cryptographic hash function known for its simplicity and efficiency. Despite its historical significance, MD4's security weaknesses make it unsuitable for modern use. It has been largely replaced by more robust hash functions that provide better security against various cryptographic attacks.