<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?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="info" ipr="full3978"-->
<rfc category="std" docName="draft-ram-straw-b2bua-dtls-srtp-00"
     ipr="trust200902">
  <front>
    <title abbrev="DTLS-SRTP handling in SIP B2BUA">DTLS-SRTP Handling
    in Session Initiation Protocol (SIP) Back-to-Back User Agents
    (B2BUAs)</title>

    <author fullname="Ram Mohan Ravindranath" initials="R."
            surname="Ravindranath">
      <organization>Cisco</organization>

      <address>
        <postal>
          <street>Cessna Business Park</street>

          <street>Sarjapur-Marathahalli Outer Ring Road</street>

          <city>Bangalore</city>

          <region>Karnataka</region>

          <code>560103</code>

          <country>India</country>
        </postal>

        <email>rmohanr@cisco.com</email>
      </address>
    </author>

    <author fullname="Tirumaleswar Reddy" initials="T."
            surname="Reddy">
      <organization>Cisco</organization>

      <address>
        <postal>
          <street>Cessna Business Park, Varthur Hobli</street>

          <street>Sarjapur Marathalli Outer Ring Road</street>

          <city>Bangalore</city>

          <region>Karnataka</region>

          <code>560103</code>

          <country>India</country>
        </postal>

        <email>tireddy@cisco.com</email>
      </address>
    </author>

    <author fullname="Gonzalo Salgueiro" initials="G."
            surname="Salgueiro">
      <organization abbrev="Cisco">Cisco Systems, Inc.</organization>

      <address>
        <postal>
          <street>7200-12 Kit Creek Road</street>

          <city>Research Triangle Park</city>

          <region>NC</region>

          <code>27709</code>

          <country>US</country>
        </postal>

        <email>gsalguei@cisco.com</email>
      </address>
    </author>

    <author fullname="Victor Pascual" initials="V." surname="Pascual">
      <organization abbrev="Quobis">Quobis</organization>

      <address>
        <postal>
          <!-- Street is mandatory under postal XML tag. So, change the taga from country to street -->

          <street>Spain</street>
        </postal>

        <email>victor.pascual@quobis.com</email>
      </address>
    </author>

    <date year="2014"/>

    <area>Real-time Applications and Infrastructre (RAI)</area>

    <workgroup>STRAW</workgroup>

    <abstract>
      <t>Session Initiation Protocol (SIP) Back-to-Back User Agents
      (B2BUAs) often function on the media plane, rather than just on
      the signaling path. This document describes the behavior B2BUAs
      should follow when acting on the media plane that use Secure
      Real-time Transport Protocol (SRTP) security context setup with
      Datagram Transport Layer Security (DTLS) protocol.</t>
    </abstract>
  </front>

  <middle>
    <section title="Introduction">
      <t><xref target="RFC5763"/> describes how Session Initiation
      Protocol (SIP) <xref target="RFC3261"/> can be used to establish
      a Secure Real-time Transport Protocol (SRTP) <xref
      target="RFC3711"/> security context with Datagram Transport
      Layer Security (DTLS) <xref target="RFC4347"/> protocol. It
      describes a mechanism of transporting a certificate fingerprint
      in the Session Description Protocol (SDP) <xref
      target="RFC4566"/>, which identifies the certificate that will
      be presented during the DTLS handshake. DTLS-SRTP is defined for
      point-to-point media sessions, in which there are exactly two
      participants. Each DTLS-SRTP session contains a single DTLS
      association, and either two SRTP contexts (if media traffic is
      flowing in both directions on the same host/port quartet) or one
      SRTP context (if media traffic is only flowing in one
      direction).</t>

      <t>In many SIP deployments, SIP entities exist in the SIP
      signaling path between the originating and final terminating
      endpoints. These SIP entities, as described in <xref
      target="RFC7092"/>, modify SIP and SDP bodies and also are
      likely to be on the media path. Such entities, when present in
      the signaling/media path, are likely to do several things. For
      example, some B2BUAs modify parts of the SDP body (like IP
      address, port) and subsequently modify the RTP headers as well.
      There are other types of B2BUAs that completely modify the RTP
      packet, including the payload (e.g., a transcoder). In all these
      cases a DTLS association would break unless the B2BUA
      participates in the DTLS setup and ensures the contexts are
      setup properly. B2BUA that are in media path MUST support DTLS
      stack and SRTP extensions needed for DTLS as described in <xref
      target="RFC5763"/> so that it can function as DTLS proxy.</t>

      <t><xref target="RFC7092"/> describes three different categories
      of such B2BUAs, according to the level of activities performed
      on the media plane:</t>

      <t><list style="hanging">
          <t>A B2BUA that act as a simple media relay effectively
          unaware of anything that is transported and only modifies
          the UDP/IP header of the packets.</t>

          <t>A B2BUA that performs a media-aware role. It inspects and
          potentially modifies RTP or RTP Control Protocol (RTCP)
          headers; but it does not modify the payload of RTP/RTCP.</t>

          <t>A B2BUA that performs a media-termination role and
          operates at the media payload layer, such as RTP/RTCP
          payload (e.g., a transcoder).</t>
        </list></t>

      <t>The following sections will describe the behaviour B2BUAs
      should follow in order to avoid any impact on end-to-end
      DTLS-SRTP streams.</t>
    </section>

    <section anchor="sec-term" title="Terminology">
      <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"/>.</t>

      <t>The following generalized terms are defined in <xref
      target="RFC3261"/>, Section 6.</t>

      <t><list style="hanging">
          <t>B2BUA: a SIP Back-to-Back User Agent, which is the
          logical combination of a User Agent Server (UAS) and User
          Agent Client (UAC).</t>

          <t>UAS: a SIP User Agent Server.</t>

          <t>UAC: a SIP User Agent Client.</t>
        </list></t>

      <t>All of the pertinent B2BUA terminology and taxonomy used in
      this document is based on <xref target="RFC7092"/>.</t>

      <t>It is assumed the reader is already familiar with the
      fundamental concepts of the RTP protocol <xref
      target="RFC3550"/> and its taxonomy <xref
      target="I-D.ietf-avtext-rtp-grouping-taxonomy"/>, as well as
      those of SRTP <xref target="RFC3711"/>, and DTLS <xref
      target="RFC4347"/>.</t>
    </section>

    <section title="Media Plane B2BUAs">
      <section title="Media Relay">
        <t>A media relay as identified in section 3.2.1 of <xref
        target="RFC7092"/> basically just forwards, from an
        application layer point-of-view, all packets it receives on a
        negotiated UDP connection, without either inspecting or
        modifying them. They just forward the UDP payload as-is by
        changing only the UDP/IP header.</t>

        <t>A media relay B2BUA MUST forward the certificate
        fingerprint and setup attribute it receives in the SDP from
        the originating endpoint as-is to the remote side and
        vice-versa. The below example shows a "INVITE with SDP" SIP
        call flow with both SIP user agents doing DTLS-SRTP with a
        media relay B2BUA that changes the UDP/IP address/port.</t>

        <t><figure anchor="Figure1"
            title="INVITE with SDP callflow for Media Relay B2BUA">
            <artwork align="center"><![CDATA[
 +-------+            +------------------+              +-----+         
 | Alice |            | MediaRelay B2BUA |              | Bob |
 +-------+            +------------------+              +-----+
     |(1) INVITE               |  (3)INVITE                |
     |   a=setup:actpass       |   a=setup:actpass         |
     |   a=fingerprint1        |   a= fingerprint1         | 
     |   (alice's IP/port)     |   (B2BUA's IP, port)      |                        
     |------------------------>|-------------------------->|
     |                         |                           |
     |    (2)  100 trying      |                           |
     |<------------------------|                           |
     |                         | (4) 100 trying            |
     |                         |<--------------------------|
     |                         |                           |
     |                         |  (5)200 OK                |
     |                         |   a=setup:active          |
     |                         |    a=fingerprint2         |
     |                         |  (Bob's IP, port)         |
     |<------------------------|<--------------------------|
     |    (6) 200 OK           |                           |
     |    a=setup:active       |                           |
     |    a=fingerprint2       |                           |
     |    B2BUA's address,port |                           |
     |               (7, 8)ClientHello + use_srtp          |
     |<------------------------|<--------------------------|
     |                         |                           |
     |                         |                           |
     |           (9,10)ServerHello + use_srtp              |
     |------------------------>|-------------------------->|
     |                 (11)    |                           |
     |  [Certificate exchange between Alice and Bob over   | 
     |   DTLS ]                |                           |  
     |                         |                           |
     |         (12)            |                           |
     |<---------SRTP/SRTCP---->|<----SRTP/SRTCP----------->|
     |   [B2BUA just changes UDP/IP header]                |   
          ]]></artwork>
          </figure></t>

        <t>NOTE: For the sake of brevity the entire fingerprint
        attribute is not shown.</t>

        <t>For each RTP or RTCP flow the peers do a DTLS handshake on
        the same source and destination port pair to establish a DTLS
        association. In this case, Bob, after he receives an INVITE
        triggers a DTLS connection. Note the DTLS handshake and the
        response to the INVITE may happen in parallel, thus, the B2BUA
        SHOULD be prepared to receive media on the ports it advertised
        to Bob in the OFFER. Since a media relay B2BUA does not
        differentiate between a DTLS, RTP or any packet sent it just
        changes the UDP/IP addresses and forwards the packet on either
        leg.</t>

        <t>[[TODO: ICE handling w.r.t media relay B2BUA will be
        discussed in STUN passthrough STRAW WG item and the reference
        will be added in this section]]</t>
      </section>

      <section title="Media Aware or Media Termination">
        <t>A media-aware relay, unlike the the media relay discussed
        in the previous section, is actually aware of the media
        traffic it is handling. A media-aware relay inspects SRTP and
        SRTCP packets flowing through it, and may even be able to
        modify the headers in any of them before forwarding them. A
        B2BUA performing such a media- aware role de-crypts the
        payload and re-encrypt it, but it does not modify the contents
        of the payload itself. Note that when such a media-aware B2BUA
        modifies SRTP headers it MUST act as a DTLS intermediary and
        terminate the DTLS connection so it can decrypt/re-encrypt in
        order to properly update the compound SRTCP packet to make
        them consistent. This DTLS proxy functionality of media-aware
        B2BUAs is discussed in greater detail in Section X of <xref
        target="I-D.ietf-straw-b2bua-rtcp"/>.</t>

        <t>[[TODO: Update reference to STRAW RTCP document once this
        new section appears in the next version (in progress).]]</t>

        <t>In addition to modifying the headers, a B2BUA performing a
        media termination role can modify parts of the payload as
        well. For example, a transcoder is a type of media terminator
        that modifies the payload before it forwards the packet. These
        B2BUA's SHOULD have the capability to distinguish between
        DTLS, SRTP, SRTCP or other packets (e.g., STUN) received on
        the same UDP port by using the algorithm mentioned in section
        5.1.2 of <xref target="RFC5764"/> and takes care of handling
        them separately.</t>

        <t>Below example shows how a DTLS-SRTP session is setup for
        these B2BUA</t>

        <t><figure anchor="Figure2"
            title="INVITE with SDP callflow with Media-aware B2BUA">
            <artwork align="center"><![CDATA[
 +-------+           +------------------+               +-----+         
 | Alice |           | MediaAware B2BUA |               | Bob |
 +-------+           +------------------+               +-----+
     |(1) INVITE               |  (3)INVITE                |
     |   a=setup:actpass       |   a=setup:actpass         |
     |   a=fingerprint1        |   a= fingerprint2         | 
     |   (alice's IP/port)     |   (B2BUA's IP, port)      |                        
     |------------------------>|-------------------------->|
     |                         |                           |
     |    (2)  100 trying      |                           |
     |<------------------------|                           |
     |                         | (4) 100 trying            |
     |                         |<--------------------------|
     |                         |                           |
     |                         |  (5)200 OK                |
     |                         |   a=setup:active          |
     |                         |    a=fingerprint3         |
     |                         |  (Bob's IP, port)         |
     |                         |<--------------------------|
     |                         |(6)ClientHello + use_srtp  |
     |                         |<--------------------------|
     |    (7) 200 OK           |                           |
     |    a=setup:active       | ServerHello + use_srtp (8)|
     |    a=fingerprint4       |-------------------------->|
     |    B2BUA's address,port |             (9,10)        |
     |<------------------------|   [Cert Exchange between] |
     |  (11)ClientHello+       |      Bob and B2BUA over   |
     |     use_srtp            |              DTLS         |
     |<------------------------|                           |
     |  (12)ServerHello+       |                           |
     |   use_srtp              |                           |
     |------------------------>|                           |
     |                 (13,14  |                           |
     |  [Cert exchange between |                           |
     |   Alice and B2BUA       |                           |
     |   DTLS ]                |                           |
     |                         |                           |
     |         (15)            |          (16)             |
     |<---------SRTP/SRTCP---->|<----SRTP/SRTCP----------->|
     |   [B2BUA modifies SRTP/SRTCP header and/or payload]  |   
          ]]></artwork>
          </figure></t>

        <t>NOTE: For the sake of brevity the entire fingerprint
        attribute is not shown.</t>

        <t>NOTE: The same call flow would be applicable to "INVITE
        without SDP" Offer calls.</t>

        <t>NOTE: Steps 5,6 may be parallel and so the B2BUA MAY
        receive ClientHello before it sees a 200OK. Steps 7,8 can
        happen in any order. Also steps 9,10, 11 may be parallel.
        B2BUA should be prepared to handle these responses on each leg
        independently.</t>

        <t>A media termination B2BUA MUST change the certificate
        fingerprint from both the endpoints so that it can signal its
        own certificate fingerprint in the SDP. This allows the B2BUA
        to act as a DTLS-SRTP proxy and modify the payload.</t>
      </section>

      <section title="Media Plane B2BUA with NAT handling">
        <t>It is possible that DTLS exchange and offer/answer exchange
        happens in parallel. In case of NAT exists between B2BUA and
        UA, ClientHello message in DTLS will be lost in case the
        answer is not received in UA. To overcome this issue,
        retransmission of ClientHello of DTLS as mentioned in Sec
        4.2.4.1 of <xref target="RFC6347"/> SHALL be followed or
        ClientHello MAY be started only after offer/answer exchange is
        complete.</t>
      </section>
    </section>

    <section title="DTLS-SRTP Handling in B2BUA with Forked Signaling">
      <t>B2BUA's may receive multiple answers for an outbound INVITE
      due to a downstream proxy forking the INVITE to multiple
      targets. It is possible that each of these responses have
      different certificate fingerprints. The B2BUA SHOULD take care
      of setting separate DTLS-SRTP associations with each of the
      forked targets.</t>
    </section>

    <section title="Security Considerations">
      <t>This document simply describes the behavior B2BUAs should
      follow when acting on the media plane that use SRTP security
      context setup with the DTLS protocol. It does not introduce any
      specific security considerations beyond those detailed in <xref
      target="RFC5763"/>. The B2BUA behaviors outlined here also do
      not impact the security and integrity of the DTLS-SRTP session
      nor the data exchanged over it.</t>
    </section>

    <section anchor="sec.iana-considerations"
             title="IANA Considerations">
      <t>This document makes no request of IANA.</t>
    </section>

    <section title="Acknowledgments">
      <t>Special thanks to Lorenzo Miniero, Ranjit Avarsala, Hadriel
      Kaplan, Muthu Arul Mozhi, Paul Kyzivat, Peter Dawes and Brett
      Tate for their constructive comments, suggestions, and early
      reviews that were critical to the formulation and refinement of
      this document.</t>
    </section>

    <section title="Contributors">
      <t>Rajeev Seth provided substantial contributions to this
      document.</t>
    </section>
  </middle>

  <back>
    <references title="Normative References">
      <?rfc include="reference.RFC.2119"?>

      <?rfc include="reference.RFC.3550"?>

      <?rfc include="reference.RFC.3711"?>

      <?rfc include="reference.RFC.4347"?>

      <?rfc include="reference.RFC.5763"?>

      <?rfc include="reference.RFC.5764"?>

      <?rfc include="reference.RFC.6347"?>
    </references>

    <references title="Informative References">
      <?rfc include="reference.RFC.3261"?>

      <?rfc include="reference.RFC.4566"?>

      <?rfc include="reference.RFC.7092"?>

      <?rfc include="reference.I-D.ietf-avtext-rtp-grouping-taxonomy"?>

      <?rfc include="reference.I-D.ietf-straw-b2bua-rtcp"?>
    </references>
  </back>
</rfc>
