Weblog entry #48 for dkg
moving in an orderly fashion toward the theater exits,deprecating SHA-1 where possible with an eye toward abandoning it soon (one point of reference: US gov't federal agencies have been directed to cease all reliance on SHA-1 by the end of 2010, and this directive was issued before the latest results).
Since Debian relies heavily on OpenPGP and other cryptographic infrastructure, i'll be blogging about how Debian users can responsibly and carefully migrate toward better digests. This post focuses on some first steps for users of gpg, and for Debian Developers and Debian Maintainers in particular.
The good news is that gpg and gpg2 both support digest algorithms from the stronger SHA-2 family: SHA512, SHA384, SHA256, and SHA224.
By using these stronger digest algorithms some of your signatures may be un-readable by users of older software. However, gpg and PGP (a proprietary implementation) have both had support for at least SHA256 for well over 5 years. Debian's gnupg packages have supported the full SHA-2 family since sarge.
However, most existing signatures in today's Web of Trust were made over the SHA-1 digest algorithm, which means that abandoning it immediately would cause the Web of Trust as we know it to evaporate. So we need to rely on SHA-1-based signatures until a reasonably-fleshed-out Web of Trust based on stronger digests is in place. Since we don't want to have to rely on SHA-1 for too much longer, we need to collectively start the transition now.
So what can you do to help facilitate the move away from SHA-1? I'll outline three steps that current gpg users can do today, and then i'll walk through how to do each one:
- start making data signatures and web-of-trust certifications using stronger digests,
- explicitly state your preferences for stronger digests when receiving private communications, and
- If you are currently using a 1024-bit DSA primary key (which relies for signatures on a 160-bit hash, traditionally SHA-1), transition to a new 2048-bit RSA key.
- Start making data signatures and web-of-trust certifications using stronger digests
The simplest thing that you can do is to start making signatures using stronger digests by default. Add three lines to the end of your GnuPG configuration:
cat >>~/.gnupg/gpg.conf <<EOF personal-digest-preferences SHA256 cert-digest-algo SHA256 default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed EOF
This will cover most messages sent out, including clearsigned messages that are sent to mailing lists, and signatures over Debian packages. The last line ensures that when you create new keys, the new keys will prefer stronger digests.
- Indicate that you prefer stronger digests when receiving signed messages privately
Your preferences for the types of digest you wish to receive will be published to the public keyservers, so people who send you signed messages will know that you can (and prefer to) accept messages signed by stronger digests. The example assumes that your OpenPGP key ID is $KEYID:
test@foo:~ $ gpg --edit-key $KEYID gpg (GnuPG) 1.4.9; Copyright (C) 2008 Free Software Foundation, Inc. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Secret key is available. pub 2048R/8A4EA1C3 created: 2009-05-06 expires: 2010-05-06 usage: SC trust: ultimate validity: ultimate [ultimate] (1). Test User (DO NOT USE) <test@example.org> Command> showpref [ultimate] (1). Test User (DO NOT USE) <test@example.org> Cipher: AES256, AES192, AES, CAST5, 3DES Digest: SHA1, SHA256, RIPEMD160 Compression: ZLIB, BZIP2, ZIP, Uncompressed Features: MDC, Keyserver no-modify Command> setpref SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed Set preference list to: Cipher: AES256, AES192, AES, CAST5, 3DES Digest: SHA512, SHA384, SHA256, SHA224, SHA1 Compression: ZLIB, BZIP2, ZIP, Uncompressed Features: MDC, Keyserver no-modify Really update the preferences? (y/N) y You need a passphrase to unlock the secret key for user: "Test User (DO NOT USE) <test@example.org>" 2048-bit RSA key, ID 8A4EA1C3, created 2009-05-06 pub 2048R/8A4EA1C3 created: 2009-05-06 expires: 2010-05-06 usage: SC trust: ultimate validity: ultimate [ultimate] (1). Test User (DO NOT USE) <test@example.org> Command> save test@foo:~ $
The important command here is the weird, long setpref line — you need to type the whole thing:
setpref SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed
Note that we're setting digest, cipher, and compression preferences all at once here. Note also that gpg displays the implied 3DES cipher and SHA1 digest at the end of your stated preferences even though you did not ask for them. This is because RFC 4880 requires implementations to support these two algorithms, and gpg is subtly informing you that people might end up using them anyway, even though you aren't asking for them.Now that the preferences are updated, publish them to the public keyservers so that your correspondents can discover them:
test@foo:~ $ gpg --keyserver keys.gnupg.net --send-key $KEYID gpg: sending key 8A4EA1C3 to hkp server keys.gnupg.net test@foo:~ $
That does it!
- Replace your 1024-bit DSA keys with 2048-bit RSA keys or larger
The Digital Signature Algorithm, in its original form, only allowed maximum 1024-bit asymmetric keys, and the signature process itself signs a 160-bit hash, initially officially specified as SHA-1. This means that 1024-bit DSA keys should be phased out as well.
So if you have a 1024-bit DSA key as your primary key (this is the vast majority of Debian Developers: 1675 out of 2243 keys in /usr/share/keyrings/debian-keyring.gpg are DSA-1024), you should consider creating a new primary key and starting the migration process.
Also, if you are responsible for a DSA-1024 OpenPGP primary key for a Debian team, role, or archive, please consider something similar to the process below for the Debian-related key as well. I'm happy to note that the Debian Archive Automatic Signing Key (5.0/lenny) <ftpmaster@debian.org> has a 4096-bit RSA primary key, but unfortunately most of our other important infrastructural keys are still 1024-bit DSA.
A reasonable migration process over the course of 3 months might be:
- (day 0) Create a new key, using 2048-bit RSA at least (gpg appears to be about to change the default key generation to 2048-bit RSA shortly, if you need more justification). Be sure to configure ~/.gnupg/gpg.conf to use the stronger digest before creating the new key, and set up strong digest preferences on the new key (see above) immediately after key creation. Send the new key to the public keyservers. Generate a revocation certificate too, and store it in a safe place!
- (day 0) Sign your new key with your old one (not the other way around!), and publish the signature. Write up a transition statement (here's an example from an earlier key transition), clearsign it with both keys (old and new), and publish it in a stable place.
- (day 0) Write up or print out the User IDs and fingerprint of your new key on paper to hand out to people.
- (day 0 through day 90) Collect certifications binding the new key to your User ID to re-establish your connection to the Web of Trust. Some reasonable ways to do this effectively are
- local keysigning parties (e.g. in NYC this coming Friday, 2009-05-08),
- debconf (less than 90 days away!), and
- contacting known and trusted friends, pointing them to the transition statement and asking them to reissue their certifications.
- (day 0 through day 90) Review the set of public certifications you've made (
keys you've signed
) with your old key. For keys you believe to still be active, check with the key owner, and verify that they are still in control of the key. If they are, consider issuing a new certification with your new key. If you get a request for new keysignings, use your new key during this period. - (well before day 90) Ensure that your new key is in available everywhere you need it to be (like the Debian keyring). Use your new key in those contexts and make sure it is accepted and acceptable.
- (day 90) Publish your stored revocation certificate for your old key. You had a revocation certificate for the old key already, right? If not, generate a new one, and publish it.
I welcome comments and suggestions about anything i've missed or screwed up here. The steps above do not complete the removal of SHA-1, but (if most of us take similar action soon) they lay the groundwork for an orderly and non-disruptive abandonment of SHA-1 in the future. The sooner this groundwork is in place, the less susceptible our infrastructure will be to potential compromise by reasonably-well-funded organizations.
That wraps up this set of suggestions. As i work through other consequences and practicalities around the gradual deprecation of SHA-1, i'll post more notes on this blog. Questions and pointers are welcome!
UPDATE: I've clarified step 5 of the key transition process above in response to feedback from David Shaw: please make sure the keyholder is still active and in full control of the key before re-issuing certifications.
Another UPDATE: i've added a new suggestion to the ~/.gnupg/gpg.conf additions, to set default-preference-list so that new keys are generated with stronger preferences. Thanks to David Crick for the suggestion.
Comments on this Entry
[ Parent | Reply to this comment ]
Note that you can easily decrypt mail that's been encrypted to a GPG key which was revoked, if you so wish.
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Send Message | View dkg's Scratchpad | View Weblogs ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Send Message | View dkg's Scratchpad | View Weblogs ]
[ Parent | Reply to this comment ]
Wouldn't it be much easier to switch to DSA2, rather than getting rid of all existing DSA keys and replacing them with RSA keys? Your crusade against DSA seems unneeded; but please do enlighten me if I'm missing something here.
[ Parent | Reply to this comment ]
[ Send Message | View dkg's Scratchpad | View Weblogs ]
We could get similar benefits with a DSA2 key, but DSA2 is not nearly as widely implemented as RSA is, so is not a good option for a default key at this time.
And i was under the impression that while DSA2 allows the use of larger hashes, it does so for smaller keysizes only by truncating them to the size of the traditional hash for that keysize. So a key transition (to a larger DSA key) would be necessary at any rate to take advantage of the full strength of the larger hash.
If you're going through a key transition, switching to a more widely-used standard seems reasonable to me, but i would be happy if people switched to DSA-2048 instead. I wanted to make simple, clear recommendations in the main piece here, so i picked RSA because of the above reasons. Thanks for broadening the discussion a bit, though. If you have pointers to good arguments why people should switch to DSA-2048 instead of RSA-2048, i'd be happy to read them.
[ Parent | Reply to this comment ]
Use of SHA2 and DSA2 were promoted pretty much hand-in-hand. But I will not contest that SHA2 is more widely-used than DSA2: it probably is.
And for the record: I'm not claiming that DSA-2048 is better then RSA-2048. However I don't know of any reason why RSA-2048 in itself would be better than DSA-208, which is why found your strong suggestion to switch to RSA strange. I'd say both algorithms are rather equal. Your additional arguments have made this choice clearer: thank you for explaining.
[ Parent | Reply to this comment ]
I have stumbled across so may trolls lately, that it is a real pleasure to see that there are still nice and well behaved people out there that have a serious discussion, disagree AND are polite about it.
Thanks.
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Send Message | View dkg's Scratchpad | View Weblogs ]
Cards with Version < 2.0 support RIPEMD-160 and SHA-1 onlybut version 2.0 appears to support digests from the SHA-2 family, up to and including SHA-512.
But if you're stuck with a pre-2.0 card? I don't have a good answer for you. Maybe get a 2.0 card? Even the 2.0 card still only supports 1024-bit RSA, though, which is smaller than any key you'd want to use more than a year from now (e.g. ssh-keygen has been creating 2048-bit RSA keys since etch).
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Send Message | View dkg's Scratchpad | View Weblogs ]
While RIPEMD-160 is an option, the longer digest lengths of SHA-2, more intense public scrutiny of SHA, and wider adoption of RSA seem like they add up to a better plan for the future to me. But i would be happy to hear evaluations of the situation from people with a stronger crypto background than myself. I'm pretty much learning as i go here (as usual).
[ Parent | Reply to this comment ]
[ Send Message | View dkg's Scratchpad | View Weblogs ]
[ Parent | Reply to this comment ]
[ Send Message | View dkg's Scratchpad | View Weblogs ]
[ Parent | Reply to this comment ]
[ Send Message | View dkg's Scratchpad | View Weblogs ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Send Message | View dkg's Scratchpad | View Weblogs ]
But i wanted to provide a set of instructions that will cause people the least hassle while still building the post-SHA-1 WoT.
[ Parent | Reply to this comment ]
Maybe you know what the different it is between DSA2 and RSA in hash length. FIPS 186-3 states that it can use 256 bit hashes for 3072 and 2048 keys. I couldn't find any such information for rsa. Is the rsa signature algorithm without hash length bounds?
[ Parent | Reply to this comment ]
DSA actually uses 2 moduli, one of which is 160 bits, which is why DSA signatures are 320 bits long. The signature scheme is similar to El Gamal signatures, but the second modulus makes the signature twice as large as the smaller modulus instead of twice as large as the public key modulus. (El Gamal signatures with a 2048-bit key are 4096-bits long.) The math still all works out if you increase the size of the smaller modulus, but the larger modulus minus one must be a multiple of the smaller modulus (if memory serves), so you can't just start using longer hashes with an existing key unless you truncate the hash, as would be possible with RSA.
It's a shame SHA-3 hasn't been finalized by now, or we could be leapfrogging over the SHA-2 transition right now.
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Send Message | View dkg's Scratchpad | View Weblogs ]
However, i tend to interact more with the free software world, so perhaps upgrade paths for my peers are less onerous than they would be for people with proprietary vendors.
If anyone does run into trouble with the certifications or data signatures i produce, please e-mail me about it! My e-mail address is well-bound to my OpenPGP key (0xCCD2ED94D21739E9), and i'd be happy to help diagnose any trouble if it happens.
[ Parent | Reply to this comment ]
--------
Felipe Sateler
[ Parent | Reply to this comment ]
Afaik only ElGamal as signing functions is hard to implement really secure and thus not recommended for signing. The last thing I read about ElGamal vs. RSA for encryption from Bruce Schneier was that they are equal secure. This doesn't mean if you can find a weakness in RSA that ElGamal also has that weakness in every situation as it would be with ElGamal and Diffie-Hellmann....
So, you can create a RSA cert/signing key with "gpg2 --gen-key" or a DSA2 cert/signing key with "gpg2 --enable-dsa2 --gen-key" and afterwards use "gpg2 --edit $KEYID" and the gpg command "addkey" to add a encryption key. Be sure that you use a recent version of gnupg for key generation since some weaknesses were found in old versions.
[ Parent | Reply to this comment ]
Oh great I see. So gpg will just automatically create the sign/encrypt pair on DSA/ElGamal keys, and just create a master key for RSA, so I have to manually create the encryption subkey.
Thanks for explaining.
--------
Felipe Sateler
[ Parent | Reply to this comment ]
[ Send Message | View dkg's Scratchpad | View Weblogs ]
[ Parent | Reply to this comment ]
in the 2nd step of the last section: "clearsign it with both keys (old and new)", but how to clearsign a file with two secret keys?
thanks.
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[0] --list-packets
iter+salt S2K, algo: 3, SHA1 protection, hash: 2
[1] PGP, GnuPG, & the New SHA1 Secret Key Hash
http://www.spywarewarrior.com/uiuc/ss/sec-key/sec-key.htm
[ Parent | Reply to this comment ]
[ Send Message | View dkg's Scratchpad | View Weblogs ]
My understanding is that the string-to-key (S2K) use of a digest algorithm in OpenPGP does not rely on the collision-resistance of the digest itself, the way that digital signatures do.
Basically, what S2K does is to take a human-memorizable string (like "th1s1sMY53krit%pazzwd" -- note:do not use this password!) and munge it up to make a stronger key that itself is used to encrypt (via a standard symmetric cipher like AES) your actual secret key material. The goal of S2K is to ensure that this new key has each bit position be equally-likely to be 0 or 1. It also is designed to force a user to spend computational resources to do this, to make recurrent attacks harder. Why do this? Some things to notice:
- If you look at the underlying byte values in the UTF-8 representation of the human-memorizable string, you see that the underlying values have a distinct probability distribution, with values in some ranges never even showing up at all:
0 dkg@pip:~$ printf "%s" "th1s1sMY53krit%pazzwd" | hd 00000000 74 68 31 73 31 73 4d 59 35 33 6b 72 69 74 25 70 |th1s1sMY53krit%p| 00000010 61 7a 7a 77 64 |azzwd| 00000015 0 dkg@pip:~$
This is due to the fact that UTF-8 (and other character encoding schemes) are reasonably well-organized, and that humans tend to use certain characters (like "e") more frequently than other characters (like "q"). Compare this to the distribution of bytes in the digested version:0 dkg@pip:~$ printf "%s" "th1s1sMY53krit%pazzwd" | sha1sum 2052ab047c8a9126a04eee752d454e4c3ccba281 - 0 dkg@pip:~$
- Note also that if you run the digest over more data, it takes a longer time to calculate:
0 dkg@pip:~$ time perl -e "print 'th1s1sMY53krit%pazzwd'x1000;" | sha1sum f538f59d0fbbd953e3f729738d6f3db77e64c452 - real 0m0.007s user 0m0.004s sys 0m0.004s 0 dkg@pip:~$ time perl -e "print 'th1s1sMY53krit%pazzwd'x1000000;" | sha1sum 19843526fe65b45c2aeb2684238714842ff4daf0 - real 0m0.704s user 0m0.424s sys 0m0.112s 0 dkg@pip:~$
This is why you should prefer the iterated S2K algorithms, because they force an attacker who is trying a brute force attack against your encrypted secret key to spend many more computational resources for each attempted decryption.
In fact, if someone proposes that you should switch your S2K algorithm from SHA-1 to a digest algorithm which happens to be faster to compute than SHA-1 (i don't believe that the SHA-2 family is faster than SHA-1, but some of the proposed SHA-3 possibilities apparently are), you may want to re-consider, as it would reduce the cost of a brute-force attack.
That said, should you decide that you do want to change the digest algorithm used for S2K within OpenPGP, you probably want --s2k-digest-algo, which can also be stored in ~/.gnupg/gpg.conf.
[ Parent | Reply to this comment ]
http://blogs.ubuntu-nl.org/dennis/2009/05/10/evolution-vs-sha256/
[ Parent | Reply to this comment ]
[ Send Message | View dkg's Scratchpad | View Weblogs ]
i've added a new suggestion to the ~/.gnupg/gpg.conf additions, to set default-preference-list so that new keys are generated with stronger preferences. Thanks to David A. Crick for the suggestion.
[ Parent | Reply to this comment ]
[ Send Message | View dkg's Scratchpad | View Weblogs ]
In particular, my proposed 3 month window for key transitions was based on my own key transition in 2007 (that time frame worked well for me) and the date of debconf (when new keysignings will be easy for many members of the Debian community). It is not a deadline after which SHA-1 should be considered useless.
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Send Message | View dkg's Scratchpad | View Weblogs ]
[ Parent | Reply to this comment ]
[ Send Message | View dkg's Scratchpad | View Weblogs ]
Since this article is about digest algorithms, not ciphers, i stuck with the default cipher preferences chosen by gpg. I am not going to update the article to change that list, because i don't know enough about the state of the various ciphers to know why that's currently set up that way. If you're curious, i recommend asking on gnupg-users (after searching its archives, of course).
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Send Message | View dkg's Scratchpad | View Weblogs ]
Choosing this strategy right now will help you make new, stronger certifications, but those certifications themselves should be considered suspect by anyone who distrusts SHA-1, simply because they are only bound to your primary key (your only real entry in the Web of Trust) by a signature over SHA-1.
Note that no one is saying that SHA-1 itself is actively broken right now. But if you want to plan for a build-out of the post-SHA-1 WoT, doing so with a subkey hooked to a 1024-bit DSA primary key would not really contribute.
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
Just a little note: Once you have configured default-preference-list, it is sufficient - when editing a key - to just issue setpref without additional arguments.
Since the new preferences you are setting will be displayed before the change is committed, this should be safe enough.
[ Parent | Reply to this comment ]
If I have a 1024D key that is not signed yet (except self-signed) and the public key is submitted to a key-server, how are the above steps modified?
[ Parent | Reply to this comment ]