Monday, November 24, 2014

MAC / Message Authentication Code

MAC / Message Authentication Code

Asymmetric & Symmetric
Disadvantage for Asymmetric :
·         Slower
·         Output cipher text is generally longer than input plain text
Disadvantage for symmetric :
·         Same key for encryption & decryption
Digital envelope specified that key is secure and output = plain text

     A---------------------------B
Sender                         Receiver

Step 1 : A is sender encrypts data using symmetric key cryptographic algorithms
E g: AES, RC-5…
Suppose the output is CT . Key used is k1 (symmetric key)

Step 2 : Sender encrypts the k1 (symmetric key) using B’s public key (k2)
Step 3 : A takes the CT (cipher text) & encrypted k1 & puts inside digital envelope.
Step 4: A transmit this digital envelopes to B
Step 5 : B receive the digital envelopes and CT & encrypted key
Step 6 : B decrypts the encrypted key using B’s Private key.
            B will get k1.
Step 7 : B decrypts the encrypted data using k1 à PT



MAC / Message Authentication Code
Fingerprint of the message
No encryption algorithm involved (only for maintaining integrity)
     A-------------------------B
Sender                   Receiver
Step 1 : A & B agree upon a symmetric key that is not know to third person
Message is à M
Key is à K
Step 2 : A calculates MAC using symmetric K
            M ---------------àH1 (MAC)
                  +key (k)
Step 3 : A sends M1+ h1 to B
Step 4 : B receives M + H1
B also checks that whether the message is altered, so B calculates again MAC over  message M.
Step 5 : B now compares H1 & H2 if H1=H2.
No modification of the message otherwise H1 H2  then same modification of the message.

HMAC / Hash based Message Authentication Code
1.      Chosen as mandatory security implementation for internet protocol.
2.      Also used for SLL / secure socket layer in internet
3.      It was message digest algorithm like MDS or SHA-1




Original message
Using MD5 or SHA-1


HMAC

MD

Disadvantages :
1.      Key exchange
2.      If multiply receivers & one sender

Digital Signature
Introduction ;
1.      Ro resolve problem related ro HMAC, DSS (digital signature standard) was introduced
2.      NIST published this DSS as federal information processing standard (FIPS) PUB 186 in 1991 and was further revised in 1993 & 1996
3.      DSS was either DSA à Digital Signature Algorithm or RSA.

Working of DS
   A---------------B
Sender      Receiver
Step 1 : Sender A uses SHA-1 algorithm to find out hash value over original message (M)
Original Message
              SHA-1
MDI



Step 2 : Sender A encrypts the message digest generated in step 1 by A’s private key
MDI---------encrypted using private key-----------------à Digital Signature
Step 3: A sends message and digital signature to B
Step 4 : B receives message and DS
Step 5 : B calculates message digest on the message received from.
A or B decrypts the digital signatures using A’s private public key.

Digital Certificates

Digital certificare was introduced to solve problem man –in the middle attecks.
Passport à issued government authority
DC à Issued by trusted organization  known as certification authority (CA)
Public key infrastructure :
1.      Certification authority (CA)
2.      Registration authority (RA)
3.      Self signature digital certification
4.      Cross-certification
5.      Certificate Revocation list (CRL)

1.Certification authority (CA)

·         Trusted agency that can issue digital certificates
·         CA can be financial institutions or s/w company or government organization like post office
·         It provide standard for digital certificates X.509 is popularly used for DC
Structure of Digital Certificates
·         Version
·         Certificate serial number
·         Signature algorithm identifier
·         Issuer name
·         Validity (not before |no after)
·         Subject name
·         Subject public key information
·         Issuer unique identifier
·         Extention
·         Certificates authority DS

2.Registration Authority

RA provide following services :
ü  Accepting & verifying the request for issue of digital certificates
ü  Generating keys on behalf of end users
ü  Accepting & authorizing request for key back up & recovery
ü  Accepting & authorizing request for certificate revocation

Sunday, November 23, 2014

SHA (Secure Hash Algorithm)



Developed by NIST (National Institute of Standard Technology)
The differences with MD5 is it generates 160 bits message digest or hash value.
SHA-1
SHA-192
SHA-256
SHA-1024
SHA-2080

How SHA Working !
Step 1 : Padding à Same as MD5
Step 2 : Append length à Same  as MD5
Step 3 : Divide into 512bits blocksà Same  as MD5
Step 4 : Initialize 5 chairing variable A,B,C,D,E
Step 5 : Processing of blocks
5.1 à copy this 5 chairing in step 4 into 5
a=A, b=B, c=C,  d=D , e=E
5.2à Devide every 512 bits block into corresponding 16 sub-blocks of 32 bits each
5.3 à  SHA has 4 rounds  à 20 steps à80 iteration

abdce= ( e + Process P + 55 (a) + W [t] + k[t], a, s30 (b), c,d)

COMPARISON OF MD5 & SHA

No.
MD5
SHA -1
Message digest in bits
128  bits
160 bits
Number of attacks to be performed to find out original message
2 128 operation
2160 operation
Speed
Faster
Slower

Hash Generation à to double check original content from the sender whether its modified or not.

Sender à Encrypted files + hash value MD5 or SHA ----------à  Receiver Decrypted files + hash value MD5 or SHA

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.