<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Openssl on Guardian Project</title>
    <link>https://guardianproject.github.io/info/tags/openssl/</link>
    <description>Recent content in Openssl on Guardian Project</description>
    <generator>Hugo -- gohugo.io</generator>
    <lastBuildDate>Fri, 10 Nov 2023 00:00:00 +0000</lastBuildDate>
    
        <atom:link href="https://guardianproject.github.io/info/tags/openssl/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>Quick set up guide for Encrypted Client Hello (ECH)</title>
      <link>https://guardianproject.github.io/info/2023/11/10/quick-set-up-guide-for-encrypted-client-hello-ech/</link>
      <pubDate>Fri, 10 Nov 2023 00:00:00 +0000</pubDate>
      
      <guid>https://guardianproject.github.io/info/2023/11/10/quick-set-up-guide-for-encrypted-client-hello-ech/</guid>
      <description>

&lt;p&gt;The Encrypted Client Hello (ECH) mechanism &lt;a href=&#34;https://tools.ietf.org/html/draft-ietf-tls-esni&#34;&gt;draft-spec&lt;/a&gt; is a way to plug a few privacy-holes that remain in the Transport Layer Security (TLS) protocol that&amp;rsquo;s used as the security layer for the web. OpenSSL is a widely used library that provides an implementation of the TLS protocol. The &lt;a href=&#34;https://defo.ie/&#34;&gt;DEfO project&lt;/a&gt; has developed an implementation of ECH for OpenSSL, and proof-of-concept implementations of various clients and servers that use OpenSSL, and other TLS libraries, as a demonstration and for interoperability testing. DEfO is funded by the Open Technology Fund (OTF).&lt;/p&gt;

&lt;p&gt;This guide is aimed at those who would like to try out ECH with our experimental Debian &lt;em&gt;unstable&lt;/em&gt; packages for OpenSSL, &lt;em&gt;curl&lt;/em&gt; and &lt;em&gt;nginx&lt;/em&gt;. The DEfO project is making packages temporarily available so people can carry out such experiments before upstream maintainers include ECH in standard releases.&lt;/p&gt;

&lt;p&gt;This guide describes two set ups: one assumes that you want to setup everything (i.e. a web server and associated DNS authoritative server) on one virtual machine and a second describes a way to set up an ECH-enabled web server if you have an existing DNS configuration elsewhere. Many other configurations are of course possible. Comments/questions are welcome via &lt;a href=&#34;mailto:info@defo.ie&#34;&gt;email&lt;/a&gt; or as GitLab issues/merge requests.&lt;/p&gt;

&lt;p&gt;In summary this guide shows how to:
- find and install our Debian &lt;em&gt;unstable&lt;/em&gt; packages
- configure a minimal DNS setup (using dnsmasq or bind) that enables use of ECH from browsers
- configure a minimal &lt;em&gt;nginx&lt;/em&gt; setup for an ECH enabled web sites
- test your DNS set up and that ECH is working&lt;/p&gt;

&lt;p&gt;We assume the reader is comfortable with simple DNS management and system administration tasks.
When commands shown below should be run as &lt;code&gt;root&lt;/code&gt; they are prepended with a &amp;lsquo;#&amp;rsquo;, if not they are prepended with a &amp;lsquo;$&amp;rsquo;.&lt;/p&gt;

&lt;h2 id=&#34;install-packages&#34;&gt;Install packages&lt;/h2&gt;

&lt;p&gt;You need to first have access to a virtual machine running Debian &lt;em&gt;unstable&lt;/em&gt;. Many online resources describe many ways to do this.&lt;/p&gt;

&lt;p&gt;We start with an empty (minimal) Debian &lt;em&gt;unstable&lt;/em&gt; system and install OpenSSL from the DEfO apt repository.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&#34;language-bash&#34;&gt;# apt install ca-certificates
# echo &amp;quot;deb [trusted=yes] https://defo.ie/debian/ ./&amp;quot; &amp;gt; /etc/apt/sources.list.d/defo.list
# apt update
# apt install openssl
&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id=&#34;pick-some-dns-names-to-use&#34;&gt;Pick some DNS names to use&lt;/h2&gt;

&lt;p&gt;In the text below we assume that the web server for which we wish to benefit from ECH is called &lt;code&gt;hidden.example.com&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;ECH also involves a so-called &lt;code&gt;public_name&lt;/code&gt; - that&amp;rsquo;s present in the outer ClientHello when ECH is used and hence is visible to a network observer, unlike the server name we include inside the Encrypted Client Hello. The &lt;code&gt;public_name&lt;/code&gt; we use below is &lt;code&gt;example.com&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;You should obviously substitute your chosen DNS names.&lt;/p&gt;

&lt;h2 id=&#34;generate-an-ech-key-pair&#34;&gt;Generate an ECH key pair&lt;/h2&gt;

&lt;p&gt;For ECH to work, we need a new asymmetric key pair. (Different from those used for TLS server authentication), so next we generate an ECH key pair:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&#34;language-bash&#34;&gt;# mkdir /etc/echkeydir/
# openssl ech -public_name example.com -pemout /etc/echkeydir/example.pem.ech
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Note that we need this file later to set up DNS as well as &lt;em&gt;nginx&lt;/em&gt;. &lt;em&gt;Nginx&lt;/em&gt; will make use of the private key from the ECH key file, whilst the DNS will be used to publish the corresponding public key in an HTTPS resource record (that&amp;rsquo;s where ECH-enabled browsers will look for ECH public keys).&lt;/p&gt;

&lt;p&gt;The file name chosen should end with &lt;code&gt;.pem.ech&lt;/code&gt;&lt;/p&gt;

&lt;h2 id=&#34;set-up-dns&#34;&gt;Set up DNS&lt;/h2&gt;

&lt;p&gt;There are many ways in which one can set up the DNS records required to enable experimenting with ECH. We document two ways here, the first is where the main DNS name with which you&amp;rsquo;re experimenting is newly registered DNS name and has no existing DNS set up. The second describes a case where a DNS name exists but we need to add some new resource records to enable ECH.&lt;/p&gt;

&lt;p&gt;In both cases, &lt;code&gt;&amp;lt;IP&amp;gt;&lt;/code&gt; should be the IPv4 address for the host running the web server. (We leave IPv6 handling as an exercise for the reader, but there&amp;rsquo;s nothing ECH-specific required for IPv6.)&lt;/p&gt;

&lt;h3 id=&#34;standalone-new-setup-dnsmasq-as-a-authoritative-dns-server-to-serve-the-ech-key-on-the-same-vm&#34;&gt;Standalone/New setup : dnsmasq as a authoritative DNS server to serve the ECH key (on the same VM)&lt;/h3&gt;

&lt;p&gt;In this case we also need to pick some DNS nameserver names, we assume the authoritative primary nameserver for both web server DNS names is &lt;code&gt;ns.example.com&lt;/code&gt; with a secondary of &lt;code&gt;ns2.example.com&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;The DNS set up to use starting from a clean dnsmasq install:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&#34;language-bash&#34;&gt;# apt install dnsmasq
# cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/dnsmasq.d/example.conf
no-resolv
no-hosts
auth-server=ns.example.com,ns2.example.com
auth-zone=example.com
auth-sec-servers=ns2.example.com
auth-soa=42,admin.example.com
host-record=example.com,&amp;lt;IP&amp;gt;
host-record=hidden.example.com,&amp;lt;IP&amp;gt;
dns-rr=hidden.example.com,65,&amp;lt;ascii-hex encoded HTTPS rdata&amp;gt;
EOF
# systemctl restart dnsmasq
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Note that you need to bump the SOA version (42 in the above) every time you change the config and make sure the zone distributes to ns2.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;&amp;lt;ascii-hex encoded HTTPS rdata&amp;gt;&lt;/code&gt; will be published as the HTTPS resource record (type == 65) for &lt;code&gt;hidden.example.com&lt;/code&gt; and can be produced from the file we generated earlier via a shell script you can download and use as follows:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&#34;language-bash&#34;&gt;$ _curl_ https://raw.githubusercontent.com/sftcd/openssl/ECH-draft-13c/esnistuff/pem2rr.sh -o pem2rr.sh
$ chmod u+x pem2rr.sh
$ ./pem2rr.sh /etc/echkeydir/example.pem.ech
0001000005003b0039fe0d0035db0020002059907d619054c907a1f296ceb63dde1d57f72f15db172601a2f6b55e66e7cd0f00040001000100066261722e69650000
$
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&#34;existing-dns-name-setup-using-bind-to-publish-new-ech-related-resource-records&#34;&gt;Existing DNS name setup: using bind to publish new ECH related resource records&lt;/h3&gt;

&lt;p&gt;Let&amp;rsquo;s assume you have an existing bind-based DNS setup for &lt;code&gt;example.com&lt;/code&gt;&lt;code&gt;, but are moving the IP address for that to a new VM that&#39;ll run the ECH-enabled web server for both&lt;/code&gt;example.com&lt;code&gt;and&lt;/code&gt;hidden.example.com`&lt;code&gt;. The change you might then make using the bind&lt;/code&gt;nsupdate` command on the authoritative DNS server would then look like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Change/add IP address records for our DNS names.&lt;/li&gt;
&lt;/ul&gt;

&lt;pre&gt;&lt;code class=&#34;language-bind&#34;&gt;$ sudo nsupdate -l
&amp;gt; update delete example.com a
&amp;gt; update delete example.com aaaa
&amp;gt; update add example.com 300 a &amp;lt;IP&amp;gt;
&amp;gt; update add hidden.example.com 300 a &amp;lt;IP&amp;gt;
&amp;gt; send
&amp;gt; quit
$
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Add new HTTPS resource record for &lt;code&gt;hidden.example.com&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;First we need to get the base64 encoded public from our &lt;code&gt;/etc/echkeydir/example.pem.ech&lt;/code&gt; file:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&#34;language-bash&#34;&gt;$ tail -2 /etc/echkeydir/example.pem.ech | head -1
ADr+DQA2mQAgACAF7cLT+KtK0oR2DrRCGXmzBWM1eHgJgDEGLqL644/OcAAEAAEAAQAHaG9iYS5pZQAA
$
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That base64 encoded value is what we need to publish in the DNS&amp;hellip;&lt;/p&gt;

&lt;pre&gt;&lt;code class=&#34;language-bash&#34;&gt;$ sudo nsupdate -l
&amp;gt; update delete hidden.example.com HTTPS
&amp;gt; update add hidden.example.com 300 HTTPS 1 . ech=&amp;lt;base64-encoded-value&amp;gt;
&amp;gt; send
&amp;gt; quit
$
&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id=&#34;checking-your-dns-set-up&#34;&gt;Checking your DNS set up&lt;/h2&gt;

&lt;p&gt;You can check that value is correctly published in the DNS e.g. using the &lt;code&gt;dig command&lt;/code&gt;`:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&#34;language-bash&#34;&gt;$ dig +short https hidden.example.com
1 . ech=ADr+DQA2mQAgACAF7cLT+KtK0oR2DrRCGXmzBWM1eHgJgDEGLqL644/OcAAEAAEAAQAHaG9iYS5pZQAA
$
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If your version of &lt;code&gt;dig&lt;/code&gt; is older and doesn&amp;rsquo;t know about HTTPS resource records, then you may need to check via:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&#34;language-bash&#34;&gt;$ dig +short +unknownformat -t TYPE65 hidden.example.com
\# 67 0001000005003C003AFE0D0036990020002005EDC2D3F8AB4AD28476 0EB4421979B30563357878098031062EA2FAE38FCE70000400010001 0007686F62612E69650000
$
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The 2nd-last invocation of &lt;code&gt;dig&lt;/code&gt; above shows the presentation format version of the HTTPS resource record. The last invocation above shows the equivalent in ascii-hex, which (minus the spaces) is what &lt;code&gt;dnsmasq&lt;/code&gt; needs in it&amp;rsquo;s configuration file.&lt;/p&gt;

&lt;p&gt;We assume &lt;code&gt;dnsmasq&lt;/code&gt; will likely accept presentation format for HTTPS resource records in future as &lt;code&gt;bind&lt;/code&gt; tooling already.&lt;/p&gt;

&lt;h2 id=&#34;set-up-nginx-to-serve-an-outer-and-an-inner-hidden-website&#34;&gt;Set up &lt;em&gt;nginx&lt;/em&gt; to serve an outer and an inner (hidden) website&lt;/h2&gt;

&lt;p&gt;Install &lt;em&gt;nginx&lt;/em&gt;-light from the DEfO repo, as above:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&#34;language-bash&#34;&gt;# apt install _nginx_-light certbot python3-certbot-_nginx_
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you don&amp;rsquo;t already have a web server config for &lt;code&gt;example.com&lt;/code&gt; then you can create a basic pair of &lt;code&gt;sites-enabled&lt;/code&gt; configuration files via the following commands:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&#34;language-bash&#34;&gt;# rm /etc/_nginx_/sites-enabled/default
# cp /etc/_nginx_/sites-available/default /etc/_nginx_/sites-enabled/example.conf
# sed -i &#39;s/server_name _;/server_name example.com;/&#39; /etc/_nginx_/sites-enabled/example.conf
# echo &amp;quot;ssl_echkeydir /etc/echkeydir/;&amp;quot; &amp;gt;&amp;gt; /etc/_nginx_/sites-enabled/example.conf
# cp /etc/_nginx_/sites-available/default /etc/_nginx_/sites-enabled/hidden.example.conf
# sed -i -e &#39;s/server_name _;/server_name hidden.example.com;/&#39; -e sed &#39;s/\(listen.*\)default_server;/\1;/&#39; /etc/_nginx_/sites-enabled/hidden.example.conf
# systemctl restart _nginx_
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It&amp;rsquo;s possible the &lt;code&gt;sed&lt;/code&gt; commands above may not work for you, e.g. if default files change, or perhaps you won&amp;rsquo;t use those if you have an existing web server config for &lt;code&gt;example.com&lt;/code&gt;&lt;code&gt;. In that case you can simply edit the config files to ensure the following, before running&lt;/code&gt;certbot``:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;you have &lt;code&gt;example.com&lt;/code&gt; and &lt;code&gt;hidden.example.com&lt;/code&gt; servers set up with correct &lt;code&gt;server_name&lt;/code&gt;`&lt;/li&gt;
&lt;li&gt;optionally change the DocRoot (&lt;code&gt;root&lt;/code&gt;) in these configuration files to serve different content&lt;/li&gt;
&lt;li&gt;there&amp;rsquo;s a line within the &lt;code&gt;http&lt;/code&gt; stanza as follows:
  &lt;code&gt;ssl_echkeydir /etc/echkeydir/;&lt;/code&gt;`&lt;/li&gt;
&lt;li&gt;the &lt;code&gt;ssl_echkeydir&lt;/code&gt; line can in &lt;code&gt;_nginx_.conf&lt;/code&gt; within the &lt;code&gt;http&lt;/code&gt; stanza or within either of the files in &lt;code&gt;sites-enabled&lt;/code&gt; when it must be outside the &lt;code&gt;server&lt;/code&gt; stanza&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&#34;run-certbot-to-get-a-tls-server-certificate&#34;&gt;Run certbot to get a TLS server certificate&lt;/h2&gt;

&lt;p&gt;Next you need to rRun &lt;code&gt;certbot&lt;/code&gt; to get TLS server public keys certificates for both DNS names (&lt;code&gt;example.com` and `hidden.example.com&lt;/code&gt;). Those can be in the same certificate (or not) for the purposes of this experimental setup.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&#34;language-bash&#34;&gt;# certbot --nginx
...iteractions...
#
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;code&gt;certbot&lt;/code&gt; may prompt you for e.g. an email address or approval and if you have an existing certificate for &lt;code&gt;example.com&lt;/code&gt; you may be prompted as to whether you want to add &lt;code&gt;hidden.example.com&lt;/code&gt; to that certificate.&lt;/p&gt;

&lt;h2 id=&#34;use-curl-to-test-the-set-up&#34;&gt;Use &lt;em&gt;curl&lt;/em&gt; to test the set up&lt;/h2&gt;

&lt;p&gt;Install our ECH-enabled &lt;em&gt;curl&lt;/em&gt; package from the DEfO repo and run:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&#34;language-bash&#34;&gt;$ curl -v --ech true --doh-url https://1.1.1.1/dns-query https://hidden.example.com/ |&amp;amp; grep Succeeded
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You should see this in the output:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&#34;language-bash&#34;&gt;ECH: result: status is Succeeded, inner is hidden.example.com, outer is example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id=&#34;check-with-browsers&#34;&gt;Check with browsers&lt;/h2&gt;

&lt;p&gt;If you&amp;rsquo;re running a recent browser version (chromium-based since version 105, firefox since before then:-) you can enable ECH in the browser by &lt;a href=&#34;https://defo.ie/#clients&#34;&gt;following our client configuration instructions&lt;/a&gt;. Unfortunately, browsers don&amp;rsquo;t provide user interface to show if ECH has succeeded or not, but you can verify that your browser is able to use ECH if you visit &lt;a href=&#34;https://defo.ie/ech-check.php&#34;&gt;https://defo.ie/ech-check.php&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&#34;feedback&#34;&gt;Feedback&lt;/h2&gt;

&lt;p&gt;All going well, you should now have an ECH-enabled web site and be able to extend/play with that as you like. We&amp;rsquo;d appreciate feedback on this guide if you have a chance. As before, comments/questions are welcome via &lt;a href=&#34;mailto:info@defo.ie&#34;&gt;email&lt;/a&gt; or as GitLab issues/merge requests.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>DEfO - Developing ECH for OpenSSL (round two)</title>
      <link>https://guardianproject.github.io/info/2023/11/09/defo-developing-ech-for-openssl-round-two/</link>
      <pubDate>Thu, 09 Nov 2023 00:00:00 +0000</pubDate>
      
      <guid>https://guardianproject.github.io/info/2023/11/09/defo-developing-ech-for-openssl-round-two/</guid>
      <description>

&lt;p&gt;Encrypted ClientHello (ECH) plugs a privacy-hole in TLS, hiding previously visible details from network observers. The most important being the name of the web-site the client wishes to visit (the Server Name Indication or SNI).  This can be a major privacy leak, like when accessing a dissident news source hosted on a Content Delivery Network (&lt;a href=&#34;https://en.wikipedia.org/wiki/Content_delivery_network&#34;&gt;CDN&lt;/a&gt;). A visible domain name also provides a straightforward method for censors to block websites and internet services. &lt;a href=&#34;https://www.tolerantnetworks.com/about-us.html&#34;&gt;Tolerant Networks Limited&lt;/a&gt; and the Guardian Project successfully ran the &lt;a href=&#34;https://www.opentech.fund/&#34;&gt;OTF&lt;/a&gt;-funded &lt;a href=&#34;https://defo.ie/&#34;&gt;DEfO&lt;/a&gt; project that &lt;a href=&#34;https://guardianproject.info/2021/11/30/implementing-tls-encrypted-client-hello/&#34;&gt;developed interoperable implementations&lt;/a&gt; of ECH for OpenSSL, Conscrypt and, via those libraries, a range of ECH-enabled web servers and clients.  This second funded project, DEfO-2, is a timely continuation of that project from the same the team.  As needed for disambiguation, we use DEfO-1 to refer the completed project and DEfO-2 for this current project. When there’s no ambiguity, we use the DEfO acronym to cover both past and future work related to ECH for OpenSSL, related applications and other TLS stacks.&lt;/p&gt;

&lt;p&gt;As the IETF standard for ECH completes, our key objectives are to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Upstream DEfO code&lt;/li&gt;
&lt;li&gt;Integrate ECH into more clients and servers&lt;/li&gt;
&lt;li&gt;Gain and document operational experience&lt;/li&gt;
&lt;li&gt;Submit key code for red team audits&lt;/li&gt;
&lt;li&gt;Publish open-source ECH provisioning tools&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The key challenges we expect to face in meeting those objectives are: firstly, dealing with the OpenSSL and other upstream code bases (e.g. nginx, Apache HTTP Server) - satisfying upstream developers when dealing with complex code changes, as are involved here, has proven to be quite time and effort consuming. Secondly, it is a challenge to arrange the trials we have envisaged for DEfO-2 but doing so should help to demonstrate that web sites can easily and safely enable ECH without putting themselves at risk of interoperability failures or adverse attention from censors and without further centralising the web. Lastly, there are some remaining technical challenges not addressed in DEfO-1 (proprietary TLS ClientHello extension handling, interactions between TLS Hello Retry Request and ECH, and privacy analyses of split-mode ECH deployments) that we plan to address in DEfO-2.&lt;/p&gt;

&lt;p&gt;The key challenges we aim to mitigate for users is the ease with which user activity can be tracked and blocked based on clear text SNI. Secondarily, our focus on web-server integrations and provisioning mechanisms for ECH addresses Internet centralisation (which itself poses potential risks for censorship) by ensuring this technology can be easily deployed without having to depend on entities such as global-scale CDNs.&lt;/p&gt;

&lt;p&gt;The primary gaps addressed by DEfO are: the privacy-leak that is clear text SNI in TLS and secondly that nobody else has been developing an ECH implementation for OpenSSL, which is one of the most widely used TLS stacks, particularly for web servers. That situation has not changed since DEfO-1 started. Arguably filling that gap has become more pressing as some browsers now ship with ECH support.&lt;/p&gt;

&lt;p&gt;ECH is designed to contribute to the safety of users by removing one the the main remaining aspects of the web that allows network observers to easily monitor and censor web traffic based on either client DNS queries (browsers typically only use ECH when DoH has been used) and the Server Name Indication (SNI) in the TLS handshake, which is encrypted via ECH. The eventual goal is that use of ECH becomes near ubiquitous, and that goal is very achievable for web sites that make use of a CDN. DEfO however also has a focus on ECH support in various web servers and proxies (Apache, nginx, lighttpd, HAProxy) so that users of deployments that don’t use a commercial CDN can also benefit from ECH. The result of using ECH should be that neither the DNS query nor the TLS exchange leak the name of the web server with which the browser is establishing contact, thus taking away a still-easy opportunity for monitoring and censorship.&lt;/p&gt;

&lt;p&gt;Censors however, especially at the nation-state level, might choose to block all uses of ECH, which is something that is to be expected. The main mitigation for that envisaged is that browsers, even while not using ECH, will emit “fake” (or GREASEd) ECH values, thus increasing the costs if a censor decides to block all use of ECH. The extent to which GREASEing will be an effective mitigation for blocking all ECH will essentially
end up as a political/commercial decision for censors, browser makers, and web sites, but what we can say is that for now at least, browser makers and the larger CDNs do seem committed to making use of ECH. So we can have some hope that even the most capable censors might have to think hard before blocking all ECH. In DEfO-2 we are also planning some significant-scale trials that, if successful, should go a long way towards helping other significant web sites overcome fears related to enabling ECH. Overcoming a fear that one’s web site may be blocked if one deploys ECH will be a valuable result of DEfO-2 should our trials come to fruition as we hope.&lt;/p&gt;

&lt;p&gt;We do see a number of usability issues for those deploying web servers that need to be addressed, and that we plan to address in DEfO-2. Our approach is to aim for the same level of usability for web server administrators as has been achieved by &lt;a href=&#34;https://certbot.eff.org/&#34;&gt;&lt;em&gt;certbot&lt;/em&gt;&lt;/a&gt; as it interacts with Let&amp;rsquo;s Encrypt or other CAs. Making it easy to enable ECH, especially for &amp;ldquo;smaller&amp;rdquo; web properties is high priority for DEfO.&lt;/p&gt;

&lt;p&gt;The outcome for which we hope is the upstreaming of ECH into important code bases, and to have demonstrated that one can deploy ECH easily at either small or large scale. The impact we expect is that we continue to significantly contribute to the use of ECH becoming near ubiquitous.&lt;/p&gt;

&lt;h2 id=&#34;timeliness&#34;&gt;Timeliness&lt;/h2&gt;

&lt;p&gt;The time is now ripe for DEfO-2:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://support.mozilla.org/en-US/kb/faq-encrypted-client-hello&#34;&gt;Firefox&lt;/a&gt; now supports ECH by default.&lt;/li&gt;
&lt;li&gt;Chrome supports ECH in &lt;a href=&#34;https://groups.google.com/a/chromium.org/g/blink-dev/c/KrPqrd-pO2M/m/_8Lfd5xcAwAJ&#34;&gt;10% of stable releases&lt;/a&gt; as of August 2023.&lt;/li&gt;
&lt;li&gt;Brave now also supports ECH, &lt;a href=&#34;https://github.com/brave/brave-browser/issues/1851#issuecomment-1763176335&#34;&gt;behind the same flags&lt;/a&gt; as Chromium&lt;/li&gt;
&lt;li&gt;These browser developments, plus the server code developed by DEfO-1, now enable us to plan real-world experiments&lt;/li&gt;
&lt;li&gt;Cloudflare has &lt;a href=&#34;https://developers.cloudflare.com/ssl/edge-certificates/ech/&#34;&gt;beta support&lt;/a&gt; for enabling ECH.&lt;/li&gt;
&lt;li&gt;During the run-time of DEfO-2 we expect to be in a position to run trials with significant players that could significantly assist with the goal of making use of ECH common for large web sites.&lt;/li&gt;
&lt;li&gt;The DEfO-2 project timeline should also cover the finalisation of the IETF specification for ECH, significant progress on ancillary specifications (e.g. for provisioning) and provide sufficient time for upstreaming of DEfO code&lt;/li&gt;
&lt;li&gt;DEfO-2 benefits from the same team as DEfO-1 – Tolerant Networks and the Guardian Project having co-operated successfully on DEfO-1 are looking forward to continuing that collaboration and to extending the team for DEfO-2&lt;/li&gt;
&lt;li&gt;HPKE, a core part of ECH, but with broader applicability, is now RFC9180 and the OpenSSL maintainers merged our DEfO code for HPKE in November 2022.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&#34;our-development-projects&#34;&gt;Our development projects&lt;/h2&gt;

&lt;p&gt;The DEfO project implemented Encrypted ClientHello (ECH) support for OpenSSL and Conscrypt, carried out interoperability testing of those implementations, and also used those libraries to ECH-enable various web servers and clients. We deployed services using these web servers and the DNS infrastructure required to support automated key upated for the HTTPS RRs associated with those services. Here we provide a short overview of that work in order to help with larger scale experiments and with further development of the ECH specification.&lt;/p&gt;

&lt;h3 id=&#34;libraries&#34;&gt;Libraries&lt;/h3&gt;

&lt;p&gt;As part of the DEfO project, we ECH-enabled two important TLS libraries:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.conscrypt.org/&#34;&gt;Conscrypt&lt;/a&gt; is a Java Security Provide (a library) that provides a Java &amp;ldquo;wrapper&amp;rdquo; for the C++ language boringssl library. Conscrypt is commonly used as the TLS provider for applications running on Android devices and is thus an attractive target to allow many clients to be ECH-enabled. (We do not target browser clients in DEfO as work on ECH-enabling those is being done by browser-makers.) The authors of boringssl (Google) have added ECH support to a version of their code, and we used that to enhance Conscrypt to call the new borinssl APIs required to use ECH and to provide mechanisms for applications to default to, or signal use of, ECH.&lt;/li&gt;
&lt;li&gt;OpenSSL is a long-lived library providing cryptographic and TLS services that is used by many applications, including many web servers and hence is an attractive target for ECH-enabling, especially for server-side functionality. Our ECH-enabled fork of OpenSSL is here.&lt;/li&gt;
&lt;li&gt;We have and will continue to work with the developers of other TLS libraries (e.g. wolfSSL) to assist in ECH-enabling their code, mostly via interoperability testing.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&#34;clients&#34;&gt;Clients&lt;/h3&gt;

&lt;p&gt;We ECH-enabled implemented the following TLS client applications:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;OpenSSL &lt;code&gt;s_client&lt;/code&gt; - this client application comes as part of the OpenSSL build but is commonly used for testing and as an extremely simple scriptable TLS client.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;curl&lt;/em&gt; is a widely-used command line web client that can use OpenSSL for TLS support, so we &lt;a href=&#34;https://github.com/sftcd/curl/blob/ECH-experimental/docs/ECH.md&#34;&gt;ECH-enabled that&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;F-Droid is an Android client application that provides an installable catalogue of FOSS applications and that uses Conscrypt. We made an ECH-enabled build called &lt;a href=&#34;https://f-droid.org/packages/ie.defo.ech_apps/&#34;&gt;DEfO ECH Apps&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&#34;servers&#34;&gt;Servers&lt;/h3&gt;

&lt;p&gt;We ECH-enabled implemented the following web servers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Apache HTTP Server is one of the two most commonly used web servers today, you can try our &lt;a href=&#34;https://github.com/sftcd/httpd&#34;&gt;ECH-enabled fork&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;nginx&lt;/em&gt; is the other web server in the &amp;ldquo;top two.&amp;rdquo;, you can try our &lt;a href=&#34;https://github.com/sftcd/nginx&#34;&gt;ECH-enabled fork&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;lighttpd is a web server that is commonly used on smaller devices such as home routers, you can try our &lt;a href=&#34;https://github.com/sftcd/lighttpd1.4&#34;&gt;ECH-enabled fork&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;HAProxy is widely used as an HTTP ingress proxy and so is a good target for exploring ECH split-mode, you can try our &lt;a href=&#34;https://github.com/sftcd/haproxy&#34;&gt;ECH-enabled fork&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;OpenSSL &lt;code&gt;s_server&lt;/code&gt; - this example server application is part of the OpenSSL build and is commonly used for testing and experimentation.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&#34;test-tools&#34;&gt;Test tools&lt;/h3&gt;

&lt;p&gt;Amongst the test tooling we developed are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Comprehensive OpenSSL make test targets for HPKE and ECH.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/defo-project/EchInteropTest&#34;&gt;ECHInteropTest&lt;/a&gt; is a Java client for interoperability testing on Android.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/sftcd/echdnsfuzz&#34;&gt;&lt;em&gt;echdnsfuzz&lt;/em&gt;&lt;/a&gt; is a catalogue of &amp;ldquo;interesting&amp;rdquo; ECHConfigList values that could cause issues for clients combined with a service to randomly select one of those for publication in the public DNS every 30 minutes. This is a useful part of fuzz-testing an ECH-enabled client application.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&#34;issues-arising&#34;&gt;Issues Arising&lt;/h2&gt;

&lt;p&gt;We saw the following issues that could benefit from further work to ease deployment of ECH:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For HAProxy, since DEfO-1 we have achieved support for HelloRetryRequest in ECH split-mode but have further work to do on ECH key rotation.&lt;/li&gt;
&lt;li&gt;There can sometimes be a lack of clarity as to which software component should be responsible for choosing to attempt real (i.e. non-GREASEd) ECH, and hence to be responsible for the additional DNS queries required to acquire an ECHConfig. For libraries like OpenSSL and boringssl it clearly only makes sense for that decision (and hence any new DNS handling code) to be outside the library. For a browser, it as clearly makes sense for that code to be in the browser application layer. With &amp;ldquo;middleware&amp;rdquo; though, such as OkHTTP or Conscrypt it can be hard to know which is the correct decision.&lt;/li&gt;
&lt;li&gt;The new DNS code required for handling HTTPS RRs is not too complex but the full generality of SVCB is extremely complex. Adding such complexity (and associated caching) is a major change for clients like curl that have to date only had to have a very simple model for DNS - essentially only querying A/AAAA and having almost trivial caching in the application itself.&lt;/li&gt;
&lt;li&gt;The client implementation of ECH is relatively complex in that it &amp;ldquo;touches&amp;rdquo; the TLS state machine in many ways, and hence requires changes in a lot of places. As well as increasing the cost of implementing this also increases the costs associated with testing and upstreaming.&lt;/li&gt;
&lt;li&gt;Achieving the same level of usability as &lt;code&gt;certbot&lt;/code&gt; for web server administrators may be challenging, but is an important goal to make it easy for web server administrators to be able to easily deploy ECH.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&#34;conclusions&#34;&gt;Conclusions&lt;/h2&gt;

&lt;p&gt;ECH is demonstrably implementable and can be deployed. We don&amp;rsquo;t yet know if new issues will become apparent as larger-scale experiments are carried out, but we should find out during the run-time of DEfO-2.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>IETF116 Conference Report: Tuesday March 28, 2023</title>
      <link>https://guardianproject.github.io/info/2023/03/29/ietf116-conference-report-tuesday-march-28-2023/</link>
      <pubDate>Wed, 29 Mar 2023 00:00:00 +0000</pubDate>
      
      <guid>https://guardianproject.github.io/info/2023/03/29/ietf116-conference-report-tuesday-march-28-2023/</guid>
      <description>&lt;p&gt;&lt;em&gt;Day Two of the &lt;a href=&#34;https://www.ietf.org/how/meetings/116/&#34;&gt;116th IETF meeting&lt;/a&gt; in Yokohama Japan.  For the rundown on Day One, see my &lt;a href=&#34;https://guardianproject.info/2023/03/28/ietf116-conference-report-monday-march-28-2023/&#34;&gt;daily report&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The &lt;a href=&#34;https://datatracker.ietf.org/wg/ohai/about/&#34;&gt;OHAI Working Group&lt;/a&gt; has submitted the core draft of &lt;a href=&#34;https://datatracker.ietf.org/doc/draft-ietf-ohai-ohttp/&#34;&gt;Oblivious HTTP Application Intermediation&lt;/a&gt; to the RFC Editor for editorial finalization and publication. OHAI is designed to support &lt;em&gt;transational&lt;/em&gt; uses of the HTTP protocol that seek IP address privacy (by means of a relay pair, one associated with the client and one associated with the target resource). The target resource is, thus, said to be &lt;em&gt;oblivious&lt;/em&gt; to the requester&amp;rsquo;s IP address.  While the initially-imagined use case for OHAI was access to the DNS service (with some in the IETF feeling DNS-over-HTTP did not go far enough to protect user privacy), the dominant  use case imagined today is &lt;em&gt;telemetry&lt;/em&gt; - monitoring vendor-, application- or operating system-defined usage parameters on centralized systems.&lt;/p&gt;

&lt;p&gt;It&amp;rsquo;s fair to ask how OHAI-capable services are to be discovered.  The OHAI Working Group is proposing to use DNS &lt;em&gt;Service Binding Records&lt;/em&gt; (SVCB, defined &lt;a href=&#34;https://datatracker.ietf.org/doc/draft-ietf-dnsop-svcb-https/&#34;&gt;here&lt;/a&gt; and well-described &lt;a href=&#34;https://www.sobyte.net/post/2022-01/dns-svcb-https/&#34;&gt;here&lt;/a&gt;). TLS 1.3 Encrypted Client Hello is among the other IETF standards leveraging SVCB.  SVCB records, similar to the (also new) HTTPS records, allow a host of define multiple ways to make connection with parameterization using just the DNS lookup (as opposed to the multiple round-trip mechanism of HTTP&amp;rsquo;s Alt-Svc header).  The draft - &lt;a href=&#34;https://datatracker.ietf.org/doc/draft-ietf-ohai-svcb-config/&#34;&gt;Discovery of Oblivious Services via Service Binding Records&lt;/a&gt; has been under Working Group discussion since IETF113 and is close to submission for last call (technical completion).&lt;/p&gt;

&lt;p&gt;Speaking of &lt;a href=&#34;https://datatracker.ietf.org/doc/rfc8446/&#34;&gt;TLS 1.3&lt;/a&gt; and Service Binding Records, Encrypted Client Hello &lt;a href=&#34;https://www.ietf.org/archive/id/draft-ietf-tls-esni-14.html&#34;&gt;ECH&lt;/a&gt; was, in fact, the reason SVCB records were defined. DNS lookup is the only point at which certain cryptographic information can be made available before all the connection encryption starts to happen.  Unfortunately, the SVCB draft is stuck in the RFC Editor work queue behind ECH, even though there is language in ECH that references SVCB.  The Working Group is therefore required to remove all the SVCB language from the ECH draft so that it may proceed.  This procedural detail - and accompanying delay - has important consequences: the major open source software package that requires modification before ECH can expect wide adoption (OpenSSL) is waiting for ECH to become a full-fledged RFC before the submitted pull requests will be granted.  Meanwhile there is plenty of experimentation with ECH happening on the live Internet with Mozilla/Firefox and Cloudflare running experiments.&lt;/p&gt;

&lt;p&gt;It turns out there&amp;rsquo;s an alternative (or perhaps &lt;em&gt;parallel&lt;/em&gt;) proposal for TLS 1.3 - &lt;a href=&#34;https://datatracker.ietf.org/doc/draft-ietf-tls-ctls/&#34;&gt;CompactTLS&lt;/a&gt; - an effort begun in 2019 and now in it&amp;rsquo;s eighth revision.  cTLS proposes to &lt;code&gt;save bandwidth by trimming obsolete material, tighter encoding, a template-based specialization technique, and alternative cryptographic techniques. cTLS is not directly interoperable with TLS 1.3 or DTLS 1.3 since the over-the-wire framing is different.&lt;/code&gt;  cTLS is undergoing formal analysis and implementation work proceeds, though no results are currently available.&lt;/p&gt;

&lt;p&gt;The &lt;a href=&#34;https://datatracker.ietf.org/wg/httpbis/charter/&#34;&gt;HTTPbis Working Group&lt;/a&gt; formally adopted the &lt;a href=&#34;https://datatracker.ietf.org/doc/draft-ietf-httpbis-unprompted-auth/&#34;&gt;HTTP Unprompted Authentication&lt;/a&gt; specification in the month before IETF116.  As a reminder, Unprompted Authentication allows a server to offer authenticated services without advertising that it does so (meaning the authenticated resources can not be actively probed). A number of semantic elements are under discussion, mostly to understand how this new feature is unique among existing HTTP features (and can, or can not, be aligned with &lt;em&gt;adjacent&lt;/em&gt; capabilities). An action item for IETF117 is a formal analysis of the cryptography used, with several alternatives being proposed.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>IETF: Year End Review 2021</title>
      <link>https://guardianproject.github.io/info/2021/12/23/ietf-year-end-review-2021/</link>
      <pubDate>Thu, 23 Dec 2021 00:00:00 +0000</pubDate>
      
      <guid>https://guardianproject.github.io/info/2021/12/23/ietf-year-end-review-2021/</guid>
      <description>&lt;p&gt;In terms of potential impact on Internet Freedom, it’s been a banner year at the Internet Engineering Task Force &lt;a href=&#34;https://ietf.org/&#34;&gt;(IETF)&lt;/a&gt;.  &lt;a href=&#34;https://datatracker.ietf.org/doc/rfc9000/&#34;&gt;QUIC&lt;/a&gt; (featuring the improved privacy and security of &lt;a href=&#34;https://datatracker.ietf.org/doc/html/rfc8446&#34;&gt;TLS1.3&lt;/a&gt;) reached Proposed Standard status, with implementations and rollouts from every major vendor on both server and client, and with multiple &lt;a href=&#34;https://en.wikipedia.org/wiki/QUIC#Source_Code&#34;&gt;open source toolkit options&lt;/a&gt; for developers.  &lt;a href=&#34;https://datatracker.ietf.org/doc/draft-ietf-tls-esni/&#34;&gt;Encrypted Client Hello&lt;/a&gt; for TLS1.3 gained traction via the &lt;a href=&#34;https://defo.ie&#34;&gt;DEfO project&lt;/a&gt; that, through pull requests, makes a huge privacy enhancement easily available to the major security library (OpenSSL) underpinning the Internet’s most important service engines (nginx, apache, lighttpd, haproxy on the server, even curl on the client).  IP address privacy got new attention with a working group formed around Oblivious HTTP Application Intermediation (&lt;a href=&#34;https://datatracker.ietf.org/doc/charter-ietf-ohai/&#34;&gt;OHAI&lt;/a&gt;), as did Privacy-Preserving Measurement (&lt;a href=&#34;https://datatracker.ietf.org/doc/bofreq-privacy-preserving-measurement/&#34;&gt;PPM&lt;/a&gt;) which seeks to drastically reduce the amount of personal information swept up in the pervasive monitoring of all public Internet activity.  Meanwhile, the Internet Research Task Force (&lt;a href=&#34;https://irtf.org&#34;&gt;IRTF&lt;/a&gt;) has focused on developing new cryptographic techniques to serve these rapidly-evolving privacy-focused activities. IRTF also fosters work on truly-global Internet access and, in a sense, serves as the IETF’s conscience through it’s work on the &lt;a href=&#34;https://datatracker.ietf.org/rg/hrpc/about/&#34;&gt;human rights implications of protocol design&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Yet, it’s valid to ask: will the Internet be more free when/if these proposals become widely-deployed standards? While there’s sound reason for hope, I see two major concerns that could significantly reduce the positive impact of this work.&lt;/p&gt;

&lt;p&gt;The first concern is extreme pushback from the major state actors who want more control over how their citizens use the Internet.  While QUIC, TLS1.3 and ECH appear to be headed for full adoption in regions where the Internet is already nominally free, they amount to a &lt;a href=&#34;https://www.poker.org/poker-hands-ranking-chart/&#34;&gt;royal flush&lt;/a&gt; for the good guys in the regions where it is not. The reaction? Stop playing the game (the major state actors have already blocked QUIC).  What’s going to be the reaction when ECH makes ubiquitous domain-fronting possible?  Will that just increase the number of states participating in blocking QUIC?  It’s important to remember, state actors &lt;a href=&#34;https://www.huawei.com/us/technology-insights/industry-insights/innovation/new-ip&#34;&gt;have options&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The second concern is centralization.  The Internet has gotten more centralized over time, both in the way the breadth of its content is hosted and in the number of services users visit to view that content.  Further, national gateways have seen massive consolidation in the last five years as most states reduce exposure in the name of terrorism prevention and reducing the flow of disinformation.  This centralization has worsened the &lt;a href=&#34;https://datatracker.ietf.org/doc/rfc7258/&#34;&gt;pervasive monitoring&lt;/a&gt; all users suffer under and has made it difficult (at best) to trust service providers with even the most benign-seeming of our personal data. Yet, the privacy solutions under development at IETF - OHAI and PPM, along with &lt;a href=&#34;https://datatracker.ietf.org/wg/privacypass/about/&#34;&gt;Privacy Pass&lt;/a&gt; and others - all rely on layers of new infrastructure operated by these same providers, seeming to require us to put even more trust in them.  Directionally, is that sustainable?  It’s important to remember, we users also &lt;a href=&#34;https://permission.io/blog/web-3-0/&#34;&gt;have options&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;During 2022, I’ll be looking more critically at how IETF addresses these concerns. IETF continues to be the most open and responsive standards organization determining the Internet’s future.  It feels like we’re reaching a point where Internet Freedom isn’t any longer a niche interest, but rather the central focus of progress for mankind in terms of our intercommunication as citizens of the planet. The best option would seem to be an IETF at the forefront of that progress.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Implementing TLS Encrypted Client Hello</title>
      <link>https://guardianproject.github.io/info/2021/11/30/implementing-tls-encrypted-client-hello/</link>
      <pubDate>Tue, 30 Nov 2021 00:00:00 +0000</pubDate>
      
      <guid>https://guardianproject.github.io/info/2021/11/30/implementing-tls-encrypted-client-hello/</guid>
      <description>

&lt;p&gt;As part of the &lt;a href=&#34;https://defo.ie/&#34;&gt;DEfO&lt;/a&gt; project, we have been working on
accelerating the development &lt;a href=&#34;https://www.ietf.org/archive/id/draft-ietf-tls-esni-13.html&#34;&gt;Encrypted Client Hello
(ECH)&lt;/a&gt; as
standardized by the IETF.  ECH is the next step in improving Transport Layer
Security (TLS).  TLS is one of the basic building blocks of the internet, it is
what puts the S in HTTPS.  The ECH standard is nearing completion.  That is
exciting because ECH can encrypt the last plaintext TLS metadata that it is
possible to encrypt.  So ECH will bring some real improvements in privacy and
censorship resistance.&lt;/p&gt;

&lt;p&gt;ECH is built on top of TLSv1.3 and &lt;a href=&#34;https://blog.cloudflare.com/handshake-encryption-endgame-an-ech-update/&#34;&gt;completes unfinished
work&lt;/a&gt;
from the TLSv1.3 effort, now that private DNS is a thing. ECH is now in draft-13
and there are many implementations that are interoperating. ECH is working for
&lt;a href=&#34;https://github.com/sftcd/openssl&#34;&gt;OpenSSL&lt;/a&gt;, &lt;a href=&#34;https://bugs.chromium.org/p/boringssl/issues/detail?id=275&#34;&gt;BoringSSL&lt;/a&gt;, &lt;a href=&#34;https://github.com/sftcd/nginx&#34;&gt;nginx&lt;/a&gt;, &lt;a href=&#34;https://github.com/sftcd/httpd&#34;&gt;Apache HTTPD&lt;/a&gt;, &lt;a href=&#34;https://github.com/sftcd/lighttpd1.4&#34;&gt;lighttpd&lt;/a&gt;,
&lt;a href=&#34;https://github.com/sftcd/haproxy/commits/ECH-experimental&#34;&gt;HAProxy&lt;/a&gt;, &lt;a href=&#34;https://github.com/guardianproject/conscrypt/tree/2.6.alpha1638179154.job1828169525&#34;&gt;Conscrypt&lt;/a&gt;, &lt;a href=&#34;https://github.com/niallor/curl&#34;&gt;curl&lt;/a&gt;, and more. There is work underway in &lt;a href=&#34;https://bugzilla.mozilla.org/show_bug.cgi?id=1725938&#34;&gt;Firefox&lt;/a&gt;
and &lt;a href=&#34;https://bugs.chromium.org/p/chromium/issues/detail?id=1091403&#34;&gt;Chromium&lt;/a&gt;. It has been sketched out for &lt;a href=&#34;https://github.com/square/okhttp/issues/6539&#34;&gt;OkHTTP&lt;/a&gt;. Draft versions of ESNI
and ECH have been deployed in Firefox releases and some production web services.&lt;/p&gt;

&lt;p&gt;The main downside of ECH is that it is
&lt;a href=&#34;https://defo.ie/report.html#issuesarising&#34;&gt;complex&lt;/a&gt;, and most of that is
unavoidable.  Large scale websites have complicated server-side setups, and ECH
has to work in those setups.  That is where ECH&amp;rsquo;s complexity comes from.  &lt;a href=&#34;https://www.ietf.org/archive/id/draft-ietf-dnsop-svcb-https-07.html&#34;&gt;DNS
SVCB and HTTPS RR
Types&lt;/a&gt; is a
related standard to encapsulate the complexity of large scale websites a single
DNS lookup.  It adds additional complexity since it might include the TCP port
number for the service, while TLS implementations mostly assume that the port
number is known before doing a DNS lookup.&lt;/p&gt;

&lt;p&gt;ECH was formerly known as Encrypted SNI (ESNI), which it replaces.  So do not
expect updates to ESNI unless ECH proves too complicated for implementers. ECH
is more complex to implement in the TLS library than ESNI.  Once it is
implemented in the TLS library, then implementing the next level of managing the
keys and hostnames is quite similar between ESNI and ECH.  The rest of this post
will be diving into details about that complexity and what it takes to implement
ECH.&lt;/p&gt;

&lt;p&gt;&lt;img src=&#34;do-not-stick-out.jpg&#34; alt=&#34;Do Not Stick Out&#34; /&gt;&lt;/p&gt;

&lt;h2 id=&#34;do-not-stick-out&#34;&gt;Do Not Stick Out&lt;/h2&gt;

&lt;p&gt;ECH implementers must also work to ensure that their implementation does not
create packets that look &lt;a href=&#34;https://www.ietf.org/archive/id/draft-ietf-tls-esni-13.html#name-do-not-stick-out&#34;&gt;look
different&lt;/a&gt;
than other implementations.  How ECH is implemented will affect
fingerprintability.  Right now, BoringSSL, OpenSSL, and Firefox all put the ECH
extension in different places, so it is easy for a network observer to tell
which of them is serving as the client in a TLS session.  Ideally, all
implementations would create network packages that look identical to the network
observer.  To get an idea of this problem in the real world, see &lt;a href=&#34;https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40014&#34;&gt;this detailed
technical
discussion&lt;/a&gt;
of metadata ordering in DTLS as used in WebRTC.&lt;/p&gt;

&lt;h2 id=&#34;getting-the-keys&#34;&gt;Getting the keys&lt;/h2&gt;

&lt;p&gt;ECH encrypts the first stage of the negotiation between the client and server,
the &lt;em&gt;ClientHello&lt;/em&gt; packet using a new type of key and related configuration.
This is known as an &amp;ldquo;ECH Config&amp;rdquo;.  This negotiation is what sets up the
encrypted TLS connection, so to encrypt the negotiation, so the keys can not be
derived from the certificates and negotiation itself.  ECH also needs new
methods distributing this ECH Config.  HTTPS/SVCB therefore includes ECH Config Lists,
and DNS is the recommended way to get ECH Config Lists.  Other distribution
methods are also possible, and ECH implementation should provide a method to
directly supply ECH Config Lists.&lt;/p&gt;

&lt;p&gt;When using ECH in conjunction with HTTPS/SVCB, the DNS needs to be handled differently
than the common, decades old practices that most TLS stacks are built on.  The
ECH Config List must match the IP address so that multi-CDN setups still work.
That ensures the server gets the ECH Config that matches its ECH private keys,
not the one for a separate server.  If the A/AAAA lookup is done separately from
the HTTPS/SVCB lookup, they might not match since the results could come from
different caches, etc.  It is not yet clear where the right place to handle that
DNS is, but it is clear that clients that implement HTTPS/SVCB and ECH will need to
consider that DNS will touch different parts of the stack.&lt;/p&gt;

&lt;p&gt;Which part of the stack will handle the HTTPS/SVCB look up depends on whether
the code is acting as a library or more as the client itself.  For example,
libraries like OkHTTP or Conscrypt can both act as a TLS library, providing the
blocks for implementing TLS in an app.  They can also act as the TLS client
itself, the app just needs to open the hostname and port to get a connection.
This is especially true for OkHTTP, which can also handle DNS itself with its
own DNS-over-HTTPS implementation.  Most apps will expect to just open a URL and
have it work without providing anything else.  In the case of HTTP libraries
like OkHTTP or Volley, Conscrypt becomes the provider of TLS functions rather
than the client.  OkHTTP&amp;rsquo;s default setup will probably want to treat Conscrypt
like the client and do zero config.  But there are use cases where apps want to
handle DNS in OkHTTP, in that case Conscrypt is a library.  Another way this
could be broken down would be to have Conscrypt only be the TLS library, then
leave the DNS to the HTTP stacks.  Then each HTTP library would have to have
their own ECH and HTTPS/SVCB handling (In Android, that would mean
&lt;tt&gt;HttpURLConnection&lt;/tt&gt;, OkHTTP, Volley, Apache HTTP Client, etc).  Python
provides another example with HTTP libraries like &lt;a href=&#34;https://github.com/psf/requests/issues/5972&#34;&gt;Requests&lt;/a&gt; working in
combination with the core &lt;a href=&#34;https://bugs.python.org/issue45567&#34;&gt;&lt;tt&gt;ssl&lt;/tt&gt;&lt;/a&gt; module.&lt;/p&gt;

&lt;p&gt;One thing that is clear here: whichever piece initiates the HTTPS/SVCB DNS query
should also handle the ECH Config, and setting up the lower levels.  On top of
this, ECH has GREASE and &amp;ldquo;Retry Configs&amp;rdquo;.  GREASE is a key part of ensuring that
ECH connections do not stick out.  GREASE makes the network observer see TLS
packets that look the same as connections that successfully used an ECH Config
to encrypt.  Retry Configs are sent by the server if it cannot decrypt what the
client sent.  Whichever piece of the code handles the ECH Config List should
then also handle GREASE and the Retry Configs.&lt;/p&gt;

&lt;p&gt;&lt;a href=&#34;https://blog.cloudflare.com/encrypted-client-hello/&#34;&gt;&lt;img src=&#34;tls-ech-negotiation.png&#34; alt=&#34;TLS ECH Negotiation&#34; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&#34;outer-and-inner-clienthello&#34;&gt;Outer and Inner &lt;em&gt;ClientHello&lt;/em&gt;&lt;/h2&gt;

&lt;p&gt;This post began by saying that ECH was complex.  Most of that complexity stems
from the concept of &lt;em&gt;ClientHelloOuter&lt;/em&gt; and &lt;em&gt;ClientHelloInner&lt;/em&gt;.  They are sort of
parallel versions of the TLS &lt;em&gt;ClientHello&lt;/em&gt;, with &lt;em&gt;ClientHelloOuter&lt;/em&gt; being
plaintext and &lt;em&gt;ClientHelloInner&lt;/em&gt; being encrypted.  Many of the same bits of
metadata can be set in either &lt;em&gt;ClientHelloOuter&lt;/em&gt; or &lt;em&gt;ClientHelloInner&lt;/em&gt;, or even
in both.  And the outer and inner values can be different.  For example, the
outer plaintext SNI could be set to a generic domain name, while the inner could
be set to a different domain name that the client wants to protect.  Whenever
the client needs to manage what is set in &amp;ldquo;inner&amp;rdquo;, &amp;ldquo;outer&amp;rdquo;, etc., then extra
complexity is exposed all the way up to the app using the ECH client.  Also, so
many possible configuration options also means so many ways that the negotiation
might fail.&lt;/p&gt;

&lt;p&gt;BoringSSL&amp;rsquo;s &lt;code&gt;SSL_set1_ech_config_list()&lt;/code&gt; provides a good example of this complexity:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If a supported ECHConfig is found, &lt;tt&gt;ssl&lt;/tt&gt; will encrypt the true
ClientHello parameters. If the server cannot decrypt it, e.g. due to a key
mismatch, ECH has a recovery flow. &lt;tt&gt;ssl&lt;/tt&gt; will handshake using the
cleartext parameters, including a public name in the ECHConfig. If using
&lt;tt&gt;SSL_CTX_set_custom_verify&lt;/tt&gt;, callers should use
&lt;tt&gt;SSL_get0_ech_name_override&lt;/tt&gt; to verify the certificate with the public
name. If using the built-in verifier, the &lt;tt&gt;X509_STORE_CTX&lt;/tt&gt; will be
configured automatically.&lt;/p&gt;

&lt;p&gt;If no other errors are found in this handshake, it will fail with
&lt;tt&gt;SSL_R_ECH_REJECTED&lt;/tt&gt;. Since it didn&amp;rsquo;t use the true parameters, the
connection cannot be used for application data. Instead, callers should handle
this error by calling &lt;tt&gt;SSL_get0_ech_retry_configs&lt;/tt&gt; and retrying the
connection with updated ECH parameters. If the retry also fails with
&lt;tt&gt;SSL_R_ECH_REJECTED&lt;/tt&gt;, the caller should report a connection failure.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&#34;a-walk-through-which-pieces-needs-to-do-what&#34;&gt;A walk through which pieces needs to do what&lt;/h2&gt;

&lt;p&gt;Let us return to the Python example to go through the pieces needed to implement
ECH there.  Starting at the lowest level, the Python &lt;tt&gt;ssl&lt;/tt&gt; is built on
top of OpenSSL, so the new ECH functions in OpenSSL need to be included and
exposed in &lt;tt&gt;ssl&lt;/tt&gt;&amp;rsquo;s API.  Unlike with a plain TLSv1.3 connection,
&lt;tt&gt;ssl&lt;/tt&gt; would not set up an ECH connection without additional configuration
as long as &lt;tt&gt;ssl&lt;/tt&gt; does not include the additional DNS requirements needed
to fetch the ECH Config.  The DNS could instead be implemented in the HTTP
library.  Requests is built on top of urllib3, so urllib3 could implement
HTTPS/SVCB handling.  Then Requests would automatically get ECH connections.
Since it can be necessary to handle the ECH Config outside of DNS, urllib3 and
Requests could provide methods for the app to submit the ECH Config.  This would
mean overriding any HTTPS/SVCB handling in Requests and urllib3.&lt;/p&gt;

&lt;p&gt;Based on this outline, these are the pieces that need to be implemented:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTTPS/SVCB DNS queries for getting ECH Config Lists, IP, and other config.&lt;/li&gt;
&lt;li&gt;A way to provide ECH Config Lists as bytes directly to the &lt;tt&gt;ssl&lt;/tt&gt; module.&lt;/li&gt;
&lt;li&gt;A method to ensure encrypted DNS is used so all metadata is encrypted.&lt;/li&gt;
&lt;li&gt;A method to enable and disable GREASE, ideally with GREASE default on.&lt;/li&gt;
&lt;li&gt;A callback that gets called whenever ECH negotiation fails and the server
offers a &amp;ldquo;Retry Config&amp;rdquo;.&lt;/li&gt;
&lt;li&gt;Potentially also controls of what to send in the &lt;em&gt;ClientHelloOuter&lt;/em&gt; versus the
&lt;em&gt;ClientHelloInner&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;From the point of view of the client implementation, there is a big difference
between TLS before and after ECH.  This new complexity may look scary but this
is a clear path to providing strong privacy protections with TLS that can be as
widely deployed as TLSv1.3 is now.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Security in a thumb drive: the promise and pain of hardware security modules, take one!</title>
      <link>https://guardianproject.github.io/info/2014/03/28/security-in-a-thumb-drive-the-promise-and-pain-of-hardware-security-modules-take-one/</link>
      <pubDate>Fri, 28 Mar 2014 16:54:39 -0400</pubDate>
      
      <guid>https://guardianproject.github.io/info/2014/03/28/security-in-a-thumb-drive-the-promise-and-pain-of-hardware-security-modules-take-one/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://guardianproject.info/wp-content/uploads/2014/03/cryptostick-usb-flash-drive-security-software.jpg&#34;&gt;&lt;img src=&#34;https://guardianproject.info/wp-content/uploads/2014/03/cryptostick-usb-flash-drive-security-software.jpg&#34; alt=&#34;security in a thumb drive&#34; width=&#34;219&#34; height=&#34;119&#34; class=&#34;alignleft size-full wp-image-12311&#34; srcset=&#34;https://guardianproject.info/wp-content/uploads/2014/03/cryptostick-usb-flash-drive-security-software.jpg 219w, https://guardianproject.info/wp-content/uploads/2014/03/cryptostick-usb-flash-drive-security-software-100x54.jpg 100w, https://guardianproject.info/wp-content/uploads/2014/03/cryptostick-usb-flash-drive-security-software-150x81.jpg 150w, https://guardianproject.info/wp-content/uploads/2014/03/cryptostick-usb-flash-drive-security-software-200x108.jpg 200w&#34; sizes=&#34;(max-width: 219px) 100vw, 219px&#34; /&gt;&lt;/a&gt;Hardware Security Modules (aka Smartcards, chipcards, etc) provide a secure way to store and use cryptographic keys, while actually making the whole process a bit easier. In theory, one USB thumb drive like thing could manage all of the crypto keys you use in a way that makes them much harder to steal. That is the promise. The reality is that the world of Hardware Security Modules (HSMs) is a massive, scary minefield of endless technical gotchas, byzantine standards (PKCS#11!), technobabble, and incompatibilities. Before I dive too much into ranting about the days of my life wasted trying to find a clear path through this minefield, I’m going to tell you about one path I did find through to solve a key piece of the puzzle: Android and Java package signing.&lt;/p&gt;

&lt;p&gt;&lt;a href=&#34;https://guardianproject.info/wp-content/uploads/2014/03/moreinfo_acr38t_ibs.jpg&#34;&gt;&lt;img src=&#34;https://guardianproject.info/wp-content/uploads/2014/03/moreinfo_acr38t_ibs.jpg&#34; alt=&#34;ACS ACR38-T-IBS&#34; width=&#34;320&#34; height=&#34;248&#34; class=&#34;alignright size-full wp-image-12313&#34; srcset=&#34;https://guardianproject.info/wp-content/uploads/2014/03/moreinfo_acr38t_ibs.jpg 320w, https://guardianproject.info/wp-content/uploads/2014/03/moreinfo_acr38t_ibs-300x232.jpg 300w, https://guardianproject.info/wp-content/uploads/2014/03/moreinfo_acr38t_ibs-100x77.jpg 100w, https://guardianproject.info/wp-content/uploads/2014/03/moreinfo_acr38t_ibs-150x116.jpg 150w, https://guardianproject.info/wp-content/uploads/2014/03/moreinfo_acr38t_ibs-200x155.jpg 200w&#34; sizes=&#34;(max-width: 320px) 100vw, 320px&#34; /&gt;&lt;/a&gt;For this round, I am covering the &lt;a href=&#34;http://www.aventra.fi/English/products_MyEID_E.html&#34; target=&#34;_blank&#34;&gt;Aventra MyEID PKI Card&lt;/a&gt;. I bought a SIM-sized version to fit into an &lt;a href=&#34;http://www.smartcardfocus.com/ilp/id~99/ACR38T_IBS/p/readers.shtml&#34; target=&#34;_blank&#34;&gt;ACS ACR38T-IBS-R&lt;/a&gt; smartcard reader (it is apparently no longer made, and the &lt;a href=&#34;http://acs.com.hk/en/products/1/acr38t-d1-plug-in-sim-sized-card-reader/&#34; target=&#34;_blank&#34;&gt;ACT38T-D1&lt;/a&gt; is meant to replace it). Why such specificity you may ask? Because you have to be sure that your smartcard will work with your reader, and that your reader will have a working driver for you system, and that your smartcard will have a working PKCS#11 driver so that software can talk to the smartcard. Thankfully there is the &lt;a href=&#34;https://github.com/OpenSC/OpenSC/wiki&#34; target=&#34;_blank&#34;&gt;OpenSC&lt;/a&gt; project to cover the PKCS#11 part, it implements the PKCS#11 communications standard for many smartcards. On my Ubuntu/precise system, I had to install an extra driver, &lt;code&gt;libacr38u&lt;/code&gt;, to get the ACR38T reader to show up on my system.&lt;/p&gt;

&lt;p&gt;So let’s start there and get this thing to show up! First we need some packages. The OpenSC packages are out-of-date in a lot of releases, you need version 0.13.0-4 or newer, so you have to add our PPA (Personal Package Archive) to get current versions, which include a &lt;a href=&#34;https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=742089&#34; target=&#34;_blank&#34;&gt;specific fix for the Aventra MyEID&lt;/a&gt;: (fingerprint: &lt;code&gt;F50E ADDD 2234 F563&lt;/code&gt;):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo add-apt-repository ppa:guardianproject/ppa
sudo apt-get update
sudo apt-get install opensc libacr38u libacsccid1 pcsc-tools usbutils
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;First thing, I use &lt;code&gt;lsusb&lt;/code&gt; in the terminal to see what USB devices the Linux kernel sees, and thankfully it sees my reader:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&#34;language-console&#34;&gt;$ lsusb
Bus 005 Device 013: ID 072f:9000 Advanced Card Systems, Ltd ACR38 AC1038-based Smart Card Reader
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Next, its time to try &lt;code&gt;pcsc_scan&lt;/code&gt; to see if the system can see the smartcard installed in the reader. If everything is installed and in order, then &lt;code&gt;pcsc_scan&lt;/code&gt; will report this:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&#34;language-console&#34;&gt;$ pcsc_scan 
PC/SC device scanner
V 1.4.18 (c) 2001-2011, Ludovic Rousseau &amp;lt;&amp;amp;#x6c;u&amp;amp;#x64;ov&amp;amp;#x69;c.&amp;amp;#x72;o&amp;amp;#x75;&amp;amp;#x73;s&amp;amp;#x65;au&amp;amp;#x40;f&amp;amp;#x72;&amp;amp;#x65;e&amp;amp;#x2e;fr&amp;gt;
Compiled with PC/SC lite version: 1.7.4
Using reader plug&#39;n play mechanism
Scanning present readers...
0: ACS ACR38U 00 00

Thu Mar 27 14:38:36 2014
Reader 0: ACS ACR38U 00 00
  Card state: Card inserted, 
  ATR: 3B F5 18 00 00 81 31 FE 45 4D 79 45 49 44 9A
[snip]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If &lt;code&gt;pcsc_scan&lt;/code&gt; cannot see the card, then things will not work. Try re-seating the smardcard in the reader, make sure you have all the right packages installed, and if you can see the reader in &lt;code&gt;lsusb&lt;/code&gt;. If your smartcard or reader cannot be read, then &lt;code&gt;pcsc_scan&lt;/code&gt; will report something like this:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&#34;language-console&#34;&gt;$ pcsc_scan 
PC/SC device scanner
V 1.4.18 (c) 2001-2011, Ludovic Rousseau &amp;lt;&amp;amp;#x6c;&amp;amp;#x75;&amp;amp;#x64;&amp;amp;#x6f;&amp;amp;#x76;&amp;amp;#x69;c.rousse&amp;amp;#x61;&amp;amp;#x75;&amp;amp;#x40;&amp;amp;#x66;&amp;amp;#x72;&amp;amp;#x65;e.fr&amp;gt;
Compiled with PC/SC lite version: 1.7.4
Using reader plug&#39;n play mechanism
Scanning present readers...
Waiting for the first reader...
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Moving right along… now &lt;code&gt;pcscd&lt;/code&gt; can see the smartcard, so we can start playing with using the OpenSC tools. These are needed to setup the card, put PINs on it for access control, and upload keys and certificates to it. The last annoying little preparation tasks are finding where &lt;code&gt;opensc-pkcs11.so&lt;/code&gt; is installed and the “slot” for the signing key in the card. These will go into a config file which &lt;code&gt;keytool&lt;/code&gt; and &lt;code&gt;jarsigner&lt;/code&gt; need. To get this info on Debian/Ubuntu/etc, run these:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&#34;language-console&#34;&gt;$ dpkg -S opensc-pkcs11.so
opensc: /usr/lib/x86_64-linux-gnu/opensc-pkcs11.so
$ pkcs11-tool --module /usr/lib/x86_64-linux-gnu/opensc-pkcs11.so \
&amp;gt;     --list-slots
Available slots:
Slot 0 (0xffffffffffffffff): Virtual hotplug slot
  (empty)
Slot 1 (0x1): ACS ACR38U 00 00
  token label        : MyEID (signing)
  token manufacturer : Aventra Ltd.
  token model        : PKCS#15
  token flags        : rng, login required, PIN initialized, token initialized
  hardware version   : 0.0
  firmware version   : 0.0
  serial num         : 0106004065952228
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This is the info needed to put into a &lt;code&gt;opensc-java.cfg&lt;/code&gt;, which &lt;code&gt;keytool&lt;/code&gt; and &lt;code&gt;jarsigner&lt;/code&gt; &lt;a href=&#34;http://docs.oracle.com/javase/7/docs/technotes/guides/security/p11guide.html&#34; target=&#34;_blank&#34;&gt;need in order to talk&lt;/a&gt; to the Aventra HSM. The name, library, and slot fields are essential, and the description is helpful. Here is how the &lt;code&gt;opensc-java.cfg&lt;/code&gt; using the above information looks:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&#34;language-console&#34;&gt;name = OpenSC
description = SunPKCS11 w/ OpenSC Smart card Framework
library = /usr/lib/x86_64-linux-gnu/opensc-pkcs11.so
slot = 1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now everything should be ready for initializing the HSM, generating a new key, and uploading that key to the HSM. This process generates the key and certificate, puts them into files, then uploads them to the HSM. That means you should only run this process on a trusted machine, certainly with some kind of disk encryption, and preferably on a machine that is not connected to a network, running an OS that has never been connected to the internet. A live CD is one good example, I recommend &lt;a href=&#34;https://tails.boum.org/download/index.en.html#index4h1&#34; target=&#34;_blank&#34;&gt;Tails on a USB thumb drive&lt;/a&gt; running with the &lt;a href=&#34;https://tails.boum.org/doc/first_steps/persistence/index.en.html&#34; target=&#34;_blank&#34;&gt;secure persistent store&lt;/a&gt; on it (we have been working here and there on making a TAILS-based distro specifically for managing keys, we call it &lt;a href=&#34;https://dev.guardianproject.info/projects/psst/wiki/CleanRoom&#34; target=&#34;_blank&#34;&gt;CleanRoom&lt;/a&gt;).&lt;/p&gt;

&lt;div id=&#34;attachment_12321&#34; style=&#34;width: 560px&#34; class=&#34;wp-caption aligncenter&#34;&gt;
  &lt;a href=&#34;https://guardianproject.info/wp-content/uploads/2014/03/cstick2.jpg&#34;&gt;&lt;img aria-describedby=&#34;caption-attachment-12321&#34; src=&#34;https://guardianproject.info/wp-content/uploads/2014/03/cstick2-1024x805.jpg&#34; alt=&#34;HSM plugged into a laptop&#34; width=&#34;550&#34; height=&#34;432&#34; class=&#34;size-large wp-image-12321&#34; srcset=&#34;https://guardianproject.info/wp-content/uploads/2014/03/cstick2-1024x805.jpg 1024w, https://guardianproject.info/wp-content/uploads/2014/03/cstick2-300x235.jpg 300w, https://guardianproject.info/wp-content/uploads/2014/03/cstick2-100x78.jpg 100w, https://guardianproject.info/wp-content/uploads/2014/03/cstick2-150x117.jpg 150w, https://guardianproject.info/wp-content/uploads/2014/03/cstick2-200x157.jpg 200w, https://guardianproject.info/wp-content/uploads/2014/03/cstick2-450x353.jpg 450w, https://guardianproject.info/wp-content/uploads/2014/03/cstick2-600x471.jpg 600w, https://guardianproject.info/wp-content/uploads/2014/03/cstick2-900x707.jpg 900w, https://guardianproject.info/wp-content/uploads/2014/03/cstick2.jpg 1600w&#34; sizes=&#34;(max-width: 550px) 100vw, 550px&#34; /&gt;&lt;/a&gt;
  
  &lt;p id=&#34;caption-attachment-12321&#34; class=&#34;wp-caption-text&#34;&gt;
    HSM plugged into a laptop
  &lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;First off, the HSM needs to be initialized, then set up with a signing PIN and a “Security Officer” PIN (which means basically an “admin” or “root” PIN). The signing PIN is the one you will use for signing APKs, the “Security Officer PIN” (SO-PIN) is used for modifying the HSM setup, like uploading new keys, etc. Because there are so many steps in the process, I’ve written up scripts to run thru all of the steps. If you want to see the details, &lt;a href=&#34;https://github.com/guardianproject/smartcard-apk-signing/blob/master/Aventra_MyEID_Setup/setup.sh&#34; target=&#34;_blank&#34;&gt;read&lt;/a&gt; &lt;a href=&#34;https://github.com/guardianproject/smartcard-apk-signing/blob/master/openssl-gen/gen.sh&#34; target=&#34;_blank&#34;&gt;the&lt;/a&gt; &lt;a href=&#34;https://github.com/guardianproject/smartcard-apk-signing/blob/master/Aventra_MyEID_Setup/finalize.sh&#34; target=&#34;_blank&#34;&gt;scripts&lt;/a&gt;. The next step is to generate the key using &lt;code&gt;openssl&lt;/code&gt; and upload it to the HSM. Then the HSM needs to be “finalized”, which means the PINs are activated, and keys cannot be uploaded. Don’t worry, as long as you have the SO-PIN, you can erase the HSM and re-initialize it. But be careful! Many HSMs will permanently self-destruct if you enter in the wrong PIN too many times, some will do that after only three wrong PINs! As long as you have not finalized the HSM, any PIN will work, so play around a lot with it before finalizing it. Run the init and key upload procedure a few times, try signing an APK, etc. Take note: the script will generate a random password for the secret files, then echo that password when it completes, so make sure no one can see your screen when you generate the real key. Alright, here goes!&lt;/p&gt;

&lt;pre&gt;&lt;code class=&#34;language-console&#34;&gt;code $ git clone https://github.com/guardianproject/smartcard-apk-signing
code $ cd smartcard-apk-signing/Aventra_MyEID_Setup
Aventra_MyEID_Setup $ ./setup.sh 
Edit pkcs15-init-options-file-pins to put in the PINs you want to set:
Aventra_MyEID_Setup $ emacs pkcs15-init-options-file-pins
Aventra_MyEID_Setup $ ./setup.sh 
Using reader with a card: ACS ACR38U 00 00
Connecting to card in reader ACS ACR38U 00 00...
Using card driver MyEID cards with PKCS#15 applet.
About to erase card.
PIN [Security Officer PIN] required.
Please enter PIN [Security Officer PIN]: 
Using reader with a card: ACS ACR38U 00 00
Connecting to card in reader ACS ACR38U 00 00...
Using card driver MyEID cards with PKCS#15 applet.
About to create PKCS #15 meta structure.
Using reader with a card: ACS ACR38U 00 00
Connecting to card in reader ACS ACR38U 00 00...
Using card driver MyEID cards with PKCS#15 applet.
Found MyEID
About to generate key.
Using reader with a card: ACS ACR38U 00 00
Connecting to card in reader ACS ACR38U 00 00...
Using card driver MyEID cards with PKCS#15 applet.
Found MyEID
About to generate key.
next generate a key with ./gen.sh then ./finalize.sh
Aventra_MyEID_Setup $ cd ../openssl-gen/
openssl-gen $ ./gen.sh 
Usage: ./gen.sh &amp;quot;CertDName&amp;quot; [4096]
  for example:
  &amp;quot;/C=US/ST=New York/O=Guardian Project &amp;amp;#x54;e&amp;amp;#x73;&amp;amp;#x74;/&amp;amp;#x43;N=&amp;amp;#x74;es&amp;amp;#x74;.&amp;amp;#x67;&amp;amp;#x75;a&amp;amp;#x72;di&amp;amp;#x61;np&amp;amp;#x72;o&amp;amp;#x6a;&amp;amp;#x65;c&amp;amp;#x74;&amp;amp;#x2e;i&amp;amp;#x6e;fo&amp;amp;#x2f;em&amp;amp;#x61;i&amp;amp;#x6c;&amp;amp;#x41;d&amp;amp;#x64;re&amp;amp;#x73;s=&amp;amp;#x74;e&amp;amp;#x73;&amp;amp;#x74;@&amp;amp;#x67;&amp;amp;#x75;a&amp;amp;#x72;di&amp;amp;#x61;np&amp;amp;#x72;o&amp;amp;#x6a;&amp;amp;#x65;c&amp;amp;#x74;.i&amp;amp;#x6e;fo&amp;quot;
openssl-gen $ ./gen.sh &amp;quot;/C=US/ST=New York/O=Guardian Project Te&amp;amp;#x73;t&amp;amp;#x2f;C&amp;amp;#x4e;=&amp;amp;#x74;e&amp;amp;#x73;t&amp;amp;#x2e;g&amp;amp;#x75;ardi&amp;amp;#x61;n&amp;amp;#x70;r&amp;amp;#x6f;j&amp;amp;#x65;c&amp;amp;#x74;.&amp;amp;#x69;n&amp;amp;#x66;o/em&amp;amp;#x61;i&amp;amp;#x6c;A&amp;amp;#x64;d&amp;amp;#x72;e&amp;amp;#x73;s&amp;amp;#x3d;t&amp;amp;#x65;st&amp;amp;#x40;g&amp;amp;#x75;a&amp;amp;#x72;d&amp;amp;#x69;a&amp;amp;#x6e;p&amp;amp;#x72;o&amp;amp;#x6a;e&amp;amp;#x63;t.&amp;amp;#x69;n&amp;amp;#x66;o&amp;quot;
Generating key, be patient...
2048 semi-random bytes loaded
Generating RSA private key, 2048 bit long modulus
.......................................+++
..................................................+++
e is 65537 (0x10001)
Signature ok
subject=/C=US/ST=New York/O=Guardian Project Test/&amp;amp;#x43;&amp;amp;#x4e;&amp;amp;#x3d;&amp;amp;#x74;&amp;amp;#x65;st.gu&amp;amp;#x61;&amp;amp;#x72;&amp;amp;#x64;&amp;amp;#x69;&amp;amp;#x61;nproj&amp;amp;#x65;&amp;amp;#x63;&amp;amp;#x74;&amp;amp;#x2e;&amp;amp;#x69;nfo/e&amp;amp;#x6d;&amp;amp;#x61;&amp;amp;#x69;&amp;amp;#x6c;&amp;amp;#x41;ddres&amp;amp;#x73;&amp;amp;#x3d;&amp;amp;#x74;&amp;amp;#x65;&amp;amp;#x73;t@gua&amp;amp;#x72;&amp;amp;#x64;&amp;amp;#x69;&amp;amp;#x61;&amp;amp;#x6e;proje&amp;amp;#x63;&amp;amp;#x74;&amp;amp;#x2e;&amp;amp;#x69;&amp;amp;#x6e;fo
Getting Private key
writing RSA key
Your HSM will prompt you for &#39;Security Officer&#39; aka admin PIN, wait for it!
Enter destination keystore password:  
Entry for alias 1 successfully imported.
Import command completed:  1 entries successfully imported, 0 entries failed or cancelled
[Storing keystore]
Key fingerprints for reference:
MD5 Fingerprint=90:24:68:F3:F3:22:7D:13:8C:81:11:C3:A4:B6:9A:2F
SHA1 Fingerprint=3D:9D:01:C9:28:BD:1F:F4:10:80:FC:02:95:51:39:F4:7D:E7:A9:B1
SHA256 Fingerprint=C6:3A:ED:1A:C7:9D:37:C7:B0:47:44:72:AC:6E:FA:6C:3A:B2:B1:1A:76:7A:4F:42:CF:36:0F:A5:49:6E:3C:50
The public files are: certificate.pem publickey.pem request.pem
The secret files are: secretkey.pem certificate.p12 certificate.jkr
The passphrase for the secret files is: fTQ*he-[:y+69RS+W&amp;amp;+!*0O5i%n
openssl-gen $ cd ../Aventra_MyEID_Setup/
Aventra_MyEID_Setup $ ./finalize.sh 
Using reader with a card: ACS ACR38U 00 00
Connecting to card in reader ACS ACR38U 00 00...
Using card driver MyEID cards with PKCS#15 applet.
Found MyEID
About to delete object(s).
Your HSM is ready for use! Put the secret key files someplace encrypted and safe!
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now your HSM should be ready for use for signing. You can try it out with &lt;code&gt;keytool&lt;/code&gt; to see what is on it, using the signing PIN not the Security Officer PIN:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;smartcard-apk-signing $ /usr/bin/keytool -v \
&amp;gt;     -providerClass sun.security.pkcs11.SunPKCS11 \
&amp;gt;     -providerArg opensc-java.cfg \
&amp;gt;     -providerName SunPKCS11-OpenSC -keystore NONE -storetype PKCS11 \
&amp;gt;     -list
Enter keystore password:  

Keystore type: PKCS11
Keystore provider: SunPKCS11-OpenSC

Your keystore contains 1 entry

Alias name: 1
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: &amp;amp;#x45;&amp;amp;#x4d;&amp;amp;#x41;&amp;amp;#x49;&amp;amp;#x4c;&amp;amp;#x41;&amp;amp;#x44;&amp;amp;#x44;RESS=test@g&amp;amp;#x75;&amp;amp;#x61;&amp;amp;#x72;&amp;amp;#x64;&amp;amp;#x69;&amp;amp;#x61;&amp;amp;#x6e;&amp;amp;#x70;&amp;amp;#x72;oject.info, CN=test.guardianproject.info, O=Guardian Project Test, ST=New York, C=US
Issuer: E&amp;amp;#x4d;A&amp;amp;#x49;LA&amp;amp;#x44;D&amp;amp;#x52;ES&amp;amp;#x53;=&amp;amp;#x74;e&amp;amp;#x73;&amp;amp;#x74;@&amp;amp;#x67;u&amp;amp;#x61;rd&amp;amp;#x69;a&amp;amp;#x6e;pr&amp;amp;#x6f;j&amp;amp;#x65;ct&amp;amp;#x2e;i&amp;amp;#x6e;f&amp;amp;#x6f;, CN=test.guardianproject.info, O=Guardian Project Test, ST=New York, C=US
Serial number: aa6887be1ec84bde
Valid from: Fri Mar 28 16:41:26 EDT 2014 until: Mon Aug 12 16:41:26 EDT 2041
Certificate fingerprints:
	 MD5:  90:24:68:F3:F3:22:7D:13:8C:81:11:C3:A4:B6:9A:2F
	 SHA1: 3D:9D:01:C9:28:BD:1F:F4:10:80:FC:02:95:51:39:F4:7D:E7:A9:B1
	 SHA256: C6:3A:ED:1A:C7:9D:37:C7:B0:47:44:72:AC:6E:FA:6C:3A:B2:B1:1A:76:7A:4F:42:CF:36:0F:A5:49:6E:3C:50
	 Signature algorithm name: SHA1withRSA
	 Version: 1


*******************************************
*******************************************
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And let’s try signing an actual APK using the &lt;a href=&#34;https://developer.android.com/tools/publishing/app-signing.html&#34; target=&#34;_blank&#34;&gt;arguments that Google recommends&lt;/a&gt;, again, using the signing PIN:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&#34;language-console&#34;&gt;smartcard-apk-signing $ /usr/bin/jarsigner -verbose \
&amp;gt;     -providerClass sun.security.pkcs11.SunPKCS11 \
&amp;gt;     -providerArg opensc-java.cfg -providerName SunPKCS11-OpenSC \
&amp;gt;     -keystore NONE -storetype PKCS11 \
&amp;gt;     -sigalg SHA1withRSA -digestalg SHA1 \
&amp;gt;     bin/LilDebi-release-unsigned.apk 1
Enter Passphrase for keystore: 
   adding: META-INF/1.SF
   adding: META-INF/1.RSA
  signing: assets/busybox
  signing: assets/complete-debian-setup.sh
  signing: assets/configure-downloaded-image.sh
  signing: assets/create-debian-setup.sh
  signing: assets/debian-archive-keyring.gpg
  signing: assets/debootstrap.tar.bz2
  signing: assets/e2fsck.static
  signing: assets/gpgv
  signing: assets/lildebi-common
[snip]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now we have a working, but elaborate, process for setting up a Hardware Security Module for signing APKs. Once the HSM is setup, using it should be quite straightforward. Next steps are to work out as many kinks in this process as possible so this will be the default way to sign APKs. That means things like figuring out how &lt;a href=&#34;https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=742831&#34; target=&#34;_blank&#34;&gt;Java can be pre-configured to use OpenSC in the Debian package&lt;/a&gt;, as well as including all &lt;a href=&#34;https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=742089&#34; target=&#34;_blank&#34;&gt;relevant fixes&lt;/a&gt; in the &lt;code&gt;pcscd&lt;/code&gt; and &lt;code&gt;opensc&lt;/code&gt; packages. Then the ultimate is to add support for using HSMs in Android’s generated build files like the &lt;code&gt;build.xml&lt;/code&gt; for &lt;code&gt;ant&lt;/code&gt; that is generated by &lt;code&gt;android update project&lt;/code&gt;. Then people could just plug in the HSM and run &lt;code&gt;ant release&lt;/code&gt; and have a signed APK!&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>
