Re: [jose] Should we delete the "typ" header field

"Manger, James H" <James.H.Manger@team.telstra.com> Thu, 30 May 2013 06:07 UTC

Return-Path: <James.H.Manger@team.telstra.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 38D1121F9080 for <jose@ietfa.amsl.com>; Wed, 29 May 2013 23:07:56 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.901
X-Spam-Level:
X-Spam-Status: No, score=-0.901 tagged_above=-999 required=5 tests=[AWL=-0.001, BAYES_00=-2.599, HELO_EQ_AU=0.377, HOST_EQ_AU=0.327, HTML_MESSAGE=0.001, RELAY_IS_203=0.994]
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 sCbPvALHdLxC for <jose@ietfa.amsl.com>; Wed, 29 May 2013 23:07:50 -0700 (PDT)
Received: from ipxcno.tcif.telstra.com.au (ipxcno.tcif.telstra.com.au [203.35.82.208]) by ietfa.amsl.com (Postfix) with ESMTP id 6497C21F93F4 for <jose@ietf.org>; Wed, 29 May 2013 23:07:47 -0700 (PDT)
X-IronPort-AV: E=Sophos; i="4.87,768,1363093200"; d="scan'208,217"; a="132829242"
Received: from unknown (HELO ipcani.tcif.telstra.com.au) ([10.97.216.200]) by ipocni.tcif.telstra.com.au with ESMTP; 30 May 2013 16:07:45 +1000
X-IronPort-AV: E=McAfee;i="5400,1158,7090"; a="85427837"
Received: from wsmsg3755.srv.dir.telstra.com ([172.49.40.196]) by ipcani.tcif.telstra.com.au with ESMTP; 30 May 2013 16:07:45 +1000
Received: from WSMSG3153V.srv.dir.telstra.com ([172.49.40.159]) by WSMSG3755.srv.dir.telstra.com ([172.49.40.196]) with mapi; Thu, 30 May 2013 16:07:45 +1000
From: "Manger, James H" <James.H.Manger@team.telstra.com>
To: "jose@ietf.org" <jose@ietf.org>
Date: Thu, 30 May 2013 16:07:44 +1000
Thread-Topic: [jose] Should we delete the "typ" header field
Thread-Index: Ac5ct7bsKO37MhFARcu9P04lU2GoQQAHNwHw
Message-ID: <255B9BB34FB7D647A506DC292726F6E1151AD1B9CF@WSMSG3153V.srv.dir.telstra.com>
References: <02b701ce5cb8$46ae77e0$d40b67a0$@augustcellars.com>
In-Reply-To: <02b701ce5cb8$46ae77e0$d40b67a0$@augustcellars.com>
Accept-Language: en-US, en-AU
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
acceptlanguage: en-US, en-AU
Content-Type: multipart/alternative; boundary="_000_255B9BB34FB7D647A506DC292726F6E1151AD1B9CFWSMSG3153Vsrv_"
MIME-Version: 1.0
Subject: Re: [jose] Should we delete the "typ" header field
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: Thu, 30 May 2013 06:07:56 -0000

> Can anybody justify why this field should be present in the document – or should it just disappear?

It seems there are at least 3 different meanings given to "typ" in the header of a JOSE message:

[1] The "typ" value indicates the serialization of the JOSE message. For example, "typ":"JWE" and "typ":"JWE+JSON" distinguish the compact (dot-separated-b64-blobs) and JSON serializations.

[2] The "typ" value indicates the high-level semantics of the JOSE structure. For example, "typ":"JWE" and "typ":"JWS" distinguish the semantics defined in the separate JWE and JWS specifications.

[3] The "typ" value indicates the application-layer semantics of the message. For example, "typ":"JWT" value indicates that the message conveys a set of claims (as a JSON object) wrapped as a JOSE message (either unprotected, signed, MACed, encrypted, or signed then encrypted) that use the compact serialization.

Indicating the serialization [1] does not seem helpful as the recipient needs to know the serialization before they can extract the header to see the "typ" value. Indicating the serialization is actually harmful as it tightly couples a message to one serialization, whereas serialization is generally thought of as a transport-layer choice that is independent of the message security or semantics.

Indicating the high-level semantics of the JOSE structure [2] is slightly useful so a message can be switched to different code according to its structure. It is not that useful, however, as further switching is required to distinguish different modes (eg unprotected vs asymmetric signature vs MAC). This meaning only helps if the field is made mandatory, and the presence/absence of the "enc" field or looking up the class of the "alg" value are not specified as alternatives.
Being able to indicate application-layer semantics [3] could theoretically be useful. Perhaps the "profile" attribute or "rel=’profile’" link relation in HTML5 is analogous. In this case JOSE should not define values for the field. "JWS", "JWS+JSON", "JWE", and "JWE+JSON" make no sense as application-layer semantics — and certainly not inside the JOSE message.

Most (all?) of the many specs mentioning the "typ" field make it optional, and if they suggest particular "typ" values those are only “MAY”s or “SHOULD”s — not “MUST”s. Consequently, apps cannot rely on "typ" regardless of its meaning.


My suggestions:

* For [1], define two media types to distinguish the two serializations, not a header field.

*  1st preference for [3], drop it from JOSE specs; let an application using JOSE (eg JWT) define a field (and value) for this. If the application defines the field in a generic fashion for reuse by other applications that is a nice bonus.

* 2nd preference for [3], define a field (but no values) that can hold an application-layer semantics identifier – but only put this definition in a spec that defines JOSE messages as a whole (not specs specific to JWE or JWS). Use a different name: "app" or "profile" or "mean"ing or "pur"pose.

* For [2], define a mandatory field that indicates the semantics of the JOSE structure at a low enough level that a JOSE implementation built on top of a crypto library could (almost) work without needing to recognize the "alg" value. "typ" would have been a reasonable name for this field but is now too polluted with confusion. How about "t"?
Consider for instance a JOSE implementation that only supports "alg":"HS256". To add support for "alg":"HS3" (HMAC with SHA-3) minimal (if any) new code is needed in a JOSE layer: perhaps an extra table entry mapping the JOSE label "HS3" to a crypto library label (eg "HmacSHA3"). "t":"mac" can accompany both these algs. To support "alg":"RS512", in contrast, requires calls to different crypto library functions (knowing the difference between public & private keys for instance). This deserves a separate value, say, "t":"sig".

--
James Manger