Re: [OAUTH-WG] PKCE: SHA256(WAT?)

Nat Sakimura <sakimura@gmail.com> Fri, 30 January 2015 14:15 UTC

Return-Path: <sakimura@gmail.com>
X-Original-To: oauth@ietfa.amsl.com
Delivered-To: oauth@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id A0D8F1A037F for <oauth@ietfa.amsl.com>; Fri, 30 Jan 2015 06:15:20 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.999
X-Spam-Level:
X-Spam-Status: No, score=-1.999 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, HTML_MESSAGE=0.001, SPF_PASS=-0.001] autolearn=ham
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pI3yr_Hn-BGa for <oauth@ietfa.amsl.com>; Fri, 30 Jan 2015 06:15:12 -0800 (PST)
Received: from mail-oi0-x22a.google.com (mail-oi0-x22a.google.com [IPv6:2607:f8b0:4003:c06::22a]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id C9FA71A0252 for <oauth@ietf.org>; Fri, 30 Jan 2015 06:15:11 -0800 (PST)
Received: by mail-oi0-f42.google.com with SMTP id i138so34718086oig.1 for <oauth@ietf.org>; Fri, 30 Jan 2015 06:15:11 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=W0zYRNMIhtyWwRtgQhkSRDBhgP1/QvUaTWGPAXie9Lc=; b=lTd8n3SljSGYv8fDEIU0FYeYjNjYNO2fjgZ2LtOP69qZw+uz30bo9raeduiBiFva34 MU7Htycc3pTGcqW4aOxlHkXx8dceIr63LGAXZdh4weHfp/bNK/W7Hq0WZcNT3CKNpQGR vIeQny/u/eGabQDLg6V0BxaBj9nNRn+mIuQgwLxHwtogffgH5yC7XaDUV8fRsDFFcEud zICDTdChHSo4dyuP4/Y7S/lBkUrS88+boKdp7PqhMmmfA4ruUxisb8abCpklfbT/N95h mw8XO6L3n/W7TinJdyEmP9+1MKZjtrIaRO9G7mju+hJRJZmTw4qA6m/nJiD9WYFDtSNJ 2jEw==
MIME-Version: 1.0
X-Received: by 10.60.44.70 with SMTP id c6mr3882462oem.36.1422627311039; Fri, 30 Jan 2015 06:15:11 -0800 (PST)
Received: by 10.60.171.196 with HTTP; Fri, 30 Jan 2015 06:15:10 -0800 (PST)
In-Reply-To: <CA+k3eCRn0xT+_fA0G3Q3OjjH9Lq-2AfC+Mv7Gq8bYnHqH5TFDw@mail.gmail.com>
References: <CA+k3eCQHZJYJ3mMfdGTdO=S3VVQdU+qhjVz+QsEeobJokNSHEA@mail.gmail.com> <FD9F9F2A-8B32-4A26-95CC-59C8C465A202@sakimura.org> <CA+k3eCRn0xT+_fA0G3Q3OjjH9Lq-2AfC+Mv7Gq8bYnHqH5TFDw@mail.gmail.com>
Date: Fri, 30 Jan 2015 23:15:10 +0900
Message-ID: <CABzCy2CWnjmeBGT8hgQY-R9Z6u=UFM8AAvHDr1MV81kJXST9WQ@mail.gmail.com>
From: Nat Sakimura <sakimura@gmail.com>
To: Brian Campbell <bcampbell@pingidentity.com>
Content-Type: multipart/alternative; boundary=001a11c21c7085bb6c050ddf3bba
Archived-At: <http://mailarchive.ietf.org/arch/msg/oauth/AdSCkPi74pIkln3N7EvgiKiysJM>
Cc: oauth <oauth@ietf.org>, Naveen Agarwal <naa@google.com>
Subject: Re: [OAUTH-WG] PKCE: SHA256(WAT?)
X-BeenThere: oauth@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: OAUTH WG <oauth.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/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: Fri, 30 Jan 2015 14:15:25 -0000

I do not think we need ASCII(). It is quite clear without it, I suppose.

In 4.1, I would rather do like:

 code_verifier = high entropy cryptographic random
   octet sequence using the url and filename safe Alphabet [A-Z] / [a-z]
   / [0-9] / "-" / "_" from Sec 5 of RFC 4648 [RFC4648], with length
   less than 128 characters.

Nat

2015-01-30 22:51 GMT+09:00 Brian Campbell <bcampbell@pingidentity.com>om>:

> That's definitely an improvement (to me anyway).
>
> Checking that the rest of the document uses those notations appropriately,
> I think, yields a few other changes. And probably begs for the
> "ASCII(STRING) denotes the octets of the ASCII representation of STRING"
> notation/function, or something like it, to be put back in. Those changes
> might look like the following:
>
>
> In 4.1.:
>
> OLD:
>    code_verifier = high entropy cryptographic random ASCII [RFC0020]
>    octet sequence using the url and filename safe Alphabet [A-Z] / [a-z]
>    / [0-9] / "-" / "_" from Sec 5 of RFC 4648 [RFC4648], with length
>    less than 128 characters.
>
> NEW (maybe):
>   code_verifier = high entropy cryptographically strong random STRING
>   using the url and filename safe Alphabet [A-Z] / [a-z]
>    / [0-9] / "-" / "_" from Sec 5 of RFC 4648 [RFC4648], with length
>    less than 128 characters.
>
>
> In 4.2.:
>
> OLD:
>    S256  "code_challenge" = BASE64URL(SHA256("code_verifier"))
>
> NEW (maybe):
>    S256  "code_challenge" = BASE64URL(SHA256(ASCII("code_verifier")))
>
>
> In 4.6.:
>
> OLD:
>    SHA256("code_verifier" ) == BASE64URL-DECODE("code_challenge").
>
> NEW (maybe):
>    SHA256(ASCII("code_verifier")) == BASE64URL-DECODE("code_challenge").
>
>
>
>
> On Thu, Jan 29, 2015 at 8:37 PM, Nat Sakimura (=nat) <nat@sakimura.org>
> wrote:
>
>> I take your point, Brian.
>>
>> In our most recent manuscript, STRING is defined inside ASCII(STRING) as
>>
>> STRING is a sequence of zero or more ASCII characters
>>
>> but it is kind of circular, and we do not seem to use ASCII().
>>
>> What about re-writing the section like below?
>>
>> STRING denotes a sequence of zero or more ASCII  [RFC0020]
>> <http://xml2rfc.ietf.org/cgi-bin/xml2rfc.cgi#RFC0020> characters.
>>
>> OCTETS denotes a sequence of zero or more octets.
>>
>> BASE64URL(OCTETS) denotes the base64url encoding of OCTETS, per Section 3
>> <http://xml2rfc.ietf.org/cgi-bin/xml2rfc.cgi#Terminology> producing a
>> ASCII[RFC0020] <http://xml2rfc.ietf.org/cgi-bin/xml2rfc.cgi#RFC0020>
>>  STRING.
>>
>> BASE64URL-DECODE(STRING) denotes the base64url decoding of STRING, per Section
>> 3 <http://xml2rfc.ietf.org/cgi-bin/xml2rfc.cgi#Terminology>, producing a
>> sequence of octets.
>>
>> SHA256(OCTETS) denotes a SHA2 256bit hash [RFC6234]
>> <http://xml2rfc.ietf.org/cgi-bin/xml2rfc.cgi#RFC6234> of OCTETS.
>>
>>
>>
>>
>>
>>
>> On Jan 30, 2015, at 08:15, Brian Campbell <bcampbell@pingidentity.com>
>> wrote:
>>
>> In §2 [1] we've got "SHA256(STRING) denotes a SHA2 256bit hash [RFC6234]
>> of STRING."
>>
>> But, in the little cow town where I come from anyway, you hash
>> bits/octets not character strings (BTW, "STRING" isn't defined anywhere but
>> it's kind of implied that it's a string of characters).
>>
>> Should it say something more like "SHA256(STRING) denotes a SHA2 256bit
>> hash [RFC6234] of the octets of the ASCII [RFC0020] representation of
>> STRING."?
>>
>> I know it's kind of pedantic but I find it kind of confusing because the
>> code_verifier uses the url and filename safe alphabet, which has me second
>> guessing if SHA256(STRING) actually means a hash of the octet produced by
>> base64url decoding the string.
>>
>> Maybe it's just me but, when reading the text, I find the transform
>> process to be much more confusing than I think it needs to be. Removing and
>> clarifying some things will help. I hate to suggest this but maybe an
>> example showing the computation steps on both ends would be helpful?
>>
>> Also "UTF8(STRING)" and "ASCII(STRING)" notations are defined in §2 but
>> not used anywhere.
>>
>> And §2 also says, "BASE64URL-DECODE(STRING) denotes the base64url
>> decoding of STRING, per Section 3, producing a UTF-8 sequence of octets."
>> But what is a UTF-8 sequence of octets? Isn't it just a sequence octets?
>> The [RFC3629] reference, I think, could be removed.
>>
>> [1] https://tools.ietf.org/html/draft-ietf-oauth-spop-06#section-2
>>
>>
>> Nat Sakimura
>> nat@sakimura.org
>>
>>
>>
>>
>>
>>
>


-- 
Nat Sakimura (=nat)
Chairman, OpenID Foundation
http://nat.sakimura.org/
@_nat_en