I'm going to guess the latter, but just wanted to ask here.

I want to have a relatively short signature, and my goal is to take a substring of the resulting hash.

  • $\begingroup$ Duplicate of HMAC-SHA1 vs HMAC-SHA256 and HMAC-SHA1 vs HMAC-SHA256 for data storage. In sum, use HMAC-SHA-256 because SHA-1 shouldn't be used for any new protocols, but HMAC-SHA-1 isn't broken. $\endgroup$ Nov 27, 2022 at 8:18
  • $\begingroup$ HMAC doesn't depend on collision resistance of the hash used, so HMAC-SHA1 isn't insecure. However, as a general practice, it's always better to HMAC-SHA256 for newer implementations $\endgroup$
    – user93353
    Nov 27, 2022 at 10:30
  • 1
    $\begingroup$ @samuel-lucas6 Neither directly addresses the substring issue, although it is mentioned in one of the comments in the first question. That said, taking a substring from a well distributed randomized value doesn't alter the strength of the algorithm. Uh, maybe that's the answer :) $\endgroup$
    – Maarten Bodewes
    Nov 27, 2022 at 16:39
  • $\begingroup$ Are you asking about HMAC-SHA1 with a 160-bit tag vs plain SHA-256 truncated to 160 bits? $\endgroup$
    – forest
    Nov 27, 2022 at 22:47
  • $\begingroup$ yes that's what I meant $\endgroup$ Nov 28, 2022 at 3:12


Your Answer

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

Browse other questions tagged or ask your own question.