Re: aes128gcm: why verify padding?

Martin Thomson <martin.thomson@gmail.com> Mon, 23 January 2017 23:40 UTC

Return-Path: <ietf-http-wg-request+bounce-httpbisa-archive-bis2juki=lists.ie@listhub.w3.org>
X-Original-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Delivered-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id C3E91129422 for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Mon, 23 Jan 2017 15:40:25 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -9.72
X-Spam-Level:
X-Spam-Status: No, score=-9.72 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, RP_MATCHES_RCVD=-3.199, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com
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 mQkJbCzDZzS5 for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Mon, 23 Jan 2017 15:40:24 -0800 (PST)
Received: from frink.w3.org (frink.w3.org [128.30.52.56]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id B3EF1129420 for <httpbisa-archive-bis2Juki@lists.ietf.org>; Mon, 23 Jan 2017 15:40:24 -0800 (PST)
Received: from lists by frink.w3.org with local (Exim 4.80) (envelope-from <ietf-http-wg-request@listhub.w3.org>) id 1cVoBv-0005Cu-HO for ietf-http-wg-dist@listhub.w3.org; Mon, 23 Jan 2017 23:38:27 +0000
Resent-Date: Mon, 23 Jan 2017 23:38:27 +0000
Resent-Message-Id: <E1cVoBv-0005Cu-HO@frink.w3.org>
Received: from titan.w3.org ([128.30.52.76]) by frink.w3.org with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from <martin.thomson@gmail.com>) id 1cVoBs-0005C9-Iq for ietf-http-wg@listhub.w3.org; Mon, 23 Jan 2017 23:38:24 +0000
Received: from mail-qt0-f177.google.com ([209.85.216.177]) by titan.w3.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <martin.thomson@gmail.com>) id 1cVoBm-0004bk-JL for ietf-http-wg@w3.org; Mon, 23 Jan 2017 23:38:19 +0000
Received: by mail-qt0-f177.google.com with SMTP id v23so152601899qtb.0 for <ietf-http-wg@w3.org>; Mon, 23 Jan 2017 15:37:58 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=x/MiRN+KlHN1CkKK68v9o6mORgezGejCleYfPwH2hwA=; b=FBn2K6hHR+i7ijK/nucd1Zcbaz5lKAvdFWZXdJvhCy1/frE70Vpw4kkYC3AE0TRVH3 AzLYuXMOarMT7ToWyEZCMLCLrHXUzMaS0WddNjb+B/+FaFD6ipJNq1oJcWldwBrksZSP NQYmxRGGq7OLMt6HKg9Utd/MAwETlXzSh+2TXYyUPIK5wEHoYX3eeca1AY1h9DAeaWM0 MY2MIY+lUA4v+fWKfC65s+qhJzNuq0wEZvT0K+X+pebj3ro/rhszJ0RAcWq8eHDEZT1d ZexH6u0lUgxSQxsF9Z/V+2s1JD4oiPD6Y3skyW2zm/lAB20aSqROWhf4QzEMAbMe8DXp MV4A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=x/MiRN+KlHN1CkKK68v9o6mORgezGejCleYfPwH2hwA=; b=R44+tOpKM8aCbYtrc5Ahs45LDENKzpi65bs5BFPvEUo9O/T8S49VG+2AUb1jTrzrSo BRXAJzgKohOZ6kjZ1vzYmBkVhw8qABr3bfgcuj3khOC4ZHpyoY7NGBawE4e5RET9wbSP UILry29baRgAD4bKmo+DYupwYFrasnjW9kUSc+VgiEj5skhwX/FIjlO+NO/k0d/HTLvC AmyOxG/zD01CkpZMR1DNHqC7gBCWH75gn6Zw/xVbnm390g3G1KHSmERTomi5dFzeFaXe bTbqgQi0HF4ecN04rKc7osPbvPv+VD3Sys2mL6VhrTOqQK5GnwQSw24SElQZyqJE2m1G PKhg==
X-Gm-Message-State: AIkVDXJJsWswNmocj7BLW1o5pfv+suZrn/DIDTPGNxB3PrSh5Jma3R1IYbgLS+V/svmQwUA6PmkS6Z4+6JwlfQ==
X-Received: by 10.55.99.85 with SMTP id x82mr26231512qkb.147.1485214672684; Mon, 23 Jan 2017 15:37:52 -0800 (PST)
MIME-Version: 1.0
Received: by 10.140.19.112 with HTTP; Mon, 23 Jan 2017 15:37:51 -0800 (PST)
In-Reply-To: <SYXPR01MB1615798CC057FB3232B2FA4BE5720@SYXPR01MB1615.ausprd01.prod.outlook.com>
References: <SYXPR01MB161520224A59CDCE0D433A2CE57A0@SYXPR01MB1615.ausprd01.prod.outlook.com> <CABkgnnUo-tf69AzJC=OUy2rjDZwedTd5Ua9mhOiJBqaA0VKrYw@mail.gmail.com> <SYXPR01MB16150F4D3D19CC69D18E1A09E57D0@SYXPR01MB1615.ausprd01.prod.outlook.com> <CABkgnnV_OatRWyZBE3Rak22gS1jrOZKjCGwOePpbqJCAeJFM4Q@mail.gmail.com> <SYXPR01MB1615DD56268D7EF9929F3DBFE5720@SYXPR01MB1615.ausprd01.prod.outlook.com> <20170123073623.GA28101@LK-Perkele-V2.elisa-laajakaista.fi> <SYXPR01MB1615798CC057FB3232B2FA4BE5720@SYXPR01MB1615.ausprd01.prod.outlook.com>
From: Martin Thomson <martin.thomson@gmail.com>
Date: Tue, 24 Jan 2017 08:37:51 +0900
Message-ID: <CABkgnnW4e+FOz+gsu6vZ2d9WOSv9Yohn+OejrNom9HCBiMrRWQ@mail.gmail.com>
To: "Manger, James" <James.H.Manger@team.telstra.com>
Cc: "ilariliusvaara@welho.com" <ilariliusvaara@welho.com>, "ietf-http-wg@w3.org" <ietf-http-wg@w3.org>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass client-ip=209.85.216.177; envelope-from=martin.thomson@gmail.com; helo=mail-qt0-f177.google.com
X-W3C-Hub-Spam-Status: No, score=-5.8
X-W3C-Hub-Spam-Report: AWL=-0.230, BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001, W3C_AA=-1, W3C_DB=-1, W3C_IRA=-1, W3C_WL=-1
X-W3C-Scan-Sig: titan.w3.org 1cVoBm-0004bk-JL fc352fd7c81bbc7605120040eb106698
X-Original-To: ietf-http-wg@w3.org
Subject: Re: aes128gcm: why verify padding?
Archived-At: <http://www.w3.org/mid/CABkgnnW4e+FOz+gsu6vZ2d9WOSv9Yohn+OejrNom9HCBiMrRWQ@mail.gmail.com>
Resent-From: ietf-http-wg@w3.org
X-Mailing-List: <ietf-http-wg@w3.org> archive/latest/33360
X-Loop: ietf-http-wg@w3.org
Resent-Sender: ietf-http-wg-request@w3.org
Precedence: list
List-Id: <ietf-http-wg.w3.org>
List-Help: <http://www.w3.org/Mail/>
List-Post: <mailto:ietf-http-wg@w3.org>
List-Unsubscribe: <mailto:ietf-http-wg-request@w3.org?subject=unsubscribe>

On 23 January 2017 at 21:47, Manger, James
<James.H.Manger@team.telstra.com> wrote:
> A padding byte to distinguish intermediate and final records could indeed work.

I like it.  You can pad an arbitrary amount and you only pay one octet
per record overhead if you don't like padding, and the trailing record
requirement goes away.

> It doesn't consume any extra bytes in this scheme as it piggy-backs on an end-of-padding byte. But in a different multiple-AEAD-record scheme that didn't offer padding (a nice, but not strictly necessary feature) it wouldn't be so ideal. I've seen ideas to put the first-vs-intermediate-vs-last indicator in the nonce, in the KDF, in the AAD, in the record length, and now in the plaintext. I'm not sure how to pick.

I believe that it doesn't matter.

> What do you do if last non-zero byte isn't 0x01 or 0x02?

Explode and discard the data - it's corrupted.  If we don't require
that, then an attacker gains a decryption oracle.  (Same reason for
requiring that the padding be fixed in size.)