HMAC and SHA-1 weakness? Imagine the following scenario:


Select known data (known to several parties)
Mix data with secret key and generate SHA-1 hash
Mix SHA-1 hash with secret key and generate HMAC


The purpose is to verify the integrity of the data - to ensure that data has not been altered after the generation of the HMAC.

My question is:


Is there any weakness to using a SHA-1 hash rather than for example SHA-256 in this scenario?
Does the use of SHA-1 make it easier to for example extract the secret key compared to SHA-256?
Select known data (known to several parties)


If the data is already known then there is no reason to distribute it. You could just refer to it.


  Mix data with secret key and generate SHA-1 hash


That's what you use a HMAC for.


  Mix SHA-1 hash with secret key and generate HMAC


You'd normally use your symmetric key only once.




  Is there any weakness to using a SHA-1 hash rather than for example SHA-256 in this scenario?


It's got smaller output and therefore less protection against brute force attacks, but HMAC in itself isn't vulnerable. SHA-1 is however under attack, with collision resistance the first to go. If you manage to muck up step 2 then you're likely in trouble. If you use HMAC then you may not be directly vulnerable to current known attacks. But attacks only get better.


  Does the use of SHA-1 make it easier to for example extract the secret key compared to SHA-256?


No, the fact that SHA-1 may be less collision resistant doesn't mean that the algorithm is reversible.



That said, unless there are pressing requirements to use SHA-1, e.g. backwards compatibility, I would rather choose SHA-256 or SHA-512/256.