<?xml version="1.0" encoding="US-ASCII"?>
<?xml-stylesheet type='text/xsl' href='http://xml.resource.org/authoring/rfc2629.xslt' ?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY rfc2119 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC3447 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3447.xml">
<!ENTITY RFC4627 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4627.xml">
<!ENTITY RFC4648 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4648.xml">
]>
<?rfc toc="yes"?>
<?rfc tocompact="yes"?>
<?rfc tocdepth="3"?>
<?rfc tocindent="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<rfc category="std" docName="draft-jones-json-web-key-01"
     ipr="trust200902">
  <front>
    <title abbrev="JWK">JSON Web Key (JWK)</title>

    <author fullname="Michael B. Jones" initials="M.B." surname="Jones">
      <organization>Microsoft</organization>
      <address>
        <email>mbj@microsoft.com</email>
        <uri>http://self-issued.info/</uri>
      </address>
    </author>

    <date day="25" month="July" year="2011" />

    <area>Security</area>

    <keyword>RFC</keyword>
    <keyword>Request for Comments</keyword>
    <keyword>I-D</keyword>
    <keyword>Internet-Draft</keyword>
    <keyword>Assertion</keyword>
    <keyword>Simple Web Token</keyword>
    <keyword>Security Token</keyword>
    <keyword>SWT</keyword>
    <keyword>JavaScript Object Notation</keyword>
    <keyword>JSON</keyword>
    <keyword>JSON Web Token</keyword>
    <keyword>JWT</keyword>
    <keyword>JSON Web Signature</keyword>
    <keyword>JWS</keyword>
    <keyword>JSON Web Encryption</keyword>
    <keyword>JWE</keyword>
    <keyword>JSON Web Key</keyword>
    <keyword>JWK</keyword>

    <abstract>
      <t>
	A JSON Web Key (JWK) is a JSON data structure that represents
	a set of public keys.
      </t>
    </abstract>

    <note title="Requirements Language">
      <t>
	The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL
	NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and
	"OPTIONAL" in this document are to be interpreted as described
	in <xref target="RFC2119">RFC 2119</xref>.
      </t>
    </note>
  </front>

  <middle>
    <section title="Introduction">
      <t>
	A JSON Web Key (JWK) is a JSON data structure that represents
	a set of public keys as a JSON object <xref
	target="RFC4627" />.  The JWK format is used to
	represent bare keys; representing certificate chains is an
	explicit non-goal of this specification.  JSON Web Keys are
	referenced in JSON Web Signatures (JWSs) <xref target="JWS" />
	using the <spanx style="verb">jku</spanx> (JSON Key URL)
	header parameter.
      </t>
    </section>

    <section title="Terminology">
      <t>
	<list style="hanging">

          <t hangText="JSON Web Key (JWK)">
	    A JSON data structure that represents a set of public
	    keys.  A JWK consists of a single JWK Container Object
	    that contains an array of JWK Key Objects.
	  </t>
	  <t hangText="JWK Container Object">
	    A JSON object that contains an array of JWK Key Objects as
	    a member.
	  </t>
	  <t hangText="JWK Key Object">
	    A JSON object that represents a single public key.
	  </t>
          <t hangText="Base64url Encoding">
	    For the purposes of this specification, this term always
	    refers to the URL- and filename-safe Base64 encoding
	    described in <xref target="RFC4648">RFC 4648</xref>,
	    Section 5, with the '=' padding characters omitted, as
	    permitted by Section 3.2.
	  </t>
        </list>
      </t>
    </section>

    <section title="JSON Web Key (JWK) Overview">

      <t>
	It is sometimes useful to be able to reference public key
	representations, for instance, in order to verify the
	signature on content signed with the corresponding private
	key.  The JSON Web Key (JWK) data structure provides a
	convenient JSON representation for sets of public keys
	utilizing either the Elliptic Curve or RSA families of algorithms.
      </t>

      <section title="Example JWK" anchor="ExampleJWK">

	<t>
	  The following example JWK contains two public keys: one
	  using an Elliptic Curve algorithm and a second one using an RSA
	  algorithm.  In both cases, integers are represented using
	  the base64url encoding of their big endian representations.
	</t>

	<artwork><![CDATA[{"keyvalues":
   [
     {"algorithm":"EC",
      "curve":"P-256",
      "x":"MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4",
      "y":"4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM",
      "use":"encryption",
      "keyid":"1"},
 
    {"algorithm":"RSA",
      "modulus": "0vx7agoebGcQSuuPiLJXZptN9nndrQmbXEps2aiAFbWhM78LhWx4cbbfAAtVT86zwu1RK7aPFFxuhDR1L6tSoc_BJECPebWKRXjBZCiFV4n3oknjhMstn64tZ_2W-5JsGY4Hc5n9yBXArwl93lqt7_RN5w6Cf0h4QyQ5v-65YGjQR0_FDW2QvzqY368QQMicAtaSqzs8KJZgnYb9c7d0zgdAZHzu6qMQvRL5hajrn1n91CbOpbISD08qNLyrdkt-bFTWhAI4vMQFh6WeZu0fM4lFd2NcRwr3XPksINHaQ-G_xBniIqbw0Ls1jF44-csFCur-kEgU8awapJzKnqDKgw",
      "exponent":"AQAB",
      "keyid":"2011-04-29"}
   ]
 }
]]></artwork>

      </section>
    </section>

    <section title="JWK Format">

      <t>
	A JWK consists of a JWK Container Object, which is a JSON
	object that contains an array of JWK Key Objects as a member.
	This section specifies the format of these objects.
      </t>

      <section title="JWK Container Object Format">
	<t>
	  A JWK Container Object is a JSON object containing a
	  specific member.  This member is:
	</t>

	<texttable title="JWK Container Object Member">
	  <ttcol align="left">Member Name</ttcol>
	  <ttcol align="left">JSON Value Type</ttcol>
	  <ttcol align="left">Container Object Member Semantics</ttcol>

	  <c>keyvalues</c>
	  <c>array</c>
	  <c>
	    The <spanx style="verb">keyvalues</spanx> member value
	    contains an array of JWK Key Objects.  This member is
	    REQUIRED.
	  </c>

	</texttable>

	<t>
	  Additional members MAY be present in the JWK Container
	  Object.  If present, they MUST be understood by
	  implementations using that JWK.
	</t>
      </section>

      <section title="JWK Key Object Format">
	<t>
	  A JWK Key Object is a JSON object containing specific
	  members.  Those members that are common to all key types are
	  as follows:
	</t>

	<texttable title="JWK Key Object Members">
	  <ttcol align="left">Member Name</ttcol>
	  <ttcol align="left">JSON Value Type</ttcol>
	  <ttcol align="left">Key Object Member Semantics</ttcol>

	  <c>algorithm</c>
	  <c>string</c>
	  <c>
	    The <spanx style="verb">algorithm</spanx> member
	    identifies the cryptographic algorithm family used with the key.
	    Values defined by this specification are <spanx
	    style="verb">EC</spanx> and <spanx
	    style="verb">RSA</spanx>.  Specific additional members are
	    required to represent the key, depending upon the <spanx
	    style="verb">algorithm</spanx> value.  The <spanx
	    style="verb">algorithm</spanx> value is case sensitive.
	    This member is REQUIRED.
	  </c>

	  <c>use</c>
	  <c>string</c>
	  <c>
	    The <spanx style="verb">use</spanx> member identifies the
	    intended use of the key.  Values defined by this
	    specification are <spanx style="verb">signature</spanx>
	    and <spanx style="verb">encryption</spanx>.  Other values
	    MAY be used.  The <spanx style="verb">use</spanx> value is
	    case sensitive.  This member is OPTIONAL.
	  </c>

	  <c>keyid</c>
	  <c>string</c>
	  <c>
	    The <spanx style="verb">keyid</spanx> (Key ID) member can
	    be used to match a specific key.  This can be used, for
	    instance, to choose among a set of keys within the JWK
	    during key rollover.  The <spanx
	    style="verb">keyid</spanx> value MAY correspond to a JWS
	    <spanx style="verb">kid</spanx> value.  The interpretation
	    of the <spanx style="verb">keyid</spanx> value is
	    unspecified.  This member is OPTIONAL.
	  </c>

	</texttable>

	<t>
	  Additional members MAY be present in the JWK Key Object.  If
	  present, they MUST be understood by implementations using
	  that key.
	</t>

	<section title="JWK Key Object Members for Elliptic Curve Keys">
	  <t>
	    JWKs can represent Elliptic Curve <xref
	    target="FIPS.186-3" /> keys.  In
	    this case, the <spanx style="verb">algorithm</spanx>
	    member value MUST be <spanx style="verb">EC</spanx>.
	    Furthermore, these additional members MUST be present:
	  </t>

	  <texttable title="Members for Elliptic Curve Keys">
	    <ttcol align="left">Member Name</ttcol>
	    <ttcol align="left">JSON Value Type</ttcol>
	    <ttcol align="left">Key Object Member Semantics</ttcol>

	    <c>curve</c>
	    <c>string</c>
	    <c>
	      The <spanx style="verb">curve</spanx> member identifies
	      the cryptographic curve used with the key.  Values
	      defined by this specification are <spanx
	      style="verb">P-256</spanx>, <spanx
	      style="verb">P-384</spanx> and <spanx
	      style="verb">P-521</spanx>.  Additional <spanx
	      style="verb">curve</spanx> values MAY be used, provided
	      they are understood by implementations using that Elliptic Curve
	      key.  The <spanx style="verb">curve</spanx> value is
	      case sensitive.
	    </c>

	    <c>x</c>
	    <c>string</c>
	    <c>
	      The <spanx style="verb">x</spanx> member contains the x
	      coordinate for the elliptic curve point.  It is
	      represented as the base64url encoding of the
	      coordinate's big endian representation.
	    </c>

	    <c>y</c>
	    <c>string</c>
	    <c>
	      The <spanx style="verb">y</spanx> member contains the y
	      coordinate for the elliptic curve point.  It is
	      represented as the base64url encoding of the
	      coordinate's big endian representation.
	    </c>

	  </texttable>

	</section>

	<section title="JWK Key Object Members for RSA Keys">
	  <t>
	    JWKs can represent RSA <xref target="RFC3447" /> keys.  In
	    this case, the <spanx style="verb">algorithm</spanx>
	    member value MUST be <spanx style="verb">RSA</spanx>.
	    Furthermore, these additional members MUST be present:
	  </t>

	  <texttable title="Members for RSA Keys">
	    <ttcol align="left">Member Name</ttcol>
	    <ttcol align="left">JSON Value Type</ttcol>
	    <ttcol align="left">Key Object Member Semantics</ttcol>

	    <c>modulus</c>
	    <c>string</c>
	    <c>
	      The <spanx style="verb">modulus</spanx> member contains
	      the modulus value for the RSA public key.  It is
	      represented as the base64url encoding of the value's big
	      endian representation.
	    </c>

	    <c>exponent</c>
	    <c>string</c>
	    <c>
	      The <spanx style="verb">exponent</spanx> member contains
	      the exponent value for the RSA public key.  It is
	      represented as the base64url encoding of the value's big
	      endian representation.
	    </c>

	  </texttable>

	</section>

      </section>
    </section>

    <section title="Base64url encoding as used by JWKs" anchor="base64urllogic">
      <t>
	JWKs make use of the base64url encoding as defined in <xref
	target="RFC4648">RFC 4648</xref>. As allowed by Section 3.2 of
	the RFC, this specification mandates that base64url encoding
	when used with JWKs MUST NOT use padding.  Notes on
	implementing base64url encoding can be found in the JWS <xref
	target="JWS" /> specification.
      </t>
    </section>

    <section title="IANA Considerations" anchor="IANA">
      <t>
	No IANA actions are required by this specification.
      </t>
    </section>

    <section title="Security Considerations" anchor="Security">
      <t>
	TBD
      </t>
    </section>
  </middle>

  <back>
    <references title="Normative References">
      &rfc2119;
      &RFC3447;
      &RFC4627;
      &RFC4648;

      <reference anchor="FIPS.186-3">
        <front>
          <title>Digital Signature Standard (DSS)</title>

          <author>
            <organization>National Institute of Standards and
            Technology</organization>
          </author>

          <date month="June" year="2009" />
        </front>
        <format target="http://csrc.nist.gov/publications/fips/fips186-3/fips_186-3.pdf" type="PDF" />
        <seriesInfo name="FIPS" value="PUB 186-3" />
      </reference>

    </references>

    <references title="Informative References">

      <reference anchor="MagicSignatures">
        <front>
          <title>Magic Signatures</title>

          <author fullname="John Panzer (editor)" initials="J." surname="Panzer (editor)"></author>

          <author fullname="Ben Laurie" initials="B." surname="Laurie"></author>

          <author fullname="Dirk Balfanz" initials="D." surname="Balfanz"></author>

          <date month="August" year="2010" />
        </front>
        <format target="http://salmon-protocol.googlecode.com/svn/trunk/draft-panzer-magicsig-experimental-00.html" type="HTML" />
      </reference>

      <reference anchor="JWS">
        <front>
          <title>JSON Web Signature (JWS)</title>

	  <author fullname="Michael B. Jones" initials="M.B." surname="Jones">
	    <organization>Microsoft</organization>
	    <address>
	      <email>mbj@microsoft.com</email>
	      <uri>http://self-issued.info/</uri>
	    </address>
	  </author>

	  <author fullname="Dirk Balfanz" initials="D." surname="Balfanz">
	    <organization>Google</organization>
	    <address>
	      <email>balfanz@google.com</email>
	    </address>
	  </author>

	  <author fullname="John Bradley" initials="J." surname="Bradley">
	    <organization>independent</organization>
	    <address>
	      <email>ve7jtb@ve7jtb.com</email>
	    </address>
	  </author>

	  <author fullname="Yaron Y. Goland" initials="Y.Y." surname="Goland">
	    <organization>Microsoft</organization>
	    <address>
	      <email>yarong@microsoft.com</email>
	    </address>
	  </author>

	  <author fullname="John Panzer" initials="J." surname="Panzer">
	    <organization>Google</organization>
	    <address>
	      <email>jpanzer@google.com</email>
	    </address>
	  </author>

	  <author fullname="Nat Sakimura" initials="N." surname="Sakimura">
	    <organization>Nomura Research Institute</organization>
	    <address>
	      <email>n-sakimura@nri.co.jp</email>
	    </address>
	  </author>

	  <author fullname="Paul Tarjan" initials="P." surname="Tarjan">
	    <organization>Facebook</organization>
	    <address>
	      <email>pt@fb.com</email>
	    </address>
	  </author>

	  <date day="18" month="July" year="2011" />
        </front>
        <format target="http://self-issued.info/docs/draft-jones-json-web-signature.html" type="HTML" />
      </reference>

    </references>

    <section title="Acknowledgements" anchor="Acknowledgements">

      <t>
	A JSON representation for RSA public keys was previously
	introduced in <xref target="MagicSignatures">Magic
	Signatures</xref>.
      </t>

    </section>

    <section title='Document History'>
      <t>
        -01
        <list style='symbols'>
          <t>
	    Changed <spanx style="verb">algorithm</spanx> member value
	    for Elliptic Curve keys from <spanx
	    style="verb">ECDSA</spanx> to <spanx
	    style="verb">EC</spanx>, since Elliptic Curve keys can be
	    used with more algorithms than just the Elliptic Curve
	    Digital Signature Algorithm (ECDSA).
          </t>
	  <t>
	    Added OPTIONAL <spanx style="verb">use</spanx> member to
	    identify intended key usage, especially since the same
	    Elliptic Curve key should not be used for both signing and
	    encryption operations.
	  </t>
        </list>
      </t>
      <t>
        -00
        <list style='symbols'>
          <t>
	    Created first version based upon decisions made at the
	    Internet Identity Workshop (IIW), as documented at
	    http://self-issued.info/?p=390.
          </t>
        </list>
      </t>
    </section>     

  </back>
</rfc>
