{emayili} Sending Encrypted Email

In a previous post I documented what I had learned while trying to understand the structure of encrypted emails. I then took an informal Twitter poll to gauge how many people are using encrypted email messages.

Twitter poll about use of email encryption.

It’s by no means a statistically representative sample, but I’ll go out on a limb and state that not many people are actually encrypting their email. I have a few hypotheses which might explain this:

  • Maybe they feel it’s unnecessary?
  • Perhaps they find it inconvenient or difficult to set up?
  • Possibly they didn’t even know that it was possible?

I think that securing your personal communications is becoming progressively more important. So I’m going to be using GnuPG to encrypt and sign emails in future.

In this post I’m going to demonstrate a new feature in {emayili}, which makes it possible to easily send encrypted messages from R. This feature leans heavily on the excellent {gpg} package developed by Jeroen Ooms.

Load Emayili

First let’s load {emayili}.

library(emayili)
#
# And {dplyr} because I use this everywhere!
#
library(dplyr)

packageVersion("emayili")

The encryption feature is only available from version 0.7.0. At present you’ll need to install this from GitHub because it’s not on CRAN yet.

You don’t need to explicitly load {gpg} to use encryption with {emayili}, but we’ll do so just to check on the version of GPG and create some keys to play with.

library(gpg)

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

Creating Keys

We’ll set the scene by creating a few keys in a temporary location so that we don’t clobber our existing keyring.

gpg_restart(home = tempdir(), silent = TRUE)

For entertainment we’ll simulate encrypted communications around the D-Day landings. We’ll need some (obviously fictitious) email addresses and keys.

FLOTILLA  <- "flotilla@kriegsmarine.gov"
BORCHERS  <- "borchers-276@kriegsmarine.gov"
SCHUNK  <- "schunk-348@kriegsmarine.gov"
gpg_keygen(name = "Flotilla", email = FLOTILLA)
gpg_keygen(name = "U 276 Borchers", email = BORCHERS)
gpg_keygen(name = "U 348 Schunk", email = SCHUNK)

Now take a look at our keyring.

gpg_list_keys() %>% select(id, fingerprint, name)
                id                              fingerprint           name
1 A54509CACB0F295E CE08B765CA067CAA57764F5EA54509CACB0F295E       Flotilla
2 0897DF3055C00B2F AAA3971869729272BBD61F730897DF3055C00B2F U 276 Borchers
3 0665C3E83FBB901B EF5AA9E78B78836AD16399180665C3E83FBB901B   U 348 Schunk

Publishing Keys

Publishing those keys could be done as follows (although we won’t actually publish the keys for obvious reasons!):

gpg --keyserver keyserver.ubuntu.com --send-key CE08B765CA067CAA57764F5EA54509CACB0F295E
gpg --keyserver pgp.mit.edu --send-key AAA3971869729272BBD61F730897DF3055C00B2F
gpg --keyserver keys.openpgp.org --send-key 0665C3E83FBB901B

The keys can be referenced by id or fingerprint.

Creating a Message

What about a message body? The message below was intercepted at 04:30 UTC on 6 June 1944 and subsequently decrypted by the codebreakers at Bletchley Park.

SUBJECT <- "Attention"
TEXT <- "Immediate readiness. There are indications that the invasion has begun."

Create an {emayili} message object.

msg <- envelope(
  from = FLOTILLA,
  to = c(BORCHERS, SCHUNK),
  subject = SUBJECT,
  text = TEXT
)
Date:                         Fri, 15 Apr 2022 04:42:00 GMT
X-Mailer:                     {emayili}-0.7.9
MIME-Version:                 1.0
To:                           borchers-276@kriegsmarine.gov,
                              schunk-348@kriegsmarine.gov
From:                         flotilla@kriegsmarine.gov
Subject:                      Attention
Content-Type:                 text/plain; 
                              charset=utf-8; 
                              format=flowed
Content-Transfer-Encoding:    7bit
Content-MD5:                  HvL4qIrj5lMuW+E5BW4APA==

Immediate readiness. There are indications that the invasion has begun.

This is a simple, unsecured text massage.

Sign a Message

To add a digital signature to the message use the encrypt() function and set encrypt = FALSE but sign = TRUE. It’s also possible to enable a signature using the sign option to envelope().

msg %>% encrypt(encrypt = FALSE, sign = TRUE)
Date:                         Fri, 15 Apr 2022 04:42:00 GMT
X-Mailer:                     {emayili}-0.7.9
MIME-Version:                 1.0
To:                           borchers-276@kriegsmarine.gov,
                              schunk-348@kriegsmarine.gov
From:                         flotilla@kriegsmarine.gov
Subject:                      Attention
Content-Type:                 multipart/signed; 
                              micalg="pgp-sha256"; 
                              protocol="application/pgp-signature"; 
                              boundary="5a173ab9"

This is an OpenPGP/MIME signed message (RFC 4880 and 3156).
--5a173ab9
Content-Type:                 multipart/mixed; 
                              boundary="8722b57d"

--8722b57d
Content-Type:                 text/plain; 
                              charset=utf-8; 
                              format=flowed
Content-Transfer-Encoding:    7bit
Content-MD5:                  HvL4qIrj5lMuW+E5BW4APA==

Immediate readiness. There are indications that the invasion has begun.
--8722b57d
Content-Type:                 application/pgp-keys; 
                              name="keys.asc"
Content-Description:          OpenPGP public key
Content-Disposition:          attachment; 
                              filename="keys.asc"
Content-Transfer-Encoding:    quoted-printable
Content-MD5:                  ignBQJfgx2ZQbi+QxL6Ouw==

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

mQGNBGJY95MBDACpC3TKRxcSI2c+6W6lPciPiA1NE7ftwe+OfNWtF79nHnP33F6H
8Pfa3yD5n6Mx4Tc50WgIsa/V5Xg8wfuFpK3OxzZuOo4N0l+1slJXH30u/MJ2bPYb
XtMUM/htHBfG3TYPMsQfssWV23IdSdD8FiBFGakWTWihbDbb0ly8+xGghdAKmay5
zWrlMJqRnM4Lo7HGsfWJDdGBDw5qMazqWX1JBgTJCFXnVoRsa2Fu7nqnWXRToVI6
j6erQUpmhm2PhENmZkD9OcdBvHK31qRoJXy2ilyKafGfviHGRJesq/CxJD8vSBWp
QiWbuUSNek3ex8Um5hW8UDaFwghtvsICWtm7MZPTkOcro6+kbYMzJVCuZPuo0Lvj
aHwudJtXxTRQ9rvUcFBnHjIXxoHnROvcaoGptG8/ld66y52A1D3Eqqh22XRNQwWU
SVmPJ3zGi5TiWazMUE3oZBZsmXVOPBdl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QiI9XdKkpDPUgmQU
epfScqbUtrmhmciciKzt4QfC1v3IXXMkb71Qcp6tBCcFsqiyNlwpuTM+r/sx3dfp
FclwnXbuXsBZ1mHb+ife+kReLJiKmpslzl67TiTGQrNHYXyvucwFiqT4AGB/pQPX
OxX2JXcxL0hGstiW5PVKyqJmDcm0WdN2ZtzlDTrw6K5oAU9yiMv4vRHpdtMFaWFU
mHVL3dk+PmkAEQEAAYkBtgQYAQoAIBYhBI2StvxMShLrtpaVvqZlhUonghQyBQJi
WPeTAhsMAAoJEKZlhUonghQy9k8MAJUKQaJUVVUSsYSBJPaiq40IPuTzPo2pxAYz
+eY6xTLRjmBr8U4o85XqHh8EBQxCIQo/mt8546iCGtG3W6qify/bOp3HehXqm1Gm
CzqHVpmTOleZy1GnR1MgIKuNAqsVQz2Vp/vAVakbrAyHuOPx0FWm2YAoZ+VkoYK+
tnqsuCTZ8zzdDKBIZkMpRGPXDKEpow2hurCdubUPtF5PRo7MLyDvy92z1LnMHX17
+pUOvSNfCuruq66hE19ELEHXTdb3T+xZZ0B/NNTag9S4fAzZSuJFdwSuFbKEv/oB
PjQ1aPvg6RnRGuUTo7tzgBEdxAQyZtlXeO2ZykLIgcSx3d7KFfuabUsHzzPAgliB
OD0eyOMB7QRsdV0+r7RLodpyV4uTQV2L8ybmQDjLfuAb9H5JCvY56C6kCbVpbNxM
7Kh5Mm0p50TyIZ+Mh4HdUSSuRT8frXip+uWBfUzEr8+FVxoS5LIfduo8vvFL2zCx
YBpiabRrueUI1NsK5tiqzJCRhdGKnA=3D=3D
=3D71FP
-----END PGP PUBLIC KEY BLOCK-----

--8722b57d--
--5a173ab9
Content-Type:                 application/pgp-signature; 
                              name="signature.asc"
Content-Description:          OpenPGP digital signature
Content-Disposition:          attachment; 
                              filename="signature.asc"

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

iQGzBAABCgAdFiEEjZK2/ExKEuu2lpW+pmWFSieCFDIFAmJY95gACgkQpmWFSieC
FDID0gv+MxHBbDumo1Vm5izIBvBrq8j/hufi8kHSuas5TMV/goKxYIQkAj0EanE5
KBq2lQssFPGBmB/GK5UXIUmmZqr1kY427DSRh4s11GgVw3hmaarytvVute13mFj9
Lt21L+5cfu5S6YhdTZYU08e0m8GQDqHQPdZyHAjSAMyjF7942nL53d6h7gN+npxl
EEcafudWdCPB/qxyvP0mw5+6aehf1gKogXVaMzgkqUfn270ly/sEOoOiejcVHSSb
5hhl4o8mBtHzaYVN5VoxgQrtiWWi+AW8E+m2DRY69JM6oPKKg/pWRYri3OMFDEuN
jTnmVA/WvTCObHjz9SnfxfRx1STQkG9njHAmh9XosTomKFphPk+oZOC0zhIGpK9J
Ty0zWue+oOUaIDHr1J6UlxFKBkDOarrQQ7Y6KyhYomIr8WE7xgXVIFIHLqX6m4ZO
/SSHonUm+lGR+3IFiI9Rf6ZD7P7DzlrZ8WRcKpGSkxdrwpOPDzU5lyMqCtBxRsJ/
gfMjs4+4
=qc1G
-----END PGP SIGNATURE-----

--5a173ab9--

The resulting message now includes:

  • the public key for the sender (PGP PUBLIC KEY) and
  • a digital signature (PGP SIGNATURE).

The structure of the MIME message is such that the signature covers both the message and the public key. In this way the sender is also authenticating the validity of the public key that they are sharing. For brevity you can omit the public key by setting the public_key = FALSE option to encrypt().

The commanders of U 276 and U 348 could validate the authenticity of the message by using the published public key for flotilla@kriegsmarine.gov.

Encrypt a Message

Signing a message establishes its authenticity, but for secure communications you’d want to encrypt the contents of the message too. Again, use the encrypt() function with encrypt = TRUE (this is the default). It’s also possible to enable encryption using the encrypt option to envelope().

msg %>% encrypt(encrypt = TRUE)
Date:                         Fri, 15 Apr 2022 04:42:00 GMT
X-Mailer:                     {emayili}-0.7.9
MIME-Version:                 1.0
To:                           borchers-276@kriegsmarine.gov,
                              schunk-348@kriegsmarine.gov
From:                         flotilla@kriegsmarine.gov
Subject:                      Attention
Content-Type:                 multipart/encrypted; 
                              protocol="application/pgp-encrypted"; 
                              boundary="b8989ec4"

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

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

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

hQGMAyOY2jau2m/NAQv6A6Ia7VeFC0nE8EVux/wdg48MG713Hm4uZ1fkIZqINDRt
/5GC3wNw5942/7KXBY9wmanf8sx3FAG4gNvxMTvyRX0llATEDy0oI5kWJUPCgZCy
JKobjjA9MY/R8naEQJvO0TLb/3Knshjsxyr/rS+wFiK7gr1a44b4WkQs8IW6OX3A
D77SxDtcsWIRDbQFr3KpstAA3wtnSKJPgT/92aVKYI8eAwkeJjIayhDUAAHhAK9v
debAic6ElKSRJAX7s0ILUds238o1uD7e2tZJAiXLoiO9np1Uo3un4BOOe6/1Pdix
pZh+dhtaK/hdJL+K/hMajTdtosQztNajmHbh+4/NCjlwTP2CpY0vdDKMokaG9vh3
2l/MirfGQIoqRSiYftFNgrqW2u91Yp7HsVte6qxrjkZivUyrTI3a7ey2eeaYk+5P
as41OQLlvg8EYD/Uhdj2fvuOf2G3l0v9YIK6Tqig2qBNfmAkqTEpKZ2uarkuAPWo
7ERyibddF/BhLgLnNhvdhQGMAz30LaI6UPFIAQv/fAnejM4LYGbkWUT6mKg0ixod
ZERy22jk93t+G0lsvwRKmFyR5u5y6/GsDs3FbWWqC/Oj62/rFDxxszOzoEwzQxHq
WV2KIGu/bcMj6KAQFb7MM0QFq0CsAneR7k6kDnRQk9OzI/9ipSJyJmGt5C+zJ7m0
782JmPyga1jeBmeiVyqs+pp+zRHpM5DWIKCZ20KTI+QQRU4zgSZ/CknEUORcmOJK
r5HRctg9mgsG0yaKKtKlmGzapqhSxaT32UOciJxztNQ7wA9aiWuRWEi8b3n6uzzg
QgXo5VvRp8kTsmngEtxYQmcn3sNAfgW/YyLJomE4xZgrMDuERLLChhOPaJ7zajYF
TWZ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enRObUAVYZI1KmVuj1J9DqmLPSF0bOoLwltmP6prl3cwSTf7vDFiIl/x
MfyzOpDzMm7B2BcJ74F21IeAkajOEIpKuQfVC8tmAVAubDIKvUx2L0kf/4VixJNJ
LEEh4AK3b9duRBVdnFHUDNz2850xSLDToo8FvjBjzJnKrG5Ncm4eEf5AWu7XKpNN
+D4rVbWGYybO3ZbMNU3/32WzfR7mTsdeUVwHztBCqi1X+9at9AOyqto+I6MBbsGY
/tepfh0rOw51V2oz9AAZfsHIvmnYoNArs2C842g3+a4neD4Zl0z6e7dWJFbLazzu
2WJUJz2uJyNO4cUaoPtKJXYgCf3vHXiu/17bp3VygNFPJEgum/jZ3Lgmjjbsw73c
wsCQKvd9tb1xz8rIFgjEgwgNtX4v1rHJROK76O9i+Q5wKz/eBB0j+a12l/wKKo0m
X/U6lu8YbiLxpx1WlV0h4lZQ2ScaYbLkmiS0FeFYI05umsqbHmgqgi7cBD6GIHTD
VuJJI8ItNfB3ncUGeIhhK13JnEA/Px6vUcbciPf6EUC+v6hM4gIJQFSgjUcTfftQ
je8li8zVv+m0EslrbCmLNq/nF2JK6ifk/V1djKBHYZadeLN9huQS87Ppw2WdOCex
JglpRI+ZXZQj3ZSTzaYkLewxXKYwWUym76mAGE7+K4a83/KBxevNfDHOzvOiIc5n
PVF71BAzY4sC7rzCAfE5jxrC+3yDhqxQ0sopDolyjGSjtYATA7HFCUlqu4OYWzAD
JZW7u+dB7XrRaUYMwnoH6FXsfRN/oKnVcjaVutJvLuPNo+Y7rBLc/3E68ksFOw59
7/jP
=o+w2
-----END PGP MESSAGE-----

--b8989ec4--

The resulting message is now essentially opaque. It’s been encrypted using the public keys of the recipients. All of the useful information (the public key of the sender, the signature and the message content) are encrypted. A recipient would use their private key to decrypt the contents.

Encryption Pipeline

The encryption pipeline, showing a message, a signing step and an encryption step.

The order in which signing and encrypting happen is important. If a message is signed and encrypted then the signature is inside the encrypted body of the message. The message needs to first be decrypted before the signature can be read. This makes sense because only the intended recipient (the target of the encryption) should be able to see who signed the message.

Conclusion

At Fathom Data we routinely use {emayili} for sending messages from R. This forms a core component of many of our automated workflows. Being able to encrypt those messsages, ensuring that the data we’re sending is secure, is going to be very useful indeed.

I’m very interested in feedback on this new feature. Please give it a try and let me know if there are any issues. If you find this useful, please tweet about and don’t forget to tag @datawookie and @fathomdata.


Logo for {emayili} package.

Logo for Fathom Data.

The {emayili} package is developed & supported by Fathom Data.