{"id":86,"date":"2020-01-28T20:41:56","date_gmt":"2020-01-28T20:41:56","guid":{"rendered":"http:\/\/helgavelroyen.de\/?p=86"},"modified":"2020-04-13T14:21:25","modified_gmt":"2020-04-13T14:21:25","slug":"pgp-signed-wedding-stationery","status":"publish","type":"post","link":"https:\/\/helgavelroyen.de\/?p=86","title":{"rendered":"PGP-signed Wedding Stationery"},"content":{"rendered":"\n<p>Information security is important &#8211; also when getting married. To ensure your wedding guests that it is indeed you getting married, you can &#8211; and should &#8211; use cryptography. When we got married about a year ago, we had PGP\/GPG-signed save-the-date cards. See below how I created those (with code!).<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1392\" height=\"982\" src=\"https:\/\/helgavelroyen.de\/wp-content\/uploads\/2020\/01\/front.png\" alt=\"\" class=\"wp-image-87\"\/><figcaption>The front (with a sample picture and layout).<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1386\" height=\"987\" src=\"https:\/\/helgavelroyen.de\/wp-content\/uploads\/2020\/01\/back.png\" alt=\"\" class=\"wp-image-88\"\/><figcaption>The back (with sample text).<\/figcaption><\/figure>\n\n\n\n<!--more-->\n\n\n\n<p>The rough idea was the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Generate individual texts for the back of the card based on a CSV file with the recipients&#8217; data.<\/li><li>Sign the text with a GPG key generated for our common email address.<\/li><li>Create a tex template of a postcard and insert signed message.<\/li><li>Generate the pdf and send it to the printer.<\/li><\/ul>\n\n\n\n<p><strong>Step 1: Common email address<\/strong><\/p>\n\n\n\n<p>I guess the most romantic part of creating there cards was the epiphany that for a proper GPG signature you need a GPG key of for a real email address. And what would more romantic to create a common email address like lisa-and-millhouse@simpson.com and make it forward all mail to both of the individuals that are getting married.<\/p>\n\n\n\n<p><strong>Step 2: Create a GPG key<\/strong><\/p>\n\n\n\n<p>Once you have the email address, you can create a GPG (or PGP) key for it. We used <a href=\"https:\/\/linux.die.net\/man\/1\/gpg2\">gpg2<\/a> on an Ubuntu for it. <\/p>\n\n\n\n<p><strong>Step 3: Collect your guests&#8217; data<\/strong><\/p>\n\n\n\n<p>For the card we created a CSV file containing our guests&#8217; data:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Post address<\/li><li>How we want to address them in the opening of the text. Depending on what terms you are with them, you might have a range of &#8220;Yo, bro!&#8221; and &#8220;Dear Aunt Mary,&#8221;.<\/li><li>Whether we address them in the singular or plural form (in German, that make&#8217;s a difference).<\/li><li>How we want to close the text. Here for example, we put the person&#8217;s name first who is closer to the guests, e.g. &#8220;Best regards, Lisa and Millhouse&#8221; vs. &#8220;Best regards, Millhouse and Lisa&#8221;.<\/li><\/ul>\n\n\n\n<p><strong>Step 4: Generate the texts<\/strong><\/p>\n\n\n\n<p>To generate the text for the back of the cards I used a Jinja2 template that would contain a couple of if-statements depending on the variations listed in Step 3. My script then wrote the generated text to text files.<\/p>\n\n\n\n<p><strong>Step 5: Sign the texts<\/strong><\/p>\n\n\n\n<p>Here, my script basically does what a human user would do when signing a text file. Basically a <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gpg2 --armor --clearsign --local-user &lt;KEY_ID> text.txt<\/code><\/pre>\n\n\n\n<p>Note, that you need to run a gpg-agent, or otherwise you have to type in the passphrase of your key as often times as the number of guests you want to invite. And you did generate a key with a proper passphrase, right?<\/p>\n\n\n\n<p><strong>Step 6: Insert the signed texts into a tex file<\/strong><\/p>\n\n\n\n<p>As easy as it sounds, this took the most fine-tuning. As both jinja and tex use various control characters like &#8220;{ }&#8221; and &#8220;%&#8221;, I abstained from using jinja here and resorted to some simple string substitution.<\/p>\n\n\n\n<p>Mind you, this whole endeavor will be fun enough. Encoding errors and wonderful hboxes are the least of it. In particular, it was tricky to make sure that the signed message was rendered in the pdf to look exactly like the original text message, because otherwise your guests will have trouble to verify the signature. And it becomes all the more fun if your text is not in English but in a language with umlauts. Also, whitespace is not as innocent as it looks.<\/p>\n\n\n\n<p><strong>Step 7: Render the individual PDF files<\/strong><\/p>\n\n\n\n<p>That is basically a pdflatex on the tex file. Easy once you have all the encoding and whitespace traps.<\/p>\n\n\n\n<p><strong>Step 8: Merge the individual PDFs into one<\/strong><\/p>\n\n\n\n<p>&#8230; and off they go to the printer. But before that, we suggest you double-check that the messages&#8217;s signature is actually verifiable (at least with one or two).<\/p>\n\n\n\n<p>The code for this is on <a href=\"https:\/\/github.com\/helgar\/papeterie\">github<\/a>. Have fun!<\/p>\n\n\n\n<p>Also, don&#8217;t be disappointed if the number of guests who really try to verify it is rather small. Information security does not have a high priority in the common population, unfortunately. \ud83d\ude41<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Information security is important &#8211; also when getting married. To ensure your wedding guests that it is indeed you getting married, you can &#8211; and should &#8211; use cryptography. When we got married about a year ago, we had PGP\/GPG-signed save-the-date cards. See below how I created those (with code!).<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-86","post","type-post","status-publish","format-standard","hentry","category-side-project"],"_links":{"self":[{"href":"https:\/\/helgavelroyen.de\/index.php?rest_route=\/wp\/v2\/posts\/86","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/helgavelroyen.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/helgavelroyen.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/helgavelroyen.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/helgavelroyen.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=86"}],"version-history":[{"count":6,"href":"https:\/\/helgavelroyen.de\/index.php?rest_route=\/wp\/v2\/posts\/86\/revisions"}],"predecessor-version":[{"id":96,"href":"https:\/\/helgavelroyen.de\/index.php?rest_route=\/wp\/v2\/posts\/86\/revisions\/96"}],"wp:attachment":[{"href":"https:\/\/helgavelroyen.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=86"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/helgavelroyen.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=86"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/helgavelroyen.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=86"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}