[jose] Binary encoding for JSON

Phillip Hallam-Baker <hallam@gmail.com> Tue, 11 June 2013 11:47 UTC

Return-Path: <hallam@gmail.com>
X-Original-To: jose@ietfa.amsl.com
Delivered-To: jose@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 6F15321F938E for <jose@ietfa.amsl.com>; Tue, 11 Jun 2013 04:47:25 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.386
X-Spam-Level:
X-Spam-Status: No, score=-2.386 tagged_above=-999 required=5 tests=[AWL=0.213, 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 gXP9J0PTKFdg for <jose@ietfa.amsl.com>; Tue, 11 Jun 2013 04:47:24 -0700 (PDT)
Received: from mail-wg0-x22f.google.com (mail-wg0-x22f.google.com [IPv6:2a00:1450:400c:c00::22f]) by ietfa.amsl.com (Postfix) with ESMTP id 13A2A21F91BF for <jose@ietf.org>; Tue, 11 Jun 2013 04:47:23 -0700 (PDT)
Received: by mail-wg0-f47.google.com with SMTP id l18so2338520wgh.14 for <jose@ietf.org>; Tue, 11 Jun 2013 04:47:23 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=nQV3CEncYmZF2WcbZPfAmgiHSb3ADAeaAURhMgC28NU=; b=GGZk65e6ac9k1bl5NBeoDMdDcbdxuIl+JgYadAdSS/ZW7x2stsxopfsDtFGrgrcI8v NxkXfxK3GO7GIZ0pR7/AyebwQF/JQNcYgcooGdr792u3rsxQ+CsRa1DZzfvp+UV20qSk BD1ygWzewXa8z84lGSg+SVawpvKEMZpQpj2ejhjf0t7RO8u/WR/3jsozR2skILqKdsFe o3XqHp6EOeSnGvF+6OoUygGFGqEqgZAAjmsY7ZRaJDw2maSCjj1nxwbe0qL1izVb3jEJ b3leBcO4ui3/OkEzK/Z55di/0UdYYsLlNDbEEDy+2+m2qissSnFhRGfKucSsOcrVaR0L Alww==
MIME-Version: 1.0
X-Received: by 10.194.157.2 with SMTP id wi2mr8268068wjb.77.1370951243201; Tue, 11 Jun 2013 04:47:23 -0700 (PDT)
Received: by 10.194.44.100 with HTTP; Tue, 11 Jun 2013 04:47:22 -0700 (PDT)
Date: Tue, 11 Jun 2013 07:47:22 -0400
Message-ID: <CAMm+LwjBXHK-3Lsq1o=_Hu95xyqXZTKbg0U_piiANtAWFaOF5w@mail.gmail.com>
From: Phillip Hallam-Baker <hallam@gmail.com>
To: "jose@ietf.org" <jose@ietf.org>
Content-Type: multipart/alternative; boundary="089e0122f540db0a9204dedf751a"
Subject: [jose] Binary encoding for JSON
X-BeenThere: jose@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: Javascript Object Signing and Encryption <jose.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/jose>, <mailto:jose-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/jose>
List-Post: <mailto:jose@ietf.org>
List-Help: <mailto:jose-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/jose>, <mailto:jose-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 11 Jun 2013 11:47:25 -0000

http://tools.ietf.org/html/draft-hallambaker-jsonbcd-00

The big problem I have found with using JSON for crypto is the lack of a
binary encoding for data. This means that binary blobs have to be encoded
as Base64 which is not too bad in itself except that when using nested
structures the base64 overhead expands the data by 33% each time it is
wrapped.

JSON-B is basically just a scheme that adds in a run-length encoding for
strings and binary data to JSON encoding. It is a superset of JSON and it
is very easy to adapt a JSON parser or encoder to add in support for JSON-B.

Unlike other binary encodings for JSON (BJSON etc), there is no need to
distinguish the binary form from the regular. A JSON-B decoder will accept
either form. This simplifies protocol negotiation as the only concern is
ensuring that the sender emits a form that the receiver can understand.

JSON-B also provides binary encodings for integers (including bignums up to
(2^23)  bits long) and doubles. The last being important in scientific
applications as converting to and from decimal form results in precision
loss.


There is also a JSON-C (Compact) and JSON-D (Data) defined.


The practical benefit of using this with JOSE is that it can be used to
frame the crypto data in the same way that ASN.1 is used in CMS but with
the same simplicity as using traditional JSON.


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