Re: [TLS] draft-mcgrew-aead-aes-cbc-hmac-sha2 can't be used as TLS 1.2 AEAD ciphers

David McGrew <mcgrew@cisco.com> Tue, 27 August 2013 21:20 UTC

Return-Path: <mcgrew@cisco.com>
X-Original-To: tls@ietfa.amsl.com
Delivered-To: tls@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id CEC2E11E81FA for <tls@ietfa.amsl.com>; Tue, 27 Aug 2013 14:20:56 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -110.599
X-Spam-Level:
X-Spam-Status: No, score=-110.599 tagged_above=-999 required=5 tests=[BAYES_00=-2.599, RCVD_IN_DNSWL_HI=-8, USER_IN_WHITELIST=-100]
Received: from mail.ietf.org ([12.22.58.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id q9pHbFfRL2R3 for <tls@ietfa.amsl.com>; Tue, 27 Aug 2013 14:20:51 -0700 (PDT)
Received: from rcdn-iport-6.cisco.com (rcdn-iport-6.cisco.com [173.37.86.77]) by ietfa.amsl.com (Postfix) with ESMTP id 7B3D911E81D6 for <tls@ietf.org>; Tue, 27 Aug 2013 14:20:51 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2405; q=dns/txt; s=iport; t=1377638451; x=1378848051; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=yK3cjvLQN4/f4l0RmPkz5M0h3vJ5tDT0kKjoEeiwNxs=; b=FSziX4pBRRxon1SEkgSQwOvXUmwGtf+sNTJbEby9A9bVqEE/jRIQMu86 9u/nSY57PI88aghQC430Gkbiap2HlloWEDSeREU36ILUryjtCvi1UGg2A /ia3WaUsAdNZLZEaE9Hud+VVA6CwE8OHQis4xm5Szx1TRIitcMIAEXI3N A=;
X-IronPort-AV: E=Sophos;i="4.89,970,1367971200"; d="scan'208";a="252378167"
Received: from rcdn-core-3.cisco.com ([173.37.93.154]) by rcdn-iport-6.cisco.com with ESMTP; 27 Aug 2013 21:20:51 +0000
Received: from [10.0.2.15] (rtp-mcgrew-8912.cisco.com [10.117.10.227]) by rcdn-core-3.cisco.com (8.14.5/8.14.5) with ESMTP id r7RLKo3u031236; Tue, 27 Aug 2013 21:20:50 GMT
Message-ID: <1377638449.4027.222.camel@darkstar>
From: David McGrew <mcgrew@cisco.com>
To: Wan-Teh Chang <wtc@google.com>
Date: Tue, 27 Aug 2013 17:20:49 -0400
In-Reply-To: <CALTJjxEjN04jfCb=mjo1ZWPvgX_sw0Dw6v+AMPKdXp=9BbCxow@mail.gmail.com>
References: <CALTJjxEjN04jfCb=mjo1ZWPvgX_sw0Dw6v+AMPKdXp=9BbCxow@mail.gmail.com>
Content-Type: text/plain; charset="UTF-8"
X-Mailer: Evolution 3.4.4-3
Mime-Version: 1.0
Content-Transfer-Encoding: 7bit
Cc: foleyj@cisco.com, "tls@ietf.org" <tls@ietf.org>, Ryan Sleevi <sleevi@google.com>
Subject: Re: [TLS] draft-mcgrew-aead-aes-cbc-hmac-sha2 can't be used as TLS 1.2 AEAD ciphers
X-BeenThere: tls@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: "This is the mailing list for the Transport Layer Security working group of the IETF." <tls.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/tls>, <mailto:tls-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/tls>
List-Post: <mailto:tls@ietf.org>
List-Help: <mailto:tls-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/tls>, <mailto:tls-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 27 Aug 2013 21:20:56 -0000

Hi Wan-Teh,

thanks to you and Ryan for identifying and raising this issue, more
inline:

On Wed, 2013-08-21 at 10:49 -0700, Wan-Teh Chang wrote:
> While reviewing the NSS patch for the AES-GCM TLS cipher suites, my
> colleague Ryan Sleevi noticed that the AEAD algorithms defined in
> draft-mcgrew-aead-aes-cbc-hmac-sha2 can't be used as TLS 1.2 AEAD
> ciphers. The problem is how TLS 1.2 specifies the additional
> authenticated data for AEAD ciphers:
> 
> RFC 5246 Section 6.2.3.3 says:
> 
>    The plaintext is the TLSCompressed.fragment.
> 
>    The additional authenticated data, which we denote as
>    additional_data, is defined as follows:
> 
>       additional_data = seq_num + TLSCompressed.type +
>                         TLSCompressed.version + TLSCompressed.length;
> 
>    where "+" denotes concatenation.
> 
> So additional_data includes the length of the plaintext
> (TLSCompressed.length). But a TLS 1.2 record only gives us the length
> of the AEAD ciphertext. So the recipient needs to calculate the
> plaintext's length using only the ciphertext.
> 
> This is difficult to do with the AEAD algorithms in
> draft-mcgrew-aead-aes-cbc-hmac-sha2 because the amount of padding, and
> therefore the plaintext length, is only known after CBC decryption.

Yes, this is true.

Given the CBC decryption key, it is not hard to find the length of the
plaintext (and the final block can be decrypted as P_n = AES-DEC(K, C_n)
XOR C_{n-1} without decrypting any other blocks, if that is desired).
But it would be undesirable to use this technique, since we want the key
to "stay inside" the AEAD algorithm.  

RFC 5116 asks that each algorithm "provide a description relating the
length of the plaintext to that of the ciphertext."   What you have
found is that draft-mcgrew-aead-aes-cbc-hmac-sha2 provides a
relationship for finding the ciphertext length from the plaintext
length, but not the reverse, and it is impossible to find that reverse
relationship without the secret key.  

All of the AEAD algorithms in the registry (which are based on CCM, GCM,
and SIV) use counter-mode style encryption, and don't have this
problem.   

I have some thoughts on changes that can improve the situation, which
I'll send in reply to John's email.

thanks,

David

> 
> Is this a known problem with TLS 1.2 AEAD ciphers?
> 
> Wan-Teh Chang