16 MD5
16 MD5
CS 703
Department of CSE/IT
MD5
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 448modulo 512. In all, at least one bit and at most 512 bits
are appended.
Step 2. Append Length
A 64-bit representation of b (the length of the message before the padding bits
were added) is appended to the result of the previous step. In the unlikely event
that b is greater than 2^64, then only the low-order 64 bits of b are used. (These
bits are appended as two 32-bit words and appended low-order word first in
accordance with the previous conventions.)
At this point the resulting message (after padding with bits and with b) has a
length that is an exact multiple of 512 bits. Equivalently, this message has a length
that is an exact multiple of 16 (32-bit) words. Let M[0 ... N-1] denote the words
of the resulting message, where N is a multiple of 16.
word A: 01 23 45 67
word B: 89 ab cd ef
word C: fe dc ba 98
word D: 76 54 32 10
F(X,Y,Z) = XY v not(X) Z
G(X,Y,Z) = XZ v Y not(Z)
H(X,Y,Z) = X xor Y xor Z
I(X,Y,Z) = Y xor (X v not(Z))
The functions G, H, and I are similar to the function F, in that they act in "bitwise
parallel" to produce their output from the bits of X, Y, and Z, in such a manner
that if the corresponding bits of X, Y, and Z are independent and unbiased, then
each bit of G(X,Y,Z), H(X,Y,Z), and I(X,Y,Z) will be independent and unbiased.
Note that the function H is the bit-wise "xor" or "parity" function of its inputs.
Step 5. Output
The message digest produced as output is A, B, C, D. That is, we begin with the
low-order byte of A, and end with the high-order byte of D.