File and Email Signing and Encryption

File and email encryption provide data confidentiality and authenticity. The goal is for encrypted data to be unreadable by anybody beside the intended recipient. To achieve encryption, the sender uses either a key identical to the recipient's (symmetric keys) or a private key mathematically linked to the public key distributed to others. See the section "How to Obtain Public Keys," later in this chapter, which describes how the recipient can obtain the correct key.

There are two ways to encrypt data: the first one is to do crypto at the application layer, while the second is to do it at the transport layer. A number of protocols support transport layer encryption (e.g., HTTPS for the Web, SMTPS to deliver email, POP3S and IMAPS to retrieve emails from a mailbox). However, none of those guarantee email end-to-end encryption at the transport layer. In effect, each SMTP relay server will decrypt your message at reception and re-encrypt to the next relay if that next relay supports SMTPS.

Encrypting data at the application layer is the best option to guarantee confidentiality. The two most popular standards to do so are OpenPGP and Secure/Multipurpose Internet Mail Extensions (S/MIME). OpenPGP also provides files encryption.

In addition to confidentiality, those two standards also provide email authenticity through digital signatures. Email digital signatures are the best way to avoid phishing (see Chapter 17) and avoid online identity theft. Signing requires the use of a key, but the signed data can be read by anybody.

Last but not least, you can also use OpenPGP to sign files. Digital signature is not the same as MD5 hashing. Large files available for download from the Internet are often provided with an MD5 hash file. This is to ensure that the downloaded file on the client's machine is the same as the file on the web server, but it does not ensure that it is the original file put in place by its author.

Tip

Message-Digest algorithm 5 (MD5) is a hash algorithm that produces a fixed-length 32-byte string. It guarantees file integrity only.

Several widely used software applications have been modified by inserting a backdoor and then been presented as a legitimate copy. For example, see the libpcap source code that included a backdoor in 2002 (CERT advisory CA-2002-30). To avoid this type of attack, software should be signed and put online along with the resulting signature and its author's public key. Users downloading the file should verify that the signature matches the binary prior to running it.