<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<?rfc toc="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc compact="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc subcompact="no"?>
<?rfc rfcedstyle="yes"?>
<?rfc-ext allow-markup-in-artwork="yes" ?>
<!DOCTYPE rfc [
]>

<rfc ipr="pre5378Trust200902"
     docName="draft-ietf-sipcore-digest-scheme-12"
     category="std"
     xml:lang="en"
     updates="3261">


<!-- ********************************** FRONT ********************************** -->
<front>

  <title abbrev="SIP Digest Authentication">
         The Session Initiation Protocol (SIP) Digest Authentication Scheme
  </title>

  <author initials="R." surname="Shekh-Yusef" fullname="Rifaat Shekh-Yusef">
    <organization>Avaya</organization>
    <address>
      <postal>
        <street>425 Legget Dr.</street>
        <city>Ottawa</city>
        <region>Ontario</region>
        <country>Canada</country>
      </postal>
      <phone>+1-613-595-9106</phone>
      <email>rifaat.ietf@gmail.com</email>
    </address>
  </author>

  <date year="2019" />
  <area>RAI</area>
  <workgroup>SIP Core</workgroup>
  <keyword>Digest Auth</keyword>
  
  <abstract><t>
   This document updates RFC 3261 by updating the Digest Access 
   Authentication scheme used by the Session Initiation Protocol (SIP) to add support 
   for more secure digest algorithms, e.g., SHA-256 and SHA-512-256, to replace the 
   broken MD5 algorithm.
  </t></abstract>

</front>



<!-- ********************************** MIDDLE ********************************** -->
<middle>

  <section title="Introduction" anchor="introduction">


  <t>
    The Session Initiation Protocol <xref target="RFC3261"/> uses the same mechanism
    that the Hypertext Transfer Protocol (HTTP) uses for authenticating
    users. This mechanism is called Digest Access Authentication, and
    it is a simple challenge-response mechanism that allows a server
    to challenge a client request and allows a client to provide
    authentication information in response to that challenge. The
    version of Digest Access Authentication that <xref target="RFC3261"/> references
    is specified in <xref target="RFC2617"/>.
  </t>

  <t>
    The default hash algorithm for Digest Access Authentication is MD5.
    However, it has been demonstrated that the MD5 algorithm is not
    collision resistant, and is now considered a bad choice for a hash function <xref target="RFC6151"/>.
  </t>

  <t>
    The HTTP Digest Access Authentication <xref target="RFC7616"/> document obsoletes
    [RFC2617] and adds stronger algorithms that can be used with
    the Digest Authentication scheme, and establishes a registry for
    these algorithms, known as the "Hash Algorithms for HTTP Digest
    Authentication" registry, so that algorithms can be added in the
    future.
  </t>

  <t>
    This document updates the Digest Access Authentication scheme used
    by SIP to support the algorithms listed in the "Hash Algorithms
    for HTTP Digest Authentication" registry defined by <xref target="RFC7616"/>.
  </t>
  
  <t> <vspace blankLines="1" /> </t>

  <section title="Terminology" anchor="terminology">
    <t>
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL
      NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED",
      "MAY", and "OPTIONAL" in this document are to be interpreted as
      described in BCP 14 <xref target="RFC2119" /> <xref target="RFC8174" /> when, 
      and only when, they appear in all capitals, as shown here.
    </t>

    <t> <vspace blankLines="1" /> </t>

  </section>

  </section> <!-- Introduction -->



  <section title="SIP Digest Authentication Scheme Updates"
           anchor="sip.digest.scheme">

  <t>
    This section describes the modifications to the operation of the
    Digest mechanism as specified in <xref target="RFC3261"/> in order to support 
    the algorithms defined in the "Hash Algorithms for HTTP Digest Authentication" 
    registry described in <xref target="RFC7616"/>.
  </t>

  <t>
    It replaces the reference used in <xref target="RFC3261"/> for Digest Access Authentication, 
    substituting <xref target="RFC7616"/> for the obsolete <xref target="RFC2617"/>, and describes 
    the modifications to the usage of the Digest mechanism in <xref target="RFC3261"/> 
    resulting from that reference update. It adds support for the SHA-256 and SHA-512/256 algorithms. 
    It adds required support for the "qop" parameter. It provides additional User Agent Client (UAC) 
    and User Agent Server (UAS) procedures regarding usage of multiple SIP Authorization, 
    WWW-Authenticate and Proxy-Authenticate header fields, including in which order to insert 
    and process them. It provides guidance regarding forking. Finally, it updates the SIP BNF 
    as required by the updates.
  </t>

  <t> <vspace blankLines="1" /> </t>


    <section title="Hash Algorithms" anchor="hash.algorithms">

    <t>
      The Digest scheme has an 'algorithm' parameter that specifies the
      algorithm to be used to compute the digest of the response. The IANA
      registry named the "Hash Algorithms for HTTP Digest Authentication" specifies 
      the algorithms that correspond to 'algorithm' values.
    </t>

    <t>
      <xref target="RFC3261"/> specifies only one algorithm, MD5, which is used by default.
      This document extends <xref target="RFC3261"/> to allow use of any algorithm listed in
      the "Hash Algorithms for HTTP Digest Authentication" registry.
    </t>

    <t>
      A UAS prioritizes which algorithm to use based on the ordering of the
      challenge header fields in the response it is preparing.  That process is
      specified in section 2.3 and parallels the process used in HTTP
      specified by <xref target="RFC7616"/>.
    </t>


    <t> <vspace blankLines="1" /> </t>
    </section> <!-- Hash Algorithms -->


    <section title="Representation of Digest Values" anchor="rep.digest.values">

    <t>
      The size of the digest depends on the algorithm used.  The bits in
      the digest are converted from the most significant to the least
      significant bit, four bits at a time to the ASCII representation as
      follows. Each four bits is represented by its familiar hexadecimal
      notation from the characters 0123456789abcdef, that is binary 0000 is
      represented by the character '0', 0001 by '1' and so on up to the
      representation of 1111 as 'f'. If the SHA-256 or SHA-512/256 algorithm is 
      used to calculate the digest, then the digest will be represented as 64 
      hexadecimal characters.      
    </t>

    <t> <vspace blankLines="1" /> </t>

    </section>

    <section title="UAS Behavior" anchor="uas.behavior">

    <t>
      When a UAS receives a request from a UAC, and an acceptable
      Authorization header field is not received, the UAS can challenge the
      originator to provide credentials by rejecting the request with a
      401/407 status code with the WWW-Authenticate/Proxy-Authenticate
      header field respectively. The UAS MAY add multiple WWW-Authenticate/Proxy-Authenticate
      header fields to allow the UAS to utilize the best available
      algorithm supported by the client.
    </t>

    <t>
      If the UAS challenges with multiple WWW-Authenticate/Proxy-Authenticate 
      header fields with the same realm, then each one of these
      header fields MUST use a different digest algorithm. The UAS MUST add these
      header fields to the response in the order that it would prefer to see them
      used, starting with the most preferred algorithm at the top, followed
      by the less preferred algorithms. The UAS cannot assume that the client 
      will use the algorithm specified at the topmost header field.
    </t>

    <t> <vspace blankLines="1" /> </t>
    </section>


    <section title="UAC Behavior" anchor="uac.behavior">

    <t>
      When the UAC receives a response with multiple WWW-Authenticate/Proxy-Authenticate 
      header fields with the same realm it SHOULD use the topmost 
      header field that it supports, unless a local policy dictates otherwise. 
      The client MUST ignore any challenge it does not understand.
    </t>

    <t>
      When the UAC receives a 401 response with multiple WWW-Authenticate
      header fields with different realms it SHOULD retry and add an
      Authorization header field containing credentials that match the topmost
      header field of any one of the realms, unless a local policy dictates otherwise.
    </t>

    <t>
    If the UAC cannot respond to any of the challenges in the response,
    then it SHOULD abandon attempts to send the request unless a local
    policy dictates otherwise.  For example, if the UAC does not have
    credentials or has stale credentials for any of the realms, the UAC
    will abandon the request.      
    </t>

    <t> <vspace blankLines="1" /> </t>
    </section>


    <section title="Forking" anchor="forking">

    <t>
      Section 22.3 of <xref target="RFC3261"/> discusses the operation of the proxy-to-user
      authentication, which describes the operation of the proxy when it
      forks a request. This section clarifies that operation.
    </t>

    <t>
      If a request is forked, various proxy servers and/or UAs may wish to
      challenge the UAC. In this case, the forking proxy server is
      responsible for aggregating these challenges into a single response.
      Each WWW-Authenticate and Proxy-Authenticate value received in
      responses to the forked request MUST be placed into the single
      response that is sent by the forking proxy to the UAC.
    </t>

    <t>
    When the forking proxy places multiple WWW-Authenticate and Proxy-Authenticate header
    fields received from one downstream proxy into a single response, it MUST maintain
    the order of these header fields.  The ordering of values received from different downstream 
    proxies is not significant.      
    </t>

    <t> <vspace blankLines="1" /> </t>
    </section> <!-- Forking -->


    <section title="HTTP Digest Authentication Scheme Modifications" anchor="http.modifications">

    <t>
      This section describes the modifications and clarifications required
      to apply the HTTP Digest authentication scheme to SIP. The SIP scheme
      usage is similar to that for HTTP. For completeness, the bullets specified 
      below are mostly copied from section 22.4 of <xref target="RFC3261"/>; the 
      only semantic changes are specified in bullets 1, 7, and 8 below.
    </t>

    <t>
      SIP clients and servers MUST NOT accept or request Basic
      authentication.
    </t>

    <t>
      The rules for Digest authentication follow those defined in HTTP,
      with "HTTP/1.1" <xref target="RFC7616"/> replaced by "SIP/2.0" in addition to the following
      differences:
    </t>


    <t>
      1. The URI included in the challenge has the following BNF <xref target="RFC5234"/>:
    <list><t>
      URI  =  Request-URI ; as defined in <xref target="RFC3261"/>, Section 25
    </t></list>
    </t>

    <t>
      2. The 'uri' parameter of the Authorization header field MUST be
         enclosed in quotation marks.
    </t>



    <t>
      3. The BNF for digest-uri-value is:
    <list><t>
         digest-uri-value  =  Request-URI
    </t></list>
    </t>

    <t>
      4. The example procedure for choosing a nonce based on Etag does not
         work for SIP.
    </t>


    <t>
      5. The text in <xref target="RFC7234"/> regarding cache operation does not
         apply to SIP.
    </t>

    <t>
      6. <xref target="RFC7616"/> requires that a server check that the URI in the
          request line and the URI included in the Authorization header
          field point to the same resource.  In a SIP context, these two
          URIs may refer to different users, due to forwarding at some
          proxy.  Therefore, in SIP, a UAS MUST check if the Request-URI in the
          Authorization/Proxy-Authorization header field value corresponds to a
          user for whom the UAS is willing to accept forwarded or direct
          requests, but MAY still accept it if the two fields are not equivalent.                    
    </t>


    <t>
      7.  As a clarification to the calculation of the A2 value for
          message integrity assurance in the Digest authentication
          scheme, implementers should assume, when the entity-body is
          empty (that is, when SIP messages have no body) that the hash
          of the entity-body resolves to the hash of an empty
          string:

    <list><t>
              H(entity-body) = &lt;algorithm>("")
    </t></list>
              For example, when the chosen algorithm is SHA-256, then:
    <list><t>
          H(entity-body) = SHA-256("") =
         "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
    </t></list>
    </t>


    <t>
      8. A UAS MUST be able to properly handle "qop" parameter received
         in an Authorization/Proxy-Authorization header field, and a UAC MUST be able to
         properly handle "qop" parameter received in WWW-Authenticate and
         Proxy-Authenticate header fields. However, for backward compatibility 
         reasons, the "qop" parameter is optional for RFC3261-based clients and 
         servers to receive. If the "qop" parameter is not specified, then the default 
         value is "auth".
    </t>
    <t>
         A UAS MUST always send a "qop" parameter in WWW-Authenticate
         and Proxy-Authenticate header field values, and a UAC MUST
         send the "qop" parameter in any resulting authorization header
         field.
    </t>

    <t> <vspace blankLines="1" /> </t>
    <t>
      The usage of the Authentication-Info header field continues to be
      allowed, since it provides integrity checks over the bodies and
      provides mutual authentication.
    </t>

    <t> <vspace blankLines="1" /> </t>

    </section> <!-- HTTP Modifications -->

  


  <section title="Augmented BNF for SIP" anchor="abnf">
    <t>
      This document updates the Augmented BNF <xref target="RFC5234"/> for SIP as
      follows.
    </t>

    <t>
      It extends the request-digest as follows to allow for different
      digest sizes:
    </t>

    <t>
    <list><t>
      request-digest = LDQUOT *LHEX RDQUOT
    </t></list>
    </t>

    <t>
      The number of hex digits is implied by the length of the value of the 
      algorithm used.
    </t>

    <t>
      It extends the algorithm parameter as follows to allow for any algorithm 
      in the registry to be used:
    </t>

    <t>
    <list><t>
      algorithm =  "algorithm" EQUAL ( ("MD5" / "SHA-512-256" / "SHA-256")[-sess]) 
      / token )
    </t></list>
    </t>
    <t>
     Each one of these algorithms might have a "-sess" variant, e.g., MD5-sess, 
     SHA-256-sess, etc, as defined in <xref target="RFC7616"/>
    </t>
<t> <vspace blankLines="1" /> </t>
  </section> <!-- Augmented BNF for the SIP Protocol-->
</section> <!-- The SIP Digest Authentication Scheme -->


  <section title="Security Considerations" anchor="security.considerations">
  <t>
    This specification adds new secure algorithms to be used with the
    Digest mechanism to authenticate users. The broken MD5 algorithm
    remains only for backward compatibility with <xref target="RFC2617"/> but its use is
    NOT RECOMMENDED.
  </t>

  <t>
    This opens the system to the potential of a downgrade attack by an on-path attacker.
    The most effective way of dealing with this type of attack is to either validate the 
    client and challenge it accordingly, or remove the support for backward compatibility 
    by not supporting MD5.
  </t>

  <t>
  See section 5 of <xref target="RFC7616"/> for a detailed security discussion of
  the Digest scheme.
  </t>

  <t> <vspace blankLines="1" /> </t>
  </section> <!-- Security Considerations -->



  <section title="IANA Considerations" anchor="iana.considerations">
  <t>
   <xref target="RFC7616"/> defines an IANA registry named "Hash Algorithms
   for HTTP Digest Authentication" to simplify the introduction of new
   algorithms in the future. This document specifies that algorithms defined in 
   that registry may be used in SIP digest authentication.
  </t>
    <t>
  This document has no actions for IANA.
  </t>
  <t> <vspace blankLines="1" /> </t>
  </section> <!-- IANA Considerations -->


  <section title="Acknowledgments" anchor="acknowledgments">
  <t>
    The author would like to thank the following individuals
    for their careful reviews, comments, and suggestions: Paul Kyzivat,
    Olle Johansson, Dale Worley, Michael Procter, Iņaki Baz Castillo,
    Tolga Asveren, Christer Holmberg, Brian Rosen, Jean Mahoney, Adam Roach, 
    Barry Leiba, Roni Even, Benjamin Kaduk, and Alissa Cooper.
  </t>
  <t> <vspace blankLines="1" /> </t>
  </section> <!-- Acknowledgments -->

</middle>



<!-- ********************************** BACK ********************************** -->
<back>

  <references title="Normative References">

   <?rfc include="reference.RFC.8174.xml"?>
   <?rfc include="reference.RFC.2119.xml"?>
   

    <reference anchor="RFC3261">
      <front>
        <title abbrev="SIP">SIP: Session Initiation Protocol</title>
        <author initials="J." surname="Rosenberg" fullname="Jonathan Rosenberg" />
        <author initials="H." surname="Schulzrinne" fullname="Henning Schulzrinne" />
        <author initials="H." surname="Camarillo" fullname="Gonzalo Camarillo" />
        <author initials="A." surname="Johnston" fullname="Alan Johnston" />
        <author initials="J." surname="Peterson" fullname="Jon Peterson" />
        <author initials="R." surname="Sparks" fullname="Robert Sparks" />
        <author initials="M." surname="Handley" fullname="Mark Handley" />
        <author initials="E." surname="Schooler" fullname="Eve Schooler" />
        <date month="June" year="2002" />
      </front>
      <seriesInfo name="RFC" value="3261" />
    </reference>


    <reference anchor="RFC7234">
      <front>
        <title abbrev="HTTP Caching">Hypertext Transfer Protocol (HTTP/1.1): Caching</title>
        <author initials="R." surname="Fielding" fullname="Roy Fielding" />
        <author initials="M." surname="Nottingham" fullname="Mark Nottingham" />
        <author initials="J." surname="Reschke" fullname="Julian Reschke" />
        <date month="June" year="2014" />
      </front>
      <seriesInfo name="RFC" value="7234" />
    </reference>


    <reference anchor="RFC7616">
      <front>
        <title abbrev="HTTP Digest">HTTP Digest Access Authentication</title>
        <author initials="R." surname="Shekh-Yusef" fullname="Rifaat Shekh-Yusef" />
        <author initials="D." surname="Ahrens" fullname="David Ahrens" />
        <author initials="S." surname="Bremer" fullname="Sophie Bremer" />
        <date month="September" year="2015" />
      </front>
      <seriesInfo name="RFC" value="7616" />
    </reference>


  </references>
  
    <references title="Informative References">

    <reference anchor="RFC2617">
      <front>
        <title abbrev="HTTP Basic and Digest">HTTP Authentication: Basic and Digest Access Authentication</title>
        <author initials="J." surname="Franks" fullname="John Franks" />
        <author initials="P." surname="M. Hallam-Baker" fullname="Phillip M. Hallam-Baker" />
        <author initials="J." surname="L. Hostetler" fullname="Jeffery L. Hostetler" />
        <author initials="S." surname="D. Lawrence" fullname="Scott D. Lawrence" />
        <author initials="P." surname="J. Leach" fullname="Paul J. Leach" />
        <author initials="A." surname="Luotonen" fullname="Ari Luotonen" />
        <author initials="L." surname="C. Stewart" fullname="Lawrence C. Stewart" />
        <date month="June" year="1999" />
      </front>
      <seriesInfo name="RFC" value="2617" />
    </reference>

   <?rfc include="reference.RFC.6151.xml"?>
   <?rfc include="reference.RFC.5234.xml"?>

  </references>

</back>


</rfc>
