Re: [TLS] rfc7366: is encrypt-then-mac implemented?

Manuel Pégourié-Gonnard <mpg@polarssl.org> Thu, 30 October 2014 14:47 UTC

Return-Path: <mpg@polarssl.org>
X-Original-To: tls@ietfa.amsl.com
Delivered-To: tls@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 154101AD440 for <tls@ietfa.amsl.com>; Thu, 30 Oct 2014 07:47:36 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 0.397
X-Spam-Level:
X-Spam-Status: No, score=0.397 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HELO_MISMATCH_COM=0.553, HOST_EQ_NL=1.545, MIME_8BIT_HEADER=0.3, SPF_PASS=-0.001] autolearn=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id U-_Th9izVC74 for <tls@ietfa.amsl.com>; Thu, 30 Oct 2014 07:47:34 -0700 (PDT)
Received: from vps2.offspark.com (vps2.brainspark.nl [141.138.204.106]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 9219D1AD443 for <tls@ietf.org>; Thu, 30 Oct 2014 07:47:34 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=polarssl.org; s=exim; h=Subject:Content-Transfer-Encoding:Content-Type:In-Reply-To:References:To:MIME-Version:From:Date:Message-ID; bh=kKqbDedBhIh3dyLKcQB1g6HmnVE1gUlDKJOB7QkcfLI=; b=N5DUbdGeEb85hG2oCKV9ltj2qlU9ldl0t1AtEMq/TwyyiuiO1yxvgiwYQAfVRGJSDbDqHJ05u9fX8YYF4wJ6484TsSX7Bsi5GGqCa/KB8xH7uPWuzWYy+DPQKNav5ne2ET3J4Slcr9pDHHm1JA7sR6Frm6l6ueT1MYSV8TgFbFk=;
Received: from thue.elzevir.fr ([88.165.216.11] helo=[192.168.0.124]) by vps2.offspark.com with esmtpsa (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from <mpg@polarssl.org>) id 1Xjr0Y-00033C-K2; Thu, 30 Oct 2014 15:47:27 +0100
Message-ID: <54524F83.3010405@polarssl.org>
Date: Thu, 30 Oct 2014 15:47:31 +0100
From: Manuel Pégourié-Gonnard <mpg@polarssl.org>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0
MIME-Version: 1.0
To: henrick@streamsec.se, tls@ietf.org
References: <9A043F3CF02CD34C8E74AC1594475C739B9DC0AA@uxcn10-5.UoA.auckland.ac.nz> <545240DD.9010803@streamsec.se>
In-Reply-To: <545240DD.9010803@streamsec.se>
Content-Type: text/plain; charset="windows-1252"
Content-Transfer-Encoding: 8bit
X-SA-Exim-Connect-IP: 88.165.216.11
X-SA-Exim-Mail-From: mpg@polarssl.org
X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000)
X-SA-Exim-Scanned: Yes (on vps2.offspark.com)
Archived-At: http://mailarchive.ietf.org/arch/msg/tls/ejD3iqiaUAqhDh3VdLlRlf188Ug
Subject: Re: [TLS] rfc7366: is encrypt-then-mac implemented?
X-BeenThere: tls@ietf.org
X-Mailman-Version: 2.1.15
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: Thu, 30 Oct 2014 14:47:36 -0000

On 30/10/2014 14:45, Henrick Hellström wrote:
> On 2014-10-30 14:40, Peter Gutmann wrote:
>> The correct notation to use is quite confusing, intuitively you can say "the
>> length used in the MAC calculation is the length of the data that gets MAC'd",
>> but specifying it in notation isn't so easy, it's the length of the padded
>> encrypted TLSCompressed value as well as the length of the IV if TLS 1.1 or
>> newer is used.  If there's some clear way of saying that that, say, at least
>> three different people can agree on I'll use it.
> 
> Would it be overkill to define a new TLSIntermediaryCiphertext record type?
> 
Another (related) idea: explicitly change the definition of
GenericBlockCipher when EtM is in use (which is already implicitly done
at some point). Eg (unchanged text is indicated by a | in the margin,
left there for context at the beginning):

 | Once the use of encrypt-then-MAC has been negotiated, processing of
 | TLS/DTLS packets switches from the standard:
 |
 | encrypt( data || MAC || pad )
 |
 | to the new:
 |
 | encrypt( data || pad ) || MAC
 |
   with the MAC covering the encrypted data as well as metadata, as
   described below.  In TLS [2] notation, the definition of
   GenericBlockCipher is changed, for TLS 1.0 without the explicit
   Initialization Vector (IV), to:

      struct {
          block-ciphered struct {
              opaque content[TLSCompressed.length];
              uint8 padding[GenericBlockCipher.padding_length];
              uint8 padding_length;
          } ciphertext;
          opaque MAC[CipherSpec.hash_size];
      } GenericBlockCipher;

   and for TLS 1.1 and greater with an explicit IV to:

      struct {
          struct {
              opaque IV[SecurityParameters.record_iv_length];
              block-ciphered struct {
                  opaque content[TLSCompressed.length];
                  uint8 padding[GenericBlockCipher.padding_length];
                  uint8 padding_length;
              };
          } ciphertext;
          opaque MAC[SecurityParameters.mac_length];
      } GenericBlockCipher;

   All fields have the same definition as in RFC 2246 and RFC 5246
   respectively, except the MAC which is:

 | MAC(MAC_write_key, seq_num +
 |     TLSCipherText.type +
 |     TLSCipherText.version +
       length of GenericBlockCipher.ciphertext +
       GenericBlockCipher.ciphertext);

   where the length is encoded as two bytes in the usual way.
 | (For DTLS, the sequence number is replaced by the combined epoch and
 | sequence number as per DTLS [4].)
   The input to the MAC function differs from the data sent on the wire
   in two few ways: the first is the prepended sequence number (which,
   with TLS is not on the wire, and with DTLS is on the wire in a
   different position); the second is that the length on the wire
   includes the length of the MAC while the lenght in the input of the
   MAC function does not.

 | Note from the GenericBlockCipher annotation that this only applies to
 | standard block ciphers that have distinct encrypt and MAC operations.
   [rest of the section unchanged]
   [note: no need to recall/redefine TLSCiphertext any more]

Please criticize! (An obvious drawback is it looks quite heavy for an erratum,
compared to the other idea that changes only a few lines.)

Manuel.