<?xml version="1.0" encoding="US-ASCII"?>
<!-- comment -->
<!DOCTYPE rfc SYSTEM "rfc2629.dtd"[]>
<?rfc toc="yes" ?>
<?rfc compact="yes" ?>
<?rfc sortrefs="no" ?>
<rfc number="8055"
     ipr="trust200902"
     category="std" 
     submissionType="IETF" 
     consensus="yes"
     xml:lang="en">
	<front>
		<title abbrev="Received Realm">
			Session Initiation Protocol (SIP) Via Header Field
			Parameter to&nbsp;Indicate&nbsp;Received&nbsp;Realm
		</title>
		<author initials="C.H." surname="Holmberg" fullname="Christer Holmberg">
			<organization>Ericsson</organization>
			<address>
				<postal>
					<street>Hirsalantie 11</street>
					<code>02420</code>
					<city>Jorvas</city>
					<country>Finland</country>
				</postal>
				<email>christer.holmberg@ericsson.com</email>
			</address>
		</author>
		<author initials="Y.J." surname="Jiang" fullname="Yi Jiang ">
			<organization>China Mobile</organization>
			<address>
				<postal>
					<street> No.32 Xuanwumen West Street </street>
					<code> Xicheng District 100053</code>
					<city>Beijing</city>
					<country>China</country>
				</postal>
				<email>jiangyi@chinamobile.com</email>
			</address>
		</author>
		<date month="January" year="2017" />
		<area>Transport</area>
		<workgroup>SIPCORE Working Group</workgroup>
		<keyword>SIP</keyword>
		<keyword>Via</keyword>
		<keyword>transit</keyword>
		<keyword>realm</keyword>
		<abstract>
			<t>
				This specification defines a new Session Initiation Protocol (SIP)
				Via header field parameter, 'received-realm', which allows a SIP entity acting
				as an entry point to a transit network to indicate from which adjacent upstream
				network a SIP request is received by using a network realm value associated
				with the adjacent network.
			</t>
		</abstract>

	</front>
	<middle>
		<section title="Introduction" toc="default">
			<section title="General" toc="default">
				<t>
          When Session Initiation Protocol (SIP) <xref target="RFC3261"/>
          sessions are established between networks belonging to different
					operators or between interconnected networks belonging to the same operator
					(or enterprise), the SIP requests associated with the session might
          traverse transit networks.
				</t>
				<t>
					Such transit networks might provide different kinds of services. In order
					to provide such services, a transit network often needs to know to which operator
					(or enterprise) the adjacent upstream network from which the SIP session
					initiation request is received belongs.
				</t>
				<t>
					This specification defines a new SIP
					Via header field parameter, 'received-realm', which allows a SIP entity acting
					as an entry point to a transit network to indicate from which adjacent upstream
					network a SIP request is received by using a network realm value associated
					with the adjacent network.
				</t>
				<t>
					NOTE: As the adjacent network can be an enterprise network, an Inter Operator
					Identifier (IOI) cannot be used to
					identify the network because IOIs are not
					defined for enterprise networks.
				</t>
				<t>
					The following sections describe use cases where the information is needed.
				</t>
			</section>
			<section title="Use Case: Transit Network Application Services" toc="default">
				<t>
					The Third Generation Partnership Project (3GPP) TS 23.228 <xref target="TS.3GPP.23.228"
					pageno="false" format="default"/> specifies how an IP Multimedia Subsystem (IMS)
					network can be used to provide transit functionality. An operator can use its IMS
					network to provide transit functionality, e.g., to non-IMS customers, to enterprise
					networks, and to other network operators.
				</t>
				<t>
					The transit network operator can provide application services to the networks
					for which it is providing transit functionality. Transit application services are
					typically not provided on a per user basis, as the transit network does not have access
					to the user profiles of the networks for which the application services are provided.
					Instead, the application services are provided per served network.
				</t>
				<t>
					When a SIP entity that provides application services (e.g., an Application Server)
					within a transit network receives a SIP request, in order to apply the correct
					services, it needs to know the adjacent upstream network from which the SIP request
					is received.
				</t>
			</section>
			<section title="Use Case: Transit Network Routing" toc="default">
				<t>
					A transit network operator normally interconnects to many different
   					operators, including other transit network operators, and provides
   					transit routing of SIP requests received from one operator network
   					towards the destination. The destination can be within an operator network
   					to which the transit network operator has a direct interconnect or
					within an operator network that only can be reached via one or more
   					interconnected transit operators.
				</t>
				<t>
   					For each customer (i.e., interconnected network operator) for which
   					the transit network operator routes SIP requests towards the
   					requested destination, a set of transit routing policies are defined.
   					These policies are used to determine how a SIP request shall be routed
   					towards the requested destination to meet the agreement the transit
   					network operator has with its customer.
				</t>
				<t>
   					When a SIP entity that performs the transit routing functionality
   					receives a SIP request, in order to apply the correct set of transit
   					routing policies, it needs to know from which of its
   					customers (i.e., adjacent upstream network) the SIP request is
   					received.
				</t>
			</section>
		</section>

		<section title="Applicability" toc="default">
			<t>
				The mechanism defined in this specification MUST only be used by SIP entities that
				are able to verify from which adjacent upstream network a SIP request is received.
			</t>
			<t>
				The mechanism for verifying from which adjacent upstream network a SIP request is
				received is outside the scope of this
				specification. Such a mechanism might be
				based on, for instance, receiving the SIP request on an authenticated Virtual Private
				Network (VPN), on a
				specific IP address, or on a specific
				network access.
			</t>
		</section>

		<section title="Conventions" toc="default">
			<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
				BCP 14, RFC 2119 <xref target="RFC2119" pageno="false" format="default" />.
			</t>
		</section>

		<section title="Definitions" toc="default">
			<t>
				SIP entity: A SIP User Agent (UA), or SIP proxy, as defined in RFC 3261.
			</t>
			<t>
				Adjacent upstream SIP network: The adjacent SIP network in the direction
				from which a SIP request is received.
			</t>
			<t>
				Network entry point: A SIP entity on the
				border of the network, which receives SIP requests
				from adjacent upstream networks.
			</t>
			<t>
				Inter Operator Identifier (IOI): A globally unique identifier to correlate billing
				information generated within the IP Multimedia Subsystem (IMS).
			</t>
			<t>
				JWS: A JSON Web Signature, as defined in <xref target="RFC7515" pageno="false" format="default"/>.
			</t>
		</section>

		<section title="Via 'received-realm' Header Field Parameter" anchor="sec-via" toc="default">
			<section title="General" anchor="sec-via-gen">
        <t>
						The Via 'received-realm' header field parameter value is represented as a
						combination of an operator identifier whose value represents the adjacent
						network and a serialized JSON Web Signature (JWS) <xref target="RFC7515" pageno="false" format="default"/>.
						The JWS Payload consists of the operator identifier and other SIP information element values.
				</t>
				<t>
						The procedures for encoding the JWS and calculating the signature are defined in
						<xref target="RFC7515" pageno="false" format="default"/>. As the JWS Payload
						information is found in other SIP information elements, the JWS Payload is detached
						from the serialized JWS conveyed in the header field parameter, as described in Appendix F of
						<xref target="RFC7515" pageno="false" format="default"/>. The operator identifier and
						the serialized JWS are separated using a colon character.
				</t>
			</section>
			<section title="Operator Identifier" anchor="sec-via-ope">
        <t>
					The operator identifier is a token value that represents the adjacent operator. The
					scope of the value is only within the network that inserts the value.
        </t>
				<t>
					The operator identifier value is case insensitive.
				</t>
			</section>
			<section title="JWS Header" anchor="sec-via-header">
					<t>The following header parameters MUST be included in the JWS.
							<list style="symbols">
									<t>The "typ" parameter MUST have a "JWT" value.</t>
									<t>The "alg" parameter MUST have the value of the algorithm used to calculate the JWS.</t>
							</list>
					</t>
					<t>
						NOTE: Operators need to agree on the set of supported algorithms for calculating the JWT signature.
					</t>
					<t>
						NOTE: The "alg" parameter values for specific algorithms are listed in the IANA JSON Web Signature
						and Encryption Algorithms sub-registry of the JSON Object Signing and Encryption (JOSE) registry.
						Operators need to use algorithms for which an associated "alg" parameter value has been
						registered. The procedures for defining new values are defined in <xref target="RFC7518" pageno="false"
						format="default"/>.
					</t>
                                        <figure>
                            <artwork align="left" alt="" height="" name="" type="" width="" xml:space="preserve"><![CDATA[
Example:

{
        "typ":"JWT",
        "alg":"HS256"
}
                            ]]></artwork>
 </figure>
				</section>
				<section title="JWS Payload" anchor="sec-via-payload">
					<t>The following claims MUST be included in the JWS Payload:
						<list style="symbols">
						<t> The "sip_from_tag" claim has the value of the From 'tag' header field parameter of the SIP message.</t>
						<t> The "sip_date" claim has
						the value of the Date header
						field in the SIP message,
							encoded in JSON NumericDate format <xref target="RFC7519" pageno="false" format="default"/>.</t>
						<t> The "sip_callid" claim has the value of the Call-ID header field in the SIP message.</t>
						<t> The "sip_cseq_num" claim
						has the numeric value of the
						CSeq header field in the SIP message.</t>
						<t> The "sip_via_branch" claim
						has the value of the Via branch header field parameter of the Via header
					            field, in the SIP message, to which the 'received-realm' header field parameter is attached.</t>
						<t> The "sip_via_opid" claim
						has the value of the operator identifier part of the Via 'received-realm'
							header field parameter of the Via header field, in the SIP message, to which the 'received-realm'
							header field parameter is attached.</t>
					  </list>
					</t>
                                        <figure>
                            <artwork align="left" alt="" height="" name="" type="" width="" xml:space="preserve"><![CDATA[
Example:

{
        "sip_from_tag":"1928301774",
        "sip_date":1472815523,
        "sip_callid":"a84b4c76e66710@pc33.atlanta.com",
        "sip_cseq_num":"314159",
        "sip_via_branch":"z9hG4bK776asdhds",
        "sip_via_opid":"myoperator"
}
                            ]]></artwork>
	        </figure>
			</section>

      <section title="JWS Serialization" anchor="sec-via-serialization">
				<t>
				  As the JWS Payload is not carried in the 'received-realm' parameter,
			    in order to make sure that the sender and the receiver construct the
			    JWS Payload object in the same way, the JSON representation of the
			    JWS Payload object MUST be computed as follows:
          <list style="symbols">
           <t>All claims MUST be encoded using lowercase characters.</t>
           <t>The claims MUST be in the same order as listed in
					 <xref target="sec-via-payload" pageno="false" format="default"/>.</t>
           <t>All claims except "sip_date" MUST be encoded as StringOrURI JSON
			     string value <xref target="RFC7519" pageno="false" format="default"/>.</t>
			     <t>The "sip_date" claim MUST be encoded as a JSON NumericDate value
			     <xref target="RFC7519" pageno="false" format="default"/>.</t>
			     <t>The JWS Payload MUST follow the rules for the construction of the
			     thumbprint of a JSON Web Key (JWK) as defined in
			     
			     Section 3, Step 1 only, of 
					 <xref target="RFC7638" pageno="false" format="default"/>.</t>
				  </list>
			  </t>

<!-- [rfced] Is the example in Section 5.5 intentionally formatted
differently than the examples in Sections 5.3 and 5.4?
If not, would you like it to be updated as follows?

Original:
 {"sip_from_tag":"1928301774","sip_date":1472815523,
 "sip_callid":"a84b4c76e66710@pc33.atlanta.com","sip_cseq_num":"314159",
 "sip_via_branch":"z9hG4bK776asdhds","sip_via_opid":"myoperator"}

Perhaps:
   {
           "sip_from_tag":"1928301774",
           "sip_date":1472815523,
           "sip_callid":"a84b4c76e66710@pc33.atlanta.com",
           "sip_cseq_num":"314159",
           "sip_via_branch":"z9hG4bK776asdhds",
           "sip_via_opid":"myoperator"
   }
-->

                                <figure>
                                <artwork align="left" alt="" height="" name="" type="" width="" xml:space="preserve"><![CDATA[
Example:

{"sip_from_tag":"1928301774","sip_date":1472815523,
"sip_callid":"a84b4c76e66710@pc33.atlanta.com",
"sip_cseq_num":"314159","sip_via_branch":"z9hG4bK776asdhds",
"sip_via_opid":"myoperator"}
                                ]]></artwork>
				</figure>
<t>NOTE: Line breaks are for display purposes only.</t>
			</section>

			<section title="Syntax" anchor="sec-syntax" toc="default">
				<section title="General" anchor="sec-syntax-gen" toc="default">
					<t>
						This section describes the syntax extensions to the ABNF syntax defined in
						<xref target="RFC3261" pageno="false" format="default"/> by defining a
						new Via header field parameter, 'received-realm'.  The ABNF defined in this
						specification is conformant to RFC 5234 <xref target="RFC5234" pageno="false"
						format="default"/>. "EQUAL", "LDQUOT", "RDQUOT", and "ALPHA" are defined in
						<xref target="RFC3261" pageno="false" format="default"/>. "DIGIT" is defined in
						<xref target="RFC5234" pageno="false" format="default"/>.
					</t>
				</section>

				<section title="ABNF" anchor="sec-syntax-abnf" toc="default">
                                      
 <figure>
                                                <preamble></preamble>
                                                <artwork><![CDATA[
via-params     =/ received-realm
received-realm = "received-realm" EQUAL LDQUOT op-id COLON jws RDQUOT
op-id          = token
jws            = header ".." signature
header         = 1*base64-char
signature      = 1*base64-char
base64-char    = ALPHA / DIGIT / "/" / "+"
]]></artwork></figure>

<t>
  EQUAL, COLON, token, LDQUOT, RDQUOT, ALPHA, and DIGIT
  are as defined in <xref target="RFC3261"/>.
</t>
<t>
  NOTE: The two adjacent dots in the 'jws' part are due to the detached
  payload being replaced by an empty string <xref target="RFC7515"/>.
</t>
				</section>
			</section>

			<section title="Example: SIP Via Header Field" anchor="sec-example" toc="default">
                                <figure>
                                        <preamble></preamble>
                                        <artwork><![CDATA[
Via: SIP/2.0/UDP pc33.example.com;branch=z9hG4bK776;
received-realm="myoperator:eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1N..
dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"
                                        ]]></artwork>
 </figure>
<t>NOTE: Line breaks are for display purposes only.</t>

			</section>
		</section>

		<section title="User Agent and Proxy Behavior" anchor="sec-sipent" toc="default">
			<section title="General" anchor="sec-sipent-gen" toc="default">
				<t>
					This section describes how a SIP entity, acting as an entry point to
					a network, uses the 'received-realm' Via header field parameter.
				</t>
			</section>

			<section title="Behavior of a SIP Entity Acting as a Network Entry Point" anchor="sec-sipent-recv" toc="default">
				<t>
					When a SIP entity acting as a network
					entry point forwards a SIP request or initiates a SIP request
					on its own (e.g., a Public Switched
					Telephone Network (PSTN) gateway), the SIP entity adds a Via header field to the SIP request, according
					to the procedures in RFC 3261 <xref target="RFC3261" pageno="false" format="default" />. In addition, if
					the SIP entity is able to assert the adjacent upstream network and if the SIP entity is aware of a network
					realm value defined for that network, the SIP entity can add a 'received-realm' Via header field parameter
					conveying the network realm value as the operator identifier (<xref target="sec-via-ope" pageno="false" format="default" />)
					part of the header field parameter, to the Via header field added to the SIP request.
				</t>
				<t>
          In addition, the SIP entity MUST also calculate a JWS (<xref target="sec-via-payload" pageno="false" format="default" />)
          and add the calculated JWS Header and JWS Signature as the 'jws' part of the Via header field parameter.
				</t>
			</section>
			<section title="Behavior of a SIP Entity Consuming the 'received-realm' Value" anchor="sec-sipent-cons" toc="default">
				<t>
					When a SIP entity receives a Via 'received-realm' header field parameter and intends to perform actions
					based on the header field parameter value, it MUST first recalculate the JWS and check whether the result
					matches the JWS received. If there is not a match, the SIP entity MUST discard the received 'received-realm'
					header field parameter. The SIP entity
					MAY also take additional actions (e.g., rejecting the SIP request)
					based on local policy.
				</t>
			</section>
		</section>

    	<section title="Example: SIP INVITE Request and Response" toc="default">
                       
<t>This section shows an example of a SIP INVITE request and the associated
response, which contains a Via header field (inserted into the request and
removed from the response by the T_EP SIP proxy) with a 'received-realm'
header field parameter.</t>

 <figure>
                                <preamble></preamble>
                                <artwork><![CDATA[
Operator 1    T_EP                                 T_AS

- INVITE ------>
  Via: SIP/2.0/UDP IP_UA
              -- INVITE ---------------------------->
                 Via: SIP/2.0/UDP IP_TEP;branch=z9hG4bK776;
                  received-realm="myoperator:eyJ0eXAiOiJKV1QiLA0KICJh
                  bGciOiJIUzI1N..dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW
                  1gFWFOEjXk"
                 Via: SIP/2.0/UDP IP_UA; received=IP_UA

              <- 200 OK ----------------------------
                 Via: SIP/2.0/UDP IP_TEP;branch=z9hG4bK776;
                  received-realm="myoperator:eyJ0eXAiOiJKV1QiLA0KICJh
                  bGciOiJIUzI1N..dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW
                  1gFWFOEjXk"
                 Via: SIP/2.0/UDP IP_UA; received=IP_UA

<- 200 OK------
   Via: SIP/2.0/UDP IP_UA; received=IP_UA
                                ]]></artwork>
			</figure>
		</section>

		<section title="IANA Considerations" anchor="iana" toc="default">
			<section title="'received-realm' Via Header Field Parameter" anchor="iana-param" toc="default">
				<t>
					This specification defines a new Via header field parameter
					called 'received-realm' in the "Header Field Parameters and Parameter Values"
					sub-registry created by <xref target="RFC3968"
					pageno="false" format="default"/>. The syntax is defined in
					<xref target="sec-syntax"/>. The required information is:
				</t>
                                <figure>
                                        <preamble></preamble>
                                        <artwork><![CDATA[
                                               Predefined
Header Field            Parameter Name         Values      Reference
----------------------  ---------------------  ----------  ---------
Via                     received-realm         No          RFC 8055
                                        ]]></artwork>
                                </figure>
			</section>
			<section title="JSON Web Token Claims Registration" anchor="iana-claims" toc="default">
				<t>
					This specification defines new JSON Web Token claims in
					the "JSON Web Token Claims" sub-registry 
					created by <xref target="RFC7519" pageno="false" format="default"/>.
<?rfc subcompact="yes" ?>
					<list>
					 <t>Claim Name: sip_from_tag</t>
					 <t>Claim Description: SIP From tag header field parameter value</t>
					 <t>Change Controller: IESG</t>
					 <t>Reference: RFC 8055, RFC 3261
<vspace blankLines="1" /></t>
					 <t>Claim Name: sip_date</t>
					 <t>Claim Description: SIP Date header field value</t>
					 <t>Change Controller: IESG</t>
					 <t>Reference: RFC 8055, RFC 3261
<vspace blankLines="1" /></t>
					 <t>Claim Name: sip_callid</t>
					 <t>Claim Description: SIP Call-Id header field value</t>
					 <t>Change Controller: IESG</t>
					 <t>Reference: RFC 8055, RFC 3261
<vspace blankLines="1" /></t>
					 <t>Claim Name: sip_cseq_num</t>
					 <t>Claim Description: SIP CSeq numeric header field parameter value</t>
					 <t>Change Controller: IESG</t>
					 <t>Reference: RFC 8055, RFC 3261
<vspace blankLines="1" /></t>
					 <t>Claim Name: sip_via_branch</t>
					 <t>Claim Description: SIP Via branch header field parameter value</t>
					 <t>Change Controller: IESG</t>
					 <t>Reference: RFC 8055, RFC 3261</t>
					</list>
<?rfc subcompact="no" ?>
				</t>
			</section>
  </section>

  <section title="Security Considerations" anchor="sec-security" toc="default">
			<t>
				As the 'received-realm' Via header field parameter can be used
				to trigger applications, it is important to ensure that the parameter
				has not been added to the SIP message by an unauthorized SIP entity.
			</t>
			<t>
        The 'received-realm' Via header field parameter is inserted, signed,
        verified, and consumed within an operator network. The operator MUST
        discard parameters received from another network, and the parameter
        MUST only be inserted by SIP entities that are able to verify from
        which adjacent upstream network a SIP request is received.
      </t>
			<t>
				The operator also needs to take great care in ensuring that the key used
				to calculate the JWS Signature value is only known by the network entities
				signing and adding the JWS Signature to the 'received-realm' Via
				header field parameter of a SIP message and to network entities
				verifying and consuming the parameter value.
			</t>
			<t>
        The operator MUST use a key management policy that protects against
        unauthorized access to the stored keys within nodes where the keys
        associated with the JWS Signature are stored and that protects against
				cryptoanalysis attacks using captured data sent on the wire.
      </t>
			<t>
				A SIP entity MUST NOT use the adjacent network information if
				there is a mismatch between the JWS Signature received in the SIP header
				field and the JWS Signature calculated by the receiving entity.
			</t>
			<t>
				Generic security considerations for JWS are defined in
				<xref target="RFC7515" pageno="false" format="default"/>.
			</t>
	</section>

	</middle>
	<back>
		<references title="Normative References">
			<?rfc include="reference.RFC.2119"?>
			<?rfc include="reference.RFC.3261"?>
			<?rfc include="reference.RFC.5234"?>
			<?rfc include="reference.RFC.7515"?>
			<?rfc include="reference.RFC.7519"?>
			<?rfc include="reference.RFC.7638"?>
		</references>
		<references title="Informative References">
			<?rfc include="reference.RFC.3968"?>
			<?rfc include="reference.RFC.7518"?>
			<reference anchor="TS.3GPP.23.228" target="http://www.3gpp.org/ftp/Specs/html-info/23228.htm">
			<front>
				<title>IP Multimedia Subsystem (IMS); Stage 2</title>
				<author><organization>3GPP</organization></author>
				<date year="2016" month="September"/>
			</front>
			<seriesInfo value="23.228 14.1.0" name="3GPP TS"/>
			</reference>
		</references>
<section title="Acknowledgements" anchor="sec-acks" toc="default" numbered="no">
<t>
Thanks to Adam Roach and Richard Barnes for providing comments and 
feedback on the document. Francis Dupoint performed the Gen-ART
review.
</t>
</section>
	</back>
</rfc>
