for example here they put a gpg signature to verify what you download is what they really made. but why they just don't put a SHA256 hash value ? because its much more faster to check it and sometimes gpg may not be installed on our machine but SHA is something everywhere available also you even can upload the file on virustotal.com and it give you the hash !

if hash is secure why they use gpg if is not secure why we use hash values for everything ?

  • 3
    While anybody could create/modify a hashfile, only one could create a valid signature. Checksum is usefull for transfert or hardware issue, and signature is usefull for ensuring source. Mar 2, 2013 at 21:27
  • @F. Hauri the guy who could create/modify a hash on server can create/modify signature as well ...
    – user892001
    Mar 2, 2013 at 21:36
  • 1
    No if signing key is (correctly) password protected (Nota: Private key have to NOT be stored on public server!). Mar 2, 2013 at 22:54

3 Answers 3


When you check the hash value, you have to check it against a reference hash value: this does not solve the problem, just moves it around. You still have to make sure that you got the correct hash value. If the hash value is obtained through the same channel as the software package (i.e. you both got them from a HTTPS Web page), then you have gained nothing against attackers: if the attacker could alter the package, then he could also recompute the hash and alter the hash value you obtain so that you would not see any problem. Typically, someone who hijacks the download server itself.

Hash values "alone" are good at detecting random transmission errors (e.g. a router with bad RAM), not intentional alterations.

Digital signatures offer an enhanced service: they link the package to the individual who produced it, regardless of intermediate servers. With a GPG signature, you can download the package from a shady mirror site and still do not have to fear the package being bugged.

As for performance, know that signature verification will have the same cost as computing a hash, plus an extra mathematical operation which even an asthmatic PC should be able to do within a few milliseconds. I seriously doubt you could actually observe that extra cost.

  • if attacker can hack the server he can change signature/publickey as well ...
    – user892001
    Mar 2, 2013 at 21:37
  • 3
    Only if the keys are stored on the server, which would be a bad thing to do. Keys should be stored somewhere where they cannot easily be accessed by intruders.
    – LMS
    Mar 2, 2013 at 22:28
  • It helps a lot with the "CDN" model, you can trust a package from a third party if you verify the keys separately obtained from a trusted source (publisher). The distributed signature (e.g. .asc) can be compromised too, but it's somewhat harder to forge a signature for a specific key. Mar 3, 2013 at 20:13
  • 2
    @user892001 PGP Public Keys are usually stored on public servers, e.g. keys.gnupg.net. And there's the web of trust - others can sign the public key to certify the actual authenticity, and their keys can be signed as well etc. And if this chain contains someone you actually trust to not lie, it's a lot less likely that the file's signature is from someone else Mar 8, 2013 at 15:03

Hashes provide a service to ensure integrity of something. It is only reliable if you can be sure that you obtained this hash value from a trusted source, which that can not be altered or masqueraded.

(GPG) digital signatures combine a hash with a cryptographic process which ensures not only the integrity of the signed message (file, mail, ...) but also the authenticity of this message. By mean of these digital signatures (usually asymmetric cryptography), you can be sure that the content you checked has not been tampered with and has been issued by the owner of the key (who has access to the private key).

However, digital signatures share the same fate has simple hashes: the chain of trust. You can only be sure that this signature is okay if you can guaranty the public key you use to check the message belongs to the "real" person and not a fake one (like a hacker).

Finally, each process is as secured as the trust you can grant to the "key" element (the hash, the public key). Hashes are not better than signatures, they simply do not serve the same purpose (hashes: integrity / signatures: integrity + authentication).


With gpg it verifies that only the person with the matching private key could have generated the signature. With just a hash check anyone could have generated the hash, the could have replaced the hash on the download page with one that matches the binary they've just uploaded. The only thing a hash check alone allows is to verify that a mirror is providing the same file as the download page that sends you to the mirror says and that it didn't suffer accidental corruption during the transfer.

I would like to add that part of the signature algorithm gpg does is to hash the file with cryptographic hashing algorithm like sha256 and is exactly how cryptographic hashing algorithms like sha256 are supposed to be used.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .