<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Feb 17, 2014 at 4:03 PM, Tony Arcieri <span dir="ltr"><<a href="mailto:bascule@gmail.com" target="_blank">bascule@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">If you're interested in this sort of thing, you should have a look at JSON Web Encryption:<div><br></div>
<div><a href="http://tools.ietf.org/html/draft-ietf-jose-json-web-encryption-21" target="_blank">http://tools.ietf.org/html/draft-ietf-jose-json-web-encryption-21</a><br>

</div><div><br></div><div>...although I can't say I'm really a fan. It seems ugly to me.</div></div></blockquote><div><br></div><div>On second thoughts, maybe I should explain why signature in a text based encoding up being ugly. The encryption is just some gratuitous BASE64. Its the signature that is a problem.</div>
</div><div><br></div><div>The problem is that when you have a signature you have to know exactly what is in the signature scope. If the scope is out by one byte then verification will fail. Text based encodings invariably end up with added or subtracted whitespace being possible. This results in two approaches:</div>
<div><br></div><div>1) Convert the data to binary blobs with Base64.</div><div><br></div><div>2) Convert the text to canonical form</div><div><br></div><div>The second is only possible if you have a data model underlying everything which of course JSON does not have. Well not a model that could be considered canonicalizable. Which pushes us to the first approach.</div>
<div><br></div><div><br></div><div>Its not that jwe or jws are baddly designed, they are just having to solve an ugly problem.</div><div><br></div><div>One simple solution to this is to say that the authentication info is actually metadata and this belongs outside the signed object itself. So instead of trying to cram the signature into the application/json content of a web service request, put it in the HTTP header.</div>
<div><br></div>-- <br>Website: <a href="http://hallambaker.com/">http://hallambaker.com/</a><br>
</div></div>