<?xml version="1.0" encoding="UTF-8"?>
  <?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
  <!-- generated by https://github.com/cabo/kramdown-rfc2629 version 1.0.31 -->

<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
]>

<?rfc toc="yes"?>
<?rfc sortrefs="yes"?>
<?rfc symrefs="yes"?>

<rfc docName="draft-sullivan-tls-post-handshake-auth-00" category="std">

  <front>
    <title abbrev="TLS Post-Handshake Auth">Post-Handshake Authentication in TLS</title>

    <author initials="N." surname="Sullivan" fullname="Nick Sullivan">
      <organization>CloudFlare Inc.</organization>
      <address>
        <email>nick@cloudflare.com</email>
      </address>
    </author>
    <author initials="M." surname="Thomson" fullname="Martin Thomson">
      <organization>Mozilla</organization>
      <address>
        <email>martin.thomson@gmail.com</email>
      </address>
    </author>
    <author initials="M." surname="Bishop" fullname="Mike Bishop">
      <organization>Microsoft</organization>
      <address>
        <email>michael.bishop@microsoft.com</email>
      </address>
    </author>

    <date year="2016"/>

    <area>Security</area>
    <workgroup>TLS</workgroup>
    <keyword>Internet-Draft</keyword>

    <abstract>


<t>This document describes a mechanism for performing post-handshake
certificate-based authentication in Transport Layer Security (TLS) versions 1.3
and later. This includes both spontaneous and solicited authentication of both
client and server.</t>



    </abstract>


  </front>

  <middle>


<section anchor="introduction" title="Introduction">

<t>This document defines a way to authenticate one party of a Transport Layer
Security (TLS) communication to another using a certificate after the session
has been established. This allows both the client and server to solicit proof of
ownership of additional identities at any time after the handshake has
completed. It also allows for both the client and server to spontaneously
provide a certificate and proof of ownership of the private key to the other
party.</t>

<t>This mechanism is useful in the following situations:</t>

<t><list style="symbols">
  <t>servers that have the ability to serve requests from multiple domains over the
same connection but do not have a certificate that is simultaneously
authoritative for all of them</t>
  <t>servers that have resources that require client authentication to access and
need to request client authentication after the connection has started</t>
  <t>clients that want to assert their identity to a server after a connection has
been established</t>
  <t>clients that want a server to re-prove ownership of their private key during a
connection</t>
  <t>clients that wish to ask a server to authenticate for a new domain not covered
by the certificate included in the initial handshake</t>
</list></t>

<t>This document intends to replace the use of renegotiation for changing the
authentication of peers. It has an advantage over renegotiation in that it only
takes at most one round trip and it does not include an additional key exchange.</t>

<t>This document describes spontaneous and solicited modes for both client and
server authentication. Spontaneous authentication allows an endpoint to
advertise a certificate without explicitly being requested.  Solicited
authentication allows an endpoint to request that its peer provide
authentication details.</t>

<t>Support for different modes of authentication is negotiated using a new
<spanx style="verb">post_handshake_auth</spanx> extension.  New handshake messages are defined for use
after completion of the initial handshake, these mirror the authentication
messages that are used in the TLS 1.3 handshake.</t>

</section>
<section anchor="post-handshake-authentication" title="Post-Handshake Authentication">

<t>There is a total of four different exchanges that are enabled by this
specification.  Solicited and spontaneous authentication exchanges are largely
the same for both peers.  This section describes how each exchange operates.</t>

<t>In all cases, a unique value for the certificate_request_context is chosen.
This allows for identification of the authentication flow in application
protocols that use TLS.  Exchanges that are initiated by the client start with
an octet that has the most significant bit set; exchanges initiated by the
server have the most significant bit cleared.</t>

<section anchor="spontaneous-authentication" title="Spontaneous Authentication">

<t>An endpoint that wishes to offer spontaneous authentication sends a Certificate,
CertificateVerify, and Finished message.</t>

<figure><artwork><![CDATA[
  Certificate
  CertificateVerify
  Finished              ---------->
]]></artwork></figure>

<t>No application data records or any other handshake messages can be interleaved
with these messages.  An endpoint MUST abort a connection if it does not receive
these messages in a contiguous sequence.  A fatal <spanx style="verb">unexpected_message</spanx> alert
SHOULD be sent if these messages do not appear in sequence.</t>

<t>A client MUST NOT initiate spontaneous authentication unless the server included
client_auth_spontaneous in its <spanx style="verb">post_handshake_auth</spanx> extension.  Similarly, a
server MUST NOT initiate spontaneous authentication unless it included
server_auth_solicited in its <spanx style="verb">post_handshake_auth</spanx> extension.</t>

</section>
<section anchor="solicited-authentication" title="Solicited Authentication">

<t>Solicited authentication is initiated by sending a CertificateRequest message.</t>

<t>Endpoints that request that their peer authenticate need to account for delays
in processing requests.  In particular, client authentication in some contexts
relies on user interaction.  This means that responses might not arrive in the
order in which the requests were made.</t>

<t>If a request for authentication is accepted, the sequence of Certificate,
CertificateVerify, and Finished messages are sent by the responding peer.  As
with spontaneous authentication, these messages MUST form a contiguous sequence.</t>

<figure><artwork><![CDATA[
  CertificateRequest    ---------->
                                           Certificate
                                     CertificateVerify
                        <----------           Finished
]]></artwork></figure>

<t>A request for authentication can be rejected by sending a Certificate message
that contains an empty certificate_list field.  The extensions field of this
message MUST be empty.</t>

<t>A client MUST NOT request server authentication unless the server included
client_auth_solicited in its <spanx style="verb">post_handshake_auth</spanx> extension.  Similarly, a
server MUST NOT request client authentication unless it included
client_auth_solicited in its <spanx style="verb">post_handshake_auth</spanx> extension.</t>

</section>
</section>
<section anchor="post-handshake-authentication-tls-extension" title="Post-Handshake Authentication TLS Extension">

<t>The <spanx style="verb">post_handshake_auth</spanx> TLS extension advertises support for post-handshake
authentication.</t>

<figure><artwork><![CDATA[
    enum {
        client_auth_solicited(0),
        client_auth_spontaneous(1),
        server_auth_solicited(2),
        server_auth_spontaneous(3),
        (255)
    } AuthTypes;

    struct {
        AuthType auth_types<0..2^8-1>;
    } PostHandshakeAuth;
]]></artwork></figure>

<t>The extension data for the <spanx style="verb">post_handshake_auth</spanx> extension is PostHandshakeAuth.
This includes one or more AuthType.  Each AuthType value represents support for
a given authentication flow:</t>

<t><list style="hanging">
  <t hangText='client_auth_solicited:'>
  indicates support for client authentication solicited by a server request</t>
  <t hangText='client_auth_spontaneous:'>
  indicates support for spontaneous client authentication</t>
  <t hangText='server_auth_solicited:'>
  indicates support for server authentication solicited by a client request</t>
  <t hangText='server_auth_spontaneous:'>
  indicates support for spontaneous server authentication</t>
</list></t>

<t>The client includes a <spanx style="verb">post_handshake_auth</spanx> extension containing every type of
authentication flow it supports in its ClientHello. The server replies with an
EncryptedExtensions containing a <spanx style="verb">post_handshake_auth</spanx> extension containing a
list of authentication types that it supports. The set of AuthTypes in the
server’s <spanx style="verb">post_handshake_auth</spanx> extension MUST be a subset of those sent by the
client.</t>

<t>The <spanx style="verb">post_handshake_auth</spanx> extension MUST be omitted if the server does not
support any mode of post-handshake authentication in common with the client.</t>

<t>If a server declares support for either client_auth_solicited, or
client_auth_spontaneous, it MUST also include a “signature_algorithms” extension
(see Section 4.2.2 of <xref target="I-D.ietf-tls-tls13"/>). This contains a list of the
signature schemes that the server is able to use for client authentication,
listed in descending order of preference.</t>

<t>This extension is not compatible with the raw public key extension <xref target="RFC7250"/>.
The server MUST NOT select the raw public key extension if it uses this
mechanism.</t>

</section>
<section anchor="post-handshake-authentication-messages" title="Post-Handshake Authentication Messages">

<t>The messages used for post-handshake authentication closely mirror those used to
authenticate certificates in the standard TLS handshake.</t>

<section anchor="certificate-request" title="Certificate Request">

<t>For solicited post-handshake authentication, the first message is used to define
the characteristics required in the solicited certificate.</t>

<figure><artwork><![CDATA[
    opaque DistinguishedName<1..2^16-1>;

    struct {
        opaque certificate_extension_oid<1..2^8-1>;
        opaque certificate_extension_values<0..2^16-1>;
    } CertificateExtension;

    struct {
        opaque certificate_request_context<1..2^8-1>;
        select (Role) {
            case server:
                DistinguishedName certificate_authorities<0..2^16-1>;
                CertificateExtension certificate_extensions<0..2^16-1>;
            case client:
                HostName host_name<1..2^16-1>;
        }
    } CertificateRequest;
]]></artwork></figure>

<t>The certificate_request_context is an opaque string which identifies the
certificate request and which will be echoed in the corresponding Certificate
message. The certificate_request_context value MUST be unique for the
connection. A client MUST set the most significant bit of the first octet of the
certificate_request_context; a server MUST clear this bit.</t>

<t>For CertificateRequests sent from the server, the DistinguishedName and
CertificateExtension fields are defined exactly as in the TLS 1.3
specification.</t>

<t>For CertificateRequests send from the client, a HostName containing the Server
Name Indication (defined in <xref target="RFC6066"></xref>) used for selecting the certificate is
included.</t>

</section>
<section anchor="certificate-message" title="Certificate Message">

<t>The certificate message is used to transport the certificate. It mirrors the
Certificate message in the TLS with the addition of some certificate-specific
extensions.</t>

<figure><artwork><![CDATA[
    opaque ASN1Cert<1..2^24-1>;

    struct {
        opaque certificate_request_context<0..2^8-1>;
        ASN1Cert certificate_list<0..2^24-1>;
        Extension extensions<0..2^16-1>;
    } Certificate;
]]></artwork></figure>

<t><list style="hanging">
  <t hangText='certificate_request_context:'>
  If this message is in response to a CertificateRequest, the value of
certificate_request_context in that message.</t>
  <t hangText='certificate_list:'>
  This is a sequence (chain) of certificates. The sender’s end entity
certificate MUST come first in the list. Each following certificate SHOULD
directly certify one preceding it. Because certificate validation requires
that trust anchors be distributed independently, a certificate that specifies
a trust anchor MAY be omitted from the chain, provided that supported peers
are known to possess any omitted certificates.</t>
  <t hangText='extensions:'>
  Valid extensions include OCSP Status extensions (<xref target="RFC6066"/> and
<xref target="RFC6961"/>) and SignedCertificateTimestamps (<xref target="RFC6962"/>). Any extension
presented in a Certificate message must only be presented if the associated
ClientHello extension was presented in the initial handshake.</t>
</list></t>

<t>The certificate_request_context is an opaque string that identifies the
certificate. The certificate_request_context value MUST be unique for the
connection. If the certificate is used in response to a CertificateRequest,
certificate_request_context includes the certificate_request_context value in
the corresponding CertificateRequest. If the Certificate message part of
spontaneous authentication, the certificate_request_context value is chosen by
the sender.  When spontaneous authentication is used, a client MUST set the most
significant bit of the first octet of the certificate_request_context; a server
MUST clear this bit.</t>

<t>Any certificates provided MUST be signed using a signature scheme found in the
“signature_algorithms” extension provided by the peer in the initial
handshake. The end entity certificate MUST allow the key to be used for signing
(i.e., the digitalSignature bit MUST be set if the Key Usage extension is
present) with a signature scheme indicated in the “signature_algorithms”
extension provided by the peer in the initial handshake.</t>

</section>
<section anchor="certificateverify-message" title="CertificateVerify Message">

<t>The CertificateVerify message used in this document is defined in Section
4.3.2. of <xref target="I-D.ietf-tls-tls13"/>.</t>

<figure><artwork><![CDATA[
    struct {
        SignatureScheme algorithm;
        opaque signature<0..2^16-1>;
    } CertificateVerify;
]]></artwork></figure>

<t>The algorithm field specifies the signature algorithm used (see Section 4.2.2 of
<xref target="I-D.ietf-tls-tls13"/>). The signature is a digital signature using that
algorithm that covers the handshake context, the resumption context and a hash
of the CertificateRequest and Certificate messages:</t>

<figure><artwork><![CDATA[
    Hash(handshake_context) + resumption_context +
        Hash(CertificateRequest* + Certificate)
]]></artwork></figure>

<t>Note that the CertificateRequest message is omitted with spontaneous
authentication.</t>

<t>The value of handshake_context is the entire transcript of the initial
handshake, starting from the first ClientHello up to the final Finished message
from the client.  The value of resumption_context is defined in Section 4.4.1 of
<xref target="I-D.ietf-tls-tls13"/>.</t>

<t>The context string that is input to the digital signature is formed by taking
the endpoint role and the authentication mode.  The final value is the
concatenation of the ASCII-encoded strings:</t>

<t><list style="symbols">
  <t>“TLS 1.3, “</t>
  <t>either “client” if the client is authenticating, or “server” if the server is
authenticating</t>
  <t>a single space “ “ (0x20)</t>
  <t>“spontaneous” if no request was made; “solicited” if the peer sent a
CertificateRequest</t>
  <t>” CertificateVerify”</t>
</list></t>

<t>Thus, a client that is responding to a CertificateRequest will use the string
“TLS 1.3, client solicited CertificateVerify” as the context string.</t>

</section>
<section anchor="finished-message" title="Finished Message">

<t>Finished is defined in Section 4.3.3 of <xref target="I-D.ietf-tls-tls13"/>.  When included
in post-handshake authentication it includes a MAC over the value:</t>

<figure><artwork><![CDATA[
    Hash(Handshake Context) + resumption_context +
        Hash(CertificateRequest* + Certificate + CertificateVerify)
]]></artwork></figure>

<t>Note that the CertificateRequest message is omitted with spontaneous
authentication.</t>

<t>The Finished message uses the current traffic secret (traffic_secret_N) as the
MAC key; the hash function and HMAC function are the negotiated PRF hash
function.</t>

</section>
<section anchor="forgetting-certificates" title="Forgetting certificates">

<t>Certificate identity should not be maintained across resumption. If a connection
is resumed, additional certificate identities for both client and server
certificates SHOULD be forgotten. Either the client or the server MAY choose to
forget a certificate identity at any time.</t>

<t>Repeated requests for the same certificate should be expected. If multiple
certificate requests are recieved that differ only in the
certificate_request_context value, it is permitted to only answer the most
recent request.</t>

</section>
</section>
<section anchor="security-considerations" title="Security Considerations">

<t>TBD</t>

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

<t>Eric Rescorla and Andrei Popov were involved in helpful discussions around this
draft.</t>

</section>


  </middle>

  <back>

    <references title='Normative References'>





<reference  anchor='RFC6066' target='http://www.rfc-editor.org/info/rfc6066'>
<front>
<title>Transport Layer Security (TLS) Extensions: Extension Definitions</title>
<author initials='D.' surname='Eastlake 3rd' fullname='D. Eastlake 3rd'><organization /></author>
<date year='2011' month='January' />
<abstract><t>This document provides specifications for existing TLS extensions.  It is a companion document for RFC 5246, &quot;The Transport Layer Security (TLS) Protocol Version 1.2&quot;.  The extensions specified are server_name, max_fragment_length, client_certificate_url, trusted_ca_keys, truncated_hmac, and status_request.  [STANDARDS-TRACK]</t></abstract>
</front>
<seriesInfo name='RFC' value='6066'/>
<seriesInfo name='DOI' value='10.17487/RFC6066'/>
</reference>



<reference  anchor='RFC6961' target='http://www.rfc-editor.org/info/rfc6961'>
<front>
<title>The Transport Layer Security (TLS) Multiple Certificate Status Request Extension</title>
<author initials='Y.' surname='Pettersen' fullname='Y. Pettersen'><organization /></author>
<date year='2013' month='June' />
<abstract><t>This document defines the Transport Layer Security (TLS) Certificate Status Version 2 Extension to allow clients to specify and support several certificate status methods.  (The use of the Certificate Status extension is commonly referred to as &quot;OCSP stapling&quot;.)  Also defined is a new method based on the Online Certificate Status Protocol (OCSP) that servers can use to provide status information about not only the server's own certificate but also the status of intermediate certificates in the chain.</t></abstract>
</front>
<seriesInfo name='RFC' value='6961'/>
<seriesInfo name='DOI' value='10.17487/RFC6961'/>
</reference>



<reference  anchor='RFC6962' target='http://www.rfc-editor.org/info/rfc6962'>
<front>
<title>Certificate Transparency</title>
<author initials='B.' surname='Laurie' fullname='B. Laurie'><organization /></author>
<author initials='A.' surname='Langley' fullname='A. Langley'><organization /></author>
<author initials='E.' surname='Kasper' fullname='E. Kasper'><organization /></author>
<date year='2013' month='June' />
<abstract><t>This document describes an experimental protocol for publicly logging the existence of Transport Layer Security (TLS) certificates as they are issued or observed, in a manner that allows anyone to audit certificate authority (CA) activity and notice the issuance of suspect certificates as well as to audit the certificate logs themselves.  The intent is that eventually clients would refuse to honor certificates that do not appear in a log, effectively forcing CAs to add all issued certificates to the logs.</t><t>Logs are network services that implement the protocol operations for submissions and queries that are defined in this document.</t></abstract>
</front>
<seriesInfo name='RFC' value='6962'/>
<seriesInfo name='DOI' value='10.17487/RFC6962'/>
</reference>



<reference  anchor='RFC7250' target='http://www.rfc-editor.org/info/rfc7250'>
<front>
<title>Using Raw Public Keys in Transport Layer Security (TLS) and Datagram Transport Layer Security (DTLS)</title>
<author initials='P.' surname='Wouters' fullname='P. Wouters' role='editor'><organization /></author>
<author initials='H.' surname='Tschofenig' fullname='H. Tschofenig' role='editor'><organization /></author>
<author initials='J.' surname='Gilmore' fullname='J. Gilmore'><organization /></author>
<author initials='S.' surname='Weiler' fullname='S. Weiler'><organization /></author>
<author initials='T.' surname='Kivinen' fullname='T. Kivinen'><organization /></author>
<date year='2014' month='June' />
<abstract><t>This document specifies a new certificate type and two TLS extensions for exchanging raw public keys in Transport Layer Security (TLS) and Datagram Transport Layer Security (DTLS).  The new certificate type allows raw public keys to be used for authentication.</t></abstract>
</front>
<seriesInfo name='RFC' value='7250'/>
<seriesInfo name='DOI' value='10.17487/RFC7250'/>
</reference>



<reference anchor='I-D.ietf-tls-tls13'>
<front>
<title>The Transport Layer Security (TLS) Protocol Version 1.3</title>

<author initials='E' surname='Rescorla' fullname='Eric Rescorla'>
    <organization />
</author>

<date month='May' day='22' year='2016' />

<abstract><t>This document specifies Version 1.3 of the Transport Layer Security (TLS) protocol.  The TLS protocol allows client/server applications to communicate over the Internet in a way that is designed to prevent eavesdropping, tampering, and message forgery.</t></abstract>

</front>

<seriesInfo name='Internet-Draft' value='draft-ietf-tls-tls13-13' />
<format type='TXT'
        target='http://www.ietf.org/internet-drafts/draft-ietf-tls-tls13-13.txt' />
</reference>




    </references>




  </back>
</rfc>

