To my understanding one of the main advantages HMAC has over RSA is that HMAC is faster to compute.
My question is: How much faster? Say you are signing a SHA-1 hash function 1000 times a day. How much faster will HMAC be over RSA (2048 bit key)?
To my understanding one of the main advantages HMAC has over RSA is that HMAC is faster to compute.
My question is: How much faster? Say you are signing a SHA-1 hash function 1000 times a day. How much faster will HMAC be over RSA (2048 bit key)?
Asymmetric signatures are one of the slowest operations (on relatively small sizes of data) around. RSA signature generation is particularly slow, as it requires modular exponentiation over the private exponent. It's possible to use Chinese Remainder Theorem and/or multi-prime RSA, but those kind of optimizations won't deliver the same performance as hashing.
The specification of the algorithm above is already an indication that the speed difference of HMAC and signatures depends on a lot of parameters:
For large amounts of data and an identical hash / hash implementation it is likely that RSA signature generation is only a constant value larger than HMAC, as both simply use a single pass of the hash algorithm over the data.
To view the difference for a specific implementation and signature / HMAC configurations, use openssl speed hmac rsa
on the command line. Even then the results depend on the build configuration of OpenSSL.
Usually this question doesn't come up at all. Key pairs and symmetric keys are often used for different purposes in protocols. For instance, you cannot build a PKI (certificate / key infrastructure) with just HMAC; PKI requires asymmetric algorithms a key pairs.