Return-Path: <naitiks@gmail.com>
X-Original-To: oauth@core3.amsl.com
Delivered-To: oauth@core3.amsl.com
Received: from localhost (localhost [127.0.0.1]) by core3.amsl.com (Postfix)
 with ESMTP id 187363A6811 for <oauth@core3.amsl.com>;
 Sat,  3 Jul 2010 09:13:50 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.744
X-Spam-Level: 
X-Spam-Status: No, score=-1.744 tagged_above=-999 required=5 tests=[AWL=0.232,
 BAYES_00=-2.599, FM_FORGED_GMAIL=0.622, HTML_MESSAGE=0.001]
Received: from mail.ietf.org ([64.170.98.32]) by localhost (core3.amsl.com
 [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pjG9iEoNyxr4 for
 <oauth@core3.amsl.com>; Sat,  3 Jul 2010 09:13:48 -0700 (PDT)
Received: from mail-iw0-f172.google.com (mail-iw0-f172.google.com
 [209.85.214.172]) by core3.amsl.com (Postfix) with ESMTP id AF7A33A67D0 for
 <oauth@ietf.org>; Sat,  3 Jul 2010 09:13:47 -0700 (PDT)
Received: by iwn10 with SMTP id 10so1971870iwn.31 for <oauth@ietf.org>;
 Sat, 03 Jul 2010 09:14:00 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
 h=domainkey-signature:received:mime-version:sender:received
 :in-reply-to:references:from:date:x-google-sender-auth:message-id
 :subject:to:cc:content-type; bh=s5R0W3Gd2dFL8v8s6+xXepQPQlAWbx+iKR/6axysYGc=;
 b=c62knHDgl7UdwLdIo8o2QLlpcOpR2a2A3OsJ0TauauE6WoJ+/u2EAgO8zGuAl+UgdG
 HTlEzan8MECa+PS22mIsWhoazPoP3GKusxkJ+0P/ZQN7lNGv3z+uKpejDAV6wGWIE5QI
 PRb0vDIRbVr5BP/OHnK4Vjjw/Jmq9xKKJoRT4=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
 h=mime-version:sender:in-reply-to:references:from:date
 :x-google-sender-auth:message-id:subject:to:cc:content-type;
 b=gbccj549C4HEt6Fkh7t5gAbKJST/lXAaqbfcuSbOJLLoLDeF7JLim1zZmGXfnifg36
 HGhtYMmPa8dNaklklBp/bJ9AAyYEchn/VzZUFxjL1Rbws37wdH6u3EFmNsdEk3G/hJKA
 VJAkf9ZGHXhyibyVmlO4CG2NsHApid7xNDKdA=
Received: by 10.231.35.195 with SMTP id q3mr593605ibd.22.1278173639297;
 Sat,  03 Jul 2010 09:13:59 -0700 (PDT)
MIME-Version: 1.0
Sender: naitiks@gmail.com
Received: by 10.231.170.9 with HTTP; Sat, 3 Jul 2010 09:13:39 -0700 (PDT)
In-Reply-To: <C66A9854-02EB-4CCE-8338-382AEEC7EA61@gmail.com>
References: <AANLkTimMruKyblUWROkPMDapFKtTztOXqL64PpQxCmKO@mail.gmail.com>
 <2625894F-2979-40BD-81E1-05A6EB8723CD@facebook.com>
 <AANLkTinvLOV0f3I-aWpeAbfIpfGyxZSB2RHu52iw5mDC@mail.gmail.com>
 <AANLkTilWNneonIRX21U1RZcE80FuVSJWXU7CNm5pV275@mail.gmail.com>
 <AANLkTin-7PNLv-Hc229JJcOrIBh4fJqY5CMaLCMbmoIk@mail.gmail.com>
 <AANLkTikh_nQ8dXSp7QXJ79kCdbX1zeyPKAl_kgplb25x@mail.gmail.com>
 <3DC7AEF8-3283-4970-BB98-3D680A3E2429@gmail.com>
 <AANLkTimpvWCbCBEWdI1Id5Ig_xCUW2hvKDro5LyhufMV@mail.gmail.com>
 <FE47FED0-3850-4393-9C79-DE06F0F7B6CA@gmail.com>
 <BA564125-9FBB-4B1A-93AC-7DD1A754A5E1@facebook.com>
 <C66A9854-02EB-4CCE-8338-382AEEC7EA61@gmail.com>
From: Naitik Shah <n@daaku.org>
Date: Sat, 3 Jul 2010 09:13:39 -0700
X-Google-Sender-Auth: wUCo7wOiZt3mLy4oXex075eMyCk
Message-ID: <AANLkTikiXVruhZSH3Q6rMhdZAHRBPkhE_JVhSNOhCXmN@mail.gmail.com>
To: Dick Hardt <dick.hardt@gmail.com>
Content-Type: multipart/alternative; boundary=0022152d6cb5bb5480048a7dfd86
Cc: OAuth WG <oauth@ietf.org>
Subject: Re: [OAUTH-WG] Understanding the reasoning for Base64
X-BeenThere: oauth@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: OAUTH WG <oauth.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/listinfo/oauth>,
 <mailto:oauth-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/oauth>
List-Post: <mailto:oauth@ietf.org>
List-Help: <mailto:oauth-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/oauth>,
 <mailto:oauth-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sat, 03 Jul 2010 16:13:50 -0000

--0022152d6cb5bb5480048a7dfd86
Content-Type: text/plain; charset=UTF-8

On Sat, Jul 3, 2010 at 9:02 AM, Dick Hardt <dick.hardt@gmail.com> wrote:

>
> On 2010-07-02, at 5:04 PM, Paul Tarjan wrote:
>
> >>> We don't think base64url will work, because the most common error we'll
> see is that developers forget the "url" part and just do plain base64, and
> that's not sufficient because the stock set includes +.
> >>
> >> I think forgetting to url-decode is more likely than doing the wrong
> base64 encoding. At least with the wrong base64 encoding, what was done
> wrong is more obvious right away. The + will not be in the string.
> >
> > Most web frameworks that I know of urldecode the inputs before they even
> hit application code.
> >
> >
> >
> >>>
> >>> So it will maybe work, maybe not. Maybe they'll do urlencoding after
> anyways, since if they are passing this as a query param, or post data,
> client libraries will take a dict and try to "do the right thing". And we
> end up with pluses, and we're not quite sure if they should be urldecoded or
> not.
> >>
> >> we won't have pluses
> >
> > I think Naitik is saying that accidentally doing base64 and not base64url
> will send some '+'s along.
>
> if there are '+'s in the token, then it is easy for someone helping to spot
> the problem. also easy for servers to send back an error message saying,
> "hey, looks like you are using base64 instead of base64url encoding"
>
> ie, it is easy to detect the error -- urlencoding / decoding is hard to
> detect as an error
>

The pluses are not guaranteed. They may or may not be there depending on the
data stream you're encoding. If you don't urlencode the JSON, you'll get a
"{", if you do it once, you'll get a "%7B", if you do it twice, you'll get a
"%257B" -- seems easier to detect.




> >
> >
> >
> >
> >> why hex? ... why not base64url?
> >
> > It seems to be the encoding format in languages:
> >
> > python:
> >>>> hmac.new('secret', 'payload', hashlib.sha256).hexdigest()
> > 'b82fcb791acec57859b989b430a826488ce2e479fdf92326bd0a2e8375a42ba4'
> >
> > php:
> > print hash_hmac('sha256', 'payload', 'secret');
> > b82fcb791acec57859b989b430a826488ce2e479fdf92326bd0a2e8375a42ba
> >
> > ruby:
> >>> HMAC::SHA256.hexdigest('secret', 'payload')
> > => "b82fcb791acec57859b989b430a826488ce2e479fdf92326bd0a2e8375a42ba4"
>
> When I wrote a sample in Perl, it was pretty easy to make it base64url
> which then provides a consistent encoding.
>

Did it involve a string replace call? Or a third party library?




> >
> >> I am unclear on what your point is.
> >>
> >> The token would be included as one of the headers. This is often
> preferable as it separates the authorization layer (in header) from
> application layer parameters (query string or message body)
> >
> > With our proposal, we were focussed on url parameters (hence the choice
> of urlencode after it was all put together). I think it makes total sense to
> not do the encoding as part of the sig spec, and let the transport choice
> dictate which encoding to use.
>
> I understand what you are saying. having multiple encodings makes libraries
> harder, and leads to the issues that motivated base64url over url-encoding




> >
> > Therefore, I think we should make the signature:
> >
> >    hash + '.' + json string
> >
> > And then if you are putting it in a url parameter, you should urlencode
> the whole thing. If you are putting it in an HTTP header you should remove
> all the "\r" and "\n" in the json output (which are only whitespace as they
> aren't allowed inside strings, and most language encoders won't even output
> them by default).
> >
> > This way, this is a general signature spec, regardless of how it is being
> sent. You could send it as a DNS record and do the proper encoding for that
> scenario, or carrier pigeon encoded in Navajo, etc.
> >
> >
> >
> > So to sum up:
> >
> > * We'd like the signature first (so you can left split instead of right
> split)
>
> What are the advantages of left split vs right split?
>

Built in split function with a limit is more common, which makes the left
split easier.



-Naitik

--0022152d6cb5bb5480048a7dfd86
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<br><br><div class=3D"gmail_quote">On Sat, Jul 3, 2010 at 9:02 AM, Dick Har=
dt <span dir=3D"ltr">&lt;<a href=3D"mailto:dick.hardt@gmail.com">dick.hardt=
@gmail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class=3D"im"><br>
On 2010-07-02, at 5:04 PM, Paul Tarjan wrote:<br>
<br>
&gt;&gt;&gt; We don&#39;t think base64url will work, because the most commo=
n error we&#39;ll see is that developers forget the &quot;url&quot; part an=
d just do plain base64, and that&#39;s not sufficient because the stock set=
 includes +.<br>


&gt;&gt;<br>
&gt;&gt; I think forgetting to url-decode is more likely than doing the wro=
ng base64 encoding. At least with the wrong base64 encoding, what was done =
wrong is more obvious right away. The + will not be in the string.<br>


&gt;<br>
&gt; Most web frameworks that I know of urldecode the inputs before they ev=
en hit application code.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; So it will maybe work, maybe not. Maybe they&#39;ll do urlenco=
ding after anyways, since if they are passing this as a query param, or pos=
t data, client libraries will take a dict and try to &quot;do the right thi=
ng&quot;. And we end up with pluses, and we&#39;re not quite sure if they s=
hould be urldecoded or not.<br>


&gt;&gt;<br>
&gt;&gt; we won&#39;t have pluses<br>
&gt;<br>
&gt; I think Naitik is saying that accidentally doing base64 and not base64=
url will send some &#39;+&#39;s along.<br>
<br>
</div>if there are &#39;+&#39;s in the token, then it is easy for someone h=
elping to spot the problem. also easy for servers to send back an error mes=
sage saying, &quot;hey, looks like you are using base64 instead of base64ur=
l encoding&quot;<br>


<br>
ie, it is easy to detect the error -- urlencoding / decoding is hard to det=
ect as an error<br></blockquote><div><br></div><div>The pluses are not=C2=
=A0guaranteed. They may or may not be there depending on the data stream yo=
u&#39;re encoding. If you don&#39;t urlencode the JSON, you&#39;ll get a &q=
uot;{&quot;, if you do it once, you&#39;ll get a &quot;%7B&quot;, if you do=
 it twice, you&#39;ll get a &quot;%257B&quot; -- seems easier to detect.</d=
iv>

<div>=C2=A0</div><div><br></div><div><br></div><blockquote class=3D"gmail_q=
uote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1e=
x;">
<div class=3D"im"><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;&gt; why hex? ... why not base64url?<br>
&gt;<br>
&gt; It seems to be the encoding format in languages:<br>
&gt;<br>
&gt; python:<br>
&gt;&gt;&gt;&gt; hmac.new(&#39;secret&#39;, &#39;payload&#39;, hashlib.sha2=
56).hexdigest()<br>
&gt; &#39;b82fcb791acec57859b989b430a826488ce2e479fdf92326bd0a2e8375a42ba4&=
#39;<br>
&gt;<br>
&gt; php:<br>
&gt; print hash_hmac(&#39;sha256&#39;, &#39;payload&#39;, &#39;secret&#39;)=
;<br>
&gt; b82fcb791acec57859b989b430a826488ce2e479fdf92326bd0a2e8375a42ba<br>
&gt;<br>
&gt; ruby:<br>
&gt;&gt;&gt; HMAC::SHA256.hexdigest(&#39;secret&#39;, &#39;payload&#39;)<br=
>
&gt; =3D&gt; &quot;b82fcb791acec57859b989b430a826488ce2e479fdf92326bd0a2e83=
75a42ba4&quot;<br>
<br>
</div>When I wrote a sample in Perl, it was pretty easy to make it base64ur=
l which then provides a consistent encoding.<br></blockquote><div><br></div=
><div>Did it involve a string replace call? Or a third party library?</div>

<div>=C2=A0</div><div><br></div><div><br></div><blockquote class=3D"gmail_q=
uote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1e=
x;">
<div class=3D"im"><br>
&gt;<br>
&gt;&gt; I am unclear on what your point is.<br>
&gt;&gt;<br>
&gt;&gt; The token would be included as one of the headers. This is often p=
referable as it separates the authorization layer (in header) from applicat=
ion layer parameters (query string or message body)<br>
&gt;<br>
&gt; With our proposal, we were focussed on url parameters (hence the choic=
e of urlencode after it was all put together). I think it makes total sense=
 to not do the encoding as part of the sig spec, and let the transport choi=
ce dictate which encoding to use.<br>


<br>
</div>I understand what you are saying. having multiple encodings makes lib=
raries harder, and leads to the issues that motivated base64url over url-en=
coding=C2=A0</blockquote><blockquote class=3D"gmail_quote" style=3D"margin:=
0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

=C2=A0</blockquote><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 =
.8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class=3D"im"><br>
&gt;<br>
&gt; Therefore, I think we should make the signature:<br>
&gt;<br>
&gt; =C2=A0 =C2=A0hash + &#39;.&#39; + json string<br>
&gt;<br>
&gt; And then if you are putting it in a url parameter, you should urlencod=
e the whole thing. If you are putting it in an HTTP header you should remov=
e all the &quot;\r&quot; and &quot;\n&quot; in the json output (which are o=
nly whitespace as they aren&#39;t allowed inside strings, and most language=
 encoders won&#39;t even output them by default).<br>


&gt;<br>
&gt; This way, this is a general signature spec, regardless of how it is be=
ing sent. You could send it as a DNS record and do the proper encoding for =
that scenario, or carrier pigeon encoded in Navajo, etc.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; So to sum up:<br>
&gt;<br>
&gt; * We&#39;d like the signature first (so you can left split instead of =
right split)<br>
<br>
</div>What are the advantages of left split vs right split?<br></blockquote=
><div><br></div><div>Built in split function with a limit is more common, w=
hich makes the left split easier.</div><div><br></div><div><br></div><div>

<br></div><div>-Naitik</div></div><br>

--0022152d6cb5bb5480048a7dfd86--
