Re: [apps-discuss] CBOR: convert CBOR bignum to base64url JSON string

Phillip Hallam-Baker <hallam@gmail.com> Fri, 24 May 2013 11:59 UTC

Return-Path: <hallam@gmail.com>
X-Original-To: apps-discuss@ietfa.amsl.com
Delivered-To: apps-discuss@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id C077521F940B for <apps-discuss@ietfa.amsl.com>; Fri, 24 May 2013 04:59:35 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.599
X-Spam-Level:
X-Spam-Status: No, score=-2.599 tagged_above=-999 required=5 tests=[BAYES_00=-2.599, HTML_MESSAGE=0.001, NO_RELAYS=-0.001]
Received: from mail.ietf.org ([12.22.58.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id O4kbT9yCpUeP for <apps-discuss@ietfa.amsl.com>; Fri, 24 May 2013 04:59:34 -0700 (PDT)
Received: from mail-la0-x233.google.com (mail-la0-x233.google.com [IPv6:2a00:1450:4010:c03::233]) by ietfa.amsl.com (Postfix) with ESMTP id 0239121F938E for <apps-discuss@ietf.org>; Fri, 24 May 2013 04:59:33 -0700 (PDT)
Received: by mail-la0-f51.google.com with SMTP id lx15so4385277lab.38 for <apps-discuss@ietf.org>; Fri, 24 May 2013 04:59:32 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=tdl/hLFWc7ZGJHNj6YxBfz7f1STWrcp0SzD/nesSZuo=; b=EjyR15tsnpeT7n8YgKqHvSijCkifJam+WlctqU5NhPp5aVy2Ekm25tq+O09+k8xt7A ErTBt+GtnxfescgrB4h0oYnBF1nb5u+csyNLQ/lduX0cAu405hOh1whOqH5LC8lpjkwu JIjBFAwOb7tQBJCpwXkcZhvL7UT9IgmtROo13DCQmmvjVK0NpKMMzzD4vXVznwXeC0BP Lu0C1ItpGmkodPXNWDJRjPM8EqxVP9Kzw+9tdJxhD7Bt66nZZpGkqMAXtiTEYVLnoo6Y rs9/chlsUsc6i1Q/SpLCDay7C6NpzoLZPvrpOtMKf3G7nvmtjHiTzwLk9jOeSktFmWXy 5FZQ==
MIME-Version: 1.0
X-Received: by 10.112.73.135 with SMTP id l7mr8804451lbv.42.1369396772862; Fri, 24 May 2013 04:59:32 -0700 (PDT)
Received: by 10.112.200.169 with HTTP; Fri, 24 May 2013 04:59:32 -0700 (PDT)
In-Reply-To: <F04007CB-D23F-4547-BCC4-3ED5A7F141E1@tzi.org>
References: <255B9BB34FB7D647A506DC292726F6E1151A9721A1@WSMSG3153V.srv.dir.telstra.com> <F04007CB-D23F-4547-BCC4-3ED5A7F141E1@tzi.org>
Date: Fri, 24 May 2013 07:59:32 -0400
Message-ID: <CAMm+Lwih46xeRBLkpHKJyZGCWQN5D_M3eoitQ788zJYd=CQs-A@mail.gmail.com>
From: Phillip Hallam-Baker <hallam@gmail.com>
To: Carsten Bormann <cabo@tzi.org>
Content-Type: multipart/alternative; boundary="14dae93d8eac3402c704dd75889d"
Cc: Paul Hoffman <paul.hoffman@vpnc.org>, "apps-discuss@ietf.org Discuss" <apps-discuss@ietf.org>
Subject: Re: [apps-discuss] CBOR: convert CBOR bignum to base64url JSON string
X-BeenThere: apps-discuss@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: General discussion of application-layer protocols <apps-discuss.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/apps-discuss>, <mailto:apps-discuss-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/apps-discuss>
List-Post: <mailto:apps-discuss@ietf.org>
List-Help: <mailto:apps-discuss-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/apps-discuss>, <mailto:apps-discuss-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 24 May 2013 11:59:35 -0000

On Fri, May 24, 2013 at 2:15 AM, Carsten Bormann <cabo@tzi.org> wrote:

> On May 24, 2013, at 02:33, "Manger, James H" <
> James.H.Manger@team.telstra.com> wrote:
>
> > A minor (non-controversial?) suggested change for draft-bormann-cbor:
> >
> > Section 4.1. "Converting From CBOR to JSON" 11th dot point says:
> >
> >  o  A bignum (major type 7, tag value 8 or 9) becomes a JSON number.
> >
> > This might be right in theory, but I don't think it is in practice.
> > Presumably a bignum was used because the value (or other expected value
> for the same field) is too large for normal (32-bit, 64-bit) number types,
> which are the types many implementations use represent a JSON number. Hence
> they will fail with a bignum.
>
> That is a very good point.
> I haven't done a survey of JSON implementations how they handle large
> numbers that look like integers.
> Of those for platforms that don't have bignums, I would expect many of
> them to create a double-precision float for large numbers.
> This doesn't fail, but loses precision.


Trying to do public key crypt afterwards is not going to work very well.

Other than Mathematica, I really cant think of any platform I would expect
to be able to start reading an integer and realize that it needs to be
treated as a bignum when it goes over 64 bits.

Like many parts of the JSON syntax that is something that the specification
demands but implementations are likely to vary on.


The idea that JSON can never change by an iota seems rather silly. The
specification is not really complete. Where difficult parts come up they
are ignored and so we don't know how implementations are expected to behave
for overflow or for NaN values.

Addressing such concerns is precisely what is expected when a spec enters
IETF process.


What are JSON parsers expected to do when they come across a token litteral
they don't understand?




> > I suggest converting a bignum to a base64url encoding (without padding)
> in a JSON string. This is what you get if the positive bignum tag was
> ignored and you just processed the byte string that followed. For a
> negative bignum stick "-" before the base64url encoding.
>
> That is certainly good advice if the bignum was, say, a value from an
> ECDSA signature, where losing precision destroys the utility.
> Less so if it was the US national debt (well, for a few more weeks, that
> will still fit in a 64-bit number :-).
>

If you then try to maintain the result by adding a hundred dollars every X
milliseconds then the count is never going to increase and you will #fail.

Hey, we have just found the way to fix the national debt...



-- 
Website: http://hallambaker.com/