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

Manuel Pégourié-Gonnard <mpg@polarssl.org> Thu, 30 October 2014 10: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 F24781AD0A9 for <tls@ietfa.amsl.com>; Thu, 30 Oct 2014 03:31:54 -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 nF3kgjs8Qn4G for <tls@ietfa.amsl.com>; Thu, 30 Oct 2014 03:31:53 -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 30BE91AD0AE for <tls@ietf.org>; Thu, 30 Oct 2014 03:31:53 -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=Vv0bCilXWqfPxrvKaAykOpPBcTSoy/DqoeHkYcc3spM=; b=Pt4bhIv0OnJbOqDY//CtQWPJ/5EZ26jIi69JnHi168J/wf/bqRK9LhuYLPlXDzbZQchiZsXjK/q0xWSl3omgMQLwy+Shs1dodVx6AuZGuSsdNj1YgBOqikFYzxXmifmsuT9s2sN0rAkcoKQhy/TsjbRpe8p6NXQSxv5ndLxpL7U=;
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 1Xjn16-0002jW-5A; Thu, 30 Oct 2014 11:31:44 +0100
Message-ID: <54521394.4040509@polarssl.org>
Date: Thu, 30 Oct 2014 11:31:48 +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: Peter Gutmann <pgut001@cs.auckland.ac.nz>, "<tls@ietf.org>" <tls@ietf.org>
References: <9A043F3CF02CD34C8E74AC1594475C739B9DBED9@uxcn10-5.UoA.auckland.ac.nz>
In-Reply-To: <9A043F3CF02CD34C8E74AC1594475C739B9DBED9@uxcn10-5.UoA.auckland.ac.nz>
Content-Type: text/plain; charset="windows-1252"
Content-Transfer-Encoding: 7bit
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/F9CDZUoGtcpCxf9S_BDojMbdtiQ
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 10:31:55 -0000

On 30/10/2014 10:40, Peter Gutmann wrote:
> As far as I know all deployed implementations until the recent ones (NSS,
> PolarSSL) are compliant with RFC 7366.

Just to be clear: PolarSSL and GnuTLS are not deployed, and AFAIK (from the bug
report) neither is NSS. We make sure to test interop before releasing.

> What they aren't compliant with is an
> interpretation that says "MAC the ciphertext and then another 20/32 bytes of
> whatever follows the ciphertext", which is what the "include the MAC length"
> interpretation seems to be doing.
> 
It's not what it is doing, please see my email from 10:19 today (which you might
not have noticed before posting):

https://mailarchive.ietf.org/arch/msg/tls/uCqXIwnSC1mXlbkMFxFKpOtqbRk

> More than a year ago when the drafts were published and people implemented
> them, there were no interop problems, no-one complained about any issues, so
> the draft was published as an RFC.  I'll make that point again, during the
> entire time that it was a draft no-one informed me of any ambiguity in
> interpretation or problems with interop in regard to this particular issue, if
> they had I would have fixed them.
> 
I hear you. I honestly think it's just bad luck that nobody noticed before and
the early implementers just happened to spontaneously make the same
interpretation. I guess that's why there is an errata system.

> Now that it's an RFC, a new set of implementers have managed to come up with
> an interpretation that,

I can't speak for others, but I didn't "manage to come up with". That's the most
natural interpretation of the RFC to me. I'm aware it is not what you intended
the RFC to mean, and it is not how previous implementers read it, and that's
exactly why I want the RFC to be clarified.

We're on the same side here: we all want the RFC to be deployed and used soon.
That's why we want unambiguous text that reads the same way to everyone.

> AFAICT (a) isn't in the RFC, and (b) doesn't make any
> sense. 

Regarding (b), see the email cited above. Regarding (a), please answer to the
following questions based on the text of the RFC (assuming TLS 1.2 (not DTLS,
not TLS 1.0) for the sake of simplicity; byte numbers are 0-based).

1. What should be bytes 11 and 12 of the input to the MAC function?
2. What should go on the wire as bytes 3 and 4 of the record?

My understanding of the RFC is that the answer to both of these questions is
TLSCiphertext.length. For (1), my answer is based on:

   MAC(MAC_write_key, seq_num +
       TLSCipherText.type +
       TLSCipherText.version +
       TLSCipherText.length + // <----- bytes 11-12 of the MAC input
       IV +
       ENC(content + padding + padding_length));

For (2) it's based on:

   The overall TLS packet [2] is then:

   struct {
          ContentType type;
          ProtocolVersion version;
          uint16 length; // <----- bytes 3-4 on the wire
          GenericBlockCipher fragment;
          opaque MAC;
          } TLSCiphertext;

So, based on the text of the RFC, am I wrong saying that those two pairs of
bytes should have the same value? If so, please tell me exactly where I'm mistaken.

If I'm not wrong here, then the eid server is, because it does not use the same
value for these two pairs of bytes.

> I could certainly issue a clarification, but first I'd have to
> understand (a) how recent implementers are managing to come up with an
> interpretation that isn't in the RFC and (b) what sort of wording to use to
> correct this.
> 
Let's first agree on the answer to the above questions, then I'll be happy to
suggest wording.

Manuel.