Sunday, November 23, 2014

MD5 (Message Digest Version 5)


For maintaining integrity either MDS or SHA (Secure Hash Algorithm).
3 requirement of message digest :
1.      Given the message digest, it should be easy to find out message digest
2.      Given the message digest, it should be difficult to find out original message.
3.      Given two messages , their message digest should be unique.
History of MD

MDà Summary of the message run digest propose this MD
MDà First version suppose the message is given by 7 3 9 1 7 4 3
1.      Multiply 7 by 3 = 21
2.      Discard the first digit à1
3.      Multiply 1 by 9 = 9 if it is single digit no need to discard
4.      Multiply 9 by 1 = 9
5.      Multiple 9 by 7 = 63
6.       Discard the first digit à 3
7.      Multiply 3 by 4 = 12
8.      Discard the first digit à2
9.      Multiply 2 by 3 = 6
MD3à Was not released as it was a failure
MD4à Was much better than MD2
MD5à Was very strong

Features of MD5 :
1.      It is quite faster
2.      It produces 128 bit message digest
3.      It processes on 512 bit blocks

Working of MD5
Step 1 à PADDING
Add the padding bits to the original message out aim to make length of message 64 bits less than then multiple of 512
Exà Message length = 1000 bits

a.512 x 1 = 512
b.512 x2 = 1024
c.512 x 3 = 1536
1024-64 = 960 less than 1000 can’t be
1536-64 = 1472
1000+472 = 1472  472 is padding.
Step 2: APPEND LENGTH
Add the 64 bits to the output of step 1
Eg : 1472 + 64 = 1536
1000 + 472 + 64 = 1536 Original length , Padding, length.
Step 3 : Divide into 512bits blocks. Double the output of step 2 into 512 bits blocks.

Data to be hashed
512 bits block 1
512 bits block n


Eg à if 1536 bits is the output of step 2 then it is divided into 3 blocks.
Step 4 : Initialize the chaining variables 4 variables of 32 bits each.
Example :  Hexadecimal

A
01
23
45
67
B
89
AB
CD
EF
C
FE
DC
BA
98
D
76
54
32
10

Binaryà 0,1
Octal à 0-7
Decimal à 0-9
Step 5: processing of the blocks
Loop runs for as many the 512 bits blocks
5.1 à copy this 4 chairing in step 4 into 4
a=A, b=B, c=C,  d=D
abcd à behaves as shift register (128 bits)
5.2 à Devide every 512 bits block into corresponding 16  32bits sub-blocks.

512 blocks


Aub-block 32
Sub-blocks 16


5.3 à we have 4 rounds 16 sub-blocks and 4 rounds à16 x 4 = 64 iterarions
Every round contains following steps
1.      Process P first performed on b, c, d
2.      Variable a is added to output of process p
3.      Message  sub-block M [i] is added to the output of step 2
4.      Constants t [k] is added to output of step 3 t=0 to 15
5.      Output of step 4 is left circularly shifted by 5 bits  (5 will be given)
6.      Variable b is added to output of step 5

7.      Output of step 6 becomes new abcd for next iteration. 

No comments:

Post a Comment