Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Tfd6p-0004QK-LQ for bitcoin-development@lists.sourceforge.net; Mon, 03 Dec 2012 20:59:23 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of gmail.com designates 74.125.82.43 as permitted sender) client-ip=74.125.82.43; envelope-from=gavinandresen@gmail.com; helo=mail-wg0-f43.google.com; Received: from mail-wg0-f43.google.com ([74.125.82.43]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1Tfd6o-000887-Qs for bitcoin-development@lists.sourceforge.net; Mon, 03 Dec 2012 20:59:23 +0000 Received: by mail-wg0-f43.google.com with SMTP id e12so1533790wge.10 for ; Mon, 03 Dec 2012 12:59:16 -0800 (PST) MIME-Version: 1.0 Received: by 10.180.99.71 with SMTP id eo7mr628865wib.11.1354568356733; Mon, 03 Dec 2012 12:59:16 -0800 (PST) Received: by 10.194.27.136 with HTTP; Mon, 3 Dec 2012 12:59:16 -0800 (PST) In-Reply-To: References: <20121128233619.GA6368@giles.gnomon.org.uk> <20121129170713.GD6368@giles.gnomon.org.uk> <20121129185330.GE6368@giles.gnomon.org.uk> Date: Mon, 3 Dec 2012 15:59:16 -0500 Message-ID: From: Gavin Andresen To: Mike Koss Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: -1.6 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (gavinandresen[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1Tfd6o-000887-Qs Cc: Bitcoin Dev Subject: Re: [Bitcoin-development] Payment Protocol Proposal: Invoices/Payments/Receipts X-BeenThere: bitcoin-development@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Dec 2012 20:59:23 -0000 On Mon, Dec 3, 2012 at 2:35 PM, Mike Koss wrote: > Why don't we sign the text representation of a (utf8) JSON, rather than some > complex encoding standard of JSON? Because the results from standard JSON parsers are undefined if I give you an "envelope" JSON that has repeated keys. For example: { "pki_data" : "...hex-or-base64-encoded certificate chain...", "signature" : "....hex-or-base64-encoded-signature-bytes", "message" : "....string-encoded-utf8-JSON", "message" : "....another string-encoded-utf8-JSON", "signature" : "....more hex-or-base64-encoded-signature-bytes", "pki_data" : "...another certificate chain...", } The JSON spec doesn't say what you'll get when you decode that mess. Maybe the first instance of each field, maybe the last, maybe one picked at random... The JOSE (Javascript Signing and Encryption) spec says "Thou Shalt Use A JSON Parser That Treats Multi-defined-keys As An Error." I expect that most developers will be lazy and will just use whatever JSON parser is convenient, no matter how much the spec/documentation warns them not to. And that makes me nervous, because I can imagine attackers taking advantage of mismatches between (say) the JSON parsing software used by some back-end server process and a front-end JavaScript web wallet UI. -- -- Gavin Andresen