I want to know which is faster-HMAC or CMAC.I know CMAC is based on block cipher encryption,where output of each block is X-OR with the next plain text block. If security is not a concern,which will be faster to use?

  • 5
    $\begingroup$ It depends. What instance of CMAC (e.g. which cipher) do you want to use and for what do you have hardware-acceleration and against what HMAC (e.g. which hash) to compare? $\endgroup$
    – SEJPM
    Jul 9, 2016 at 12:31
  • 6
    $\begingroup$ If security is not a concern, why not simply use a fast hash like CRC32 or MurmurHash (optionally with a salt)? $\endgroup$ Jul 9, 2016 at 12:36
  • 2
    $\begingroup$ As is, it is not clear what you are asking as you do not mention potentially available hardware resources etc. Answering your which is faster is therefore impossible (or plainly opinion-based). Furthermore, you state If security is not a concern,which will be faster to use? which hints at the fact that you do not even need a CMAC or HMAC in your scenario. This makes me ask how your question is related to cryptography in the first place? Simply dropping crypto terms doesn’t magically turn your question into something crypto-related. Please edit the question & fix those issues! $\endgroup$
    – e-sushi
    Jul 9, 2016 at 16:29

1 Answer 1


Which MAC algorithm is faster - CBC based MAC's or HMAC - depends completely on which ciphers and hashes are used. Furthermore, it depends on the runtime environment that contains the hash and cipher implementations.

With regard to the leading CPU architecture for PC's, there are the Intel whitepapers. Both AES and SHA-2 performance can be enhanced using CPU constructions. See for AES the AES-NI page on Wikipedia. Likewise, the Intel SHA extensions for later CPU's can also be found there. Both are also available on later AMD processors because of the cross licensing agreements between those firms.

Obviously not all runtimes do get direct support for these constructions. At that point it is very much dependent on the implementation. If you can get away with using HMAC-SHA-1 then it is likely that SHA-1 outperforms any other MAC algorithm (besides MD5, which is also secure for smaller HMAC output sizes). In general you're best off to test which specific algorithms perform best on a platform.

OpenSSL CLI has a speed option that can be utilized, for instance use:

openssl speed sha512 aes-256-cbc

to see the speed of the CPU with regards to bytes processed per second (I'm always pretty stumped when I see them on my lowly mobile i7 CPU).

  • 1
    $\begingroup$ Note: Perfomance of AES-NI has been continiously improved by Intel since its introduction. Also see eBASC for a "proof". $\endgroup$
    – SEJPM
    Jul 9, 2016 at 17:57
  • $\begingroup$ Note that the difference for very small messages may be somewhat off as the pre/post processing (inclusion of the key) will take time as well. $\endgroup$
    – Maarten Bodewes
    Jul 9, 2016 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.