Hashing vs. Signing Binaries

后端 未结 4 1795
情深已故
情深已故 2021-02-14 11:00

If you want to ensure that a file is valid (untampered and came from the correct/expected source), there are two things you can do: hashing, and signing

4条回答
  •  旧巷少年郎
    2021-02-14 12:05

    The big difference between providing some data (an executable a document, whatever) along with a hash and providing the same data with a signature is with the hash, both the data and the hash value come from the same place. So, if someone can compromise one of them, he can probably also compromise the other.

    For example, if I can hack into your web server, I can easily replace your executable with my own version and replace the hash value with the correct hash for my executable.

    If you sign your executable, I can't just produce another signature for a different executable and replace your original signature. The signature verifies both the hash of the original data (the data has not changed since being signed) and that the signature was generated by your private key.

    Of course, this all assumes that people who receive your signed executable have received your public key in some trusted way. If I can trick people into using my public key instead of yours, then I can hack into your website and replace your signed executable with my own. That's why we have certificate authorities.

    This page has a high level overview of digital signatures.

提交回复
热议问题