<?xml version='1.0'?>
<!DOCTYPE rfc SYSTEM 'rfc2629.dtd'>
<rfc ipr="trust200902" docName="draft-hallambaker-json-key-exchange-02" category="info">
<?rfc toc="yes"?>  
<?rfc symrefs="yes"?>  
<?rfc sortrefs="yes"?>  
<?rfc compact="yes"?>  
<?rfc subcompact="no"?>  
<front>
<title abbrev="JSON Web Service Binding v1.0">JSON Key Exchange</title>
<author fullname="Phillip Hallam-Baker" initials="P. M." surname="Hallam-Baker">
<organization>Comodo Group Inc.</organization>
<address>
<email>philliph@comodo.com</email>
</address>
</author>
<date day="10" month="April" year="2018"/>
<area/>
<workgroup/>
<abstract>
<t>
The JSON Key Exchange</t>
<t>
This document is also available online at <eref target="http://prismproof.org/Documents/draft-hallambaker-json-key-exchange.html">
http://prismproof.org/Documents/draft-hallambaker-json-key-exchange.html</eref>
.</t>
</abstract>
</front>
<middle>
<section title="Introduction" anchor="s-1">
<t>
This document describes a lightweight key agreement mechanism using between 2 and four Diffe-Hellman or Elliptic Curve Diffie-Hallman keys. The mechanism may be used establish a shared session key with authentication of any or none of the initiator and the responder.</t>
<t>
The approach described is similar to that adopted in the X3DH Key agreement <xref target="X3DH">
</xref>
 used in Signal.</t>
<t>
The objective of the key exchange is limited to establishing a shared secret between two mutually authenticated parties that cannot be derived by any other parties and cannot be reconstructed by either of the parties after the ephemeral contributions have been deleted. </t>
<t>
The key exchange is intended for use as one component in a multi-layer security approach in which comprehensive security is provided through use of encryption and authentication at multiple layers in the protocol stack.</t>
<figure>
<preamble>
[[This figure is not viewable in this format. The figure is available at <eref target="http://prismproof.org/Documents/draft-hallambaker-json-key-exchange.html">http://prismproof.org/Documents/draft-hallambaker-json-key-exchange.html</eref>.]]</preamble>
<artwork>
</artwork>
<postamble>
Multi-layer security</postamble>
</figure>
<t>
Specifically, this key exchange is intended for use at the presentation layer (e.g. authenticate and encrypt HTTP message bodies) to establish keys for authentication and optional encryption of messages in Web Service transactions. </t>
<t><list style="hanging">
<t hangText="Data Layer">
Encryption of cryptographic keys, protocol configuration profiles.</t>
<t hangText="Presentation Layer">
Authentication of parties to a Web Service transaction.</t>
<t hangText="Transport Layer">
Protect metadata against interception at single point on the message path (link or node)</t>
<t hangText="Link Layer">
Protect messages against traffic analysis by means of interception at multiple points on the message path </t>
</list></t>
</section>
<section title="Definitions" anchor="s-2">
<t>
This section presents the related specifications and standard, the terms that are used as terms of art within the documents and the terms used as requirements language.</t>
<section title="Requirements Language" anchor="s-2_1">
<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 [RFC2119].</t>
</section>
<section title="Defined Terms" anchor="s-2_2">
<t>
No terms of art are defined.</t>
</section>
<section title="Related Specifications" anchor="s-2_3">
<t>
JSON Key Exchange is used extensively in the Mathematical Mesh and related protocols <xref target="draft-hallambaker-mesh-architecture">
</xref>
. </t>
</section>
<section title="Implementation Status" anchor="s-2_4">
<t>
The implementation status of the reference code base is described in the companion document <xref target="draft-hallambaker-mesh-developer">
</xref>
.</t>
</section>
</section>
<section title="Key Exchange Protocol" anchor="s-3">
<section title="Parameters" anchor="s-3_1">
<t>
The following parameters are defined</t>
<t><list style="hanging">
<t hangText="Algorithm">
The key exchange protocol. Diffie Hellman in discrete log, EdECDH25519 or EdECDH448.<xref target="RFC8032">
</xref>
</t>
<t hangText="Key Derivation Function">
The key derivation function. This is always HKDF <xref target="RFC5869">
</xref>
</t>
<t hangText="Key Wrap Function">
The Key Wrap function. This is always RFC3394 <xref target="RFC3394">
</xref>
</t>
</list></t>
<t>
It should be noted that the algorithm described makes use of the Edwards form of the curve and not the Montgomery form described in <xref target="RFC7748">
</xref>
. While these curves are isomorphic, implementations of the Montgomery ladder do not lend themselves easily to the approach shown.</t>
</section>
<section title="Notation" anchor="s-3_2">
<t>
The notation adopted in <xref target="X3DH">
</xref>
 is applied with minor modifications.</t>
<t><list style="hanging">
<t hangText="X ||Y">
The concatenation of the byte sequence X followed by the byte sequence Y.</t>
<t hangText="KE (PK1, PK2)">
The result of performing the key exchange (Diffie-Hellman or Elliptic Curve Diffie Hellman) with the public parameters of PK1 and the private parameters of PK2.</t>
<t hangText="PK1+PK2">
The public, private key pair formed by combining the public, private parameters of PK1 and PK2.</t>
<t hangText="Expand (PRK, info, L)">
The KDF expansion function that derives a key of length L bits from the Pre Random Key PRK using the string info as the salt.</t>
<t hangText="Extract (IKM, salt)">
The KDF extraction function that derives a Pre-Random Key from the Initial Keying Material IKM and the salt value salt. If the salt value is specified as 0, the default salt of a string of zero bits the same length as the Pre-Random Key to be extracted is used.</t>
</list></t>
</section>
<section title="Roles" anchor="s-3_3">
<t><list style="hanging">
<t hangText="Client">
The party that initiates the key exchange</t>
<t hangText="Service">
The party that responds to the key exchange</t>
</list></t>
</section>
<section title="Keys" anchor="s-3_4">
<t><list style="hanging">
<t hangText="IKC">
The identification key of the client. The encoding of this key MAY include one or more credentials such as a Mesh personal profile or an X.509 certificate binding the key to an identity.</t>
<t hangText="IKS&amp;nbsp;">
The identification key of the service. The encoding of this key MAY include one or more credentials such as a Mesh personal profile or an X.509 certificate binding the key to an identity.</t>
<t hangText="EKC&amp;nbsp;">
The ephemeral key of the client.</t>
<t hangText="EKS&amp;nbsp;">
The ephemeral key of the service.</t>
</list></t>
</section>
<section title="Derived Keys" anchor="s-3_5">
<t>
The key derivation function is used to derive separate keys for different purposes as shown below. The value L is the number of bits requires to key the algorithm specified. The salt value used to derive the PRK from the IKM is either the default salt value (all zeros) or the previous Rekey value as described below.</t>
<t><list style="hanging">
<t hangText="AK (PRK)">
Authentication Key = Expand (PRK, "authentication", L)</t>
<t hangText="EK (PRK)">
Encryption Key = Expand (PRK, "encryption", L)</t>
<t hangText="RA (PRK)">
Rekey Key = Expand (PRK, "rekey", L)</t>
<t hangText="W (PRK)">
Witness value= Expand (PRK, "witness", L)</t>
</list></t>
</section>
<section title="Initial Keying Request" anchor="s-3_6">
<t>
A key exchange request is either an initial key exchange request or a rekeying request. An initial key exchange request MAY be issued at any time but a rekeying request cannot be sent until at least one initial keying request has been completed.</t>
<t>
Rekey messages are authenticated under a Rekey shared secret established in a previous session. This may be the immediately preceding session or any prior session whose rekey token has not expired.</t>
<section title="Initial Request Message" anchor="s-3_6_1">
<t>
The client sends their identity and ephemeral key to the service. { IKC, EKC }</t>
<t>
If the request message is an initial keying request, a credential associated with the identity key MAY be provided. The request MAY be authenticated by means of a digital signature.</t>
</section>
<section title="Initial Response Message" anchor="s-3_6_2">
<t>
The service calculates the IKM value as follows:</t>
<t>
IKM = KE (IKC + EKC, IKS + EKS)</t>
<t>
PRK = Extract (IKM, 0)</t>
<t>
The service returns the values { IKS, EKS, W(IKM) } in a message authenticated under AK(IKM)</t>
</section>
</section>
<section title="Rekeying." anchor="s-3_7">
<t>
Unless the key agreement is performed to a device of restricted capability, rekeying imposes minimal load on client or server and can be performed often, particularly if the Ed25519 curve is used for rekeying.</t>
<t>
The state required for rekeying is separate from the keys used to encrypt and/or authenticate messages. This allows an application to store the rekeying key between communication sessions without risk of compromising the confidentiality or integrity of messages.</t>
<t>
The use of the chaining salt ensures that rekeying cannot compromise the security of an already established key, even if a weaker key exchange algorithm is used. Thus a client MAY use an Ed488 key to perform an initial key exchange and then preform rekey operations using a </t>
<section title="Rekeying Request Message" anchor="s-3_7_1">
<t>
The client sends a new ephemeral key to the service. { CEK }</t>
<t>
The request message MUST be authenticated under the rekeying key of the shared secret of any unexpired session previously agreed. This allows the credentials of the parties to be omitted while providing the advantage of establishing a fresh forward secrecy session. </t>
</section>
<section title="Rekeying Response Message" anchor="s-3_7_2">
<t>
The service calculates the IKM value as follows:</t>
<t>
IKM = KE (EKC, EKS)</t>
<t>
The service returns the values { EKS, W(IKM) } in a message authenticated under AK(IKM)</t>
<t>
PRK = Extract (IKM, RA')</t>
<t>
Where RA' is the previous rekeying key output.</t>
</section>
</section>
<section title="Initial Key Exchange Example" anchor="s-3_8">
<t>
Alice requests access to a service using her account identifier alice@example.com. She has already registered her Mesh personal profile with the service where it is bound to her account identifier as the corresponding credential. </t>
<t>
The Key exchange request is: </t>
<figure anchor="s-3_8-3">
<artwork>
<![CDATA[POST /.well-known/jwcexchange/HTTP/1.1
Host: example.com
Content-Length: 1069

{
  "ExchangeRequest": {
    "ClientCredential": {
      "PublicKeyDH": {
        "kid": "MDPVX-5ZINS-2CVEJ-HD5JC-SUM5J-MBY6P",
        "Domain": "
YE6bnq1MlX5ojaJto6PLP_PEwA",
        "Public": "
Al82juBrEyBpqJ629CFSLAKK9NHL4IA12i8Y68iovIQ8gQyvfvNf5LnU6IGE3w2h
hAl87JudDRDhVpQvlEmc-AMD708PKctQyiIqC8QWyYOtOOfggNesxocvMmkifbbf
eMiJYIA_Qdkgfmv0A3w20NxRI1kuLedR1i_GTP9uzobFMM-gQCSPt_J-WQzLdhTd
ciBybdFCt2TWsVY5TGdesyHB_h3qoPWDmymEtINIPcJ4RUrEsESKAzY81y1sWZP4
HdIVDIe0W6DbuACwqsIuxfwum24Fz-TNdnOLKR-leio3PWU2yaFjDoSAcyrzcbHM
mTEXollCd0s9egPgqWTmygA"}},
    "ClientNonce": {
      "PublicKeyDH": {
        "kid": "MB2H7-GOJ5V-GQMXB-C76DD-XQ655-B3VRV",
        "Domain": "
YE6bnq1MlX5ojaJto6PLP_PEwA",
        "Public": "
Qs8MsGjbVNL1q4CZh_i5G2uNFQr3nenViue5gPivstrb3eG-WxhniMZVWgV4G16l
GXNoIRNzW7ksjB0kSgIb6wemO-qF_uOadKxRVPub1xM4OTle9KGJSvYU4AVEmNbp
iSsUnmV1GWQBSzlYTym5xn3o7p0CowdONPZfKyZsF-elcT6Tn_-u-Jlw37uhQlq3
z27EQlk7QJn5GWww7HeJYEoJmGBCGP1KW4IfYlC6vwfEPt8MrdBhtSpIsTH9bFzK
O4_kD2eNKdM0CmI7YXgyrTcr1y6n0mKoy7yKHv-ujYOn-6TaHc6rixeElMTWnxTF
S8LXrMxS0QczdVmteLeweQ"}}}}]]></artwork>
</figure>
<t>
The Keyu Exchange response is </t>
<figure anchor="s-3_8-5">
<artwork>
<![CDATA[HTTP/1.1 200 OK
Date: Wed 11 Apr 2018 03:16:06
Content-Length: 1360

{
  "ExchangeResponse": {
    "Status": 201,
    "StatusDescription": "Operation completed successfully",
    "Ticket": "
T3BhcXVlIHZhbHVlIG91dHNpZGUgc2NvcGUgb2Ygc3BlY2lmaWNhdGlvbg",
    "Witness": "
j9kns3jGzq426HYhUbH3oRbQ7mV8iYdjX2QJcU4uaIs",
    "ServerCredential": {
      "PublicKeyDH": {
        "kid": "MCTPR-KNR5M-QOL4D-XD3N4-BSQPO-4LGG3",
        "Domain": "
YE6bnq1MlX5ojaJto6PLP_PEwA",
        "Public": "
BoAJI2_T34PLENkUPLRu0tWXKm9_C_K5pid6DAoe5pMqNJo7BuYGeC8csTYJoM4R
yiRVF_mE5UfQ4HQRHl2Xm8rw4dhJ5RmXSYqygo4nI_j9DdZqrJv33P45xOFoyHYf
etN7u-iaCpuIShYc_4XUsEaxjp6gMun887MWUiU-EEREjbszLz02cD16Lti4S1dJ
t_lYNW5HgvxWgV1in_WUEBK6N_P1N6nqmb5lXmdFOiWKX9wWdvJAvIJTmutyfrzY
gyXzUlB48BJ8c5e3pLsC5ByDbkiTEi9rFcQKqfmxA-1WL4-VV9mkVlbRgQMZ-p6s
5Xjg8NqMxX86rqgV0uKflwA"}},
    "ServerNonce": {
      "PublicKeyDH": {
        "kid": "MC57P-JXPTK-C4VHF-WDRUD-3M3JT-XBRT4",
        "Domain": "
YE6bnq1MlX5ojaJto6PLP_PEwA",
        "Public": "
uaJOoFSxJlSd7ZJQkyde7l-FRah65Obsjxd8PN7pQWL230NUNiRLrRmCXB6acxIF
cc0PiwIxEbfxDriu5FXn-XBiKk7ztQ_XH90nhkpFVXrDQxCNtK7FJPN-DklZ0zwG
ypE67Jf3Ud5-SIhrULoRcTRW5OkZ7A9GKwBeHz3V6YgfOYk-3_6w3cX646S0LHUU
jYlGCT9pHWm6StC2WKx-rTnJ5bOgr-7kOUrogR_zbzwQj-hFkVEIQK_Cr2vBnKCW
k3AW6d3N-_IO4_FOKMXMbPpFgKLHHYFNF06C9WfgPQNw6t3-HlVeKmWIiu4tDpGG
pahCe0WVlcnP0iK8Nj_BBg"}},
    "Encryption": ["A256CBC-HS512"],
    "Authentication": ["HS512"]}}]]></artwork>
</figure>
<t>
Note that the example has the witness value but does not authenticate the signed  result at present. Perhaps it would be better to create the witness value from the  ticket data which eliminates the need for authenticating the response?? </t>
</section>
<section title="Rekey Example" anchor="s-3_9">
<t>
(TBS) </t>
</section>
</section>
<section title="Key Exchange Service" anchor="s-4">
<t>
Supports key exchange to establish a shared secret and bound ticket between a client and a service </t>
<t><list style="hanging">
<t hangText="HTTP Well Known Service Prefix: /.well-known/jwcexchange"></t>
</list></t>
<t>
Every Recrypt Service transaction consists of exactly one request followed by exactly one response. </t>
<section title="Shared classes" anchor="s-4_1">
<section title="Structure: Algorithms" anchor="s-4_1_1">
<t>
Describes an algorithm suite. Each suite consists of sets of authentication and encryption algorithms which are mutually compatible. i.e. the counterparty MAY select any one of the encryption algorithms and use it with any one of the  authentication algorithms. </t>
<t><list style="hanging">
<t hangText="Encryption: String [0..Many]">
Algorithm identifiers of encryption and authenticated encryption algorithms offered </t>
<t hangText="Authentication: String [0..Many]">
Authentication algorithm offer  </t>
</list></t>
</section>
</section>
<section title="Utility Transactions" anchor="s-4_2">
</section>
<section title="Transaction: Exchange" anchor="s-4_3">
<t><list style="hanging">
<t hangText="Request: ExchangeRequest">
</t>
<t hangText="Request: ExchangeRequest"></t>
<t hangText="Response: ExchangeResponse"></t>
</list></t>
<t>
Perform Key Exchange to establish shared key bound to a ticket.  </t>
<section title="Message: ExchangeRequest" anchor="s-4_3_1">
<t>
Initiate the key exchange request. </t>
<t><list style="hanging">
<t hangText="Offer: Algorithms [0..Many]">
Set of message authentication and encryption algorithms offered by the client  </t>
</list></t>
</section>
<section title="Message: ExchangeResponse" anchor="s-4_3_2">
<t>
Returns the server parameters. </t>
<t><list style="hanging">
<t hangText="Ticket: Binary (Optional)">
Opaque session identifier. </t>
<t hangText="Witness: Binary (Optional)">
Opaque witness value used to prove binding to the ticket. </t>
<t hangText="Encryption: String [0..Many]">
Algorithm identifiers of encryption or authenticated encryption algorithm chosen </t>
<t hangText="Authentication: String [0..Many]">
Algorithm identifiers of authentication algorithm chosen  </t>
</list></t>
</section>
</section>
</section>
<section title="Security Considerations" anchor="s-5">
</section>
<section title="IANA Considerations" anchor="s-6">
<t>
The following registrations are required:</t>
<t><list style="hanging">
<t hangText="HTTP Content Coding Registry">
jose-jwb</t>
<t hangText="Well-Known URIs">
/.well-known/srv/</t>
<t>
[Or change registry to FCFS]</t>
<t hangText=""></t>
</list></t>
</section>
</middle>
<back>
<references title="Normative References">
<reference anchor="RFC8032">
<front>
<title>Edwards-Curve Digital Signature Algorithm (EdDSA)</title>
<author fullname="S. Josefsson" initials="S." surname="Josefsson">
<organization/>
<address>
</address>
</author>
<author fullname="I. Liusvaara" initials="I." surname="Liusvaara">
<organization/>
<address>
</address>
</author>
<date month="January" year="2017"/>
</front>
<seriesInfo name="RFC" value="8032"/>
<seriesInfo name="DOI" value="10.17487/RFC8032"/>
</reference>
<reference anchor="RFC5869">
<front>
<title>HMAC-based Extract-and-Expand Key Derivation Function (HKDF)</title>
<author fullname="H. Krawczyk" initials="H." surname="Krawczyk">
<organization/>
<address>
</address>
</author>
<author fullname="P. Eronen" initials="P." surname="Eronen">
<organization/>
<address>
</address>
</author>
<date month="May" year="2010"/>
</front>
<seriesInfo name="RFC" value="5869"/>
<seriesInfo name="DOI" value="10.17487/RFC5869"/>
</reference>
<reference anchor="RFC3394">
<front>
<title>Advanced Encryption Standard (AES) Key Wrap Algorithm</title>
<author fullname="J. Schaad" initials="J." surname="Schaad">
<organization/>
<address>
</address>
</author>
<author fullname="R. Housley" initials="R." surname="Housley">
<organization/>
<address>
</address>
</author>
<date month="September" year="2002"/>
</front>
<seriesInfo name="RFC" value="3394"/>
<seriesInfo name="DOI" value="10.17487/RFC3394"/>
</reference>
<reference anchor="draft-hallambaker-mesh-architecture">
<front>
<title>Mathematical Mesh: Architecture</title>
<author fullname="Phillip Hallam-Baker" initials="P" surname="Hallam-Baker">
<organization/>
<address>
</address>
</author>
<date day="18" month="September" year="2017"/>
</front>
<seriesInfo name="Internet-Draft" value="draft-hallambaker-mesh-architecture-04"/>
<format type="TXT" target="http://www.ietf.org/internet-drafts/draft-hallambaker-mesh-architecture-04.txt"/>
</reference>
</references>
<references title="Informative References">
<reference anchor="X3DH">
<front>
<title>The X3DH Key Agreement Protocol</title>
<author fullname="Moxie Marlinspike" initials="M" surname="Marlinspike">
<address>
</address>
</author>
<author fullname="Trevor Perrin" initials="T" surname="Perrin">
<address>
</address>
</author>
<date month="November" year="2011"/>
</front>
<format type="html" target="https://signal.org/docs/specifications/x3dh/"/>
</reference>
<reference anchor="RFC7748">
<front>
<title>Elliptic Curves for Security</title>
<author fullname="A. Langley" initials="A." surname="Langley">
<organization/>
<address>
</address>
</author>
<author fullname="M. Hamburg" initials="M." surname="Hamburg">
<organization/>
<address>
</address>
</author>
<author fullname="S. Turner" initials="S." surname="Turner">
<organization/>
<address>
</address>
</author>
<date month="January" year="2016"/>
</front>
<seriesInfo name="RFC" value="7748"/>
<seriesInfo name="DOI" value="10.17487/RFC7748"/>
</reference>
<reference anchor="draft-hallambaker-mesh-developer">
<front>
<title>Mathematical Mesh: Reference Implementation</title>
<author fullname="Phillip Hallam-Baker" initials="P" surname="Hallam-Baker">
<organization/>
<address>
</address>
</author>
<date day="18" month="September" year="2017"/>
</front>
<seriesInfo name="Internet-Draft" value="draft-hallambaker-mesh-developer-05"/>
<format type="TXT" target="http://www.ietf.org/internet-drafts/draft-hallambaker-mesh-developer-05.txt"/>
</reference>
</references>
</back>
</rfc>
