What is the Difference between a Hash and MAC (Mes

2019-03-08 01:26发布

What is the Difference between a Hash and MAC (Message Authentication code)?

By their definitions they seem to serve the same function.

Can someone explain what the difference is?

7条回答
狗以群分
2楼-- · 2019-03-08 01:58
  1. Hash functions utilize asymmetric cryptography whereas, MAC use symmetric cryptography.
  2. Cryptographic hash functions are not always a MAC, but MAC can be a cryptographic hash functions (keyed hash functions).
  3. Hash functions provide non-repudiation where MAC do no provide non-re
查看更多
霸刀☆藐视天下
3楼-- · 2019-03-08 02:01

Found this to the point answer from another forum.

These types of cryptographic primitive can be distinguished by the security goals they fulfill (in the simple protocol of "appending to a message"):

Integrity: Can the recipient be confident that the message has not been accidentally modified?

Authentication: Can the recipient be confident that the message originates from the sender?

Non-repudiation: If the recipient passes the message and the proof to a third party, can the third party be confident that the message originated from the sender? (Please note that I am talking about non-repudiation in the cryptographic sense, not in the legal sense.) Also important is this question:

Keys: Does the primitive require a shared secret key, or public-private keypairs? I think the short answer is best explained with a table:

Cryptographic primitive | Hash |    MAC    | Digital
Security Goal           |      |           | signature
------------------------+------+-----------+-------------
Integrity               |  Yes |    Yes    |   Yes
Authentication          |  No  |    Yes    |   Yes
Non-repudiation         |  No  |    No     |   Yes
------------------------+------+-----------+-------------
Kind of keys            | none | symmetric | asymmetric
                        |      |    keys   |    keys

Please remember that authentication without confidence in the keys used is useless. For digital signatures, a recipient must be confident that the verification key actually belongs to the sender. For MACs, a recipient must be confident that the shared symmetric key has only been shared with the sender.

Click here for more info

查看更多
够拽才男人
4楼-- · 2019-03-08 02:05

A hash is a function that produces a digest from a message. A cryptographically secure hash is for which it is computationally infeasible to generate a message with a given digest. On its own a hash of a message gives no information about the sender of a given message. If you can securely communicate the hash of a message then it can be used to verify that a large message has been correctly received over an unsecured transport.

A message authentication code is a way of combining a shared secret key with the a message so that the recipient of the message can authenticate that the sender of the message has the shared secret key and the no-one who doesn't know the secret key could have sent or altered the message.

An HMAC is a hash-based message authentication code. Usually this involves applying a hash function one or more times to some sort of combination of the shared secret and the message. HMAC usually refers the the algorithm documented in RFC 2104 or FIPS-198.

A MAC does not encrypt the message so the message is in plain text. It does not reveal the secret key so a MAC can be sent across on open channel with out compromising the key.

查看更多
We Are One
5楼-- · 2019-03-08 02:05

HASH FUNCTION: A function that maps a message of any length into a fixed length hash value, which serves as the authenticator.

MAC: A function of the message and a secret key that produces a fixed length value that serves as the authenticator.

查看更多
小情绪 Triste *
6楼-- · 2019-03-08 02:17

Basically the main difference is MAC uses a private key and hash does not use any keys. Because of that MAC allows us to achieve authentication.

查看更多
祖国的老花朵
7楼-- · 2019-03-08 02:18

A Hash is a summary or a finger print of a message and provide neither integrity nor authentication itself, as is it is susceptible to man-in-the-middle attack. Suppose A wants to send a message M, combined with hash H of M, to B. Instead C capture the message and generate Message M2 and hash H2 of M2, and sends it to B. Now B, by no mean can verify whether this is the original message from A or not. However, hash can be used in some other ways to achieve integrity and authentication, such as MAC.

A MAC which is also a summary of the message provide Integrity and Authentication. MAC can be computed in many ways. The simplest method is to use a hash function with two inputs, the message and a shared secret key. The use of the shared secret key adds the Authentication ability to the MAC, and thus provide integrity and authentication. However, MAC still does not provide non-repudiation, as any of the party(es) having the shared secret key can produce the message and MAC. Here comes the Digital Signature and Public Key Cryptography in action.

查看更多
登录 后发表回答