hash vs mac

14
Message Message Integrity Integrity

Upload: amindradesilva

Post on 06-May-2017

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: hash vs MAC

Message IntegrityMessage Integrity

Page 2: hash vs MAC

Hash FunctionHash FunctionA cryptographic hash function is a hash function; that is, an algorithm that takes an data block of any length and returns a fixed-size bit string (output), the hash value. Any accidental or intentional modifications to the original data will change the hash value. The data to be encoded are often called the "message," and the hash value is sometimes called the message digest or simply digest.

Page 3: hash vs MAC

The cryptographic hash function has following properties:The cryptographic hash function has following properties:it is easy to compute the hash value for any given messageit is easy to compute the hash value for any given messageUsually hash functions are publically available for useUsually hash functions are publically available for useHash functions does not use a key Hash functions does not use a key condenses a variable-length message M to a fixed sized condenses a variable-length message M to a fixed sized fingerprint (Hash value)fingerprint (Hash value)It is infeasible to modify a message without changing the hashIt is infeasible to modify a message without changing the hashIt is infeasible to generate a message that has a given hash It is infeasible to generate a message that has a given hash ((Preimage resistance) –Preimage resistance) –one wayIt is infeasible to find two different messages with the same It is infeasible to find two different messages with the same hash hash (Collision resistance)(Collision resistance)

Hash FunctionHash Function

Page 4: hash vs MAC

Cryptographic hash functions have many information security applications, notably in digital signatures.

MD5 and SHA-1 most widely used hashes along with RIPEMD-160 and SHA-2.

The MD5 Message-Digest Algorithm is a widely used cryptographic hash function that produces a 128-bit (16-byte) hash value. MD5 has been utilized in a wide variety of security applications, and is also commonly used to check data integrity. MD5 was designed by Ron Rivest in 1991 to replace an earlier hash function, MD4.

SHA-1 A US government standard (similar to MD5) and produces160 bit output

Hash FunctionHash Function

Page 5: hash vs MAC

Hash FunctionHash Function

Page 6: hash vs MAC

Message Authentication Code Message Authentication Code (MAC)(MAC)

MAC Algorithm

Plain Text

Key

MAC

Page 7: hash vs MAC

Message Authentication Code Message Authentication Code (MAC)(MAC)

An algorithm that creates a small fixed-sized An algorithm that creates a small fixed-sized blockblock depending on both message and some keydepending on both message and some key Not reversibleNot reversible

Can be appended to message as a Can be appended to message as a signaturesignature Receiver performs same computation on Receiver performs same computation on

message and checks it matches the MACmessage and checks it matches the MAC Provides assurance that message is Provides assurance that message is

unaltered and comes from senderunaltered and comes from sender

Page 8: hash vs MAC

Message Authentication Code Message Authentication Code (MAC)(MAC)

Page 9: hash vs MAC

Generates a small fixed-sized block of dataGenerates a small fixed-sized block of data Based on message + secret keyBased on message + secret key MAC = C(K,M)MAC = C(K,M) appended to message when sentappended to message when sent

The MAC value protects both a message's data The MAC value protects both a message's data integrity as well as its authenticity, by allowing integrity as well as its authenticity, by allowing verifiers or receiver (who also possess the secret verifiers or receiver (who also possess the secret key) to detect any changes to the message content.key) to detect any changes to the message content.

Message Authentication Code Message Authentication Code (MAC)(MAC)

Page 10: hash vs MAC

Message Authentication Code Message Authentication Code (MAC)(MAC)

Page 11: hash vs MAC

As illustrated the MAC provides As illustrated the MAC provides authenticationauthentication can also use encryption for secrecycan also use encryption for secrecy

generally use separate keys for eachgenerally use separate keys for each can compute MAC either before or after encryptioncan compute MAC either before or after encryption is generally regarded as better done beforeis generally regarded as better done before

why use a MAC?why use a MAC? sometimes only authentication is neededsometimes only authentication is needed sometimes need authentication to persist longer than sometimes need authentication to persist longer than

the encryption (eg. archival use)the encryption (eg. archival use) Note that a Note that a MAC is not a digital signatureMAC is not a digital signature

Message Authentication Code Message Authentication Code (MAC)(MAC)

Page 12: hash vs MAC

Requirements for MACsRequirements for MACs

Taking into account the types of attacks, MAC need Taking into account the types of attacks, MAC need to satisfy the following:to satisfy the following:

1.1. knowing a message and MAC, is infeasible to find knowing a message and MAC, is infeasible to find another message with same MACanother message with same MAC

2.2. MACs should be uniformly distributedMACs should be uniformly distributed3.3. MAC should depend equally on all bits of the MAC should depend equally on all bits of the

messagemessage

Message Authentication Code Message Authentication Code (MAC)(MAC)

Page 13: hash vs MAC

Keyed Hash Functions as MACsKeyed Hash Functions as MACs Design MAC algorithm based on a hash Design MAC algorithm based on a hash

function function Because hash functions are generally fasterBecause hash functions are generally faster Cryptographic hash function code is widely availableCryptographic hash function code is widely available

Therefore design a hash to includes a key Therefore design a hash to includes a key along with message as the inputalong with message as the input original proposal: original proposal: KeyedHash = Hash(Key|Message) KeyedHash = Hash(Key|Message) But some weaknesses were found with this But some weaknesses were found with this

So, Eventually led to development of So, Eventually led to development of HMACHMAC

Page 14: hash vs MAC

HMAC Design ObjectivesHMAC Design Objectives To use , hash functions without modificationsTo use , hash functions without modifications Allow for easy replaceability of already embedded Allow for easy replaceability of already embedded

(currently in use) hash functions(currently in use) hash functions Preserve original performance of hash function Preserve original performance of hash function

without significant degradationwithout significant degradation Use and handle keys in a simple way.Use and handle keys in a simple way. To allow any hash function to be usedTo allow any hash function to be used

eg. MD5, SHA-1, RIPEMD-160, Whirlpooleg. MD5, SHA-1, RIPEMD-160, Whirlpool