Re: [TLS] TLSFlags ambiguity

David Benjamin <davidben@chromium.org> Sun, 17 March 2024 03:53 UTC

Return-Path: <davidben@google.com>
X-Original-To: tls@ietfa.amsl.com
Delivered-To: tls@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id E31F5C151065 for <tls@ietfa.amsl.com>; Sat, 16 Mar 2024 20:53:23 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -9.257
X-Spam-Level:
X-Spam-Status: No, score=-9.257 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, HTML_MESSAGE=0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_BLOCKED=0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001, USER_IN_DEF_SPF_WL=-7.5] autolearn=no autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TjSNni8ZooAy for <tls@ietfa.amsl.com>; Sat, 16 Mar 2024 20:53:20 -0700 (PDT)
Received: from mail-yw1-x1132.google.com (mail-yw1-x1132.google.com [IPv6:2607:f8b0:4864:20::1132]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 43967C14F706 for <tls@ietf.org>; Sat, 16 Mar 2024 20:53:20 -0700 (PDT)
Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-60a068e26d8so37021187b3.3 for <tls@ietf.org>; Sat, 16 Mar 2024 20:53:20 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1710647599; x=1711252399; darn=ietf.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=oTEQEEAMNja0jVi7e8HypnIhLX55SSB/ku0gdjwaDGc=; b=VK8qxTB8OBmzW7dHZSH7axQTx5MLVk0qRyy02PTvunRWhn/VI21RCAB0BdJ5xbJagy QelM+7GKXrjS9fAayjVymuHVOykebTy6KjCsE6JFMDqI/IbptJkxhz9jLePjN2CYoJLM Oxb3DOFb3q7yL9oEDmoIbZN69uxCI9/dUo+es=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710647599; x=1711252399; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=oTEQEEAMNja0jVi7e8HypnIhLX55SSB/ku0gdjwaDGc=; b=kem0aQJ3XKWnVZkS1UbXDGTxOfvi3i04ZvtPXV7/9zLvse90QReYv8WBFTiCZsAglk iQbxfMxmGNYA3tISFgj7+jOw4oG2z0vUJpttXdQF/G8mkbh/++MKdMkNOmsTuv5TnEAf M81348jbKdb6y2AmjSR6qYr1EHY/+qXkU+QOrqW6il43zG485IU74mQrtzDXlMcnQv/N NYisuLc2iP1IWYvcspF3nWeQD9HTL5trUZwM7Ut4sZty6W+37VzWvocGvueKyL18emb7 MdpTI0F+Ku/3E69sGAXfTS/L9sNcqye7+hOWMSQZSoqsIu+0jwmQ+JiAGbNDO2GALLvQ Fo9Q==
X-Gm-Message-State: AOJu0YwVJpEanbl6bG/6DjFE8mGIckO4DkkGxQmh4aqXHrhrmXut13Ff coG97RC7pUYWSw2ppkzQi++4E5AhE1rqW8Sc/9lp8rXrkOBNc/SNbvLY8f29c1qSeoigg/JQToj Z5Xzzlj3w+IXqCE6grzU1xZFsUd0RZ3EyoTPO5db9Q1o9DNi8aOM=
X-Google-Smtp-Source: AGHT+IFa1r2NHxcdLqw9BlZjT0b9N8v+yDpO3evjg/XShDX+nnqR/htnMx1e2+mRb1+2WSUBlAMpNtQa6t0IyvBGjCQ=
X-Received: by 2002:a0d:eb91:0:b0:60d:6034:2da2 with SMTP id u139-20020a0deb91000000b0060d60342da2mr6611425ywe.4.1710647599081; Sat, 16 Mar 2024 20:53:19 -0700 (PDT)
MIME-Version: 1.0
References: <CACykbs2EtsmB-V0BjgYeo4GNeUSnZ1jKo6eKQMOVMwsShPaw8w@mail.gmail.com> <CAF8qwaCWVf=D+A1XkcJ5vaYjZ9PduzrakN5jEe3toHNfgQ-Txw@mail.gmail.com>
In-Reply-To: <CAF8qwaCWVf=D+A1XkcJ5vaYjZ9PduzrakN5jEe3toHNfgQ-Txw@mail.gmail.com>
From: David Benjamin <davidben@chromium.org>
Date: Sun, 17 Mar 2024 13:53:01 +1000
Message-ID: <CAF8qwaDKNDYC4G1nA1i=yMthzxVYez9U-LsQHvfDHB5eY==vRA@mail.gmail.com>
To: Jonathan Hoyland <jonathan.hoyland@gmail.com>, Yoav Nir <ynir.ietf@gmail.com>
Cc: "<tls@ietf.org>" <tls@ietf.org>
Content-Type: multipart/alternative; boundary="0000000000007b49700613d32e53"
Archived-At: <https://mailarchive.ietf.org/arch/msg/tls/n3fVEuJ5lowoL7ysYTVSefUeipA>
Subject: Re: [TLS] TLSFlags ambiguity
X-BeenThere: tls@ietf.org
X-Mailman-Version: 2.1.39
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: <https://mailarchive.ietf.org/arch/browse/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: Sun, 17 Mar 2024 03:53:24 -0000

Did this ever get resolved? I noticed that there was a draft-13 cut, but
the issue Jonathan pointed out was still there.

Looking at Section 2 again, it's actually even goofier than the original
email suggests. Section 2 first says:

> The FlagExtensions field contains 8 flags in each octet. The length of
the extension is the minimal length that allows it to encode all of the
present flags. Within each octet, the bits are packed such that the first
bit is the least significant bit and the eighth bit is the most significant.

This is LSB first. Then there's an example, which is also LSB first:

> For example, if we want to encode only flag number zero, the
FlagExtension field will be 1 octet long, that is encoded as follows:
>
>    00000001

So that's all consistent. But then the last paragraph of section 2 says:

> Note that this document does not define any particular bits for this
string. That is left to the protocol documents such as the ones in the
examples from the previous section. Such documents will have to define
which bit to set to show support, and the order of the bits within the bit
string shall be enumerated in network order: bit zero is the high-order bit
of the first octet as the flags field is transmitted.

This says it's MSB first for some reason. But this is not only
inconsistent, but also redundant with the text at the start of section 2.
It seems to me we could simply delete the redundant text and move on:

> Note that this document does not define any particular bits for this
string. That is left to the protocol documents such as the ones in the
examples from the previous section. Such documents will have to define
which bit to set to show support.

David

On Wed, Sep 27, 2023, 17:50 David Benjamin <davidben@chromium.org> wrote:

> Nice catch! I agree those don't match. I think bit zero should be the
> least-significant bit. That is, we should leave the examples as-is and then
> fix the specification text.
>
> Ordering bits MSB first doesn't make much sense. Unlike bytes, there is no
> inherent order to bits in memory, so the most natural order is the power of
> two represented by the bit. Put another way, everyone accesses bit N by
> ANDing with 1 << N and that's least-significant bits first. I can think of
> a couple systems (DER, GCM) that chose to order bits most-significant first
> and both have caused endless confusion and problems. (It's particularly bad
> for GCM which is actually representing a polynomial, but then messed up the
> order. Let's not repeat this blunder.)
>
> On Fri, Sep 15, 2023 at 1:37 PM Jonathan Hoyland <
> jonathan.hoyland@gmail.com> wrote:
>
>> Hi TLSWG,
>>
>> I'm working on implementing the TLS Flags extension
>> <https://datatracker.ietf.org/doc/html/draft-ietf-tls-tlsflags-12>, and
>> I just wanted to clarify a potential ambiguity in the spec.
>>
>> In Section 2 the spec says:
>> Such documents will have to define which bit to set to show support, and
>> the order of the bits within the bit string shall be enumerated in network
>> order: bit zero is the high-order bit of the first octet as the flags field
>> is transmitted.
>>
>> And also gives the example for encoding bit zero:
>> For example, if we want to encode only flag number zero, the
>> FlagExtension field will be 1 octet long, that is encoded as follows:
>>
>>    00000001
>>
>> In which it seems that the low-order bit of the first octet represents zero.
>>
>> I have no preference either way, but when transmitted on the wire, should flag 0 be transmitted as
>>
>> 0x01 or 0x80?
>>
>> Regards,
>>
>> Jonathan
>>
>> _______________________________________________
>> TLS mailing list
>> TLS@ietf.org
>> https://www.ietf.org/mailman/listinfo/tls
>>
>