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

Manuel Pégourié-Gonnard <mpg@polarssl.org> Sat, 01 November 2014 23:31 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 D7A211A1BA5 for <tls@ietfa.amsl.com>; Sat, 1 Nov 2014 16:31:03 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 0.997
X-Spam-Level:
X-Spam-Status: No, score=0.997 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, J_CHICKENPOX_37=0.6, 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 9Lnk8HL_gNIs for <tls@ietfa.amsl.com>; Sat, 1 Nov 2014 16:31:02 -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 EF6AD1A1BA4 for <tls@ietf.org>; Sat, 1 Nov 2014 16:31:01 -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=wf2h75bjszmiggdM2Jkw+HF42MM5D8WrPGw6pTQuNso=; b=gLwsfM3ZAgz/tjqvFKYlcfvxJGHmUcMLHQI08/uJEMUTDa2QkVHsU2btWn5J/eeVV4yg7heyPs8JmAJN8cQJt65oq29J1FjBvRjzyHYJzYFfMgcewioZQsexXFBpmWPietsVxtU9fbB9LVTwLpkb9YEg+gdMElkPKK+xbLPzE8k=;
Received: from mna75-11-88-161-199-191.fbx.proxad.net ([88.161.199.191] helo=[192.168.0.12]) by vps2.offspark.com with esmtpsa (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from <mpg@polarssl.org>) id 1Xki8D-0006zu-Tg; Sun, 02 Nov 2014 00:30:54 +0100
Message-ID: <54556D32.80100@polarssl.org>
Date: Sun, 02 Nov 2014 00:30:58 +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: "Yngve N. Pettersen" <yngve@spec-work.net>, tls@ietf.org
References: <9A043F3CF02CD34C8E74AC1594475C739B9DB35D@uxcn10-5.UoA.auckland.ac.nz> <op.xonuwux33dfyax@killashandra.invalid.invalid> <54555161.1040606@polarssl.org> <op.xon248yd3dfyax@killashandra.invalid.invalid>
In-Reply-To: <op.xon248yd3dfyax@killashandra.invalid.invalid>
Content-Type: text/plain; charset="iso-8859-15"
Content-Transfer-Encoding: 8bit
X-SA-Exim-Connect-IP: 88.161.199.191
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/BThNFeuWgUv2M-D4Nf3iHg-WA8Q
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: Sat, 01 Nov 2014 23:31:04 -0000

(Cutting a lot of details where we agree about the important points, to get to
the "what should be done now" part.)

On 01/11/2014 23:23, Yngve N. Pettersen wrote:
> On Sat, 01 Nov 2014 22:32:17 +0100, Manuel Pégourié-Gonnard  
> <mpg@polarssl.org> wrote:
>> I'm under the impression that Peter's paragraph in [1] suits this goal.
>>
>> [1] http://mailarchive.ietf.org/arch/msg/tls/3NOHlIUShLo9AAzXx4t2u7QV8Sw
>>
>> Do you agree? I reproduce the specific paragraph here for convenience's  
>> sake:
>>
>>   Note that the value of the 'uint16 length' field in the TLSCiphertext  
>> record
>>   differs from the length value used in the MAC calculation, since the
>>   TLSCiphertext record contains both the ciphtertext and the MAC, while  
>> the
>>   MAC calculation is performed only over the ciphertext.  So the length  
>> value
>>   encoded in the TLSCiphertext record is 'length' while the length value  
>> used
>>   in the MAC calculation is 'length - SecurityParameters.mac_length'.
> 
> It seems to describe the conclusions above, indeed, but personally I would  
> prefer that the formula should not reference TLSCiphertext.length at all,  
> but instead refer to the length of the field with the encrypted data, or  
> specifically defined as avariable in a separate formula as 'length -  
> SecurityParameters.mac_length'. Less chance of confusion, that way, and  
> having multiple values of a variable is never a good idea, unless it is  
> inside an algorithm that explicitly update the values as part of a step,  
> after it was used for something.
> 
100% agreed, I think for me the use of the same name for two different values
was the root cause of the confusion. How about combining Peter's above paragraph
with my proposed rewriting of the MAC calculation as:

           In TLS [2] notation, the MAC calculation for TLS 1.0 without
   the explicit Initialization Vector (IV) is:

   MAC(MAC_write_key, seq_num +
       TLSCipherText.type +
       TLSCipherText.version +
       length of (ENC(content + padding + padding_length)) +
       ENC(content + padding + padding_length));

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

   MAC(MAC_write_key, seq_num +
       TLSCipherText.type +
       TLSCipherText.version +
       length of (IV + ENC(content + padding + padding_length)) +
       IV +
       ENC(content + padding + padding_length));

    where the length is encoded as two bytes in the usual way.

It's admittedly not he most elegant, but at least it's clear and unambiguous,
which is probably more important than elegance for an erratum.

> I'm just putting it on the table as a (worst case) possibility; an  
> intermediate solution might be a new RFC obsoleting 7366, just updating  
> the text, if the errata text would be too extensive.
> 
Ok, it never hurts to consider possibilities. I'm not experienced enough with
the standards process to have an opinion on this one. I think it's clear that we
want an erratum soon regardless of what is or isn't deemed necessary later.

>> I'd expect any half-serious implementer to test interop with at least one
>> other implementation before releasing. Unfortunately, experience proves
>> people are not always serious about it. I honestly don't know.
>
> The possible issue is that a version might get widely deployed before a  
> specific issue is properly documented; just as examples of such issues are  
> version and extension intolerance, and personally, the SNI implementation  
> I originally wrote for Opera caused it to crash when actually encountering  
> a server responding to the SNI extension. Might not happen in this case,  
> since I am not aware of any actually deployed servers or clients.
> 
Yes, that sort of thing is unfortunately can't be ruled out. As above, I
honestly don't know what the best approach is, but it probably starts with an
erratum, and hopefully also ends with the erratum!

Manuel.