Fact-checked by Grok 2 weeks ago

MD2

MD2 (Message-Digest Algorithm 2) is a that produces a fixed 128-bit (16-byte) message digest from an input message of arbitrary length, typically rendered as a 32-digit number. Developed by Ronald Rivest and published in RFC 1319 in 1992, it was designed as a successor to MD1 for secure compression of data in schemes, such as those used with public-key cryptosystems like , where finding two messages with the same digest or a message matching a given digest is intended to be computationally infeasible. Optimized for 8-bit processors through byte-oriented operations, MD2 processes input in 16-byte blocks after appending padding to reach a multiple of 16 bytes and a 16-byte computed via a 256-entry table (). The algorithm initializes a 48-byte (three 16-byte arrays: X, M, and C) and performs 18 rounds of mixing on each block, where each round updates the using the for and applies a final mixing step across the entire . The digest is then the first 16 bytes (array X) of the final . Initially conjectured to offer 264 security against collision attacks and 2128 against preimage attacks, MD2's design relies on the one-way property of its compression function and the properties of the , which is publicly fixed. Despite its early adoption in protocols like (), MD2 has been cryptanalyzed extensively since the early , with practical collision attacks demonstrated in 2009 requiring about 263.3 operations, breaking the birthday bound and confirming its lack of . Preimage attacks have also been improved to complexities far below 2128, such as 2105 in 2008. As a result, in 2011, the (IETF), in coordination with NIST, moved MD2 to "Historic" status via 6149, declaring it unsuitable for further due to these vulnerabilities and recommending its in all applications. Today, MD2 persists only in legacy systems but is considered obsolete and insecure for any cryptographic purpose, with modern alternatives like SHA-256 preferred for hash-based security.

History

Development

MD2 was invented by Ronald Rivest in 1989 while he was working at RSA Data Security, as part of a series of message-digest algorithms designed to support cryptographic applications. Rivest, an MIT professor and co-founder of RSA Laboratories, had previously co-invented the public-key cryptosystem in 1977 with and , revolutionizing asymmetric , and developed the stream cipher in 1987. These contributions established him as a leading figure in , focusing on practical, efficient security primitives for emerging digital systems. MD2 served as the successor to MD1, an unpublished proprietary from the same , addressing the need for a publicly available . The design was motivated by the requirements of early environments, particularly optimizing on resource-constrained 8-bit processors common in that era. The primary goals of MD2 included producing a fixed 128-bit digest to enable secure of arbitrarily large messages, facilitating their in digital signature schemes such as those using encryption. This allowed efficient signing of extensive files by hashing them into a compact representation, ensuring integrity and without the overhead of encrypting the full message.

Standardization and Adoption

The MD2 message-digest algorithm, designed by Ronald Rivest, was formally specified in 1319, published in April 1992 by Burton S. Kaliski of Data Security. This informational provided the definitive description of MD2's structure and operations, enabling its implementation in cryptographic software and protocols without patent encumbrances, as Rivest had placed the algorithm in the . The publication marked the transition from Rivest's initial 1989 prototype to a standardized reference, facilitating broader evaluation and integration by developers. MD2 was incorporated into key cryptographic standards shortly after its RFC publication, including (RSA Cryptography Standard) version 1.5, where it served as a hashing component for -based digital signatures via the md2WithRSAEncryption algorithm. This inclusion supported secure signing in public-key infrastructures, with the algorithm combined with encryption to produce verifiable signatures. Early SSL implementations, such as Netscape's draft protocol from 1994, also adopted MD2 for certificate signatures using the md2withRSAEncryption object identifier, enabling authentication in secure web communications. Additionally, RFC 1422 (February 1993) integrated MD2 into () for certificate-based , using it in the Certificate Integrity Check to validate X.509-style certificates issued by certification authorities. In the , MD2 saw rapid adoption in software leveraging these standards, particularly for PKI applications. browsers, starting with 1.0 in 1994, supported MD2-signed certificates in SSL sessions to verify server identities. products, including early versions of and PKI components, incorporated MD2 for certificate validation in Authenticode and secure communications, aligning with the era's deployments. By 1993, MD2's integration into certificates via and standards led to its widespread use in digital signatures for and web security, though its prominence waned as stronger hashes emerged. This early proliferation established MD2 as a foundational element in cryptography before vulnerabilities prompted its phase-out.

Algorithm

Input Preparation

The input preparation phase of the MD2 algorithm preprocesses the input message to ensure it is suitable for block-based processing, consisting of two main steps: padding and checksum computation. First, the message is padded to make its length a multiple of 16 bytes. If the original message length in bytes is n, and n \mod 16 = r where $0 < r \leq 16, then i = 16 - r bytes are appended, with each of these i bytes set to the value i. This padding ensures the padded message length N satisfies N \equiv 0 \pmod{16}, and the padding bytes are distinct and self-descriptive, allowing recovery of the original length if needed. For example, if r = 14, two bytes each with value 2 are added. If the message is already a multiple of 16 bytes (r = 0), 16 bytes each with value 16 are appended. The padded message is denoted as M[0 \dots N-1]. Next, a 16-byte array C[0 \dots 15] is computed over the padded message and appended to it. The begins with all bytes of C initialized to 0, and a running value L set to 0. The computation iterates over each 16-byte block of the padded message, indexed by block number i from 0 to (N/16) - 1. For each block i, and for each byte position j from 0 to 15, the update proceeds sequentially as follows: let c = M[i \times 16 + j], then C = S[c \oplus L], and finally L = C. This process chains the updates across all bytes in sequence, with L carrying over within and between blocks to produce a message-dependent . The table S is a fixed 256-entry box (S-box), known as the PI_SUBST table, whose values are derived from the digits of the \pi via a deterministic generation process. Once computed, the 16-byte C is appended to the padded message, resulting in an extended message of length N + 16 bytes, which remains a multiple of 16. This extended message, including the as its final , is then ready for the core phase.

Processing and Transformation

The MD2 algorithm employs a 48-byte internal X, initialized to all zeros prior to any message blocks. This serves as the state for iterative transformations, enabling the chaining of computations across the padded message blocks. For each 16-byte message M_i, the processing begins by copying the into the second quarter of the : for j = 0 to $15, set X[16 + j] = M_i. Next, the third quarter is computed as the bitwise XOR of the first and second quarters: for j = 0 to $15, set X[32 + j] = X \oplus X[16 + j]. This step integrates the current with the prior state, as the first quarter X[0..15] holds remnants from previous blocks. The core transformation then occurs over 18 rounds of nonlinear mixing to diffuse the block data throughout the . Initialize a temporary value t = 0. For each round index j = 0 to $17, update t = (t + j) \mod 256, then for each byte position k = 0 to $47, perform the X = X \oplus S[X \oplus t], where S is the 256-entry PI_SUBST . This , derived from the digits of \pi (starting from the first digit after the point and arranged to form a full of 0 to 255), provides the nonlinear byte essential for the algorithm's mixing properties; its first few entries are S{{grok:render&&&type=render_inline_citation&&&citation_id=0&&&citation_type=wikipedia}} = 41, S{{grok:render&&&type=render_inline_citation&&&citation_id=1&&&citation_type=wikipedia}} = 46, S{{grok:render&&&type=render_inline_citation&&&citation_id=2&&&citation_type=wikipedia}} = 67, and so on up to S{{grok:render&&&type=render_inline_citation&&&citation_id=255&&&citation_type=wikipedia}} = 20. The incremental update to t ensures varying patterns across rounds, promoting effects in the . Following the 18 rounds, the is updated to chain the for the next : for j = 0 to $15, set X = X[16 + j] and X[16 + j] = X[32 + j]. This left-shift operation by 16 bytes effectively propagates the mixed data, with the third quarter's XOR value now becoming the new second quarter, preserving dependency on prior without recomputing the XOR explicitly.

Output Computation

Upon completion of processing all message , the MD2 algorithm derives the final 128-bit value directly from the 48-byte working X, specifically utilizing the first 16 bytes X[0 \dots 15] as the message digest without any further mixing or transformations. This chained from the iterative steps serves as the endpoint, ensuring the output encapsulates the entire message's content through the accumulated modifications to the . The resulting 128-bit digest is a fixed-length 16-byte value, conventionally represented as a 32-character string for readability and interoperability in cryptographic applications. For instance, the hash of an empty message (zero-length input) is specified as the value 8350e5a3e24c153df2275c9f80692773, demonstrating the algorithm's deterministic output even for inputs. This direct extraction maintains computational efficiency, as MD2 was designed for resource-constrained 8-bit environments where additional post-processing would be undesirable.

Security

Known Vulnerabilities

MD2 incorporates a 16-byte checksum appended to the padded message, computed iteratively using the algorithm's S-box to provide additional integrity checking. However, this checksum is susceptible to manipulation, enabling second preimage attacks where an attacker modifies the message padding and solves for checksum values to produce the same hash as a target message; such attacks achieve a complexity of approximately 2^{73} for 129-block messages. In 1997, researchers demonstrated partial collisions on a simplified variant of MD2 that excludes the , exploiting the linear structure inherent in its 18 processing rounds to find colliding inputs with a of roughly 2^{12} operations. Furthermore, MD2's 128-bit output renders it vulnerable to brute-force collision searches with 2^{64} effort via the birthday paradox.

Cryptanalytic Advances

In 1997, Nicolas Rogier and Pascal Chauvaud demonstrated collisions on the compression function of MD2, achieving them with a complexity of approximately $2^{12} operations and negligible memory requirements, though the attack could not be extended to the full hash function due to MD2's checksum and padding mechanisms. The first significant advance against the full MD2 hash function came in 2004, when Frédéric Muller presented a preimage attack requiring about $2^{104} evaluations of the compression function, along with a pseudo-preimage attack on the compression function itself at $2^{73} complexity; these results established that MD2 fails to achieve its expected one-way property. Building on this, Lars R. Knudsen and John Erik Mathiassen introduced in 2005 the first collision attack on the complete MD2, with a time complexity of roughly $2^{85} MD2 computations and memory usage of $2^{30} blocks, alongside an improved preimage attack at $2^{90} complexity. Further progress in 2008 by Søren S. Thomsen refined the to $2^{73} compression function evaluations, leveraging optimizations on Muller's pseudo-preimage method while requiring $2^{73} message blocks of memory. The most comprehensive analysis appeared in 2009 from Knudsen, Mathiassen, and collaborators, who developed a on the full hash at $2^{63.3} MD2 evaluations with $2^{52} blocks of memory, a at $2^{72.6} evaluations and $2^{72} memory, and a second-preimage attack at $2^{73} complexity for messages of 129 blocks; these complexities render MD2 practically broken for all security properties. Such vulnerabilities have critical implications for legacy applications, including the ability to forge certificates signed with MD2-based hashes, as demonstrated through collision construction.

Legacy

Historical Applications

MD2 found early application in public key infrastructure (PKI) systems during the 1990s, particularly for integrity checks in X.509 v1 and v2 certificates. It was embedded in Privacy Enhancement for Internet Electronic Mail (PEM), where the RSA-MD2 algorithm computed message digests for signing certificates and certificate revocation lists, ensuring data authenticity in email-based key management compatible with X.509 standards. This usage stemmed from MD2's inclusion in seminal RFCs, which facilitated its integration into nascent PKI deployments for binding public keys to identities. In software implementations, MD2 was employed in early versions of the Secure Sockets Layer (SSL) protocol developed by for securing web communications. The SSL handshake protocol utilized MD2 as a secure for () computations and certificate verification, contributing to the protocol's initial rollout in the mid-1990s. Additionally, MD2 served as the hashing mechanism in v1.5 signature schemes, where it processed data before with keys, supporting signatures in various legacy applications. MD2 also appeared in legacy Windows systems for PKI operations, including certificate chain validation, prior to later updates that disabled it for security reasons. Early PKI deployments in the mid-1990s often used MD2-signed s.

Deprecation and Alternatives

MD2's began in the late amid growing awareness of its cryptographic weaknesses, particularly its susceptibility to collision attacks that could enable . In the late , growing concerns over MD2's vulnerabilities, including collision attacks with 2^{63.3} , raised risks for , prompting efforts by standards bodies and vendors. The timeline for deprecation accelerated in 2010 when the updated its Baseline Requirements, marking MD2 as "NOT RECOMMENDED" for Root CA certificates issued after December 31, 2010, and requiring stronger hash algorithms like or SHA-256 for new publicly trusted certificates. Concurrently, disabled MD2 support by default in version 0.9.8n (released January 2010) to prevent acceptance of MD2-signed certificates, addressing CVE-2009-2409 and mitigating forgery risks in TLS connections. By 2011, the IETF formally retired MD2 through RFC 6149, moving it to Historic status due to its vulnerability to collisions (with attacks requiring approximately 2^{63.3} operations) and preimage attacks (improved to 2^{73} complexity), rendering it unsuitable for any security application. By the release of TLS 1.1 (RFC 4346, 2006), implementations increasingly avoided weak hashes like MD2 for new certificates, with full removal from major TLS implementations by 2011 as part of broader transitions away from weak hashes. The primary reason for MD2's phase-out was its lack of , which allowed attackers to craft malicious certificates that could impersonate trusted entities, undermining (PKI) security. NIST's SP 800-131A (2011), while not naming MD2 explicitly, provided overarching guidance for transitioning from insecure functions to approved alternatives, aligning with the IETF's retirement and emphasizing risks in digital signatures and protection. Initially, systems transitioned to as a faster alternative, though itself proved vulnerable and was later deprecated. Subsequent migrations favored (acceptable until 2013 for signatures per NIST), followed by from the family, which offers 128-bit security against collisions and remains widely used in TLS and certificates. For modern applications, the family (standardized in 2015 via FIPS 202) is recommended, providing sponge-based constructions resistant to known attacks on MD2-like designs. Legacy handling involved software updates to reject MD2, with tools like providing migration paths through configuration flags (e.g., disabling legacy support) and utilities for re-signing certificates with SHA-256. Post-2010 releases of and similar libraries (e.g., NSS in browsers) automatically enforce these changes, ensuring compatibility while blocking insecure usage.

References

  1. [1]
    RFC 1319: The MD2 Message-Digest Algorithm
    ### Summary of RFC 1319 - The MD2 Message-Digest Algorithm
  2. [2]
    Cryptanalysis of MD2
    Among the new attacks, there are the first collision attack breaking the birthday bound on the full. MD2 hash function and also an improved preimage attack on ...
  3. [3]
    [PDF] An improved preimage attack on MD2 - Cryptology ePrint Archive
    A collision for any hash function can be found by a birthday attack with complexity 2n/2. Preimages and 2nd preimages can be found by a brute force search with ...
  4. [4]
    RFC 6149 - MD2 to Historic Status - IETF Datatracker
    Chen Category: Informational NIST ISSN: 2070-1721 March 2011 MD2 ... MD2 is not a reasonable candidate for further standardization and should be deprecated ...
  5. [5]
    RFC 1319: The MD2 Message-Digest Algorithm
    This document describes the MD2 message-digest algorithm. The algorithm takes as input a message of arbitrary length and produces as output a 128-bit ...
  6. [6]
    RFC 2313: PKCS #1: RSA Encryption Version 1.5
    ... signatures in PKCS #7. The first signature algorithm (informally, "MD2 with RSA") combines the MD2 message-digest algorithm with RSA, the second (informally ...
  7. [7]
    draft-hickman-netscape-ssl-00 - IETF Datatracker
    ... used by the client and server during a single connection). The client ... use both MD2 and RSA encryption. Used by SSL for certificate signature ...
  8. [8]
  9. [9]
  10. [10]
  11. [11]
    None
    Nothing is retrieved...<|control11|><|separator|>
  12. [12]
    Md2 is not Secure Without the Checksum Byte | Designs, Codes and ...
    In this paper, we propose a low complexity method to find collisions for the compression function of MD2.
  13. [13]
    The MD2 Hash Function Is Not One-Way | SpringerLink
    In this paper, we show that MD2 does not reach the ideal security level of 2128. We describe preimage attacks against the underlying compression function, the ...<|control11|><|separator|>
  14. [14]
    Preimage and Collision Attacks on MD2 - SpringerLink
    This paper contains several attacks on the hash function MD2 which has a hash code size of 128 bits. At Asiacrypt 2004 Muller presents the first known ...
  15. [15]
    An improved preimage attack on MD2 - Cryptology ePrint Archive
    Abstract. This paper describes an improved preimage attack on the cryptographic hash function MD2. The attack has complexity equivalent to about ...Missing: cryptanalysis | Show results with:cryptanalysis
  16. [16]
    Cryptanalysis of MD2 | Journal of Cryptology
    Oct 28, 2009 · This paper contains the state-of-the-art cryptanalytic results on MD2, in particular collision and preimage attacks on the full hash function.Missing: partial | Show results with:partial
  17. [17]
  18. [18]
    An update that introduces the MD2 and MD4 hashing algorithm ...
    An update is available that changes the behavior of the CertGetCertificateChain function in Windows Embedded Compact 7 to disable MD2 or MD4 for all requested ...
  19. [19]
    Cryptographic weakness due to MD2 hash usage in PyCryptodome
    The MD2 hash algorithm is cryptographically broken and vulnerable to collision attacks. MD2 lacks collision resistance, making it possible for attackers to ...
  20. [20]
    MD2: hash-collision scare of the day - Random Oracle
    Sep 24, 2009 · That means a second preimage collision is necessary; simple birthday attacks will not work. Finding a second message that hashes to a given one ...<|control11|><|separator|>
  21. [21]
    RHSA-2010:0054 - Security Advisory - Red Hat Customer Portal
    Jan 19, 2010 · malicious certificate that would be treated as trusted by a browser. OpenSSL now disables the use of the MD2 algorithm inside signatures by
  22. [22]