Re: Read-out on offline connection ID discussion

Mikkel Fahnøe Jørgensen <mikkelfj@gmail.com> Thu, 25 January 2018 08:45 UTC

Return-Path: <mikkelfj@gmail.com>
X-Original-To: quic@ietfa.amsl.com
Delivered-To: quic@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id C72D212D96B for <quic@ietfa.amsl.com>; Thu, 25 Jan 2018 00:45:11 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.697
X-Spam-Level:
X-Spam-Status: No, score=-2.697 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001, URIBL_BLOCKED=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 EacMWkzyVyZM for <quic@ietfa.amsl.com>; Thu, 25 Jan 2018 00:45:09 -0800 (PST)
Received: from mail-io0-x231.google.com (mail-io0-x231.google.com [IPv6:2607:f8b0:4001:c06::231]) (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 319D812D868 for <quic@ietf.org>; Thu, 25 Jan 2018 00:45:09 -0800 (PST)
Received: by mail-io0-x231.google.com with SMTP id f34so7830557ioi.13 for <quic@ietf.org>; Thu, 25 Jan 2018 00:45:09 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:in-reply-to:references:mime-version:date:message-id:subject:to :cc; bh=y89BGQvDIVdLoxWXEdVqX8wZDYDpfgcIOzyHxbBeKD0=; b=rOIGp9ztwDaV4ltiMLSfLEz4HhH9e1y5WjxTHlg5PiLWyIoSax9U849JlVBUQGAqGR V/eFAzgzhTPZ5Ldjtmp8NWINQoG0wrBZUfEJFsYsBhCNG1cybNnyuwMsaKFNa/z4JyZK 5S81q6kMphpSyr5nXiXneqfL9Dk2DYypOsswha2xvxHuSW+SVGXjB/BaiJJIebETPpG1 0wVEpg4vtltZ+XnhtOO7xZMPbbLBcwx+ud7JOWTbunIu10cM1vuOfaZckgsMBsu96a+a OP31oLgzhCl0PbH//UwY9aHx93xP6SkJdFT6yG3FeCDoZM+X3PFZu3sQR3DdnW4hxv2v Sasg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:in-reply-to:references:mime-version:date :message-id:subject:to:cc; bh=y89BGQvDIVdLoxWXEdVqX8wZDYDpfgcIOzyHxbBeKD0=; b=P3qhJf3v+yW3+d9jT30onaQLX8NfbgF4aGgZ2JadQhwiMYkdl+gKZVoB9IRF0eWObW Sd+Xy4CoFphs67gSw39bZy6jEKYKKDl2v2ypTjTXmI5EppO/EZHEnjOBs+lrUNfcqEN4 60PqvkwnEbfrynOxbqiULfem75TZYiqCsa/0GSjXPAKlfQUVEBXrNaWCfuwvbIe6TcvQ NsXK3hscQ9ATQbveg6DJ4+C2+KerCUgfRnpUjlvpxJnjs/+4ZpDAWY6cwVVAB6w2uQ9C wW9H+vE/dslAjjuAbclhvYZC91UaywDHCH8L3xDQPLDbqW8xvd6RnPu4uq0w6adbEQIf Ogfw==
X-Gm-Message-State: AKwxytc1brCTutEXVnm0NURdhu2ck0rD+Ssxs8Zi6K3k6dI4YZ3TqUGD wrVLGMVUkR9MbTbz1Y2gIvPY8pd7miATmumNT/n56w==
X-Google-Smtp-Source: AH8x227Kw7JCtIe1fQL4kP0GlEAU0ZoHXaGxxVDX3z88h7EA0DyEa0mEPRzbwz80XicQ0x8F98k0TxUsiwFHKxtXWP8=
X-Received: by 10.107.20.200 with SMTP id 191mr11918607iou.239.1516869908462; Thu, 25 Jan 2018 00:45:08 -0800 (PST)
Received: from 1058052472880 named unknown by gmailapi.google.com with HTTPREST; Thu, 25 Jan 2018 00:45:07 -0800
From: Mikkel Fahnøe Jørgensen <mikkelfj@gmail.com>
In-Reply-To: <CABcZeBO2iRrFXNgLD1AsxmwRJ+Pz6USadWGeU5vb12Pu9eOyog@mail.gmail.com>
References: <CABcZeBO8UcdsPPp7D-3gZW8tuDqNhP-z+O1+WH=68KjbfYMr5A@mail.gmail.com> <CAN1APdewkGQULckLb6F4rEzcPtiFJPBVBQbkcNeupK3d+r6Sow@mail.gmail.com> <CABcZeBO2iRrFXNgLD1AsxmwRJ+Pz6USadWGeU5vb12Pu9eOyog@mail.gmail.com>
X-Mailer: Airmail (420)
MIME-Version: 1.0
Date: Thu, 25 Jan 2018 00:45:07 -0800
Message-ID: <CAN1APdcuyGk=2TAv+7WoRAsh3vVPxu56xXtdj0SgNaTL=ihvPA@mail.gmail.com>
Subject: Re: Read-out on offline connection ID discussion
To: Eric Rescorla <ekr@rtfm.com>
Cc: IETF QUIC WG <quic@ietf.org>
Content-Type: multipart/alternative; boundary="001a114fd4c81081ba056395ccf4"
Archived-At: <https://mailarchive.ietf.org/arch/msg/quic/nAE2S1PNiAkdI6fyj_8kNcwv-8A>
X-BeenThere: quic@ietf.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: Main mailing list of the IETF QUIC working group <quic.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/quic>, <mailto:quic-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/quic/>
List-Post: <mailto:quic@ietf.org>
List-Help: <mailto:quic-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/quic>, <mailto:quic-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 25 Jan 2018 08:45:12 -0000

On 25 January 2018 at 00.16.55, Eric Rescorla (ekr@rtfm.com) wrote:

I don’t understand this requirement for the CID to be 16 bytes in order to
be encrypted.
If you have a unique key you can encrypt 0, truncate and xor with the CID.
If you don’t have a unique key, you can encrypt a unique counter value and
do the same, or derive a unique key.


I don't believe what you are describing works correctly, but I'm not sure I
understand your proposal. Can you please flesh out precisely what you have
in mind? In particular, who is "you", who has the key, etc.?

I’m merely stating that if you want to encrypt with AES and you do not care
about authentication, then AES works fine with shorter inputs than 16
bytes. You may still have to provide an initialisation vector so the +n
still holds. The last block of AES-GCM is not a full block and works as i
described - see sect. 2.3 and figure 1 in link to GCM paper. If the last
block is the only block, you encrypt less than 16 bytes without any magic.

There are many reasons you might want to use 16 bytes, or you might want to
add authentication, but it is not AES itself that imposes those constraints
as already argued. My point is that if you need 16 bytes, please state why,
instead of blaming it on AES.

As to a possible scheme:

Assume a server cluster wants to encode routing data by selecting one out
of 256 possible routes and a 8 bit unique id for each route. This can be
done with 16 bits. (Not saying this is a good idea). Or, let’s make it
simple for a start: just have 1 routing bit R to choose between two servers
and 1 IV bit to identify the connection, and one phase bit P. The objective
is to make it unpredictable which server is hit. The encryption of the two
bits happen by encrypting the IV bit with a cluster key that all routers
are aware of. The phase bit is not needed but avoids guessing which router
key is active since it rotates every hour derived from a master key. The
encrypted CID is just 1 bit flipped randomly based on XOR’ing with
encrypting 1 or 0, depending the IV is 1 or 0. key = derive(master, R), P =
not P if key changed since last derivation. The encrypted CID ECID =
<AES(key, IV) XOR R, IV, P>.

We can readily extend the above to as many R bits as needed. The IV must be
unique but if we only care about making it hard to force a route rather
than protecting information, it is less critical, assuming we hide the
master key behind strong derivation.

The problem is that an attacker can easily flip the first bit in the ECID.
We can make this harder by having more than R bits than valid routes and
having more IV bits chosen at random. The R bits now either map to a valid
route or not. It becomes harder to guess a valid route.

We can make this harder by adding an auth tag - say of length 16 bits.
AES-GCM is not suited for short tags, but there CMACs that can do this I
believe (two times AES + padding and truncation to desired length, from
memory). However, if it is sufficiently hard to guess a route, and it is
easy to decide if a route is valid or not, it may not be necessary with an
auth tag.

In addition we want to identify the connection uniquely with respect to the
chosen server route so we add U bits to make the connection id unique.
These do not have to be encrypted, but they might as well be thrown in.

http://www.mindspring.com/~dmcgrew/gcm-nist-6.pdf

AES-GCM goes horribly wrong if the same encrypted counter value is used
twice - but we may not have a problem with horribly wrong in our use case,
which also only uses the CTR mode part.