Re: [jose] Reducing the size of JWS payloads

Anthony Nadalin <> Wed, 19 December 2012 04:44 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id 376ED21F8577 for <>; Tue, 18 Dec 2012 20:44:30 -0800 (PST)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: 0.534
X-Spam-Status: No, score=0.534 tagged_above=-999 required=5 tests=[BAYES_00=-2.599, BODY_ENHANCEMENT2=0.001, UNRESOLVED_TEMPLATE=3.132]
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id WYvyTN8gPbLc for <>; Tue, 18 Dec 2012 20:44:29 -0800 (PST)
Received: from ( []) by (Postfix) with ESMTP id 8F9BC21F84F6 for <>; Tue, 18 Dec 2012 20:44:29 -0800 (PST)
Received: from ( by ( with Microsoft SMTP Server (TLS) id 15.0.578.12; Wed, 19 Dec 2012 04:44:27 +0000
Received: from ( by ( with Microsoft SMTP Server (TLS) id 15.0.578.12 via Frontend Transport; Wed, 19 Dec 2012 04:44:26 +0000
Received: from ( by ( with Microsoft SMTP Server (TLS) id 14.2.318.3; Wed, 19 Dec 2012 04:44:08 +0000
Received: from ( by ( with Microsoft SMTP Server id; Wed, 19 Dec 2012 04:42:54 +0000
Received: from mail256-tx2 (localhost []) by (Postfix) with ESMTP id 72E2F7001E7 for <>; Wed, 19 Dec 2012 04:42:54 +0000 (UTC)
X-Forefront-Antispam-Report-Untrusted: CIP:; KIP:(null); UIP:(null); (null);; R:internal; EFV:INT
X-SpamScore: -20
X-BigFish: PS-20(zz98dI9371Id6eah148cI542I1432Izz1de0h1202h1e76h1d1ah1d2ah1082kzz1033IL17326ah8275bh8275dhz31h2a8h668h839h944hd24hf0ah1220h1288h12a5h12a9h12bdh137ah13b6h1441h1504h1537h153bh162dh1631h1758h9a9j1155h)
Received-SPF: softfail (mail256-tx2: transitioning domain of does not designate as permitted sender) client-ip=;; ; ;
X-Forefront-Antispam-Report-Untrusted: SFV:SKI; SFS:; DIR:OUT; SFP:; SCL:-1; SRVR:BY2PR03MB041; LANG:en;
Received: from mail256-tx2 (localhost.localdomain []) by mail256-tx2 (MessageSwitch) id 1355892172570578_24323; Wed, 19 Dec 2012 04:42:52 +0000 (UTC)
Received: from (unknown []) by (Postfix) with ESMTP id 88D90100043; Wed, 19 Dec 2012 04:42:52 +0000 (UTC)
Received: from ( by ( with Microsoft SMTP Server (TLS) id; Wed, 19 Dec 2012 04:42:52 +0000
Received: from ( by ( with Microsoft SMTP Server (TLS) id; Wed, 19 Dec 2012 04:42:51 +0000
Received: from ( by ( with Microsoft SMTP Server (TLS) id 15.0.586.12; Wed, 19 Dec 2012 04:42:37 +0000
Received: from ([]) by ([]) with mapi id 15.00.0586.000; Wed, 19 Dec 2012 04:42:19 +0000
From: Anthony Nadalin <>
To: Dick Hardt <>, Mike Jones <>
Thread-Topic: [jose] Reducing the size of JWS payloads
Thread-Index: Ac3dkDn1ScBaTFOCSwGyAjfBe1wGHgAAqR2AAAQEvdA=
Date: Wed, 19 Dec 2012 04:42:14 +0000
Message-ID: <>
References: <> <>
In-Reply-To: <>
Accept-Language: en-US
Content-Language: en-US
x-originating-ip: []
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Forefront-Antispam-Report: CIP:; CTRY:US; IPV:CAL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(51704002)(377454001)(24454001)(13464002)(52604002)(550184003)(56776001)(74662001)(51856001)(49866001)(76482001)(15202345001)(53806001)(74502001)(77982001)(23726001)(59766001)(54316002)(6806001)(46102001)(50466001)(33646001)(50986001)(31966008)(5343635001)(47776002)(5343655001)(46406002)(16676001)(54356001)(56816002)(44976002)(47976001)(47736001)(4396001)(47446002)(42262001)(24736002); DIR:OUT; SFP:; SCL:1; SRVR:BY2FFO11HUB037; LANG:en;
X-Forefront-PRVS: 070092A9D3
Cc: "" <>
Subject: Re: [jose] Reducing the size of JWS payloads
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: Javascript Object Signing and Encryption <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-Subscribe: <>, <>
X-List-Received-Date: Wed, 19 Dec 2012 04:44:30 -0000

This forces a specific way and does not allow the flexability

-----Original Message-----
From: [] On Behalf Of Dick Hardt
Sent: Tuesday, December 18, 2012 6:45 PM
To: Mike Jones
Cc:; Dick Hardt
Subject: Re: [jose] Reducing the size of JWS payloads

Hi Mike

Thanks for bringing this up again. 

An alternative approach I proposed was to have both the encryption and signing information in one header, and to use the signing signature to ensure integrity instead of having a separate encryption integrity check. This would reduce the size of the token by the size of the integrity value +1 bytes, as well as reduce the processing.

Given that header properties are overloaded now (they have different meanings depending on being a JWE or JWS, we could put the encryption header values into a sub object in the header. Perhaps call that 'enc'.

-- Dick

The process below has 
On Dec 18, 2012, at 6:26 PM, Mike Jones <> wrote:

> I've noticed that more than one person has expressed a desire to reduce the size of JWS payloads before signing.  This especially comes up when nested encryption and signing is being performed.  This note contains a quantitative evaluation of some possible methods of reducing JWS payload size and asks for working group input based upon the data.
> Dick proposed one method below - have a header parameter to say that the payload is already URL-safe and that base64url encoding is not to be performed.  Another way that people have proposed is to allow the use of the "zip" parameter to compress the JWS payload before base64url encoding.  To get some initial data on how the solutions compare, I tried both methods using the sample JWE value in as the JWS payload.
> CURRENT SITUATION:  The JWE is 526 characters in length.  Currently, when used as a JWS payload, base64url encoding it would increase its size to 702 characters - an increase of 33% or 176 characters.
> AVOIDING DOUBLE BASE64URL ENCODING:  If we used a header parameter "b64":false to indicate that no additional base64url encoding is to be performed, the payload would be 176 characters smaller than the current situation.  The encoded header size would increase by 16 characters - the number of characters needed to base64url encode this header parameter value and a comma, for a net decrease in size of 160 characters.  (Yes, parsing the three pieces would be slightly more difficult.)
> APPLYING DEFLATE TO THE PAYLOAD:  Believe it or not, using DEFLATE on this input results in a LARGER output - 536 bytes or a net increase of 10 bytes.  If you think about it, this isn't too surprising, as the encrypted data should contain no usable predictability/redundancy.  Base64url encoding these 536 bytes results in a 715 character payload - an increase of 189 characters or 36%.  Plus, adding "zip":"DEF" to the header adds 16 characters, for a total increase of 29 characters over the current situation.  Clearly a suboptimal choice!
> CONCLUSION:  Clearly, if we're going to enable reduction of the size of JWS payloads, avoiding the double base64url encoding is preferable to zip, which actually makes things worse.
> QUESTION TO WORKING GROUP:  I'm curious whether people would like to see us enable avoiding double base64encoding of JWS payloads when they are already URL-safe.  The space savings are significant; they come at the cost of the JWS parsing becoming [part before first period . part between first and last period . part after last period] rather than the current [part before first period . part between first and second period . part after second period (with no other periods allowed)].  Opinions?
> 				-- Mike
> -----Original Message-----
> From: [] On Behalf Of Dick Hardt
> Sent: Monday, October 29, 2012 8:57 AM
> To:
> Subject: [jose] signing an existing JWT
> Let's say we have created a JWE as such:
> 	headerOne.encryptedKeyOne.initializationVectorOne.ciphertextOne.integritityVectorOne
> This is now the payload to a JWS. Rather than increasing the token size by 4/3 by URL safe base 64 encoding the payload (since it is already URL safe), it would be useful to have a JWS header parameter that indicates the payload was not re-encoded and does not need to be URL safe base 64 decoded.
> As there are more periods than expected in a JWS, decoding would ignore all periods except the first and last one for separating out the header, payload and signature.
> The indicating parameter would seem to be either "tip" or "cty". I'm still confused about the difference between the two parameters, so not sure which one is appropriate.
> -- Dick
> _______________________________________________
> jose mailing list

jose mailing list