哈希和 MAC(消息验证码)有什么区别? [英] What is the Difference between a Hash and MAC (Message Authentication code)?

查看:72
本文介绍了哈希和 MAC(消息验证码)有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hash 和 MAC(消息认证码)有什么区别?

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?

推荐答案

主要区别是概念上的:虽然哈希用于保证数据的完整性,MAC保证完整性和身份验证.

The main difference is conceptual: while hashes are used to guarantee the integrity of data, a MAC guarantees integrity AND authentication.

这意味着在没有任何外部输入的情况下从消息中盲目生成哈希码:您获得的是可用于检查消息在传输过程中是否有任何更改的东西.

This means that a hashcode is blindly generated from the message without any kind of external input: what you obtain is something that can be used to check if the message got any alteration during its travel.

MAC 使用私钥作为它在生成代码时使用的散列函数的种子:这应该向接收者保证,不仅消息没有被修改,而且发送它的人是我们的期望:否则攻击者无法知道用于生成代码的私钥.

A MAC instead uses a private key as the seed to the hash function it uses when generating the code: this should assure the receiver that, not only the message hasn't been modified, but also who sent it is what we were expecting: otherwise an attacker couldn't know the private key used to generate the code.

根据维基百科,你有:

虽然 MAC 函数类似于加密哈希函数,但它们具有不同的安全要求.为了被认为是安全的,MAC 功能必须在选择明文攻击下抵抗存在伪造.这意味着即使攻击者可以访问拥有密钥并为攻击者选择的消息生成 MAC 的预言机,攻击者也无法在不执行不可行的计算量的情况下猜测其他消息的 MAC.

While MAC functions are similar to cryptographic hash functions, they possess different security requirements. To be considered secure, a MAC function must resist existential forgery under chosen-plaintext attacks. This means that even if an attacker has access to an oracle which possesses the secret key and generates MACs for messages of the attacker's choosing, the attacker cannot guess the MAC for other messages without performing infeasible amounts of computation.

当然,虽然它们有相似之处,但它们的实现方式不同:通常 MAC 生成算法基于哈希码生成算法,并带有关心使用私钥的扩展.

Of course, although their similarities, they are implemented in a different way: usually a MAC generation algorithm is based upon a hash code generation algorithm with the extension that cares about using a private key.

这篇关于哈希和 MAC(消息验证码)有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆