Re: [jose] #26: Allow for signature payload to not be base64 encoded

Mike Jones <Michael.Jones@microsoft.com> Sat, 29 June 2013 10:19 UTC

Return-Path: <Michael.Jones@microsoft.com>
X-Original-To: jose@ietfa.amsl.com
Delivered-To: jose@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 29D8421F9EC3 for <jose@ietfa.amsl.com>; Sat, 29 Jun 2013 03:19:02 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -3.598
X-Spam-Level:
X-Spam-Status: No, score=-3.598 tagged_above=-999 required=5 tests=[BAYES_00=-2.599, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-1]
Received: from mail.ietf.org ([12.22.58.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EDiDoGMaORo3 for <jose@ietfa.amsl.com>; Sat, 29 Jun 2013 03:18:55 -0700 (PDT)
Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2lp0203.outbound.protection.outlook.com [207.46.163.203]) by ietfa.amsl.com (Postfix) with ESMTP id 3941521F9EC1 for <jose@ietf.org>; Sat, 29 Jun 2013 03:18:55 -0700 (PDT)
Received: from BY2FFO11FD022.protection.gbl (10.1.15.200) by BY2FFO11HUB029.protection.gbl (10.1.14.114) with Microsoft SMTP Server (TLS) id 15.0.717.3; Sat, 29 Jun 2013 10:15:34 +0000
Received: from TK5EX14MLTC104.redmond.corp.microsoft.com (131.107.125.37) by BY2FFO11FD022.mail.protection.outlook.com (10.1.15.211) with Microsoft SMTP Server (TLS) id 15.0.707.0 via Frontend Transport; Sat, 29 Jun 2013 10:15:34 +0000
Received: from TK5EX14MBXC283.redmond.corp.microsoft.com ([169.254.2.25]) by TK5EX14MLTC104.redmond.corp.microsoft.com ([157.54.79.159]) with mapi id 14.03.0136.001; Sat, 29 Jun 2013 10:14:47 +0000
From: Mike Jones <Michael.Jones@microsoft.com>
To: Dick Hardt <dick.hardt@gmail.com>, Richard Barnes <rlb@ipv.sx>
Thread-Topic: [jose] #26: Allow for signature payload to not be base64 encoded
Thread-Index: AQHOcgNOsVoAPXc/s02k5Wh9HChUEZlIUkQAgACNH4CAAObIgIAAAUowgAAHOACAAFdeAIAAGdCAgAGB7wCAAAHbAIAAtFIw
Date: Sat, 29 Jun 2013 10:14:47 +0000
Message-ID: <4E1F6AAD24975D4BA5B1680429673943678A92EE@TK5EX14MBXC283.redmond.corp.microsoft.com>
References: <061.c2fcfec0a75d48eb8b194991ce56157e@trac.tools.ietf.org> <076.3f5d1244c042cd87bfb07814924fcbc9@trac.tools.ietf.org> <033a01ce729b$26bc3910$7434ab30$@augustcellars.com> <51CBA981.4050006@nri.co.jp> <048f01ce7355$19f05bc0$4dd11340$@augustcellars.com> <4E1F6AAD24975D4BA5B1680429673943678A0114@TK5EX14MBXC283.redmond.corp.microsoft.com> <04bf01ce7359$5ab862c0$10292840$@augustcellars.com> <CAL02cgTkUrQptGqOfQyhCembS1e3Qxw3peRFnO5QjswUW=XR-w@mail.gmail.com> <CAD9ie-sZ+w_HADMTnnkTC8XRJmjZvwYOmA+AhvJGTNPhhK=Z4g@mail.gmail.com> <CAL02cgQbAQ8zhumdR_uvXjhbZM0iXpfPnmgcJrMUuh4+bj11NA@mail.gmail.com> <CAD9ie-sBGnv5QbjFeQiXiMJ0Git06LPsAkoNeN7KZxRNqukv3w@mail.gmail.com>
In-Reply-To: <CAD9ie-sBGnv5QbjFeQiXiMJ0Git06LPsAkoNeN7KZxRNqukv3w@mail.gmail.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-originating-ip: [157.54.51.37]
Content-Type: multipart/alternative; boundary="_000_4E1F6AAD24975D4BA5B1680429673943678A92EETK5EX14MBXC283r_"
MIME-Version: 1.0
X-Forefront-Antispam-Report: CIP:131.107.125.37; CTRY:US; IPV:CAL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(199002)(189002)(51444003)(377454003)(24454002)(6806003)(56776001)(19300405004)(33656001)(16406001)(74502001)(76482001)(74366001)(74662001)(47446002)(76796001)(74706001)(16236675002)(15202345003)(83072001)(56816003)(77096001)(79102001)(31966008)(20776003)(44976004)(66066001)(80022001)(77982001)(54316002)(59766001)(51856001)(49866001)(4396001)(47736001)(76786001)(63696002)(47976001)(50986001)(46102001)(81542001)(54356001)(55846006)(74876001)(71186001)(65816001)(69226001)(81342001)(512954002)(53806001); DIR:OUT; SFP:; SCL:1; SRVR:BY2FFO11HUB029; H:TK5EX14MLTC104.redmond.corp.microsoft.com; CLIP:131.107.125.37; RD:InfoDomainNonexistent; A:1; MX:1; LANG:en;
X-OriginatorOrg: microsoft.onmicrosoft.com
X-O365ENT-EOP-Header: Message processed by - O365_ENT: Allow from ranges (Engineering ONLY)
X-Forefront-PRVS: 0892FA9A88
Cc: Jim Schaad <ietf@augustcellars.com>, n-sakimura <n-sakimura@nri.co.jp>, "jose@ietf.org" <jose@ietf.org>, "draft-ietf-jose-json-web-signature@tools.ietf.org" <draft-ietf-jose-json-web-signature@tools.ietf.org>
Subject: Re: [jose] #26: Allow for signature payload to not be base64 encoded
X-BeenThere: jose@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: Javascript Object Signing and Encryption <jose.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/jose>, <mailto:jose-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/jose>
List-Post: <mailto:jose@ietf.org>
List-Help: <mailto:jose-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/jose>, <mailto:jose-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sat, 29 Jun 2013 10:19:02 -0000

In the spirit of compromise, and to help further the discussion on this topic, I thought I'd suggest a possible syntax for the JWS JSON Serialization for representing an unencoded payload as a JSON string.  One way of allowing either encoded or unencoded payloads would be to use different JSON member names for them.  For instance, one could allow either of these names, but not both, in any particular JWS using the JSON Serialization:

    "payload" - Contains base64url encoded JWS Payload representation
    "verbatim" - Contains unencoded JWS Payload representation

So then, for instance, these three alternative representations would all represent the same JWS Payload:
    "payload": "SGVsbG8gd29ybGQ"
    "verbatim": "Hello world"
    "verbatim": "Hello\u0020world"

As for the signature computation, in the "payload", case there would be no change from the present.  In the "verbatim" case, I assume that the logical thing to do would be to use the octets of the UTF8 representation of the payload string in the signing input - in this example, 72 101 108 108 111 32 119 111 114 108 100.

This approach would avoid the problem I had discussed earlier of there being a default that is different than the Compact Serialization.  There would be no default.  Those encoding the content would choose either the "payload" or "verbatim" member name.

This does not avoid the problem of there being two different ways to do the same thing in the standard, with the interoperability problems that can result.

I am still not advocating that we support two ways of representing payloads.  But if the working group does decide that it's important to do so, I think that this would be a credible approach for doing so.  I think it would accomplish what Jim is after here.

Thoughts?

                                                            -- Mike

From: jose-bounces@ietf.org [mailto:jose-bounces@ietf.org] On Behalf Of Dick Hardt
Sent: Friday, June 28, 2013 4:04 PM
To: Richard Barnes
Cc: Jim Schaad; n-sakimura; Mike Jones; jose@ietf.org; draft-ietf-jose-json-web-signature@tools.ietf.org
Subject: Re: [jose] #26: Allow for signature payload to not be base64 encoded

Hi Richard, that helps.

Our you looking at a way of effectively signing a JSON payload? A complete, real world example would help alot.

On Fri, Jun 28, 2013 at 3:57 PM, Richard Barnes <rlb@ipv.sx<mailto:rlb@ipv.sx>> wrote:
Hey Dick,

I guess I should have been clearer that I was only talking about the JSON serialization.  My proposed change would have no impact on the compact serialization.  Hopefully that answers your questions about separators, etc.; they payload would just be a normal JSON string.

--Richard

On Thu, Jun 27, 2013 at 7:56 PM, Dick Hardt <dick.hardt@gmail.com<mailto:dick.hardt@gmail.com>> wrote:


On Thu, Jun 27, 2013 at 3:24 PM, Richard Barnes <rlb@ipv.sx<mailto:rlb@ipv.sx>> wrote:
I think there are two separable issues here, both of which Mike and I probably have divergent opinions on :)
1. Syntax: Should it be possible for the "payload" field JWS to be a JSON string (instead of base64) when the payload is simply a UTF-8 string?

One of the goals of the token was that it not require encoding for it to be transported in a request. IE that it be safe and SIMPLE to include in an HTTP header or in a URL

2. Crypto: Must the JWS Signing Input be base64url encoded.

The current answers to these questions are:
1. It is not possible.  Payload is always base64url encoded.
2. It is always base64url encoded.

The answers should be:
1. The payload should not be base64url encoded unless it cannot be represented as a JSON string.

How does an implementation determine which parts are separated? Are '.' escaped? Does the implementation need to parse the JSON to determine a valid separator? How does it know the end of the JSON? That sounds really hard to implement, or I am misunderstanding what you are proposing.


2. The JWS Signing Input should not be base64url encoded unless there is a JWS Protected Header

Neither of these are complicated changes:
1. Add a "b64" header parameter that indicates that the payload is base64url-encoded binary, as opposed to a UTF-8 string.  Specify that this parameter is on by default in compact-formatted JWS objects.

And how is the header separated from the payload?

2. Modify the signing/verification instructions to switch based on the presence of a JWS Protected Header: "If the JWS Protected Header is absent or empty, then the JWS Signing Input is simply the JWS Payload (not encoded).  If the JWS Protected Header has a non-empty value, then the the JWS Signing Input is the concatenation of the Encoded JWS Header, a period ('.') character, and the Encoded JWS Payload"

There are two reasons for these, both of which are important to make sure that this spec is applicable to a broad variety of use cases:
1. Compactness.  As Jim notes, quoted strings are shorter than base64url-encoded strings

The tokens are already compact enough.

2. Crypto-compatibility: Avoiding base64-encoding means that there's nothing JWS-specific about the signature value.  So for example, you could translate a JWS with no protected attributes to a CMS SignedData object with no protected attributes.

Not a useful feature from my point of view.

-- Dick