Re: [OAUTH-WG] Understanding the reasoning for Base64
Dick Hardt <dick.hardt@gmail.com> Thu, 01 July 2010 23:43 UTC
Return-Path: <dick.hardt@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 0DD253A6A96 for <oauth@core3.amsl.com>; Thu, 1 Jul 2010 16:43:06 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.461
X-Spam-Level:
X-Spam-Status: No, score=-2.461 tagged_above=-999 required=5 tests=[AWL=0.137, BAYES_00=-2.599, 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 9yc5bVl+MRfI for <oauth@core3.amsl.com>; Thu, 1 Jul 2010 16:43:04 -0700 (PDT)
Received: from mail-pv0-f172.google.com (mail-pv0-f172.google.com [74.125.83.172]) by core3.amsl.com (Postfix) with ESMTP id A422C3A6837 for <oauth@ietf.org>; Thu, 1 Jul 2010 16:43:04 -0700 (PDT)
Received: by pvd12 with SMTP id 12so1378359pvd.31 for <oauth@ietf.org>; Thu, 01 Jul 2010 16:43:13 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:mime-version :content-type:from:in-reply-to:date:cc:message-id:references:to :x-mailer; bh=j85kxQzPf1PRYoOi6bbCEN8OFs7kf/iAmeZbQpdrH68=; b=LPUhgJQPczl9eh2+wT8W05g5ijkPJvK9qXz+zXJ7gCjqBkib9+p/A8VWj4ER2+A3jx rCUhRI31hq/dGNDb3vEwDK5XARPJJUq8g95CEcJiQY934yPSOBwFYKB+lDGWeIsqF3YV 0dF52M2WKkZmANm9YQU+pog791Oax7gibk75k=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date:cc :message-id:references:to:x-mailer; b=nO9EB1esxOuGp6TjJH87rfBQQ+nxXiB0XOs4Ot+lN+lgDPKPu2HvXRWzIlVu/WZC4e KXJyf8jv9jxJla1FOh/EUC6C3VHcbEFOhNwhS+pqlc9aWEFEFTPbX9u9whfKDnnAc2k3 EhR8pk6/MImY/gQH1mM5/fylfSBym1cJgaMXg=
Received: by 10.142.139.13 with SMTP id m13mr203987wfd.348.1278027793401; Thu, 01 Jul 2010 16:43:13 -0700 (PDT)
Received: from [192.168.1.2] (c-24-130-32-55.hsd1.ca.comcast.net [24.130.32.55]) by mx.google.com with ESMTPS id w8sm33037wfd.19.2010.07.01.16.43.12 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 01 Jul 2010 16:43:12 -0700 (PDT)
Mime-Version: 1.0 (Apple Message framework v1078)
Content-Type: multipart/alternative; boundary="Apple-Mail-126--927119470"
From: Dick Hardt <dick.hardt@gmail.com>
In-Reply-To: <AANLkTimpvWCbCBEWdI1Id5Ig_xCUW2hvKDro5LyhufMV@mail.gmail.com>
Date: Thu, 01 Jul 2010 16:43:11 -0700
Message-Id: <FE47FED0-3850-4393-9C79-DE06F0F7B6CA@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>
To: Naitik Shah <n@daaku.org>
X-Mailer: Apple Mail (2.1078)
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: Thu, 01 Jul 2010 23:43:06 -0000
On 2010-07-01, at 12:52 PM, Naitik Shah wrote:
> Searching for base64url does make it better. Thanks for that pointer Dick.
>
> 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.
>
> 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
>
> For example, this doesn't give me back what I put in:
>
> base64_decode(urldecode(base64_encode('-+>')))
>
> Because the base64_encode returns something containing a +, and the usual urldecode logic will convert this into a space. In fact, looking at the PHP docs for base64 decode, there are a bunch of comments talking about pluses: http://php.net/manual/en/function.base64-decode.php.
>
> The approach I'm thinking is something like:
>
> function getSignedToken($params, $secret) {
> $json = json_encode($params);
> // Moving the signature to be before the payload makes the separator/split
> // logic be: "everything before the first dot is the sig". also, it's hex.
why hex? ... why not base64url?
> return hash_hmac('sha256', $json, $secret) . '.' . $json;
> }
>
> function parseSignedToken($token, $secret) {
> list($sig, $json) = explode('.', $token, $limit=2);
> if (hash_hmac('sha256', $json, $secret) !== $sig) {
> throw new Exception('Bad Sig');
> }
> return json_decode($json);
> }
>
> [UNTESTED!] Where url encoding and decoding happens outside of the signature process.
>
> I'm not convinced adding the request as a header is going to be used often. Headers are always sent uncompressed. I imagine signatures to be used for those that are perf sensitive and don't want the SSL overhead. So this minor detail will matter to them. This is especially true because unlike OAuth1, the header doesn't just contain a signature, but contains the entire signed payload. But there's nothing stopping us from using the same format above for sending the payload as a header.
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)
>
> One of the arguments was wrt detecting double url encoding. Since the thing we're signing is a JSON object, we always know it will start with %7B and if it's double encoded, it will be %257B.
So you really think a developer will remember the spot that it is not %7B and is %257B but will NOT to use base64url?
- [OAUTH-WG] Understanding the reasoning for Base64 Naitik Shah
- Re: [OAUTH-WG] Understanding the reasoning for Ba… Luke Shepard
- Re: [OAUTH-WG] Understanding the reasoning for Ba… Breno
- Re: [OAUTH-WG] Understanding the reasoning for Ba… Naitik Shah
- Re: [OAUTH-WG] Understanding the reasoning for Ba… John Panzer
- Re: [OAUTH-WG] Understanding the reasoning for Ba… Naitik Shah
- Re: [OAUTH-WG] Understanding the reasoning for Ba… Dick Hardt
- Re: [OAUTH-WG] Understanding the reasoning for Ba… Naitik Shah
- Re: [OAUTH-WG] Understanding the reasoning for Ba… Dick Hardt
- Re: [OAUTH-WG] Understanding the reasoning for Ba… Paul Tarjan
- Re: [OAUTH-WG] Understanding the reasoning for Ba… Dick Hardt
- Re: [OAUTH-WG] Understanding the reasoning for Ba… Naitik Shah
- Re: [OAUTH-WG] Understanding the reasoning for Ba… Ben Laurie
- Re: [OAUTH-WG] Understanding the reasoning for Ba… Dick Hardt
- Re: [OAUTH-WG] Understanding the reasoning for Ba… Dick Hardt
- Re: [OAUTH-WG] Understanding the reasoning for Ba… Luke Shepard
- Re: [OAUTH-WG] Understanding the reasoning for Ba… Naitik Shah
- Re: [OAUTH-WG] Understanding the reasoning for Ba… Dick Hardt
- Re: [OAUTH-WG] Understanding the reasoning for Ba… Evan Gilbert
- Re: [OAUTH-WG] Understanding the reasoning for Ba… Naitik Shah
- Re: [OAUTH-WG] Understanding the reasoning for Ba… Dick Hardt