Re: [TLS] TLSFlags ambiguity

"StJohns, Michael" <msj@nthpermutation.com> Sun, 17 March 2024 11:15 UTC

Return-Path: <msj@nthpermutation.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 B5204C151075 for <tls@ietfa.amsl.com>; Sun, 17 Mar 2024 04:15:50 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.903
X-Spam-Level:
X-Spam-Status: No, score=-1.903 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_NONE=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] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=nthpermutation-com.20230601.gappssmtp.com
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 tfVVmKo7Dzrr for <tls@ietfa.amsl.com>; Sun, 17 Mar 2024 04:15:46 -0700 (PDT)
Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) (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 CFC13C14F69F for <tls@ietf.org>; Sun, 17 Mar 2024 04:15:46 -0700 (PDT)
Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-5689ebef670so4013541a12.1 for <tls@ietf.org>; Sun, 17 Mar 2024 04:15:46 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nthpermutation-com.20230601.gappssmtp.com; s=20230601; t=1710674145; x=1711278945; 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=B2DdmhcR7mPa24Sx0X/A4lKbDEKSBVkHa7oPqzcdpW0=; b=ovgjpC58yfyMJEer6aT1p6G+66e9KjkC1/z6QElBWmKHy5ZB6L4R+HPs7Q3gfmBGJ+ 2MbSmpBgmL0rnz8H1Epkin6mIgOpyedfD1pyskdrfKZ5mE1q0q+SxqE2st4C1Jy2uvLy dQobXklrm4lCv+MYsJOy5LjLyd+2jawh44FBaYLSHX5UkD31TnpfTAs2u110f+DRfEpO SNDqXY/CbFM5qhrHAc/WC97CVPzR1ngFiod16AOTpTa+EkjSmE4P6Olk1xeuloejpNxF 0WZudIBOK46pzA5cV7rX9E3uiNA+dEQihzE/bDZcxjX/QZYW8vkFJvw0ByNtHnIEZoid j62Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710674145; x=1711278945; 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=B2DdmhcR7mPa24Sx0X/A4lKbDEKSBVkHa7oPqzcdpW0=; b=WvVoydwl5PtIpCS61CC5+oKQMM5t5YnBFFrJ9cgeoOE6U5ufsEpz6EXIibyRdLoOFG Aec77W3EYdFhxZ4IQdiimLzVXqT1kAskSANDMtsjF40CaqFrNlahk3X1ogdkpH9wRwq4 6lvsC2A7lMnRtnzdjiXF2sNt77ACpTdvoIXeXYfSqUZhzmg3CqvuXtGsx31zdN0KpHcJ n7a2t+QOzA7Q8iR1bAKXqOVWSe0OmjyAMgdNuW23eWtul/7PXr0kJh50V2DOd4KDPymx /WXYx+0rX9q0FeVYcx8fb9RRudz/aslqcyjoz8B0FdmfbEPL5CTeVNOY7uo1htAgO1eo efHw==
X-Gm-Message-State: AOJu0YyJE0prSsgZpQK/jNDp7kgWubbyggfUq+uSDirHd++FtaMBcfOX yA0+EttVlXE26koKI+u4RlO98+tVp9p7jAdOrDknMdsS66FDArDPSkRtg7vN0vL18zQdUzg4VWD v1DppdYD5/k04YYjHMwgWf3VU61CzrV5am2miAQ==
X-Google-Smtp-Source: AGHT+IEHZgl/psAJuMgvufob9Ck1iG2Ds/Pi+HeNPs4g1DszFhkMzPgGWbXoRqBVmyqXmuuoX/vEdA8rxaTpxULyGZo=
X-Received: by 2002:a05:6402:378f:b0:567:6a67:664e with SMTP id et15-20020a056402378f00b005676a67664emr6277083edb.34.1710674144882; Sun, 17 Mar 2024 04:15:44 -0700 (PDT)
MIME-Version: 1.0
References: <CACykbs2EtsmB-V0BjgYeo4GNeUSnZ1jKo6eKQMOVMwsShPaw8w@mail.gmail.com> <CAF8qwaCWVf=D+A1XkcJ5vaYjZ9PduzrakN5jEe3toHNfgQ-Txw@mail.gmail.com> <CAF8qwaDKNDYC4G1nA1i=yMthzxVYez9U-LsQHvfDHB5eY==vRA@mail.gmail.com>
In-Reply-To: <CAF8qwaDKNDYC4G1nA1i=yMthzxVYez9U-LsQHvfDHB5eY==vRA@mail.gmail.com>
From: "StJohns, Michael" <msj@nthpermutation.com>
Date: Sun, 17 Mar 2024 21:15:32 +1000
Message-ID: <CANeU+ZBN1AcQryHtGffmWBD=gOyMhHtyyNvD2j2UOVGv=D=vbQ@mail.gmail.com>
To: David Benjamin <davidben@chromium.org>
Cc: "<tls@ietf.org>" <tls@ietf.org>, Jonathan Hoyland <jonathan.hoyland@gmail.com>, Yoav Nir <ynir.ietf@gmail.com>
Content-Type: multipart/alternative; boundary="000000000000bb8bad0613d95cc9"
Archived-At: <https://mailarchive.ietf.org/arch/msg/tls/OzPsCH48RtW_KbUgSZ1lKn4NxaA>
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 11:15:50 -0000

Please see RFC 1700, the section on data notation.  The most significant
bit in a byte /octet or word is always bit 0.  A collection of bytes
representing a set of bits should number from 0 or 0x80 hex as a mask for
the first byte.

While 1700 was obsoleted by the protocol registries, I believe this data
notation remains the standard approach for numbering.


Best to ask the IANA about this rather than writing something that breaks
things.  They will be responsible for managing the profile registry for the
flags.


Later, Mike


On Sun, Mar 17, 2024 at 13:53 David Benjamin <davidben@chromium.org> wrote:

> 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
>>>
>> _______________________________________________
> TLS mailing list
> TLS@ietf.org
> https://www.ietf.org/mailman/listinfo/tls
>