{emayili} Understanding Encrypted Email

I’m adding encrypted message support to the {emayili} package for sending emails from R.

The first step has been understanding what the contents of an encrypted email looks like. To do this I’ve set up my email client, Thunderbird, to send encrypted emails using my GnuPG keypairs. In this post I look at the content of an encrypted message generated with Thunderbird.

For reference, I using Thunderbird 78.14.0 and GnuPG 2.2.19.

thunderbird --version
Thunderbird 78.14.0
gpg --version
gpg (GnuPG) 2.2.19
libgcrypt 1.8.5
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: /home/wookie/.gnupg
Supported algorithms:
Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
        CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2

Encrypted Message

Below is the raw content of an encrypted email message. I’ve stripped off a bunch of irrelevant header fields. The message is saved as a text file, encrypted-email.txt.

The following chunk is mostly a load of unintelligible (encrypted) nonsense. Feel free to scroll down vigorously.
MIME-Version: 1.0
Subject: ...
Content-Type: multipart/encrypted;
 protocol="application/pgp-encrypted";
 boundary="yIuKl9CZjofeRWX4nmi7Fpd5iMT9ZpzLi"

This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)
--yIuKl9CZjofeRWX4nmi7Fpd5iMT9ZpzLi
Content-Type: application/pgp-encrypted
Content-Description: PGP/MIME version identification

Version: 1

--yIuKl9CZjofeRWX4nmi7Fpd5iMT9ZpzLi
Content-Type: application/octet-stream; name="encrypted.asc"
Content-Description: OpenPGP encrypted message
Content-Disposition: inline; filename="encrypted.asc"

-----BEGIN PGP MESSAGE-----

wcFMA6JDQKC7ikaOAQ/6AracrvQeP+AG/V03MhMJQKQhCm6iihnkau7UXl/2dkLrqixE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PeLqzojClnXf49B2C00KeBLvRFhbJzygYfw9KJkbnnL88YcdvrCTeha
BeGpXhPXEhIEcYVFPnLWcs5dCB+gM5lRj9eiOrjJuu1mKL330X/voFkpZ2oS6MU3Ia7DN3TwYUnK
eXT4EVjsyPKQ5kOb1hu2fKl2bC7EH/sXlleffuM1v3XvxD3JfTkr5U1yi96Mkbj0sC3zM+Q2mG0s
sfXgymjBTpTB233TXin083XJ5giN3kCdcfx0Tau7wPNocfEhwbjpOPTpH4G5RC8pD3sY3t9kvez1
DlqTAFtWWUxslGdRH7NOA2OfRIl4vT80luuVQTNS/ZMOE8v9kE278zUVLzS8ASkUyhlV/SdVB/FQ
TcLNVH2KG1aRrYM3qzYdH3hEee9JsVCkoHe6FIO7KrU/Iiwo3WD1BduLs9xjVQG1AeAntHmNweRw
97tsjgGA5DnKrbSnXv+n2mNcq7oiF8MuM+idSsnbFEshKSmGFkN81yQcifco+RhJZs3BC8sX3Tyl
f7KlG1wCa+ia7MMUfGY8TuhIuSaiTB46rORusJbEzUVkWUS/gsD9jI+W63uFpoDP88bz3Mcu/vl2
1rDyAFs7Snms4vELzsRmqr2qsITcbTTdYJfHzIw3INNV0pLrdqJQlcg5e+ElxRtVfUczs1NLffRw
ybM6vhp/Y2deYJ9z2zyxRrirkhmoA3fk7FKjWS+LF/OUWZK25XwjQIaVaotdBfUWSJNLDSTjt8PX
2Dl4RQQ1RdfcQew5Aw8Z6KB0uodizkKKsWWCfWZHuRP+uoaql8GJEmgHsuM4BRGnPq6AJQ4caNzl
Q/UrxoI=
=+gjh
-----END PGP MESSAGE-----

--yIuKl9CZjofeRWX4nmi7Fpd5iMT9ZpzLi--

The Subject field is just a placeholder (...), and will only be populated once the message is decrypted. The body of the message and any attachments are all encrypted.

Decrypting

To see the actual content we’ll decrypt the message with gpg and the -d (or --decrypt) option.

gpg -d encrypted-email.txt
gpg: encrypted with RSA key, ID 3210F48A9FF304AF
gpg: encrypted with 4096-bit RSA key, ID A24340A0BB8A468E, created 2021-11-26
      "Alice <alice@yahoo.com>"

We get some information on the key used to encrypt the message. The rest of the output is MIME encoded. We’ll decode that with qprint.

gpg -d encrypted-email.txt | qprint -d

Here’s what the result looks like:

Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="O6WVJZQXER4dsIzUPXt9tWyET8SZP73NO"

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--O6WVJZQXER4dsIzUPXt9tWyET8SZP73NO
Content-Type: multipart/mixed; boundary="B1LtVCpc3KMkw7XaeAzMOooL7dNoXrtKx";
 protected-headers="v1"
Subject: Top Secret Message
From: Alice <alice@yahoo.com>
To: Bob <bob@gmail.com>
Message-ID: <8d5d0999-3838-1dc2-889b-ad3316de676d@yahoo.com>

--B1LtVCpc3KMkw7XaeAzMOooL7dNoXrtKx
Content-Type: multipart/mixed;
 boundary="------------FE374C6C7804A00CF598765A"
Content-Language: en-GB

This is a multi-part message in MIME format.
--------------FE374C6C7804A00CF598765A
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable

Don't share this with anybody!

--------------FE374C6C7804A00CF598765A
Content-Type: text/plain; charset=UTF-8;
 name="ave-maria.txt"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="ave-maria.txt"

TWF4aW11cyByZXggYXVjdG9yIGZvcnRpc3NpbXVzIGNvbnNvbGF0b3IgaW5jb21wcmFlaGVu
c2liaWxpcyBnbG9yaW9zdXMgcGl1cyBpbnVpc2liaWxpcyBjb25zZXJ1YXRvci4K
--------------FE374C6C7804A00CF598765A
Content-Type: application/pgp-keys;
 name="OpenPGP_0x87CC261267801A17.asc"
Content-Transfer-Encoding: quoted-printable
Content-Description: OpenPGP public key
Content-Disposition: attachment;
 filename="OpenPGP_0x87CC261267801A17.asc"

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsFNBGGgYjQBEACaevZlELmd7QdzCg6PTdj4uoW0iKSjtaYpLyrfkP3/TxF/rWL272hU8ETkeuzD
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555+K4peNNp/qGOVF
qOujKjaXwA9HGzk0OazdtTozp4P80qFBZq2dPCOz2ASZABEBAAHCwXYEGAEKACAWIQQdoxM+ilqs
lfVDRDmHzCYSZ4AaFwUCYaBiNAIbDAAKCRCHzCYSZ4AaFxLCD/9AUl4/uF6Ovxg5nNe9+yInKSAF
0C+qY1rH+H8NwNeaEQ7ncSsp6BNVOKItCKuANh9QwbpTbgTduPvSQFuKw8luaXPIZepjIYzx5x9x
PQEdeAGiUZW250uX8ZJqRvibWsqjN9NXPCIYC6moo53/2kY48hQDaeiy6dmSrmj/XEpFIm1hQGw4
ZlvsiA/kVl/XfxuxUOHB+AeTmFoVspwihW/KjSa5F2MfW7W6CdkehfTFLlGZdApvmZFj/d13rV5v
9Hy5ldeTkiEBRAReSRQGy7oCDCi/B/04J+zQ4nd1LvFngeUvMuZDtPtWcU9kV+L//iVnq09BB3f2
/ZcNc+tfhYyKs/M2nMT13wByRuuj5dzr6opNaswle7q55pmXnd9qloLi2djma2iF5+IVVFAxAiqT
uL7A36lymExI1BiDY0rlQCsb7Xw+aNgjx2I1gZcdzHA+daDT0LDvoM342aU/TqsDRhGVCD8N8ylW
jlQpVTuTjcyj65MrQCTI9DIUpuSbYMw8tMsDfavFxSQ3oPVRq87J20atwnUHQ5Tofd2bzRNwI0JZ
/R8eIiIs2tPd8cyyMLZz0uJ7cf4+POGMV6/5mBtlwberiKZ6tAcaPS1wtOqzI1E884eC55/YTbfz
ha3gdKtUmIOAemwxrHF8u9DQpPmfDKhXrL9GtiFjGTcXabbslw==
=fr2w
-----END PGP PUBLIC KEY BLOCK-----

--------------FE374C6C7804A00CF598765A--

--B1LtVCpc3KMkw7XaeAzMOooL7dNoXrtKx--

--O6WVJZQXER4dsIzUPXt9tWyET8SZP73NO
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsF5BAABCAAjFiEEHaMTPoparJX1Q0Q5h8wmEmeAGhcFAmGgdAgFAwAAAAAACgkQh8wmEmeAGhdD
GQ/7BqBwF86uEJD/0MLGW/vsqwAewGojifr8fOzcjgXBS1LKwZOydzCX2/8tk0KciIw89kolfGtI
NASFwCICq6uF2C2iMrRBvDXyx8kWvbshlGXtc6BzMa1DKUEuurfb5OsdR6GhuZP0yauhsA4XUe/0
o3goVCNHD30vJtzwB2/is0SRGTz6imy/alkHidJ4KvlGIuKD1C4jeCnkErIoL/ewaz3X2/ZiSlm/
b2THGm6v8SJGiqm9ArCVkHVZzQ9C9JbNeUXaQhI7RhgnqATM43aXLOgFa4VRaAoJl4I/0Jv40KB5
Qs22K3s3z1LDPvDaWLK2u2Pdv37eoKPrkgKOmlOGS52LpAtbosiNXQ/yzuVZRY9dd19l4lnuXVxJ
0Bs/9GftbYa8Kf/sKrzE6oX87BH10lN9tUoKUTJqI3+d9Vsy5waf4m/pQb+x1+lfmWHP4S7J9RNZ
WdGGY2v6TDkiWll7o+ZdHLqrqqRz3ietUR23UIjod1NPJHPR7CrVwvYzCUSukbxTgrlhepO/EZDM
oGzsRIXNxsoRQE1PNt3UbPR4F0NVLtHxVokmeEX4x45G3ai1paGkeBgjAPFt1IVPTH6ZurwrOO5Y
hF7HMBEWDoohePa2LnGojlmoBu1Y7PpP+gvwFK5yEPBJl6vWTbo2ylTfBmpL0qHK9/Q4InG6eDgQ
J7AüT2
-----END PGP SIGNATURE-----

--O6WVJZQXER4dsIzUPXt9tWyET8SZP73NO--

Right, so that looks a lot more like a regular email. It’s a multipart MIME document with a message body (with content “Don’t share this with anybody!") and a Base64 encoded attachment.

Attachments

This is the part of the decrypted message that contains the attachment:

--------------FE374C6C7804A00CF598765A
Content-Type: text/plain; charsetF-8;
 name="ave-maria.txt"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="ave-maria.txt"

TWF4aW11cyByZXggYXVjdG9yIGZvcnRpc3NpbXVzIGNvbnNvbGF0b3IgaW5jb21wcmFlaGVu
c2liaWxpcyBnbG9yaW9zdXMgcGl1cyBpbnVpc2liaWxpcyBjb25zZXJ1YXRvci4K

Still looks like nonsense, right? That’s because it’s Base64 encoded (see the Content-Transfer-Encoding header). We can decode it using the base64 utility.

cat << EOF | base64 -d
TWF4aW11cyByZXggYXVjdG9yIGZvcnRpc3NpbXVzIGNvbnNvbGF0b3IgaW5jb21wcmFlaGVu
c2liaWxpcyBnbG9yaW9zdXMgcGl1cyBpbnVpc2liaWxpcyBjb25zZXJ1YXRvci4K
EOF
Maximus rex auctor fortissimus consolator incompraehensibilis gloriosus pius inuisibilis conseruator.

This decrypted content of the attachment looks like Latin, but it’s actually encrypted with the Ave Maria cipher developed by Johannes Trithemius.

Public Key

The message includes Alice’s public key. This is important for Bob if he responds to Alice: he’ll need to have her public key in order to encrypt his response.

Alice can also export her public key and send it to Bob separately.

gpg --armor --export alice@yahoo.com
-----BEGIN PGP PUBLIC KEY BLOCK-----

mQINBGGgYjQBEACaevZlELmd7QdzCg6PTdj4uoW0iKSjtaYpLyrfkP3/TxF/rWL2
72hU8ETkeuzDKykoe3gKV0y5RycOA/+MMavrJI+l9k9iPtM9ETuPILyE4INZssin
aN8eiTQveqxYSUK7A3wVy1YM35pnEj+trQJuUApuzzWdsvKHzoTcldtSZNvpwtIz
5V/po9HmSNNF4vI7V1U9o1XSXhwP+2Qv34m2tMxeQ9eamYbfrfzzK7T1jie3qg6/
v8lbAUerH6Yxo+yn0dtbScl5bJ9h/5QZGGxg2aSqcIJ68KZq/x8L8Q2JbDZk4aiA
GCFVMueb7u0N/M5PkcpWHo64/uMsJwBSMt14l0VB10jYpFcY9eWe9QxxrLwJqA6M
7dWH1i5lMdYg5qW2GplOxW71n4fhlUObT2C2GTvp21NrkU468S7msIpgJsZ0YJmf
BjraWxH7wt+6iGmg0aO4yaIqfe9sHz2lKtmra1gHKhpr5rJyIR6jMERg+BgQstpX
De35O0Vxvc16aVQLv8LabpyoozpoqhTw11+dnVspAqhlVY/SQ9ekc5U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c+tfhYyKs/M2nMT13wByRuuj
5dzr6opNaswle7q55pmXnd9qloLi2djma2iF5+IVVFAxAiqTuL7A36lymExI1BiD
Y0rlQCsb7Xw+aNgjx2I1gZcdzHA+daDT0LDvoM342aU/TqsDRhGVCD8N8ylWjlQp
VTuTjcyj65MrQCTI9DIUpuSbYMw8tMsDfavFxSQ3oPVRq87J20atwnUHQ5Tofd2b
zRNwI0JZ/R8eIiIs2tPd8cyyMLZz0uJ7cf4+POGMV6/5mBtlwberiKZ6tAcaPS1w
tOqzI1E884eC55/YTbfzha3gdKtUmIOAemwxrHF8u9DQpPmfDKhXrL9GtiFjGTcX
abbslw==
=j6UK
-----END PGP PUBLIC KEY BLOCK-----

This appears superficially to differ from the public key embedded in the original message. However, the difference is limited to a few characters at the beginning and end of the key. They are also wrapped to a different line width (72 characters for GnuPG and 76 characters for Thunderbird). The difference in the key content arises from slightly different implementations in Thunderbird and GnuPG.

We can, however, compare the two versions of Alice’s public key using their fingerprints. First we’ll look at the fingerprint from GnuPG. I’ve removed the whitespace from the fingerprint for ease of comparison.

gpg --fingerprint alice@yahoo.com
pub   rsa4096 2021-11-26 [SC]
      1DA3133E8A5AAC95F543443987CC261267801A17
uid           [ultimate] Alice <alice@yahoo.com>
sub   rsa4096 2021-11-26 [E]

Now we save the public key from the email to a file, public-key-block.txt, and then extract the fingerprint from the file.

gpg  --import --import-options show-only public-key-block.txt
pub   rsa4096 2021-11-26 [SC]
      1DA3133E8A5AAC95F543443987CC261267801A17
uid                      Alice <alice@yahoo.com>
sub   rsa4096 2021-11-26 [E]

The fingerprints agree precisely. So the two version’s of Alice’s public key are equivalent and completely interoperable.

Signature

When Alice sends an encrypted message it’s first signed with her private key and then encrypted using Bob’s public key. In order for Bob to verify Alice’s signature he first needs to decrypt the message. So he decrypts the message using his private key and then verifies the signature on the message using Alice’s public key.

Because of the sequence of operations used in creating the message it’s impossible to verify the signature without first decrypting the message.

Just Encryption

It’s not necessary to sign a message. And including your public key is also optional.

So what would the decrypted message body look like without these components?

Subject: Top Secret Message
From: Alice <alice@yahoo.com>
To: Bob <bob@gmail.com>
Message-ID: <bc870861-bcc4-e120-9b66-80ca32ee9b0f@yahoo.com>

--OVgKEOX6d2wdKaEuZNnD57SxmdxfXDQ5P
Content-Type: multipart/mixed;
 boundary="------------0811FAF0B361EA1B57B21AAD"
Content-Language: en-GB

This is a multi-part message in MIME format.
--------------0811FAF0B361EA1B57B21AAD
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable

Don't share this with anybody!

--------------0811FAF0B361EA1B57B21AAD
Content-Type: text/plain; charsetF-8;
 name="ave-maria.txt"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="ave-maria.txt"

TWF4aW11cyByZXggYXVjdG9yIGZvcnRpc3NpbXVzIGNvbnNvbGF0b3IgaW5jb21wcmFlaGVu
c2liaWxpcyBnbG9yaW9zdXMgcGl1cyBpbnVpc2liaWxpcyBjb25zZXJ1YXRvci4K
--------------0811FAF0B361EA1B57B21AAD--

--OVgKEOX6d2wdKaEuZNnD57SxmdxfXDQ5P--

A lot more concise.

Conclusion & Next Steps

I feel like I now have a reasonable understanding of the anatomy of an encrypted email. It turns out to be simpler that I anticipated: the whole message is encrypted (rather than individual components of the message, the body and attachments).

Schematic layout of MIME components in a PGP signed email (left) and a PGP encrypted email (right).

I’ll be adding support for encryption to {emayili} and hope to push out an update sometime this week.

References

There are a few documents that are germane to this post: