Better security than SHA1 for signature? An application that I maintain uses Sparkle Update to update itself. I expect attacks from high level attackers (China, USA's NSA, etc.) and have some questions about how secure the cryptography Sparkle uses actually is. Specific examples of good practices would be much appreciated.




Creating public/private signing keys.


Sparkle uses the following to create public/private signing keys:

openssl dsaparam 2048 &lt; /dev/urandom &gt; dsaparam.pem
openssl gendsa dsaparam.pem -out dsa_priv.pem
openssl dsa -in dsa_priv.pem -pubout -out dsa_pub.pem


1.1 Is using "/dev/urandom" a good idea on OS X? 

1.2 Are there any other problems here? (I will probably generate a 4096-bit or larger key instead of the 2048-bit one.)




Signing the application


Sparkle protects from forged updates by signing the updates. It uses the following to generate a signature:

openssl dgst    -sha1 -binary &lt; in-file | openssl dgst -dss1 -sign private-key-file


Would changing it to

openssl dgst  -sha256 -binary &lt; in-file | openssl dgst -dss1 -sign private-key-file


(and changing the signature verification to verify the signature on a SHA256 hash, of course)

be enough to avoid the weakness in SHA1?

Or is there also a problem with "openssl dgst -dss1"?

Thanks in advance.
Is using /dev/urandom a good idea on OS X?


Yes. /dev/urandom is the preferred way to get random values on all modern unixes. Arguments that /dev/random are more secure is a complete myth.


  Are there any other problems here? (I will probably generate a 4096-bit or larger key instead of the 2048-bit one.)


2048 bits is considered secure and likely will be until ~2030. 4096 bits is overkill — the next logical step is 3072 bits, which is roughly equivalent to a 128-bit symmetric key.


  Would changing it to [SHA-256] be enough to avoid the weakness in SHA1?


Probably. But SHA-1 collisions are only just now starting to become computationally feasible. It's worth trying to get upstream to migrate onto a more resistant hash function.