022.3 Lesson 1
Certificate: |
Security Essentials |
---|---|
Version: |
1.0 |
Topic: |
022 Encryption |
Objective: |
022.3 Email Encryption |
Lesson: |
1 of 1 |
Introduction
In today’s digital landscape, email remains a critical communication tool, but it is also vulnerable to interception and unauthorized access. To safeguard sensitive information exchanged via email, encryption technologies such as OpenPGP and S/MIME provide confidentiality, integrity, and authenticity. Understanding these two encryption standards is essential for anyone involved in secure communications.
Open Pretty Good Privacy (OpenPGP) and Secure/Multipurpose Internet Mail Extensions (S/MIME) are two widely adopted protocols for encrypting and digitally signing email messages. OpenPGP relies on a decentralized trust model, allowing users to generate and manage their own encryption keys, whereas S/MIME operates with a centralized trust model, using digital certificates issued by trusted Certificate Authorities (CAs). Both standards offer encryption to protect the content of an email message from being read by unintended recipients, as well as digital signatures to verify the sender’s identity and ensure the message has not been tampered with.
We will explore Mozilla Thunderbird, a cross-platform email client, that is known for supporting and integrating both OpenPGP and S/MIME, enabling end-to-end encryption. Configuration typically involves setting up OpenPGP and S/MIME, generating public and private key pairs, importing X.509 certificates, and managing the secure sending and receiving of encrypted messages.
Email Encryption and Digital Signatures
To encrypt email, systems use public key or asymmetric cryptography. In contrast to symmetric cryptography, which relies on the same key for both encryption and decryption, public key cryptography provides each user with a key pair consisting of a public key and a private key.
As the names imply, the public key is shared openly and is accessible by anyone wishing to engage in encrypted email communication. The private key, however, remains confidential and is never shared or transmitted by the user.
The encryption process functions as follows: The sender uses the recipient’s public key to encrypt the plain text message, resulting in a ciphertext that is unreadable without the corresponding private key. Only the recipient, who holds the private key, can decrypt the ciphertext and access the original plain text.
Public key cryptography is employed in a variety of applications, such as secure web browsing via HTTPS (Hypertext Transfer Protocol Secure), secure email with S/MIME or PGP, and digital signatures, which ensure the authenticity and integrity of digital documents.
Two widely used algorithms in public key cryptography are RSA and DSA. RSA is named after its creators (Ron Rivest, Adi Shamir, and Leonard Adleman), while DSA stands for Digital Signature Algorithm. A more recent development is elliptic curve cryptography, which includes the Elliptic Curve Digital Signature Algorithm (ECDSA).
OpenPGP
As you can learn from the OpenPGP website, this technology was originally derived from the PGP software created by Phil Zimmermann. Today, OpenPGP is the most widely used email encryption standard. To show how it works, we will be using GNU Privacy Guard (GnuPG or GPG for short), a free OpenPGP implementation for encrypting and digitally signing your data and communication. GPG is published under the terms of the GNU General Public License.
GPG can use both symmetric-key and asymmetric-key cryptography. Out of all the algorithms supported, AES is perhaps the best-known for symmetric encryption, whereas RSA and ECDSA are used by GPG most often for asymmetric encryption.
Let’s start by opening a terminal and symmetrically encrypting a file containing a message in plain text:
$ echo "Hello world" > message_file.txt $ gpg --symmetric message_file.txt
You will be prompted for a passphrase twice and the encrypted file message_file.txt.gpg
will be generated. If you try to read the text now, you will get some jibberish like the following:
$ cat message_file.txt.gpg ???_?#?[??Qw?h:0???V?)??z/LBzL>?ϧQ$?֫?#U.srm[?.3?O??V?p!\@!J?w?|??90?,R??
To unencrypt it, just use the --decrypt
option and provide the passphrase when prompted:
$ gpg --decrypt message_file.txt.gpg gpg: AES256.CFB encrypted data gpg: encrypted with 1 passphrase Hello world
You can also sign and encrypt the message in one command (as long as you have created a private key previously):
$ gpg --sign --symmetric message_file.txt
You can go up one level and use GPG in a more sophisticated way by asymmetrically encrypting a message for a particular recipient. For that, you will have to create a key pair. Although we will learn how to easily generate a key pair using Mozilla Thunderbird later in the lesson, it is interesting to note that you can also use gpg
on the command line to do so:
$ gpg --full-generate-key gpg (GnuPG) 2.2.27; Copyright (C) 2021 Free Software Foundation, Inc. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. gpg: directory '/home/carol/.gnupg' created gpg: keybox '/home/carol/.gnupg/pubring.kbx' created Please select what kind of key you want: (1) RSA and RSA (default) (2) DSA and Elgamal (3) DSA (sign only) (4) RSA (sign only) (14) Existing key from card Your selection? RSA keys may be between 1024 and 4096 bits long. What keysize do you want? (3072) Requested keysize is 3072 bits Please specify how long the key should be valid. 0 = key does not expire <n> = key expires in n days <n>w = key expires in n weeks <n>m = key expires in n months <n>y = key expires in n years Key is valid for? (0) Key does not expire at all Is this correct? (y/N) y You need a user ID to identify your key; the software constructs the user ID from the Real Name, Comment and Email Address in this form: "Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>" Real name: Carol Doe E-mail address: carol.doe@example.com Comment: Generating keys is fun! You selected this USER-ID: "Carol Doe (Generating keys is fun!) <carol.doe@example.com>" Change (N)ame, (C)omment, (E)-mail or (O)kay/(Q)uit? O We need to generate a lot of random bytes. It is a good idea to perform some other action (type on the keyboard, move the mouse, utilise the disks) during the prime generation; this gives the random number generator a better chance to gain enough entropy. gpg: /home/carol/.gnupg/trustdb.gpg: trustdb created gpg: key 683714AD69979321 marked as ultimately trusted gpg: directory '/home/carol/.gnupg/openpgp-revocs.d' created gpg: revocation certificate stored as '/home/carol/.gnupg/openpgp-revocs.d/FFA136F2E1B69CAA35DE55CE683714AD69979321.rev' public and secret key created and signed. pub rsa3072 2023-05-03 [SC] FFA136F2E1B69CAA35DE55CE683714AD69979321 uid Carol Doe (Generating keys is fun!) <carol.doe@example.com> sub rsa3072 2023-05-03 [E]
Done! Your key pair is now ready. Other, quicker options for creating a key pair are --quick-generate-key
and --generate-key
.
Note
|
Perhaps the most important |
Asymmetric encryption entails encrypting the message using your private key together with the recipient’s public key, so that the message can be decrypted only with the recipient’s private key. To do this, you will need the recipient’s public key. You can have it shared with you or, more often, search for it on public key servers. This topic takes us directly to our next section.
The Role of OpenPGP Key Servers
The primary function of OpenPGP key servers is to store public keys and make them available for anyone who wishes to communicate securely with the key owner. When a user wants to send an encrypted email message or verify a digital signature, they can search for the recipient’s public key on a key server, ensuring that the encryption process can proceed without the need for manual key exchange.
Key servers store and serve cryptographic public keys, and are used to exchange public keys. The standard procedure is as follows (we will assume two users named Carol and John):
-
Carol creates a key pair (public and private) using GPG.
-
Carol keeps the private key.
-
Carol exports (uploads) her public key to a public key server so that John can use it.
-
John imports (dowloads) Carol’s public key into his keyring.
Now John can asymmetrically sign a message that can be decrypted only with Carol’s private key.
Note
|
The public key is usually included in a cryptographic certificate file containing not only the key but also information about its owner. |
S/MIME
Supported by the vast majority of email clients (such as Apple Mail, Microsoft Outlook, and Mozilla Thunderbird), S/MIME is a standard protocol for securing and authenticating email messages using public key cryptography: encryption and digital signatures. Thus, S/MIME ensures the confidentiality, integrity, and authenticity of email.
The following terms are often confused, so it is important to have a clear idea of what each means:
- Confidentiality
-
The message must be decrypted and read only by the intended recipient. This is achieved through encryption.
- Integrity
-
The message must reach its destination exactly as it was written (unmodified). This is achieved through digital signatures.
- Authenticity
-
The identities of sender and recipient must be verified. This is achieved by digitally signing and verifying email messages using the sender’s private key and the recipient’s public key, respectively.
S/MIME provides end-to-end security for email communication. The sender encrypts the email message using the recipient’s public key so that it can be decrypted only using the recipient’s private key. This is extremely important, as it guarantees that the message can be read only by the intended recipient and is not altered in transit by unauthorized parties.
Additionally, S/MIME provides digital signatures, which allow senders to digitally sign their messages using their private keys and recipients to verify that the message came from the alleged sender. This is done in the following way: The sender creates a digital signature by encrypting a hash of the message using their private key. The recipient can then verify the signature by decrypting the hash with the sender’s public key and comparing it with the hash they have computed themselves.
Note
|
A hash function takes in some input data or message and applies a set of algorithms to it in order to generate a unique fixed-length output: a sequence of characters or bits known as a message digest, a hash code, or simply a hash. This resulting hash is then typically used to validate the integrity of the input data. One of the advantages of hashing is that it allows data to be compared quickly and efficiently without having to compare the entire contents of the data. |
The Role of Certificates for S/MIME
To use S/MIME, both the sender and the recipient must have an S/MIME-capable email client and a digital certificate issued by a trusted Certificate Authority. Apart from the owner’s public key, the certificate contains other important identifying information and is used to prove the owner’s identity as well as the authenticity of the public key.
Some CAs provide free S/MIME digital certificates for a period of one year. You can also generate your own self-signed certificate with OpenSSL.
How PGP Keys and S/MIME Certificates are Associated with an Email Address
As already mentioned, both PGP and S/MIME are used for email encryption and digital signatures. However, they differ in the way that they associate keys or certificates with an email address.
PGP requires the user to generate a pair of PGP keys and associate the public key with their email address in the email client. This is normally done by sharing the public key on a key server. Other users can then search for the public key associated with the user’s email address on the key server and use it to send encrypted messages to the user.
On the other hand, S/MIME uses certificates to associate the public key with an email address. The digital certificate is issued by a trusted CA, which verifies the identity of the user and the authenticity of the public key. The user must have the digital certificate installed in their email client. The certificate contains the user’s public key as well as other identifying information, including the email address. Other users can then verify the user’s digital signature and encrypt messages to the user using the public key associated with their email address.
Using Mozilla Thunderbird to Send and Receive Encrypted Email
Mozilla Thunderbird is a multiplatform, free and open source email client that performs end-to-end email encryption and integrates both OpenPGP and S/MIME as well as built-in key management functionality. The following subsections demonstrate how to configure Thunderbird to asymmetrically encrypt and decrypt email.
The directions assume that Thunderbird is installed on your system and that an email account is already set up.
Configuring OpenPGP and Generating a Key Pair
Once your account is created, go to your “Inbox” tab and click the gear wheel icon (“Settings”) in the bottom left corner. Then, from the “Settings” tab, click “Account Settings” and finally “End-To-End Encryption.” You will find the screen shown in End-To-End Encryption screen.
Currently, no keys are available for your account (or S/MIME personal certificates, for that matter), so you should click the “Add key…” button. Now you can choose between importing an existing OpenPGP key for your email address or creating a new OpenPGP key from scratch. We will go for the second option (Creating a new PGP key pair).
Next you must do some configuration, such as selecting the expiration time of your key, the key type, and the key size (Configuring your key pair).
Finally, you are told about the time necessary for key generation and asked to confirm the operation (Confirming the creation of the key pair).
The key pair should now be successfully created (Key pair successfully generated).
Now you can click “OpenPGP Key Manager” to configure a number of things, such as a keyserver to use to search for public keys of your potential recipients (Key manager interface).
Configuring S/MIME and Importing a Certificate
Now we’ll turn to S/MIME. We start by obtaining and importing a valid X.509 certificate to digitally sign and encrypt mail with S/MIME. To keep the process simple, you can get a free certificate from a trusted CA. (Generating your own self-signed certificate lies outside the scope of this lesson.) Once you do that, click “Manage S/MIME Certificates”, search for your certificate on your local drive, and import it. If you are asked for a password, provide it as shown in Providing a password when importing a certificate.
Then select your certificate (Selecting an S/MIME certificate).
Next you will be asked for a second certificate that will be used by other people when sending your encrypted messages. You can choose the same certificate (Selecting a second certificate).
Finally, you can verify that your certificate is selected for both digital signing and encryption (Certificates are ready for use).
Now that you have configured both OpenPGP and S/MIME, you can go to the bottom of the page and choose your preferred encryption technology: OpenPGP, S/MIME, or automatic selection based on available keys or certificates (Preferred encryption technology).
Sending and Receiving Encrypted Email With OpenPGP
If you try to send a message to someone whose public key you have, Thunderbird lets you know that email encryption is available, and you can proceed to use it. Encryption is possible when you possess the recipient’s public key shows the message that appears at the bottom of the email message. The interface is quite user-friendly.
So if you send a message to yourself with the subject “Testing email encryption” and the body “Hi! Bye!”, you will be able to open and read it. On the right side of the screen, click the “OpenPGP” button to get information about the key (Sending and receiving email encrypted by PGP).
On the other hand, if you try to send a message to a recipient whose public key you do not have in your keyring, you will receive a message alerting you that encryption is not possible (Encryption is not possible unless you have a usable key for the recipient).
You can import public keys from files or search for them on the keyserver.
Sending and Receiving Encrypted Email With S/MIME
Similarly to what we have seen in the previous section, Thunderbird allows you to send encrypted email to someone whose certificate you have (Encryption is possible if you have a recipient’s valid certificate).
You can send a message to yourself with the subject “Retesting email encryption” and the same body as before. Again, you will be able to open it, read it and see the S/MIME security information by clicking on the “S/MIME” button on the right (Sending and receiving email encrypted by S/MIME).
If you try to send a message to a recipient whose certificate you do not have, an alert message will inform you accordingly (End-to-end encryption requires resolving key issues for the recipient).
Guided Exercises
-
Public key cryptography is based on a key pair consisting of a public key and a private key. Indicate to which type of key the following statements correspond:
Statement Public key or private key? Available to anyone who wants to send encrypted email
Must not be shared with anyone
Applied to a message in plain text to obtain a ciphertext
Used to decrypt email
Can be imported into your keyring
-
Indicate to which of the following concepts the following statements correspond: symmetric cryptography, ciphertext, certificate authority, digital signature, Mozilla Thunderbird, ECDSA, confidentiality, key pair, GPG, S/MIME.
Statement Concept A public key and its corresponding private key
The same key is used for both encryption and decryption
A trusted third-party that issues, revokes, and manages digital certificates
Used to verify the authenticity and integrity of a digital document
A free implementation of OpenPGP
A cryptographic algorithm for generating and verifying digital signatures
A message that has been turned unintelligible
A security protocol that guarantees end-to-end encryption
Guarantees that a message is read only by the intended recipient
A free and open source multiplatform email client that supports end-to-end encryption
Explorational Exercises
-
Apart from the three use cases named in the last exercise of the previous section, name two data exchange protocols that use asymmetric cryptography. Explain briefly how they work.
-
What protocols can ensure secure email exchange?
-
What protocols can ensure secure web browsing?
Summary
This lesson delves into the critical importance of email encryption in today’s digital world, focusing on two widely-used protocols: OpenPGP and S/MIME. These encryption standards ensure the confidentiality, integrity, and authenticity of email communications, providing protection against unauthorized access. OpenPGP operates on a decentralized trust model where users manage their own encryption keys, while S/MIME utilizes a centralized trust model backed by digital certificates issued by trusted Certificate Authorities (CAs). Both protocols enable encryption to prevent unauthorized recipients from reading email content and offer digital signatures to verify the sender’s identity.
The lesson also discusses the practical configuration of Mozilla Thunderbird, a popular email client that supports both OpenPGP and S/MIME for end-to-end encryption.
Answers to Guided Exercises
-
Public key cryptography is based on a key pair consisting of a public key and a private key. Indicate to which type of key the following statements correspond:
Statement Public key or private key? Available to anyone who wants to send encrypted email
public key
Must not be shared with anyone
private key
Applied to a message in plain text to obtain a ciphertext
public key
Used to decrypt email
private key
Can be imported into your keyring
public key
Indicate to which of the following concepts the following statements correspond: symmetric cryptography, ciphertext, certificate authority, digital signature, Mozilla Thunderbird, ECDSA, confidentiality, key pair, GPG, S/MIME.
+
Statement | Concept |
---|---|
A public key and its corresponding private key |
key pair |
The same key is used for both encryption and decryption |
symmetric cryptography |
A trusted third-party that issues, revokes, and manages digital certificates |
certificate authority |
Used to verify the authenticity and integrity of a digital document |
digital signature |
A free implementation of OpenPGP |
GPG |
A cryptographic algorithm for generating and verifying digital signatures |
ECDSA |
A message that has been turned unintelligible |
ciphertext |
A security protocol that guarantees end-to-end encryption |
S/MIME |
Guarantees that a message is read only by the intended recipient |
confidentiality |
A free and open-source multiplatform email client that supports end-to-end encryption |
Mozilla Thunderbird |
Answers to Explorational Exercises
-
Apart from the three use cases named in the last exercise of the previous section, name two data exchange protocols that use asymmetric cryptography. Explain briefly how they work.
Secure File Transfer Protocol (SFTP) and Secure Shell (SSH) secure file transfers between a client and a server.
A Virtual Private Network (VPN) provides secure and authenticated communication between remote devices over an insecure network such as the internet.
-
What protocols can ensure secure email exchange?
PGP, S/MIME.
-
What protocols can ensure secure web browsing?
SSL, TLS.