7
$\begingroup$

I am using a Java JWT library jose4j. There is a list of digital signatures algorithms which can be used.

  • HMAC using SHA-2
  • RSASSA-PKCS1-V1_5 Digital Signatures with with SHA-2
  • Elliptic Curve Digital Signatures (ECDSA) with SHA-2
  • RSASSA-PSS Digital Signatures with SHA-2

I tried to understand what the advantages/disadvantages of the algorithms are but Google searches of "HMAC vs RSASSA-PKCS1-V1_5" did not return results.

What are the pros/cons of these algorithms?

$\endgroup$
8
$\begingroup$

My answer is not original, as I am simply summing up information from different questions already solved in this site. Nevertheless, I thought it could be interesting to collect everything in one answer.

The first thing you have to know is to differentiate between a digital signature and a message authentication code (MAC). In this case, HMAC is a MAC and the rest (RSA and ECDSA) are digital signatures.

This answer to a previous question gives you an excellent overview of the different characteristics of both categories. As you can see, the main difference between HMAC and conventional digital signatures are:

  • HMAC uses symmetric keys (so both parties have to share a common secret), while Digital Signatures use asymmetric keys (i.e., public key crypto, so the prover uses a secret key, and the verifier uses an associated public key). This also has implications regarding performance, since symmetric crypto is usually much faster.
  • Digital Signatures provide non-repudiation of origin, while HMAC don't.

That is the first differential factor between them. Now, we could focus on the difference among digital signatures schemes:

  • RSASSA-PKCS1-V1_5 Digital Signatures with with SHA-2
  • Elliptic Curve Digital Signatures (ECDSA) with SHA-2
  • RSASSA-PSS Digital Signatures with SHA-2

In this case, the main differences are not about functionality, but about the underlying mathematical primitives, namely RSA vs Elliptic Curves. This also has been covered before. To sum up, the implications are mainly centered on performance, size of keys, implementations, etc.

Finally, this other answer covers the difference between RSASSA-PSS and RSASSA-PKCS1-V1_5. To sum up, the difference is mainly of theoretical interest, concerning the proof of security.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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