Re: [TLS] Length of a variable-length vector: Could it be an odd multiple?

=JeffH <Jeff.Hodges@KingsMountain.com> Fri, 22 January 2016 21:27 UTC

Return-Path: <Jeff.Hodges@kingsmountain.com>
X-Original-To: tls@ietfa.amsl.com
Delivered-To: tls@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 9E41E1A8952 for <tls@ietfa.amsl.com>; Fri, 22 Jan 2016 13:27:18 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -101.667
X-Spam-Level:
X-Spam-Status: No, score=-101.667 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, IP_NOT_FRIENDLY=0.334, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=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 p-X--KgtOd3l for <tls@ietfa.amsl.com>; Fri, 22 Jan 2016 13:27:17 -0800 (PST)
Received: from gproxy4-pub.mail.unifiedlayer.com (gproxy4-pub.mail.unifiedlayer.com [69.89.23.142]) by ietfa.amsl.com (Postfix) with SMTP id 695041A8951 for <tls@ietf.org>; Fri, 22 Jan 2016 13:27:17 -0800 (PST)
Received: (qmail 5767 invoked by uid 0); 22 Jan 2016 21:27:15 -0000
Received: from unknown (HELO cmgw3) (10.0.90.84) by gproxy4.mail.unifiedlayer.com with SMTP; 22 Jan 2016 21:27:15 -0000
Received: from box514.bluehost.com ([74.220.219.114]) by cmgw3 with id 9GSw1s0082UhLwi01GSzJk; Fri, 22 Jan 2016 21:27:12 -0700
X-Authority-Analysis: v=2.1 cv=bej4Do/B c=1 sm=1 tr=0 a=9W6Fsu4pMcyimqnCr1W0/w==:117 a=9W6Fsu4pMcyimqnCr1W0/w==:17 a=cNaOj0WVAAAA:8 a=f5113yIGAAAA:8 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=ieNpE_y6AAAA:8 a=IkcTkHD0fZMA:10 a=XYUc-DgfXtMA:10 a=-GPFTR9Xtg4A:10 a=7aQ_Q-yQQ-AA:10 a=X7Ea-ya5AAAA:8 a=woDKzmowUs0age1bP1AA:9 a=17N5ha09fH-CXec6:21 a=LTotrk_9ZNbJbNYh:21 a=QEXdDO2ut3YA:10
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kingsmountain.com; s=default; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:Cc:To:References:Subject; bh=0zXjqIBZJPR9DIJ1bdMTSke5XItlncFNmYqZSsKsCFk=; b=5ZIfkSpbmSgqZh9DU5wYmRSBfckVV90QbXxx62zF0LwCcugDyb33AATDEpnS2p4dpSezG7jEVl/ZO6gzYgk7gREGeCgFaNWZEnkWKvL4hXh3vmRtcSxQD58aSg/9GEcG;
Received: from [73.202.80.238] (port=47569 helo=[192.168.11.22]) by box514.bluehost.com with esmtpsa (TLSv1.2:DHE-RSA-AES128-SHA:128) (Exim 4.84) (envelope-from <Jeff.Hodges@KingsMountain.com>) id 1aMjEQ-0002Q9-LW; Fri, 22 Jan 2016 14:26:58 -0700
References: <56A2912F.6040100@KingsMountain.com>
To: Benjamin Kaduk <bkaduk@akamai.com>
From: =JeffH <Jeff.Hodges@KingsMountain.com>
Message-ID: <56A29E9D.9030305@KingsMountain.com>
Date: Fri, 22 Jan 2016 13:26:53 -0800
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1
MIME-Version: 1.0
In-Reply-To: <56A2912F.6040100@KingsMountain.com>
Content-Type: text/plain; charset="utf-8"; format="flowed"
Content-Transfer-Encoding: 7bit
X-Identified-User: {11025:box514.bluehost.com:kingsmou:kingsmountain.com} {sentby:smtp auth 73.202.80.238 authed with jeff.hodges+kingsmountain.com}
Archived-At: <http://mailarchive.ietf.org/arch/msg/tls/5_tQ9BDP2BHXtmCEVCP0h5c7_TY>
Cc: IETF TLS WG <tls@ietf.org>
Subject: Re: [TLS] Length of a variable-length vector: Could it be an odd multiple?
X-BeenThere: tls@ietf.org
X-Mailman-Version: 2.1.15
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: Fri, 22 Jan 2016 21:27:18 -0000

On 01/22/2016 12:29 PM, =JeffH wrote:
> [ fixed pitch font advised here ]

the below is corrected to use "byte count" rather than "index" or "indicies" 
(and to ditch the tabs)..


 > On 01/22/2016 09:42 AM, =JeffH wrote:
 > > [ resending from different account - my work addr ends up in spam
 > > bucket for many it seems ]
 > >
 > > On 1/20/16, 11:01 AM, "Benjamin Kaduk" <bkaduk@akamai.com> wrote:
 > > >On 01/20/2016 12:47 PM, Hodges, Jeff wrote:
 > > >> On 1/13/16, 12:53 PM, "Benjamin Kaduk" <bkaduk@akamai.com> wrote:
 > > >>> On 01/13/2016 02:44 PM, Jong-Shian Wu wrote:
 > > >>>> I have a question about the even-vs-odd restrictions on the
 > > length of
 > > >>>> a valid variable-length vector defined in TLS specification after
 > > >>>> reading the section 4.3 of RFC 5246 [1] which states that:
 > > >>>> "The length of an encoded vector must be an even multiple of the
 > > >>>>length
 > > >>>> of a single element (for example, a 17-byte vector of uint16
 > > would be
 > > >>>> illegal)."
 > > >>>>
 > > >>> It means "whole-number" as opposed to fractional, i.e., there should
 > > >>>not
 > > >>> be unused "junk bytes" at the end.
 > > >> In case it's helpful, here's a suggested re-write of that quoted
 > > >>sentence
 > > >> above..
 > > >>
 > > >>   The length of an encoded variable-length vector must be an
 > > >>   exact multiple of the length of a single element. For example,
 > > >>   an encoded 17-byte vector of uint16 would be illegal, and an
 > > >>   encoded variable-length vector of four 32 byte elements,
 > > >>   having a ceiling of 2^16-1, will be 130 bytes long overall
 > > >>   (2 byte length field followed by 128 bytes of data).
 > > >
 > > >Wouldn't the ceiling more properly be 2^16-4 in that case?
 > >
 > > hm, I'm not sure -- what would be the rationale?  The exact multiple
 > > criteria?  but 2^16 / 32 = 2048  while  (2^16-4) / 32 = 2047.875
 >
 > Ah, I seem to have conflated bits and bytes due to reading too quickly
 > and should have said (2^16-32), as Ilari alluded to with "or rounding
 > thereof to integral multiple of
 > elements".

hm, but in this case it seems that a variable-length vector declared with a 
length range of <0..2^16-1> would exactly accommodate up to 2048 32-byte 
elements..

   opaque     Foo[32] ;

   Foo        fooSequence<0..2^16-1>; /* will accommodate up to 2048
                                         Foo instances */

..because it has a zero-based byte count, as in this example..


   opaque Array<0..2^2-1> ;  /* should accommodate
                                2^2 = 4  1-byte elements */

   /*
   Array with 4
   elements in memory:  [ xx xx xx xx ]
   byte count (hex):       0  1  2  3        3 = 2^2-1

   byte count (binary):   00 01 10 11

   */


..yes?  or am I missing something?


thanks,

=JeffH