Re: [TLS] Encrypt-then-MAC again (was Re: padding bug)

mrex@sap.com (Martin Rex) Fri, 29 November 2013 21:09 UTC

Return-Path: <mrex@sap.com>
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 7A5841AE1DF for <tls@ietfa.amsl.com>; Fri, 29 Nov 2013 13:09:46 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -6.552
X-Spam-Level:
X-Spam-Status: No, score=-6.552 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HELO_EQ_DE=0.35, RCVD_IN_DNSWL_HI=-5, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=ham
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 IzQJd45_WZq5 for <tls@ietfa.amsl.com>; Fri, 29 Nov 2013 13:09:44 -0800 (PST)
Received: from smtpde01.sap-ag.de (smtpde01.sap-ag.de [155.56.68.170]) by ietfa.amsl.com (Postfix) with ESMTP id 99C481AE1DE for <tls@ietf.org>; Fri, 29 Nov 2013 13:09:44 -0800 (PST)
Received: from mail05.wdf.sap.corp by smtpde01.sap-ag.de (26) with ESMTP id rATL9ehW022873 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 29 Nov 2013 22:09:40 +0100 (MET)
In-Reply-To: <5298FA4C.7050803@defuse.ca>
To: Taylor Hornby <havoc@defuse.ca>
Date: Fri, 29 Nov 2013 22:09:40 +0100 (CET)
X-Mailer: ELM [version 2.4ME+ PL125 (25)]
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="US-ASCII"
Message-Id: <20131129210940.6EB5E1AB11@ld9781.wdf.sap.corp>
From: mrex@sap.com (Martin Rex)
X-SAP: out
Cc: tls@ietf.org
Subject: Re: [TLS] Encrypt-then-MAC again (was Re: padding bug)
X-BeenThere: tls@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: mrex@sap.com
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: Fri, 29 Nov 2013 21:09:46 -0000

Taylor Hornby wrote:
> 
> The quantity of code changes isn't all that matters. The complexity and
> the elegance of the changes do too.

I do not consider seperate new GenericBlockCipher PDUs (one for SSLv3+TLSv1.0
and a seperate one for TLSv1.1+TLSv1.2) particularly elegant, and neither
do I think that leaving the predictable IV in SSLv3+TLSv1.0 is sensical
when we _do_ change that PDU.


> 
> Often you can fix something with a one-line hack that makes the code
> more confusing, or you can re-write the function and do it properly.


> I suspect moving to pad-mac-encrypt instead of pad-encrypt-mac is more
> like a one-line hack that would actually make implementation harder.
> Most of the encryption APIs I've seen do the padding internally, where
> you can't access it to compute the MAC.

Admittedly, I know very few encryption APIs.  The two that I know
offer CBC with both, a function that does PKCS-padding for you,
and one that does not perform padding.
PKCS#11 v2.01 (1997) seems to have both.

There are some applications that use padding other than PKCS-padding.
XMLenc is one example (PKCS-padding is a subset of valid XML-paddings).
 

> 
> Also: Won't you still have to use the padding to *find* the MAC in the
> ciphertext, in order to check the MAC before you remove the padding? If
> so, then a padding oracle is still possible.

Nope.  when using pad-mac-encrypt, then the mac will always be at the end,
and covered by the MAC computation.

-Martin