Use cases for CMAC vs. HMAC?

Use cases for CMAC vs. HMAC?HMACwastherefirst(theRFC2104isfrom1997,whileCMACisfrom2006),whichisreasonenoughtoexplainitsprimacy.IfyouuseHMAC,youwillmoreeasilyfindtestvectorsandimplementationsag…

HMAC was there first (the RFC 2104 is from 1997, while CMAC is from 2006), which is reason enough to explain its primacy. If you use HMAC, you will more easily find test vectors and implementations against which to test, and with which to interoperate, which again explains continuedprimacy. Being the de facto standard is a very strong position.

On many embedded systems, one may expect HMAC to be faster than CMAC, because hash functions are usually faster than block ciphers. This is not true if the platform includes some hardware optimization for a specific block cipher (e.g. dedicated AES opcodes), or if the messages are short (HMAC has the same asymptotic cost as hashing, but also a fixed overhead), or if you do something stupid like selecting a slow hash function as basis for HMAC (e.g. Whirlpool). As with all performance things, actual measures are needed to reach any kind of definitive conclusion.

If you need to both encrypt and MAC, then the smart thing to do is not HMAC or CMAC, but rather to use an authenticated encryption mode which will do both properly, simultaneously, and at a lower cost (or at least so it is hoped). Usual candidates are EAX and GCM. There is an ongoing open competition for finding new, better AE modes.

 

HMAC首先出现在那里(RFC2104是1997年的,而CMAC是2006年的),这足以解释其重要性。如果您使用HMAC,您将更容易找到测试向量和实现,根据这些向量和实现进行测试,并与哪些向量和实现进行互操作,这再次解释了持续的优先性。作为事实上的标准是一个非常强大的地位。              在许多嵌入式系统中,人们可能期望HMAC比CMAC更快,因为哈希函数通常比块密码更快。如果平台包含特定块密码的某些硬件优化(例如专用的AES操作码),或者消息较短(HMAC与散列具有相同的渐进成本,但也有固定开销),或者如果您做了一些愚蠢的事情,例如选择一个慢散列函数作为HMAC的基础(如漩涡)。与所有的性能一样,需要实际的度量来得出任何类型的确定结论。              如果您同时需要加密和MAC,那么明智的做法不是使用HMAC或CMAC,而是使用一种经过身份验证的加密模式,该模式既能正确地、同时以较低的成本(或者至少希望这样做)。通常的候选人是EAX和GCM。在寻找新的、更好的AE模式方面,存在着持续的公开竞争。 

今天的文章Use cases for CMAC vs. HMAC?分享到此就结束了,感谢您的阅读,如果确实帮到您,您可以动动手指转发给其他人。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/25224.html

(0)
编程小号编程小号

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注