Re: [openpgp] AEAD Chunk Size

"Neal H. Walfield" <neal@walfield.org> Thu, 07 March 2019 17:09 UTC

Return-Path: <neal@walfield.org>
X-Original-To: openpgp@ietfa.amsl.com
Delivered-To: openpgp@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id AC9DB129A86 for <openpgp@ietfa.amsl.com>; Thu, 7 Mar 2019 09:09:31 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.9
X-Spam-Level:
X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=ham autolearn_force=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 05E9zvDBGkXZ for <openpgp@ietfa.amsl.com>; Thu, 7 Mar 2019 09:09:29 -0800 (PST)
Received: from mail.dasr.de (mail.dasr.de [217.69.77.164]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id BE730126C7E for <openpgp@ietf.org>; Thu, 7 Mar 2019 09:09:29 -0800 (PST)
Received: from p54abd93f.dip0.t-ipconnect.de ([84.171.217.63] helo=grit.huenfield.org.walfield.org) by mail.dasr.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.86_2) (envelope-from <neal@walfield.org>) id 1h1wWG-0000E4-6v; Thu, 07 Mar 2019 17:09:20 +0000
Date: Thu, 07 Mar 2019 18:09:19 +0100
Message-ID: <878sxqy5kw.wl-neal@walfield.org>
From: "Neal H. Walfield" <neal@walfield.org>
To: Tobias Mueller <muelli@cryptobitch.de>
Cc: Jon Callas <joncallas@icloud.com>, Bart Butler <bartbutler@protonmail.com>, "openpgp@ietf.org" <openpgp@ietf.org>, Vincent Breitmoser <look@my.amazin.horse>
In-Reply-To: <2a014c4a103ba7f52535546f7e77277ea2bdabdf.camel@cryptobitch.de>
References: <87mumh33nc.wl-neal@walfield.org> <F9VLV9HZWH.3RYL3UM3BN873@my.amazin.horse> <3WZ7-hy9V7TOy53p1gP5EXELzHJIqjouV9x0YTN3PWsBZedKkqvVCRm-2XzGZy-FYAYdTqP1-7YV4wbTWMWAYhSujQA6NmrnIuXfZLRHkdQ=@protonmail.com> <CAB941EE-6961-4CAB-9632-DFF738980467@icloud.com> <87h8co2t4v.wl-neal@walfield.org> <35C892F7-18A8-401E-828D-5CE180A3A731@icloud.com> <87r2brf0f1.wl-neal@walfield.org> <2a014c4a103ba7f52535546f7e77277ea2bdabdf.camel@cryptobitch.de>
User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (Gojō) APEL/10.8 EasyPG/1.0.0 Emacs/24.5 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)
MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue")
Content-Type: text/plain; charset="US-ASCII"
Archived-At: <https://mailarchive.ietf.org/arch/msg/openpgp/bPR6s4Kzjri1P6n3fbiF8u1GEEk>
Subject: Re: [openpgp] AEAD Chunk Size
X-BeenThere: openpgp@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Ongoing discussion of OpenPGP issues." <openpgp.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/openpgp>, <mailto:openpgp-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/openpgp/>
List-Post: <mailto:openpgp@ietf.org>
List-Help: <mailto:openpgp-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/openpgp>, <mailto:openpgp-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 07 Mar 2019 17:09:36 -0000

Hi Tobi,

On Sun, 03 Mar 2019 19:36:08 +0100,
Tobias Mueller wrote:
> By fixing a "chunk size" you take away the ability to benefit from AE
> for messages bigger than that size.
> Implementations could easily collect all chunks and only release the
> plaintext once all chunks check out successfully. But that could go
> wrong. And depending on implementations to get things right and clients
> to use those implementations correctly is exactly what enabled Efail to
> become an issue. I think it'd be much nicer if the protocol already
> ensures that my emails do indeed enjoy protection against modification
> rather than me having to rely too much on clients getting it right.

You're afraid of bugs.  So am I.  Dynamically resizing buffers is
error prone.  Even computing AEAD's chunk size is hard:

  #include <stdio.h>

  int chunk_size(int c) {
    return 2 << (c + 6);
  }

  int
  main(int argc, char *argv[]) {
    printf("%d\n", chunk_size(32));
  }

  $ gcc -Wall a.c
  $ ./a.out
  128

(Note that gcc doesn't even produce a warning!)

But, that's not all.  If there is the possibility of failing due to a
lack of buffer space, implementors won't bother.  And they won't
bother for a very good reason: users want to get work done.  If a
security policy prevents them from getting their work done, they will
disable it.  Or, an implementation will ignore it.  And, because it is
only a problem if there is an attack, users will be thankful for the
more "powerful" solution.

The secure implementation must be easy for both developers and users.
And the secure implementation is a small, fixed sized buffer, even if
that means the client may have to worry about truncation.

> Having said that, I understand the desire for fixing a chunk size to
> reduce complexity for implementers.  My desire as a user is to have a
> strong and resilient protocol.

Perhaps you're not a typical user :D.

> Is there another way to do real AE?

Chunked AE is still real AE: it still has ciphertext integrity; it is
just susceptible to truncation attacks.  That's not to say that
truncation attacks are not a serious issue, but I'd rather have
truncation attacks than truncation attacks *and* ciphertext modication
attacks.

:) Neal

P.S.  Consider realloc.  It is only marginally easier to write this
wrong code:

  p = realloc(p, 2 * size);
  if (! p) {
      // Oops, p has been leaked!
      return ENOMEM;
  }

than this code:

  void *temp = realloc(p, 2 * size);
  if (! temp) {
      free(p);
      return ENOMEM;
  }
  p = temp;

but I see lots of instances of the former when reading code.