Re: [jose] Canonical JSON form

Anders Rundgren <> Sat, 20 October 2018 04:55 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id 23835130E30 for <>; Fri, 19 Oct 2018 21:55:36 -0700 (PDT)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -0.5
X-Spam-Status: No, score=-0.5 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SORBS_WEB=1.5, SPF_PASS=-0.001] autolearn=no autolearn_force=no
Authentication-Results: (amavisd-new); dkim=pass (2048-bit key)
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id Bfsf8QYJTlpe for <>; Fri, 19 Oct 2018 21:55:34 -0700 (PDT)
Received: from ( [IPv6:2a00:1450:4864:20::444]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by (Postfix) with ESMTPS id E84B7130E28 for <>; Fri, 19 Oct 2018 21:55:33 -0700 (PDT)
Received: by with SMTP id 61-v6so39382881wrb.6 for <>; Fri, 19 Oct 2018 21:55:33 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=zMIvBii1R1D9d1jKJwGKluNV/3Nx9XY8a8HdJ38aLAs=; b=ovkkbrVA3RLcyyT91W2McUWnk0HbyeDxpAZNmVJop6WEW+oNPeMlFBTvM3yo6xPrZF xSmP+tsp4gHYH4OMDdnYe1lNgrJohUzZ8JUKZNBKLBAaDsTtB8KNGMSqOj66sJgqkFKZ 8F3dCgkxfGUMDq5vomiACX9cLXiICsOvk+MHqxtzKsfxJo2PGfIsl4IQMW47+YiiPY31 I2Mj1blYVjrNvRHZIKZOrvhULHvm+QlH/AiTXKKpNCzrwXCbLwVBXZeifP7s82lSNK3u SpY61vKYL731ix8rhJuQAyuE1iwCLzCc8GiflBEvaEegewuyUl5rlLG0BjDV5Xhq+SWR ZVwQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=zMIvBii1R1D9d1jKJwGKluNV/3Nx9XY8a8HdJ38aLAs=; b=pgtumDDH5jkyjUoL3XNVEVOAzo96qsPm1JkgxxAguifvce/M6p2T4Zz+X6kEnmjnYM fbFoy9TNGfls446zLfiPLqmgVp5l9rNFalHH9i/W40Wu7B+SfiXpCPbq5eGUHowGxY3E qZLa6HEfhc/BnmNvsofgEY1Jj48LxwGOeg9D4CvBJ2GUeMVDmkgHW7dYK91YBS+Cr7lM aI4lyU7LcTUVPTQ3DEeFfuvCRe2m8Dj/VuvGhFwhPomoOIUe4sLAqoE+16xfpnCVcOIF 7bj7ZRWfjvxPp807icx+ZdIW+M+HR59tFVsNTuZcb3aSn0NsBUVwsTiLGASFs1nijsX3 JAug==
X-Gm-Message-State: ABuFfogjf0Bk7Ud5wZR1/mrwRgKj5YW3gzPioezm5iZHzMYLoxo/WPkU uk4YGE3wntlNJf4JaE8ZtTo0KD74
X-Google-Smtp-Source: ACcGV60Egx2TV2o/oogcUteECGhuaceL3S3xk4Qbmdse6+b2GRS2zbsNZwOPr0yDEKsfcjFRpdxnrg==
X-Received: by 2002:adf:9e09:: with SMTP id u9-v6mr35411898wre.51.1540011331635; Fri, 19 Oct 2018 21:55:31 -0700 (PDT)
Received: from [] ( []) by with ESMTPSA id y41-v6sm6132879wrd.25.2018. (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Oct 2018 21:55:29 -0700 (PDT)
To: Bret Jordan <>
Cc: Carsten Bormann <>, Phil Hunt <>, Kathleen Moriarty <>, "Manger, James" <>,
References: <> <> <> <00ad01d460f4$69ae8a00$3d0b9e00$> <> <> <> <> <> <> <> <> <> <> <> <> <>
From: Anders Rundgren <>
Message-ID: <>
Date: Sat, 20 Oct 2018 06:55:26 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1
MIME-Version: 1.0
In-Reply-To: <>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
Archived-At: <>
Subject: Re: [jose] Canonical JSON form
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Javascript Object Signing and Encryption <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-Subscribe: <>, <>
X-List-Received-Date: Sat, 20 Oct 2018 04:55:36 -0000

On 2018-10-12 23:31, Bret Jordan wrote:
> Anders,
> How do we move forward?  What can we do to make this happen?

As you can see from the responses, there is considerable resistance and skepticism against this work.
I guess even fewer have bothered reading the actual I-D.

Personally I don't care that much since the JSON based systems I work with have up to 5 layers of signatures which doesn't translate well to the current JOSE standards.

Maybe the other editors of (which builds on a flavor of Canonical JSON) have an idea?

There is also a (very active) W3C community group working with a similar concept so clear-text signatures based on JSON canonicalization will probably reach the market regardless of IETF's position on the matter:

The 1 million of random and "edge" JSON Numbers used for testing the devised JSON canonicalization scheme, uncovered flaws in other systems as well...


> Thanks,
> Bret
> PGP Fingerprint: 63B4 FC53 680A 6B7D 1447  F2C0 74F8 ACAE 7415 0050
> "Without cryptography vihv vivc ce xhrnrw, however, the only thing that can not be unscrambled is an egg."
>> On Oct 12, 2018, at 10:47 AM, Anders Rundgren < <>> wrote:
>> On 2018-10-12 17:20, Bret Jordan wrote:
>>> Please correct me if I am wrong…. The way I understand the problem is as follows:
>> Hi Bret,
>> Comments in line...
>>> 1) If you verified the JSON string at consumption time, before it has been unmarshal-ed, then all you need to do is decide how to handle white space and carriage returns.  You could basically regex remove all white space and CR / CRLF and have a workable solution.
>> It depends on what your goal is.  Canonicalization builds on the assumption that there is a unique representation of the data, preferably even after it has passed through a processor like an intermediary.
>>> 2) Where this breaks down is, when a tool unmarshals the data into a map or struct, then you have no guarantee that you would recreate the keys in the same order (a struct may force it to the order of the struct definition). So you have no way of being able to verify the hash after it has been unmarshal-ed.  Further, if you recreate the JSON and send it back out, the next person that gets the data might have a hash that can not be verified in option 1 above.
>> Right, therefore option 1 is not very useful.  Sorting of keys is the cure for this issue.
>>> 3) Another problem once you have unmarshal-ed the data is what do you do with JSON numbers.
>> Right, but even string data needs adjustments.  "\u0020" and " " both represents a space character.
>>> Some programming languages store them as a float, some as who-knows-what.  So you would need a way to ensure that the number was always stored in the same way, especially for strongly typed systems (is this architecture dependent too?). So the options here are, if the ontology / semantics of the JSON data were well defined in schema (a meaning it was standardized and documented), then the code could know what it should do and interoperability tests could be made to ensure that it worked.
>> This is (IMO) the only part of the puzzle that is non-trivial.  In my take on the matter, I have "prescribed" that the JSON Number type must be coerced into an IEEE 754 double precision number and be serialized according to ECMAScript V6+ rules.
>> If your application needs higher precision or bigger range, you are forced using the quoted string notation which (AFAIK...) is used by every IETF standard of any significance to date defining a JSON structure.
>>> What am I not understanding here?  And what am I missing?
>> As I wrote earlier, there are (at least) two entirely different and documented approaches.
>> Using a schema based canonicalizer as you mention is also an option but that is a much more ambitious project.
>> Regards,
>> Anders
>>> Thanks,
>>> Bret
>>> PGP Fingerprint: 63B4 FC53 680A 6B7D 1447  F2C0 74F8 ACAE 7415 0050
>>> "Without cryptography vihv vivc ce xhrnrw, however, the only thing that can not be unscrambled is an egg."
>>>> On Oct 12, 2018, at 12:38 AM, Anders Rundgren < <> <>> wrote:
>>>> On 2018-10-11 22:05, Bret Jordan wrote:
>>>>> Anders,
>>>>> I really like what you have done with this.  I am trying to figure out if it will work 100% for my needs, or if it will need some tweaking.  If it does work, then I think we should really try and figure out how we get your work standardized.
>>>> Thanx Bret!
>>>> The I-D provides quite a lot of features including an extension option that can be used for adding possibly missing functionality.
>>>> There is one thing that is good to know for anyone thinking about standardizing Canonical JSON and that's the fact that canonicalization also can be performed on the text level as described by:
>>>> This has the advantage that it is very simple and supports the entire JSON RFC without restrictions.
>>>> So why didn't I took this [superficially obvious] route? There are several reasons for that:
>>>> A downside of source level canonicalization is that it doesn't integrate with JSON parsers and serializers. was explicitly designed to eventually be an option of a standard JSON serializer as it already is in my Java reference implementation.
>>>> Another issue is that it is unclear what the value is with using the JSON "Number" format outside of the IEEE range.  In fact, it excludes parsers like JavaScript's JSON.parse() unless JavaScaript would be updated to always use a "BigNumber" as fundamental numeric type.
>>>> Regards,
>>>> Anders