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

"Manger, James H" <James.H.Manger@team.telstra.com> Fri, 24 May 2013 00:33 UTC

Return-Path: <James.H.Manger@team.telstra.com>
X-Original-To: apps-discuss@ietfa.amsl.com
Delivered-To: apps-discuss@ietfa.amsl.com
Received: from localhost (localhost []) by ietfa.amsl.com (Postfix) with ESMTP id 9F9A921F9017 for <apps-discuss@ietfa.amsl.com>; Thu, 23 May 2013 17:33:24 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.531
X-Spam-Status: No, score=-0.531 tagged_above=-999 required=5 tests=[AWL=0.370, BAYES_00=-2.599, HELO_EQ_AU=0.377, HOST_EQ_AU=0.327, RELAY_IS_203=0.994]
Received: from mail.ietf.org ([]) by localhost (ietfa.amsl.com []) (amavisd-new, port 10024) with ESMTP id KUtsBkw9hxOR for <apps-discuss@ietfa.amsl.com>; Thu, 23 May 2013 17:33:18 -0700 (PDT)
Received: from ipxcno.tcif.telstra.com.au (ipxcno.tcif.telstra.com.au []) by ietfa.amsl.com (Postfix) with ESMTP id 1A6A821F9019 for <apps-discuss@ietf.org>; Thu, 23 May 2013 17:33:16 -0700 (PDT)
X-IronPort-AV: E=Sophos;i="4.87,730,1363093200"; d="scan'208";a="131840555"
Received: from unknown (HELO ipccni.tcif.telstra.com.au) ([]) by ipocni.tcif.telstra.com.au with ESMTP; 24 May 2013 10:33:15 +1000
X-IronPort-AV: E=McAfee;i="5400,1158,7084"; a="139007974"
Received: from wsmsg3705.srv.dir.telstra.com ([]) by ipccni.tcif.telstra.com.au with ESMTP; 24 May 2013 10:33:15 +1000
Received: from WSMSG3153V.srv.dir.telstra.com ([]) by WSMSG3705.srv.dir.telstra.com ([]) with mapi; Fri, 24 May 2013 10:33:14 +1000
From: "Manger, James H" <James.H.Manger@team.telstra.com>
To: Paul Hoffman <paul.hoffman@vpnc.org>, Carsten Bormann <cabo@tzi.org>
Date: Fri, 24 May 2013 10:33:13 +1000
Thread-Topic: CBOR: convert CBOR bignum to base64url JSON string
Thread-Index: Ac5YFkaG6fHGfOprStm77b2/e5M1FQ==
Message-ID: <255B9BB34FB7D647A506DC292726F6E1151A9721A1@WSMSG3153V.srv.dir.telstra.com>
Accept-Language: en-US, en-AU
Content-Language: en-US
acceptlanguage: en-US, en-AU
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
MIME-Version: 1.0
Cc: "apps-discuss@ietf.org Discuss" <apps-discuss@ietf.org>
Subject: [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 00:33:24 -0000

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.

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.

James Manger