There are two distinct purposes for file verification:
A. to protect against accidental corruption during downloading
to protect against a MITM-attack, or even webserver compromise if the private pgp key has not been compromised.
For A, a hashing function like SHA-1, MD5, ... is more than satisfactory. However it would do no harm to use a more modern hash that is still considered cryptographic.
For B, things get seriously more complicated. For starters you should be doing all communications by correctly certified HTTPS (SSL):
You're in luck, apache does provide such access to their website.
Now lets make an assessment of what risks remain and what risks have been mitigated.
A simple MITM-attack is no longer possible. To still execute a MITM-attack an attacker could however:
Obtain a certificate for this website from a Certificate Authority by:
- tricking them into believing that they own this website and paying them.
- tricking browsers in accepting them as a CA (note that several governments are included in browsers as CA, and that existing CA's can delegate the trust they receive to third parties without any notification, see the etisalat incident) If this then comes to light that this subCA does some bad shit, and the CA refuses to revoke this subCA then there is still all the websites that are legitimately certified by the CA, which causes a pressure on browsers to keep trusting the CA.
- by breaking in and stealing the private key of the CA
- by forcing them by law to make such a certificate (subpoena)
Steal the private key of the server sending the data.
Wow, that might not be perfect, but imagine having to do something like that. I bet your geek baby brother upstairs doesn't often come round to that. It considerably raises the bar for an attacker.
Further, if an attacker could just compromise the server of the website, they could just change the file as well as the md5, sha1 or other hashes as well as the pgp keys it serves, and therefore wouldn't have to do a MITM-attack. This last option is by far the preferred as it is often simpler to get into a server than to get a certificate.
Note that sometimes the hashes and downloaded files are not served from the same location. In itself that is good. It would complicate the work of an attacker. So, say I have a https certified website and you offer some files for download. I might offer to put the hashes of those files on my website to help you out. Or in case of apache, the actual downloads are on mirrors which do not have https.
Now the hashes are the crucial link in the verification. Note that MD5 has been broken and that SHA1 is on its way. It is bad from apache to still provide these for security purposes. If all else fails and both of them are available, check them both. A collision attack to yield both the same md5 and sha1 values for two file has not yet been discovered as far as I know.
What if https is not available for the given site. Well, a file served to you from that server is just as safe as a hash on the website (if it is on the same server), or a pgp key, or anything else for that matter.
If https does not satisfy your need for security (and really it shouldn't) or https was not available for the website, what can you do?
Using a pgp key to verify signatures might allow you to verify the files if you can get a legitimate public key from the signer. PGP uses a system called Web of Trust in order to verify its keys, as opposed to the central Certificate Authorities used in HTTPS.
When you include a pgp key in your keyring it is not necessarily known if this key really belongs to the user id that comes with it. To be able to verify that, users sign each others keys after verifying each other's identity, for example by meeting in person or calling that person. Further it is possible to construct a chain between you and say the apache signing key if you haven't verified them in person but someone you met did, or they met someone who did...
Thus, when a new key enters your keyring, and none of the other keys in your keyring that are already verified have signed this key and you try to use it, gpg or pgp will issue a warning, just like browsers give you a warning if you surf to an https website who's certificate can not be verified.
Apart from signing the key yourself to verify that it is legitimate the software might automatically accept it as valid if one of your fully trusted contacts signed it, or 3 marginally trusted contacts signed it... That is implementation/user dependant. Just as your browser will silently accept any SSL certificate if it is signed by a CA that is known to be trusted (by your browser that is).
What does this all mean in practice? Well, if you are in the middle of the geek-knows-geek world, this probably gives you a reasonable protection. For the rest of the world, it is more like a monstertruck without petrol.
For ordinary people pgp and the web of trust have some considerable problems:
- improper use of gpg and web of trust breaks its security
- proper use of it is difficult, complicated and free tools like gnupg and it's frontends are shaggy
- if you or the other side are not well anchored in the web of trust, verifying keys is next to impossible
- a chain of trust really means you have to trust all the people in between. The longer it gets the less safe. If say all your links to the apache signing key pass through the same persons that might set up a MITM-attack, than pgp only serves as a false sense of security.
- Web of Trust helps authorities to draw a map of your social network just like facebook.
It does however not suffer from some of the limitations of https, like it is not possible with pgp to convince one company to take your money and give you a certificate that will fool the entire world. On the other hand, it is considerably less usable for the general public. It illustrates how simplicity is a key determinant for security.
In conclusion it is important to realize that HTTPS and PGP are not mutually exclusive. No one prevents you from trying to use both to the best of your ability. What one should realize is that any chains of security are only as strong as the weakest link. Say a pgp key downloaded through https has the weaknesses of pgp and the weaknesses of https. Every link in a chain adds its weaknesses to the result.
I will keep adding interesting links to this answer as I discover them.