News for hackers. Stuff that matters.
Re:AES on the iPhone is Broken by Default by tptacek on Wednesday December 14, 2011 @10:40AM (#3352195)
Long story short: a crypto lib on the iPhone is among the many where the default is an all-zeroes IV. Does any application shipping with the iPhone use that default? The author doesn't know. I think it's unlikely.

How big a deal is CBC with an all-zeroes IV? Well, it's less of a big deal than ECB mode, which is the default in even more AES libraries. But ECB mode, is (inexplicably) an actual "mode". ECB is harder to single out as an error than an all-zeroes IV, which is explainable only as a mistake. Also, no library on the iPhone ships with a ECB default, unlike, say, OpenSSL, Cryptlib, the Java crypto extensions, &c.

In both ECB mode and CBC-with-predictable-IV mode, the problem is that the same 16 bytes of plaintext will (often, in CBC's case; always, in ECB) produce the same ciphertext. This increases malleability and allows attackers to easily rewrite messages. More importantly, if an attacker controls the size of any part of the input, they can arrange to create ciphertext blocks with only 1-2 unknown bytes, which are trivially brute forced.

By the way: here's more than you ever wanted to know about IVs in CBC mode:

http://news.ycombinator.com/item?id=2029640

If you just want to know what "IV" means, it's "fictitious first ciphertext block in a block cipher mode that involves chaining ciphertext values".

Re:AES on the iPhone is Broken by Default by exDM69 on Wednesday December 14, 2011 @11:00AM (#3352298)
The big difference between the ECB and CBC block cipher modes is that in ECB identical blocks of plaintext will produce identical blocks of ciphertext, within the same communication. This will reveal something (at least that there's lots of identical blocks) about the content of the plaintext which may be used to device an attack.

In CBC (with known IV) you only get the same ciphertext for identical blocks in the beginning of different transmissions if you use the same key for both transmissions. As you're not supposed to use the same key twice for a stream cipher, it's not a really big issue.

Re:AES on the iPhone is Broken by Default by tptacek on Wednesday December 14, 2011 @11:05AM (#3352315)
It's a significant issue. For instance, Thai Duong and Juliano Rizzo's recent SSL decrypting attack relied on predicting (not controlling) IVs --- in other words, literally the attack this thread is talking about, but under more constraints.

It is not a "really big issue" in the sense of "we forgot to put a MAC on this ciphertext to guarantee authenticity", which is a more common mistake than not setting an IV; or, a "really big issue" in the sense of "we managed to expose a padding oracle", which is a more common CBC mistake. But it is a significant mistake.

How you choose to key streams is an orthogonal concern to whether your block cipher mode leaks data.

Re:AES on the iPhone is Broken by Default by JoachimSchipper on Wednesday December 14, 2011 @11:07AM (#3352321)
The point of using an IV is that you can use the same key for multiple messages. You're not supposed to repeat (key, nonce) pairs for a stream cipher, and CBC's IV is sort-of equivalent to the nonce. (AES-CBC is not technically a stream cipher. Not all stream ciphers have nonces.)
Re:AES on the iPhone is Broken by Default by tptacek on Wednesday December 14, 2011 @11:28AM (#3352406)
Using the same key+nonce pair in a stream cipher has the effect of generating an identical keystream. It's a much, much worse problem than repeating IVs; it makes decrypting the resulting ciphertext stream almost a pencil/paper exercise.

Sorry for the pedantry.

Re:AES on the iPhone is Broken by Default by magikarp on Wednesday December 14, 2011 @10:43AM (#3352213)
The issue is less about applications shipping with the iPhone doing this and more about Apple stating that IVs are "optional," prompting many non-crypto-savvy developers to ignore IVs completely, thus resulting in highly insecure AES implementations by default in many third-party apps.
Re:AES on the iPhone is Broken by Default by tptacek on Wednesday December 14, 2011 @10:48AM (#3352232)
Again, that is no worse (better, in fact) than any of the many libraries which default to ECB mode. You might just as productively yell at Java and OpenSSL.
Re:AES on the iPhone is Broken by Default by magikarp on Wednesday December 14, 2011 @10:52AM (#3352258)
You have a good point, but it's still suggesting that you can implement CBC correctly without a good IV.
Re:AES on the iPhone is Broken by Default by tptacek on Wednesday December 14, 2011 @10:55AM (#3352276)
I think you're making a "gotcha" point. It's impossible to implement any crypto protocol safely with ECB mode. And yet libraries far more popular than this one aren't subject to blog posts dinging them for being "broken by default".

I actually agree with you that not requiring an explicit IV is a bad interface choice.

On the other hand, I'm appalled by the idea of any library that exposes AES directly to applications anyways. There's a myriad of mistakes developers make using AES directly. CBC IVs are not among the top three.

Re:AES on the iPhone is Broken by Default by marshray on Wednesday December 14, 2011 @01:10PM (#3352873)
It's impossible to implement any crypto protocol safely with ECB mode.

But ECB mode may be a useful primitive component of some other, more secure, mode. For example, this API doesn't support CTR mode, but if you needed it, probably the most efficient thing would be to fill a buffer with your nonce and counter values pass it to this API to be encrypted using "ECB mode". It's parallelizable that way.

And that is the point of this level of crypto API: providing efficient access to whatever software implementation or hardware acceleration may be available on the target system.

And yet libraries far more popular than this one aren't subject to blog posts dinging them for being "broken by default".

I want to give Nadim some credit here: he is thinking like an attacker now!

This represents a great improvement over his previous crypto implementation endeavors.

Re:AES on the iPhone is Broken by Default by tptacek on Wednesday December 14, 2011 @01:19PM (#3352921)
Sure. But I'm not talking about the availability of ECB; I'm talking about ECB as a default.

And, I agree with the fundmental point he's making: optional IVs for CBC mode are a bad interface details for lay programmers. Just remember, every AES library makes similar (usually worse) design mistakes.

Generalists are very poorly served by low-level AES libraries (where "low level" certainly includes any library where you have to think about IVs or, indeed, which block cipher mode to use).

Re:AES on the iPhone is Broken by Default by SoftwareMaven on Wednesday December 14, 2011 @01:32PM (#3352990)
I'd love to see that list. I'm sure not generating MACs is on there. I could imagine reusing keys could be there. What else?
Re:AES on the iPhone is Broken by Default by rdl on Friday December 16, 2011 @03:49AM (#3360044)
This is a pretty good visual argument against ECB (the image): http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation...
Re:AES on the iPhone is Broken by Default by maksoorah on Wednesday December 14, 2011 @12:22PM (#3352647)
The author is also the creator of crypto.cat. I think he knows what he is talking about.
Re:AES on the iPhone is Broken by Default by marshray on Wednesday December 14, 2011 @12:47PM (#3352758)
I looked at the source to crypto.cat and, in the politest possible way, I wish to disagree.
Re:AES on the iPhone is Broken by Default by soc88 on Wednesday December 14, 2011 @11:58AM (#3352530)
Before clicking on „comments“ I wondered how long it would take the John Gruber brigade to declare it non-relevant.

Thanks for answering my question.