Hashing vs. Signing Binaries

后端 未结 4 1796
情深已故
情深已故 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 11:43

    The difference is as you said: a hacker can update a hash to match the tampered-with file, but cannot generate a valid signature.

    Signing is done with the private key, verification with the public key. You said the opposite above. It's also typically done on the hash of the file and not the file itself for practical reasons.

    0 讨论(0)
  • 2021-02-14 11:55

    Hash is a output with fixed length of characters(or bits if represented in binary) for a specific data that is passed into a function. Hash is irreversible.The hash value for a particular data is always same. If a single bit in data changes almost entire hash for the altered data is changed. The process of calculating a hash is called hashing.

    In Asymmetric cryptography each communicating party has his own key pair (private key and public key). As name suggest , private key is usually kept secret and public key is shared. These keys are as such in nature that if one is used to encrypt then the only other key pair can decrypt.

    To achieve non repudiation(sender cannot deny he sent message) and to Authenticate specific entity to receive data , public key is shared to them so that they can decrypt anything that is encrypted by the sender using the corresponding private key that is with the sender(only with sender i.e secret) But note that confidentiality is week in this example as sender does not know and cannot guarantee if public key was compromised to an unknown.

    when private key is used to encrypt a Hash then it becomes a signature and the process is called signing. This achieves Authenticity (that data is coming from a genuine guy as private key is used) and also Integrity is assured because receiver verifies the Hash upon receiving data by decrypting the hash using corresponding public key given to him by sender and then calculating the same hash on his own and matching it.

    0 讨论(0)
  • 2021-02-14 12:02

    Signing verifies two things -- that the file has not been tampered with, and the identity of the signer. If you can be sure that entity giving you the hash is absolutely the entity that is supposed to be giving you the file, then the two are equivalent. Signing and certificate authorities are a way of ensuring that trust relationship.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题