Integrity and Hash Functions

Message integrity can be provided by:

* Digital Signatures
* Message Authentication Codes (MAC)

A digital signature uses public/private key pair to provide both authentication and integrity on the signed document. But digital signatures are slow and the entire message must be known prior to signature generation, which makes it unsuitable for an ongoing data stream.

Two popular hash functions are

* MD5
* SHA-1

Hash is unique for a given text. If you use the hash function on the same text again, you'll get the same hash, and you should never get the same hash with different text. Therefore hash functions are used to guarantee the data integrity.

One thing to notice is that, the input of a hash function can be of any length, but the output of the hash function has a fixed length. So two different inputs may end up with the same hash, and this is called collision. A good hash function should be strongly collision-free.

Hash functions are also irreversible, there is no way to get the given text from the hash. This makes hash functions also great for storing passwords.

Hash functions such as MD5 and SHA-1 does not prevent the man-in-the-middle attack, which means they can only provide integrity but not authentication. If the message and hash is intercepted by the third party, hash doesn't prevent him to change the message and regenerate a hash.

Keyed-Hashing, also known as Message Authentication Codes (MAC), is used to mitigate such kind of attacks. Like digital signatures, MAC can provide both authentication and integrity, unlike digital signatures, MAC is symmetric, and uses a shared key. As the most popular MAC, HMAC combines the message with a shared secret key, and then generate a hash based on that.

H((K XOR opad), H((K XOR ipad), text))

where

K is the secret key;
text is the input;
ipad is the byte 0x36 repeated B times;
opad is the byte 0x5C repeated B times;
B is the size of the input blocks;
and , is concatenation.

HMAC can use MD5 or SHA-1 as its hash function, and is denoted by HMAC-MD5 and HMAC-SHA1 respectively.

Obviously, a secure key exchange mechanism is madatory for HMAC.


Comments:
Both the scheme are popular and powerful mechanism used in high level security tool and applications. I am learning about digital signature and find the information provided in this article very useful.
digital signature certificate
 
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?