Practical Cryptography by Pathan Al-Sakib Khan Azad Saiful

Practical Cryptography by Pathan Al-Sakib Khan Azad Saiful

Author:Pathan, Al-Sakib Khan, Azad, Saiful [Pathan, Al-Sakib Khan, Azad, Saiful]
Language: eng
Format: epub
Published: 0101-01-01T00:00:00+00:00


18 6

bay zid ashik hossain

P

Q

R

S

Mi

F

Ki

<<<s

P

Q

R

S

Figure 10.1 Operational model of MD5.

and left rotation. Hence, there are three kinds of operations in MD5:

bit-wise Boolean operation, modular addition, and cyclic shift opera-

tion. All three operations are very fast on 32-bit machines, which

make MD5 quite fast.

MD5 consists of 64 of these operations, stated in Figure 10.1,

grouped in four rounds of 16 actions. F is a function that is nonlinear

in nature; in each round one function is used. Mi denotes a 32-bit

block of the message input, and Ki denotes a 32-bit constant.

The algorithm of MD5 can be described in five steps:

1. Add padding bits behind the input message.

2. Add a 64-bit binary string that is the representation of the

message’s length.

3. Initialize four 32-bit values.

4. Compress every 512-bit block.

5. Generate the 128-bit output.

10.3.1 Add Padding Bits behind the Input Message

This step is to elongate the initial message and make its length

congruent to 448 mod 512. First, a single bit 1 is appended to the

message. Then, a series of 0 bits are appended so that length (the

padded message) ≡ 448 mod 512. For example, suppose the initial

message digest algorithm 5

18 7

message has 1000 bits. Then, this step will add 1 bit 1 and 471

bits 0. As another example, consider a message with just 448 bits.

As the algorithm does not check whether the primary length is

congruent to 448 mod 512, 1 bit 1 and 511 bits 0 will be appended

to the message. As a result, the padding bits’ length is at least 1 and

at most 512.

new_len = initial_len+1;

while((new_len% 64) ! = 56){

new_len++;

}

msg = new uint8_t[new_len+8];

10.3.2 Add a 64-Bit Binary String That Is the

Representation of the Message’s Length

Consideration should be paid to the meaning of the 64-bit binary

string. One should not regard it as the first 64 bits of the initial mes-

sage. It is the binary representation of the length of the preliminary

message. For example, assume the message length is 1000 bits. Its

64-bit binary representation would be 0x00000000000003E8. If the

message is very lengthy, larger than 264, only the lower 64 bits of its

binary representation are used.

msg[initial_len] =

0x80;//append the "1" bit; most

significant bit is "first"

for (offset =

initial_len + 1; offset <new_len;

offset++)

msg[offset] = 0;

10.3.3 Initialize Four 32-Bit Values

These four 32-bit variables stated below would be used to compute the

message digest. In the Implementation 1 section, these variables are

mentioned as h0, h1, h2, and h3 and their initial values are

h0 = 0x67452301;

h1 = 0xefcdab89;

h2 = 0x98badcfe;

h3 = 0x10325476;

18 8

bay zid ashik hossain

10.3.4 Compress Every 512-Bit Block

Four supplementary functions will be defined such that each func-

tion takes an input of three 32-bit words and produces a 32-bit word

output [2].

F (X, Y, Z) = XY or not (X) Z

G (X, Y, Z) = XZ or Y not (Z)

H (X, Y, Z) = X xor Y xor Z

I (X, Y, Z) = Y xor (X or not (Z))

In each bit position, F acts as a condition such that if X, then

Y; otherwise, Z. The function F might have been defined using addition instead of or since XY and not ( X) Z will never have 1’s in the same bit position.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.