Subject: Re: [Cfrg] request for comments on "Generation of Deterministic Initialization Vectors (IVs) and Nonces"

From: David McGrew <[email-masked]>
Date: Fri, 19 Aug 2011 12:50:39 -0700

Hi Peter,

thanks for your comments - I am returning to them to pick up on one of  
the side topics:

On Jul 19, 2011, at 8:32 AM, Peter Gutmann wrote:

> David McGrew <[email-masked]> writes:
>
>> I wrote up a draft describing how deterministic IVs should be  
>> generated, and
>> reviewing how they are used in different protocols:
>>
>> http://tools.ietf.org/html//draft-mcgrew-iv-gen-00
>
> From a quick read, it looks good, with comprehensive coverage of all  
> the
> issues.  However (and you knew there was going to be a  
> 'however' :-), it
> depends on who the target audience is.  I'm concerned that, as with  
> advice on
> the correct use of RC4, the people who will be reading this  
> (security people)
> will probably be the ones who don't need it, and those who need it  
> (J.Random
> software developer) won't be reading it, or even know that it  
> exists.  The
> problem is that CTR mode (and derived modes) don't work the way that  
> (most)
> people think they do, and as 15-odd years of RC4 have shown, user  
> education is
> unlikely to be effective in dealing with this.  Developers don't even
> understand how to use IVs, with all-zero IVs being frighteningly  
> popular when
> they're forced to use a mode like CBC ("I kept getting the first  
> 8/16 bytes
> scrambled, but it's OK now, when you set the IV to zeroes everything  
> works").
> In CBC mode it's..., well not good, but also not instantly fatal  
> like it is in
> CTR mode and derived modes.
>
> If the goal is to "fix the IV problem" then I think that the  
> solution isn't to
> try and change the users to match the encryption (RC4 has shown that  
> that
> doesn't work so well), but to change the encryption to match the  
> users'
> expectations.  So start by assuming that an all-zero IV will be used  
> and
> design defensively around that.  What we'd then need, when the  
> cipher is used
> by non-cryptographers (which is what virtually all programmers are)  
> is CBC or
> CFB instead of CTR, and GCFBM or GCBCM instead of GCM.
>
> Getting back to the draft, it'd be nice to recommend some single  
> standard way
> of dealing with IVs (with an accompanying "AND STICK WITH IT!").   
> Did you
> notice, in Table 1, that every single protocol that uses them has  
> invented
> their own incompatible way of handling them?  Ugh.

Right.  Even ones that follow RFC 5116 recommendations do it  
differently :-)

> You can't even provide a
> standard implementation ("encrypt this message with AES-GCM")  
> because each
> protocol has its own incompatible way of applying it.  This also  
> means that,
> for section 6, you're going to need test vectors not to exercise AES- 
> GCM but
> to exercise AES-GCM as used in ESP, AES-GCM as used in IKE, AES-GCM  
> as used in
> TLS, AES- GCM as used in ...
>
> Peter.
>

Like you suggest, it would be valuable to define a user-oriented API  
for encryption, which hides all of the crypto details from the user  
and thus minimizes the demands that it places on their knowledge.  I  
would like to see an AEAD API developed that keeps the IV-management  
complexity away from the user, and I think that it would not be hard  
to write a new interface that builds on top of RFC 5116, perhaps cites  
the iv-generation draft as well.

Most protocols that use crypto have a packet format that includes an  
IV, a ciphertext, and a separate authentication tag.   That is, the  
protocol is aware of the crypto data types, and thus needs to be aware  
of the cryptography.  With RFC 5116, we got rid of the separate  
authentication tag.  What would really be good would be to put the IV  
into the crypto-data as well, so that the interface between the  
protocol and the crypto engine is as simple as possible.  This  
interface would meet your goal of keeping the non-crypto-expert  
developer insulated from the IV-details, and changing the encryption  
to meet the expectations of the user.   The challenging part of this  
exercise will be in getting compatibility with existing protocols,  
like TLS and ESP.  Perhaps a more modest goal would be to have the  
"user-proof" API have an IV as an ouput of the crypto algorithm,  
instead of an input.  It might be easier to get that to be backwards  
compatible.

What do you think?  Any chance that I can talk you into contributing,  
or at least reviewing, a draft defining an API like this?

David

---

From: Peter Gutmann <[email-masked]>
Date: Sun, 21 Aug 2011 20:26:16 +1200

David McGrew <[email-masked]> writes:

>Like you suggest, it would be valuable to define a user-oriented API for
>encryption, which hides all of the crypto details from the user and thus
>minimizes the demands that it places on their knowledge.  

Hmm, I can't see how trying to address things at the API level could work
because there's already a large variety of very different APIs, many dating
back 10-15 years, that would need to be changed.  I can't imagine how you'd
convince Microsoft, OpenSSL, BSAFE, whoever owns Java this week, and a bunch
of others, all to switch to, or introduce, a new unified AEAD encryption API.

All you'd really need to do is define is a single, standard way of applying
AES-GCM (or whatever), and then various vendors could then adapt it for
whatever their API looks like.

>What do you think?  Any chance that I can talk you into contributing, or at
>least reviewing, a draft defining an API like this?

See above, even if you/I/we come up with an API, I can't imagine what it'd
take for vendors to adopt it.  Look at things like the MD4 and MD5 RFCs (to
take something that's been around since the dark ages of Internet cryto),
apart from a very very low-level part of the OpenSSL API I've never seen
anything that uses it, and that was introduced at more or less the year zero
of hashing APIs (it predates SSLeay, CryptoAPI, Java, and others), but still
didn't get adopted.

So I think the way forward is to define a single unambiguous way of applying
GCM, and leave it to individual API developers to provide the interface to it.
Even then, unfortunately, for most of the major protocols (IKE, ESP, TLS, etc)
it's already too late, they've already defined their own incompatible
mechanisms.

Peter.