Re: [Json] [secdir] secdir review of draft-ietf-jsonbis-rfc7159bis-03

Nico Williams <nico@cryptonector.com> Mon, 13 March 2017 18:15 UTC

Return-Path: <nico@cryptonector.com>
X-Original-To: json@ietfa.amsl.com
Delivered-To: json@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id E92D71299C0; Mon, 13 Mar 2017 11:15:39 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.501
X-Spam-Level:
X-Spam-Status: No, score=-1.501 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_SORBS_SPAM=0.5] autolearn=no autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=cryptonector.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 ussgnInrpS35; Mon, 13 Mar 2017 11:15:39 -0700 (PDT)
Received: from homiemail-a72.g.dreamhost.com (sub4.mail.dreamhost.com [69.163.253.135]) (using TLSv1.1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 57C891299B5; Mon, 13 Mar 2017 11:15:39 -0700 (PDT)
Received: from homiemail-a72.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a72.g.dreamhost.com (Postfix) with ESMTP id DE498A04E8C1; Mon, 13 Mar 2017 11:15:38 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=cryptonector.com; h=date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=cryptonector.com; bh=7GhDPymm6L2zak 9IaA5N6WJc+Qc=; b=jB4Jyp+tWcRj2Fh7/yBUtOOCEbjlAkS9QujnRvCAIH4YGK 1CLMWElg6YQ+5GvSJJyLTjmUmjMPu0g356Z/MRzDFvshdiG0wZCbI7B1jqr2PZ1N iKOmKhfyiVgOcBgBI4n5RtnhWsHBbNY8vdT2ZiNQpyCyQY/oKKP60mEJmRyK0=
Received: from localhost (cpe-70-123-158-140.austin.res.rr.com [70.123.158.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: nico@cryptonector.com) by homiemail-a72.g.dreamhost.com (Postfix) with ESMTPSA id E4346A04E8C3; Mon, 13 Mar 2017 11:15:37 -0700 (PDT)
Date: Mon, 13 Mar 2017 13:15:34 -0500
From: Nico Williams <nico@cryptonector.com>
To: Julian Reschke <julian.reschke@gmx.de>
Message-ID: <20170313181534.GD543@localhost>
References: <382aa5c8-c977-b24d-4d19-251257833b00@gmx.de> <456b4234-0d94-1033-507c-710878bb5159@gmx.de> <20170309055348.GL30306@kduck.kaduk.org> <CAD2gp_TOxcZJxwPoMhq-xp6M+Yq+tQnMUv81YNFp-ydRMpH=5w@mail.gmail.com> <bed0e331-f5fb-f24d-6207-f5a36ec9e7be@gmx.de> <01QBU8WJOCUO0003XB@mauve.mrochek.com> <6d97dee7-7cf3-9142-aacf-f2ca4909103d@codalogic.com> <cbbd0224-da58-bac5-b751-4195dd7383dc@gmx.de> <38DEEE0A-EE2C-4ADA-9D7A-9DBBAEACB77E@tzi.org> <b9908499-a24d-5a6c-b22e-9f2c0cfaa4a5@gmx.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <b9908499-a24d-5a6c-b22e-9f2c0cfaa4a5@gmx.de>
User-Agent: Mutt/1.5.24 (2015-08-30)
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/Wfd8vhIaR-0_Qauo65EVPRyXMvU>
Cc: draft-ietf-jsonbis-rfc7159bis.all@ietf.org, John Cowan <cowan@ccil.org>, Ned Freed <ned.freed@mrochek.com>, IETF <ietf@ietf.org>, Peter Cordell <petejson@codalogic.com>, secdir@ietf.org, "json@ietf.org" <json@ietf.org>, Carsten Bormann <cabo@tzi.org>
Subject: Re: [Json] [secdir] secdir review of draft-ietf-jsonbis-rfc7159bis-03
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.17
Precedence: list
List-Id: "JavaScript Object Notation \(JSON\) WG mailing list" <json.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/json>, <mailto:json-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/json/>
List-Post: <mailto:json@ietf.org>
List-Help: <mailto:json-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/json>, <mailto:json-request@ietf.org?subject=subscribe>
X-List-Received-Date: Mon, 13 Mar 2017 18:15:40 -0000

On Mon, Mar 13, 2017 at 09:14:16AM +0100, Julian Reschke wrote:
> So the changes in RFC 7159 allow top-level strings, so we can't rely on the
> first *two* characters being US-ASCII. But we *can* rely on the first one
> being US-ASCII, no?

Correct.

If one OR two bytes of the first four are NULs, then the encoding is
UTF-16 (or something else or invalid):

> So the following should still be correct:
> 
> >   Since the first character of a JSON text will always be an ASCII
> >   character [RFC0020], it is possible to determine whether an octet
> >   stream is UTF-8, UTF-16 (BE or LE), or UTF-32 (BE or LE) by looking
> >   at the pattern of nulls in the first four octets.
> >
> >           00 00 00 xx  UTF-32BE
> >           00 xx xx xx  UTF-16BE
> >           xx 00 00 00  UTF-32LE
> >           xx 00 xx xx  UTF-16LE
> >           xx xx xx xx  UTF-8

Count the number of NULs in the first four bytes:

 - if zero -> UTF-8
 - if one or two -> UTF-16
 - if three -> UTF-32

Nico
--