Lecture#09: Cryptographic Hash Functions-MD5
Lecture#09: Cryptographic Hash Functions-MD5
Lecture#09
Cryptographic Hash Functions- MD5
Course: Cryptography & Network Security (CE-408)
Course Teacher: Ms. Rukaiya
Contact Info:
Email: [email protected]
1
Introduction
• MD5 algorithm was developed by Professor Ronald L.
Rivest in 1991.
• According to RFC 1321, “MD5 message-digest algorithm
takes as input a message of arbitrary length and
produces as output a 128-bit "fingerprint" or "message
digest" of the input.
• The MD5 algorithm is intended for digital signature
applications, where a large file must be "compressed" in
a secure manner before being encrypted with a private
(secret) key under a public-key cryptosystem such as
RSA.”
• MD5 is being used heavily from large corporations, such
as IBM, Cisco Systems, to individual programmers.
Introduction
• The MD5 hashing algorithm is a one-way
cryptographic function and used for authenticating the
original message.
• The MD5 hash function was originally designed for
use as a secure cryptographic hash algorithm for
authenticating digital signatures.
• But MD5 has been deprecated for uses other than as
a noncryptographic checksum to verify data integrity
and detect unintentional data corruption.
MD5 Parameters
• Digest Length = 128 bit
• I/P Text = 512 bit
• Sub Block size = 32bit
• 512/32 = 16 total Sub blocks
• No. Of Rounds = 4
• Iteration per round=16 steps
• T[t] constant= constructed from sine function
• O/P-> four 32-bit blocks
MD5- Implementation Steps
• Step#01: Append padding bits
• The input message is "padded" (extended) so that its length (in bits)
equals to 448 mod 512. Padding is always performed, even if the length
of the message is already 448 mod 512.
Example:
Message = 1000 bits
if length < 448
448 – length = __________
if length > 448
960 – length = __________
• In this example length is greater than 448
960 – 1000 = -40 + 512 (or mod 512)
= 472
• The padding bits will be 472 in which 471 0’s will be leading after 1
MD5- Implementation Steps
• Padding is performed as follows: a single "1" bit is appended to
the message, and then "0" bits are appended so that the length in
bits of the padded message becomes congruent to 448 mod 512.
• At least one bit and at most 512 bits are appended.
100100110…….. 100000……..
Message length =1000 bits Padding bits =472 bits
MD5- Implementation Steps
• Step#02: Append length
• A 64-bit representation of the length of the message is
appended to the result of step1.
• If the length of the message is greater than 2^64, only the
low-order 64 bits will be used.
Step#02(a):
• Divide the input into 512- bit blocks
= 1536 /512
= 3 blocks (of 512 bits)
word A: 01 23 45 67
word B: 89 ab cd ef
word C: fe dc ba 98
word D: 76 54 32 10
MD5- Implementation Steps
• Step#04: Process the message in 16-word Blocks
32 32 32 32 32
bits bits bits bits bits
T[1,…,k] = constants
(constructed from sine
function)
• In the first round, the M inputs are added into the algorithm
sequentially, e.g. M0, M1, M2… M15.
• In the second round, the M inputs are added in the following order:
M1, M6, M11, M0, M5, M10, M15, M4, M9, M14, M3, M8, M13, M2, M7,
M12
M5, M8, M11, M14, M1, M4, M7, M10, M13, M0, M3, M6, M9, M12,
M15, M2
• In the fourth round, the M inputs are added in the following order:
M0, M7, M14, M5, M12, M3, M10, M1, M8, M15, M6, M13, M4, M11,
M2, M9
MD5- Implementation Steps
• The values for K are is derived from the formula: abs(sin(i+ 1))×232
MD5- Implementation Steps
• Each operation has a preset number of shifts, and the operations use
them in sequential order (e.g. S1, S2, S3, etc.). The S values are:
•
MD5- Implementation Steps
• After all the 512-bit blocks have been processed a 128-bit message
digest is produced, which is a function of all the bits of your message
https://www.comparitech.com/blog/information-security/md5-
algorithm-with-examples/
SHA vs MD5
• Brute force attack is harder (160 vs 128 bits for MD5)
• not vulnerable to any known attacks (compared to
MD4/5)
• a little slower than MD5 (80 vs 64 steps)
• both designed as simple and compact
• optimised for big endian CPU's (SUN) vs MD5 for little
endian CPU’s (PC)