<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Signing Key on Guardian Project</title>
    <link>https://guardianproject.github.io/info/tags/signing-key/</link>
    <description>Recent content in Signing Key on Guardian Project</description>
    <generator>Hugo -- gohugo.io</generator>
    <lastBuildDate>Mon, 18 Dec 2017 05:43:34 -0400</lastBuildDate>
    
        <atom:link href="https://guardianproject.github.io/info/tags/signing-key/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>Building a Signing Server</title>
      <link>https://guardianproject.github.io/info/2017/12/18/building-a-signing-server/</link>
      <pubDate>Mon, 18 Dec 2017 05:43:34 -0400</pubDate>
      
      <guid>https://guardianproject.github.io/info/2017/12/18/building-a-signing-server/</guid>
      <description>

&lt;p&gt;The Android APK signing model sets the expectation that the signing key will be the same for the entire lifetime of the app. That can be seen in the recommended lifetype of an Android signing key: &lt;a href=&#34;https://developer.android.com/studio/publish/app-signing.html#considerations&#34;&gt;20+ years&lt;/a&gt;. On top of that, it is difficult to &lt;a href=&#34;https://guardianproject.info/2015/12/29/how-to-migrate-your-android-apps-signing-key/&#34;&gt;migrate an app to a new key&lt;/a&gt;. Since the signing key is an essential part to preventing APKs from impersonating another, Android signing keys must be kept safe for the entire life of the app.&lt;/p&gt;

&lt;p&gt;The F-Droid repo signing keys follow a very similar model: the signing key is the essential way to safely identify an F-Droid repo. So the same considerations apply to F-Droid repo signing keys as to APK signing keys. This also provides some really useful benefits. Since the integrity of the repo index file and the APKs are guaranteed by the repo signature, the files can be delivered via whatever method is most convenient, and their integrity will be automatically verified by the F-Droid client app, the &lt;em&gt;f-droid.org&lt;/em&gt; deploy process, and Repomaker.&lt;/p&gt;

&lt;p&gt;This means the security burden is shifted from the online, public webserver to a private signing machine. Just keeping that machine out of the public eye goes a long way towards improving security. There are a number of additional measures that can be taken to further improve the security of the signing process. Here are some approaches, starting with the easiest and least security, and going on to more secure setups that require more work to setup and run. Signing is not an resource intensive process, so any machine will work, even a 10 year old, basic laptop. We recommend using a minimal &lt;a href=&#34;https://www.debian.org&#34;&gt;Debian&lt;/a&gt; install, and rebuilding the machine from scratch.&lt;/p&gt;

&lt;h3 id=&#34;automated-signing-server-with-with-hsm&#34;&gt;Automated Signing Server with with HSM&lt;/h3&gt;

&lt;p&gt;For a fully automated signing setup, the machine running the signing needs to be online and running. Ideally this machine would have no remote access, at the very least remote access should be very carefully controlled and monitored. A laptop makes it easy to work with even when remote access is disabled, since it provides a built-in keyboard and monitor. If remote access is required, then any basic PC will work fine. Using a Hardware Security Module (HSM) to store the keys prevents them from being stolen if the server is broken into. An attacker could only run the signing process on that server.&lt;/p&gt;

&lt;p&gt;Ideally, this machine would only be accessible via Tor. That hides the physical location of the server, and hides the traffic from network. This makes it much harder attackers to find the actual machine to attack.&lt;/p&gt;

&lt;p&gt;For the HSM, we recommend using &lt;a href=&#34;https://www.nitrokey.com/&#34;&gt;Nitrokey&lt;/a&gt; hardware, since they are free software/hardware, and provide a wide range of options. Use a separate machine to put the signing keys on HSM. A good HSM will keep an audit trail of how many signatures have been made, so that information could be used to create an automatic auditing process to raise alarms if too many signatures have been made. That could mean that this server was breached and used to sign unauthorized packages.&lt;/p&gt;

&lt;p&gt;Other possibility it to use a setup like &lt;a href=&#34;https://pagure.io/sigul&#34;&gt;Fedora&lt;/a&gt;‘s &lt;a href=&#34;http://www.devops-blog.net/koji/gpg-signing-rpms-with-sigul-signing-server-koji-integration&#34;&gt;Sigul&lt;/a&gt; that involves three machines.&lt;/p&gt;

&lt;h3 id=&#34;basic-laptop-dedicated-to-signing&#34;&gt;Basic laptop dedicated to signing&lt;/h3&gt;

&lt;p&gt;Start with a laptop that can be wiped clean and rebuilt from scratch. What is most important is that only the essential software is installed on it, and nothing else. Do not include any browser at all, for example, since that is the most common vector of attack. No remote access setup (e.g. SSH or VNC) should be installed or configured. To sign apps and repos, someone would take out this laptop, connect it to the network, and run the signing process. The signed results can then be published via the network connection. When the signing is complete, the machine can be turned off and disconnected and kept in a safe place.&lt;/p&gt;

&lt;p&gt;This could be made quite automatic with some custom scripts. The person running the process would only need to take out the machine, connect it, turn it on, wait until the process completes, then put it all away again.&lt;/p&gt;

&lt;h3 id=&#34;fully-offline-signing-laptop-with-usb-thumb-drives&#34;&gt;Fully offline signing laptop with USB thumb drives&lt;/h3&gt;

&lt;p&gt;_&lt;strong&gt;update&lt;/strong&gt;: apt-offline has a &lt;a href=&#34;https://bugs.debian.org/871656&#34;&gt;security bug&lt;/a&gt; so it was removed from Debian/buster. It is no longer recommended! Instead, use the Debian &amp;ldquo;&lt;a href=&#34;https://www.debian.org/doc/manuals/apt-offline&#34;&gt;apt offline&lt;/a&gt;&amp;rdquo; setup._&lt;/p&gt;

&lt;p&gt;This process is based on the same basic, stripped down laptop as the previous example. But this time, the networking should be entirely disabled before the install process. For example, it is easy in many laptops to physically remove the WiFi card. Therefore, it makes sense to use a laptop that does not include an ethernet jack, which are usually not possible to remove. Otherwise, blacklisting all kernel modules related to neworking can suffice. Since this machine is fully offline, the extra work of using an HSM is not as important, but it can’t hurt to include it.&lt;/p&gt;

&lt;p&gt;Download the full &amp;ldquo;CD&amp;rdquo; or &amp;ldquo;DVD&amp;rdquo; image of Debian to run the install. Be sure to &lt;a href=&#34;https://www.debian.org/CD/verify&#34;&gt;verify&lt;/a&gt; the GPG signatures and the SHA-256 hashes. One essential utility is &lt;em&gt;apt-offline&lt;/em&gt;, which automates the process of downloading Debian packages, verifying their signatures, and copying them over to an offline machine.&lt;/p&gt;

&lt;p&gt;To be extra careful, all of the software used should be verified. Chromebooks are nice, cheap laptops that run Linux natively. They also use Coreboot for the BIOS.&lt;/p&gt;

&lt;p&gt;&lt;li id=&#34;buy-a-computer-off-the-shelf-with-cash-avoid-having-it-shipped-especially-across-borders&#34;&gt;
  Buy a computer off the shelf with cash, avoid having it shipped, especially across borders
&lt;/li&gt;
&lt;li id=&#34;buy-a-debian-supported-chromebook-with-removeable-wifi-hardware-and-needs-no-binary-blobs&#34;&gt;
  Buy a Debian-supported &lt;a href=&#34;https://www.chromium.org/chromium-os/developer-information-for-chrome-os-devices/acer-c720-chromebook&#34;&gt;Chromebook&lt;/a&gt; with removeable WiFi hardware, and needs no binary blobs
&lt;/li&gt;
&lt;li id=&#34;install-a-reproducibly-built-coreboot-binary&#34;&gt;
  Install a reproducibly built coreboot binary
&lt;/li&gt;
&lt;li id=&#34;install-from-a-reproducibly-built-debian-image-wiping-out-chrome-os-entirely&#34;&gt;
  Install from a reproducibly built Debian image, wiping out Chrome OS entirely
&lt;/li&gt;&lt;/p&gt;

&lt;h2 id=&#34;the-physical-environment&#34;&gt;The Physical Environment&lt;/h2&gt;

&lt;p&gt;The last thing to consider is the physical location where signatures happen, and where essential equipment is stored. The signing environment must be physically secure. Otherwise, there is no way to prevent laptops or HSMs from being lost or used to sign inappropriate content. For the offline machines, keeping them in a locked room is a good start. For an online machine, forcing all network traffic and remote access over Tor hides the physical location of the machine from network observers.&lt;/p&gt;

&lt;p&gt;For high risk signing keys, using multiple layers of defense is important:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Restricted physical access to HSMs or smart cards&lt;/li&gt;
&lt;li&gt;Security cameras&lt;/li&gt;
&lt;li&gt;Onsite security guards&lt;/li&gt;
&lt;li&gt;Visitor logging&lt;/li&gt;
&lt;li&gt;A tools-resistant server safe for online code-signing servers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The signing server should be physically separate from the rest of the infrastructure. And the logs, machine, and network should be periodically audited.&lt;/p&gt;

&lt;h2 id=&#34;difficult-decisions&#34;&gt;Difficult decisions&lt;/h2&gt;

&lt;p&gt;Ideally all of these practices would be put into place, but each of these security measures comes at a cost of difficulty, expense, and complexity. They can also delay the process of getting regular updates out. So there are risks of implementing too strict security policies, much like the risks of not implementing enough.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>How to Migrate Your Android App’s Signing Key</title>
      <link>https://guardianproject.github.io/info/2015/12/29/how-to-migrate-your-android-apps-signing-key/</link>
      <pubDate>Tue, 29 Dec 2015 12:03:54 -0400</pubDate>
      
      <guid>https://guardianproject.github.io/info/2015/12/29/how-to-migrate-your-android-apps-signing-key/</guid>
      <description>

&lt;p&gt;&lt;strong&gt;It is time to update to a stronger signing key for your Android app! The old default RSA 1024-bit key is weak and officially deprecated.&lt;/strong&gt;&lt;/p&gt;

&lt;h2 id=&#34;what&#34;&gt;What?&lt;/h2&gt;

&lt;p&gt;The Android OS requires that every application installed be signed by a digital key. The purpose behind this signature is to identify the author of the application, allow this author and this author alone to make updates to the app, as well as provide a mechanism to establish inter-application trust. The Android security model defines an app by two things: the package name (aka &lt;a href=&#34;https://developer.android.com/reference/android/content/Context.html#getPackageName%28%29&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;packageName&lt;/code&gt;&lt;/a&gt;, &lt;a href=&#34;https://sites.google.com/a/android.com/tools/tech-docs/new-build-system/applicationid-vs-packagename&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;ApplicationID&lt;/code&gt;&lt;/a&gt;, &lt;a href=&#34;https://developer.android.com/guide/topics/manifest/manifest-element.html#package&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;package&lt;/code&gt;&lt;/a&gt;) and the signing key. If either of those are different, then Android considers it a different app. When the package name and signing key of one APK match an installed app, then the APK is considered an update and Android will replace the installed app with the APK. If the APK is signed by a different key, then Android will prevent installing and updating.&lt;/p&gt;

&lt;p&gt;First thing is to see what the current signing key is. Check any app’s signing key using our free utility app &lt;a href=&#34;https://play.google.com/store/apps/details?id=info.guardianproject.checkey&#34; target=&#34;_blank&#34;&gt;Checkey&lt;/a&gt;:&lt;/p&gt;

&lt;div id=&#34;attachment_13170&#34; style=&#34;width: 790px&#34; class=&#34;wp-caption alignnone&#34;&gt;
  &lt;a href=&#34;https://guardianproject.info/wp-content/uploads/2015/12/checkey-1.png&#34; rel=&#34;attachment wp-att-13170&#34;&gt;&lt;img aria-describedby=&#34;caption-attachment-13170&#34; src=&#34;https://guardianproject.info/wp-content/uploads/2015/12/checkey-1-1024x576.png&#34; alt=&#34;Lookout needs to generate a new key!&#34; width=&#34;780&#34; height=&#34;439&#34; class=&#34;size-large wp-image-13170&#34; srcset=&#34;https://guardianproject.info/wp-content/uploads/2015/12/checkey-1-1024x576.png 1024w, https://guardianproject.info/wp-content/uploads/2015/12/checkey-1-300x169.png 300w, https://guardianproject.info/wp-content/uploads/2015/12/checkey-1-768x432.png 768w, https://guardianproject.info/wp-content/uploads/2015/12/checkey-1-350x197.png 350w, https://guardianproject.info/wp-content/uploads/2015/12/checkey-1-860x484.png 860w, https://guardianproject.info/wp-content/uploads/2015/12/checkey-1.png 1280w&#34; sizes=&#34;(max-width: 780px) 100vw, 780px&#34; /&gt;&lt;/a&gt;
  
  &lt;p id=&#34;caption-attachment-13170&#34; class=&#34;wp-caption-text&#34;&gt;
    Lookout needs to generate a new key!
  &lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;The official Android docs have tons of useful information about what the signing keys are good for, how to generate them, and how to use them. Unfortunately, it doesn’t provide any instructions for migrating, and for many years, 1024-bit RSA was the default. But first, why would you want or need to migrate?&lt;/p&gt;

&lt;h2 id=&#34;why&#34;&gt;Why?&lt;/h2&gt;

&lt;p&gt;Depending on when you created your signing key, you might have a particularly weak key. The primary danger of a weak key is that an adversary could break your key in order to generate fake APK signatures. Then those malicious APKs can be installed as updates to your app. There are other nefarious purposes depending on how you use the signing key in your apps. Or if you are unfortunate enough to have suffered a loss of your private key material, then it is definitely time for a new signing key.&lt;/p&gt;

&lt;p&gt;According to our friends at the &lt;a href=&#34;https://androidobservatory.org/stats&#34; title=&#34;Android Observatory&#34;&gt;Android Observatory&lt;/a&gt;, over 64% of Android apps in their data store use 1024-bit signing keys (RSA or DSA).&lt;/p&gt;

&lt;div id=&#34;visualization&#34; style=&#34;width: 600px; height: 400px;&#34;&gt;
&lt;/div&gt;

&lt;p&gt;There are several good reasons to migrate off of 1024-bit RSA keys, even though there is no &lt;em&gt;public&lt;/em&gt; proof of a 1024 prime factorization required to generate any 1024-bit key at will. The evidence has been mounting for a decade.&lt;/p&gt;

&lt;p&gt;NIST’s &lt;a href=&#34;http://csrc.nist.gov/publications/nistpubs/800-57/sp800-57_part1_rev3_general.pdf&#34;&gt;official guidelines&lt;/a&gt; (PDF, page 64 and 67) deprecated 1024-bit RSA keys at the end of 2013. This deprecation by NIST isn’t an indication that 1024-bit RSA is compromised, instead it is a preemptive move to stay ahead of attacks. Confidence in NIST might be shaken in light of &lt;a href=&#34;http://blog.cryptographyengineering.com/2013/09/on-nsa.html&#34;&gt;recent revelations&lt;/a&gt;, but in this case increasing the RSA key size is unlikely to trigger any secret NSA backdoors. If anything, the deprecation year could have been extended slightly to allow the NSA a window where they had the capacity to factor 1024-bit keys and everyone was still using them. So, it’s time to move on.&lt;/p&gt;

&lt;p&gt;For an example, a decade ago the cost of building special purpose hardware capable of breaking a single 1024-bit RSA key in one year was estimated at $10 million (&lt;a href=&#34;http://tau.ac.il/~tromer/papers/cbtwirl.pdf&#34;&gt;Adi Shamir, Eran Tromer, On the cost of factoring RSA-1024&lt;/a&gt;, 2003). Presumably the techniques have improved by orders of magnatude, and the hardware value depreciated. It is conceivable the cost has fallen enough to be affordable not only by nation-state actors, but by large criminal enterprises too.&lt;/p&gt;

&lt;p&gt;For a comprehensive talk on the state of the art (as of December 2012) when it comes to breaking 1024-bit RSA, check out the 29C3 talk &lt;a href=&#34;http://events.ccc.de/congress/2012/Fahrplan/events/5275.en.html&#34; title=&#34;FactHacks: RSA factorization in the real world&#34;&gt;FactHacks: RSA factorization in the real world&lt;/a&gt; with the cryptographers Daniel J. Bernstein, Nadia Heninger, and Tanja Lange (&lt;a href=&#34;http://events.ccc.de/congress/2012/wiki/Documentation#Recordings&#34; title=&#34;29C3 Recordings&#34;&gt;watch recording&lt;/a&gt;)&lt;/p&gt;

&lt;h2 id=&#34;how&#34;&gt;How?&lt;/h2&gt;

&lt;p&gt;Migrating to a strong key for an Android app is, unfortunately, not so simple. If you are publishing a &lt;em&gt;new&lt;/em&gt; app to the app store, then simply generate a new strong signing key and you’re done. Congratulations! However, there exists no easy way to update your signing key for an existing application, because an installed application can only take updates from an APK signed with &lt;em&gt;the same&lt;/em&gt; key.&lt;/p&gt;

&lt;p&gt;Here we outline a basic method with which you can use to fake an update to your signing key. This is not as user friendly as we would like. Some of the hard facts of performing this process is that for most app stores including Google Play, you will lose ratings and reviews since the app will show up with a new package name, and the app store will treat it like an entirely new app. Also, the user will have to manually uninstall the original app once they finish the procedure. Here is a rough outline of the process:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;generate the new signing key, &lt;em&gt;RSA 4096&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Update the first app, &lt;em&gt;App1&lt;/em&gt;, with a mechanism for exporting private data, using &lt;a href=&#34;https://github.com/guardianproject/TrustedIntents&#34; target=&#34;_blank&#34;&gt;TrustedIntents&lt;/a&gt; with a signature pin of the new key, &lt;em&gt;RSA 4096&lt;/em&gt;, which &lt;a href=&#34;https://guardianproject.info/2014/07/30/introducing-trustedintents-for-android/&#34; target=&#34;_blank&#34;&gt;Checkey will generate for you&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Create a new version of the app with a different package name, &lt;em&gt;App2&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;sign &lt;em&gt;App2&lt;/em&gt; with new key, &lt;em&gt;RSA 4096&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Add method to &lt;em&gt;App2&lt;/em&gt; for receiving user data from &lt;em&gt;App1&lt;/em&gt;, including a signature pin of the old signing key, &lt;em&gt;RSA 1024&lt;/em&gt;, for use with TrustedIntents&lt;/li&gt;
&lt;li&gt;Publish &lt;em&gt;App2&lt;/em&gt; to the app stores&lt;/li&gt;
&lt;li&gt;From &lt;em&gt;App1&lt;/em&gt;, prompt user to install &lt;em&gt;App2&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;runs and imports data from &lt;em&gt;App1&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;App2&lt;/em&gt; prompts user to uninstall &lt;em&gt;App1&lt;/em&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For &lt;a href=&#34;https://f-droid.org&#34; target=&#34;_blank&#34;&gt;F-Droid&lt;/a&gt;, there will be some easier tools for handling this. The F-Droid system is already used to multiple signing keys per app since F-Droid uses its own signing key for many of the apps it releases, and that F-Droid signing key is different from the signing key that the original developer used in their Google Play uploads. F-Droid will likely be able to support APKs with the same package name but with multiple signing keys.&lt;/p&gt;

&lt;h3 id=&#34;a-note-on-compatibility&#34;&gt;A Note on Compatibility&lt;/h3&gt;

&lt;p&gt;There is security vs compatibility trade off a few might be interested in. Pre-4.3, Android did not support any signature algorithms except SHA1. With Android &amp;gt;= 4.3, SHA256 support was fixed, and SHA384, SHA512, and ECDSA were added (&lt;a href=&#34;https://code.google.com/p/android/issues/detail?id=38321&#34;&gt;source&lt;/a&gt;). There are still android 2.3.3 (&lt;code&gt;android-10&lt;/code&gt;) devices being sold, so anyone interested in backwards compatibility will have to heed this.&lt;/p&gt;

&lt;p&gt;Also, the larger the keysize and hashsize used, the longer it takes to install and update the application. So extremely large values might be unsuitable for slower hardware. The following probably doesn’t buy you a tremendous amount of additional security but cranks the paranoia to 11. It does so at the cost of compatibility and performance.&lt;br /&gt;
&lt;code&gt;&amp;lt;br /&amp;gt;
Gen with:&amp;lt;br /&amp;gt;
  keytool -genkey -v -keystore test.keystore -alias testkey -keyalg RSA -keysize 4096 -sigalg SHA512withRSA -dname &amp;quot;cn=Test,ou=Test,c=CA&amp;quot; -validity 10000&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt;Sign with:&amp;lt;br /&amp;gt;
  jarsigner -verbose -sigalg SHA512withRSA -digestalg SHA512 -keystore test.keystore test.apk testkey&amp;lt;br /&amp;gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We have some scripts that we use to generate keys in our &lt;a href=&#34;https://github.com/guardianproject/smartcard-apk-signing&#34; target=&#34;_blank&#34;&gt;smartcard-apk-signing&lt;/a&gt; repo. It is also possible to generate an Android signing key using openssl or other libraries. It is often wise to use different software than standard for doing things like generating keys. Since the Java &lt;code&gt;keytool&lt;/code&gt; approach that is the standard, recommended method for Android, that makes it a target for adversaries that are interested in breaking keys. If a key was generated using &lt;code&gt;openssl&lt;/code&gt; or GNU TLS instead, for example, then that key would not be affected if &lt;code&gt;keytool&lt;/code&gt; had &lt;a href=&#34;https://freedom-to-tinker.com/blog/kroll/software-transparency-debian-openssl-bug/&#34; target=&#34;_blank&#34;&gt;a bug like Debian’s&lt;/a&gt; &lt;a href=&#34;https://security-tracker.debian.org/tracker/CVE-2008-0166&#34; target=&#34;_blank&#34;&gt;CVE-2008-0166&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>
