MD2 (hash function)


The MD2 Message-Digest Algorithm is a cryptographic hash function developed by Ronald Rivest in 1989. The algorithm is optimized for 8-bit computers. MD2 is specified in RFC 1319. Although MD2 is no longer considered secure, even, it remains in use in public key infrastructures as part of certificates generated with MD2 and RSA. The "MD" in MD2 stands for "Message Digest".

Description

The 128-bit hash value of any message is formed by padding it to a multiple of the block length and adding a 16-byte checksum to it. For the actual calculation, a 48-byte auxiliary block and a 256-byte S-table generated indirectly from the digits of pi are used. The algorithm runs through a loop where it permutes each byte in the auxiliary block 18 times for every 16 input bytes processed. Once all of the blocks of the message have been processed, the first partial block of the auxiliary block becomes the hash value of the message.
The S-table's values are derived from Pi, and in hex are:

MD2 hashes

The 128-bit MD2 hashes are typically represented as 32-digit hexadecimal numbers. The following demonstrates a 43-byte ASCII input and the corresponding MD2 hash:
MD2 =
03d85a0d629d2c442e987525319fc471
As the result of the avalanche effect in MD2, even a small change in the input message will result in a completely different hash. For example, changing the letter d to c in the message results in:
MD2 =
6b890c9292668cdbbfda00a4ebf31f05
The hash of the zero-length string is:
MD2 =
8350e5a3e24c153df2275c9f80692773

Security

Rogier and Chauvaud described collisions of MD2's compression function, although they were unable to extend the attack to the full MD2.
In 2004, MD2 was shown to be vulnerable to a preimage attack with time complexity equivalent to 2104 applications of the compression function. The author concludes, "MD2 can no longer be considered a secure one-way hash function".
In 2008, MD2 has further improvements on a preimage attack with time complexity of 273 compression function evaluations and memory requirements of 273 message blocks.
In 2009, MD2 was shown to be vulnerable to a collision attack with time complexity of 263.3 compression function evaluations and memory requirements of 252 hash values. This is slightly better than the birthday attack which is expected to take 265.5 compression function evaluations.
In 2009, security updates were issued disabling MD2 in OpenSSL, GnuTLS, and Network Security Services.