<?xml version="1.0" encoding="US-ASCII"?>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<?rfc toc="yes" ?>
<?rfc symrefs="yes" ?>
<?rfc sortrefs="no"?>
<?rfc iprnotified="no" ?>
<?rfc strict="no" ?>
<?rfc compact="no" ?>
<?rfc subcompact="no" ?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY RFC2246 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2246.xml">
<!ENTITY RFC4346 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4346.xml">
<!ENTITY RFC5246 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5246.xml">
<!ENTITY RFC4347 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4347.xml">
<!ENTITY RFC6066 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6066.xml">
<!ENTITY RFC3268 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3268.xml">
<!ENTITY RFC5763 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5763.xml">
<!ENTITY RFC4785 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4785.xml">
<!ENTITY RFC4279 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4279.xml">
<!ENTITY RFC5218 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5218.xml">
<!ENTITY RFC4101 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4101.xml">
<!ENTITY I-D.ietf-tls-oob-pubkey SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-tls-oob-pubkey.xml">
]>
<rfc category="std" docName="draft-tschofenig-lwig-tls-minimal-01.txt" ipr="trust200902">
  <front>
    <title abbrev="Minimal TLS">A Minimal (Datagram) Transport Layer Security Implementation</title>
 
    <author fullname="Hannes Tschofenig" initials="H.T."
            surname="Tschofenig">
      <organization>Nokia Siemens Networks</organization>
      <address>
      <postal>
        <street>Linnoitustie 6</street>
        <city>Espoo</city>
        <region></region>
        <code>02600</code>
        <country>Finland</country>
      </postal>
      <phone>+358 (50) 4871445</phone>
      <email>Hannes.Tschofenig@gmx.net</email>
      <uri>http://www.tschofenig.priv.at</uri>
      <!-- uri and facsimile elements may also be added -->
      </address>
    </author>
	 <author fullname="Johannes Gilger" initials="J.G."
            surname="Gilger">
      <organization>RWTH Aachen University</organization> 
      <address>
      <postal>
        <street>Mies-van-der-Rohe-Str. 15</street>
        <city>Aachen</city>
        <region></region>
        <code>52074</code>
        <country>Germany</country>
      </postal>
      <phone>+49 (0)241 80 20 781</phone>
      <email>Gilger@ITSec.RWTH-Aachen.de</email>
      <!-- uri and facsimile elements may also be added -->
      </address>
    </author>
    <date year="2012"/>
    <keyword>Internet-Draft</keyword>
    <keyword>TLS</keyword>
    <keyword>DTLS</keyword>
	<keyword>Internet of Things</keyword>
	<keyword>Smart Objects</keyword>

    <abstract>
   <t>Transport Layer Security (TLS) is a widely used security protocol that offers communication security services at the transport layer. The initial design of TLS was focused on the protection of applications running on top of the Transmission Control Protocol (TCP), and was a good match for securing the Hypertext Transfer Protocol (HTTP). Subsequent standardization efforts lead to the publication of Datagram Transport Layer Security (DTLS), which added the User Datagram Protocol (UDP), and the Datagram Congestion Control Protocol (DCCP). The Stream Control Transmission Protocol (SCTP), as a more recent connection-oriented transport protocol, also benefits from TLS support.</t>
   
   <t>TLS can be customized in a variety of ways and every feature has a certain cost. To offer input for implementers and system architects this document illustrates the impact each selected TLS features has on the overall code size.</t>
    </abstract>
  </front>

  <middle>

  <!-- ////////////////////////////////////////////////////////////////////////////////// -->

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

<t>The IETF published three versions of Transport Layer Security: TLS Version 1.0 <xref target="RFC2246"/>, TLS Version 1.1 <xref target="RFC4346"/>, and TLS Version 1.2 <xref target="RFC5246"/>. Section 1.1 of <xref target="RFC4346"/> explains the differences between Version 1.0 and Version 1.1; those are small security improvements, including the usage of an explicit initialization vector to protect against cipher-block-chaining attacks, which all have little impact for the size of the code. Section 1.2 of <xref target="RFC5246"/> describes the differences between Version 1.1 and Version 1.2. TLS 1.2 introduces a couple of major changes with impact to size of an implementation. In particular, prior TLS versions hardcoded the MD5/SHA-1 combination in the pseudorandom function (PRF). As a consequence, any TLS Version 1.0 and Version 1.1 implementation had to have MD5 and SHA-1 code even if the remaining cryptographic primitives used other algorithms. With TLS Version 1.2 the two had been replaced with cipher-suite-specified PRFs. In addition, the TLS extensions definition <xref target="RFC6066"/> and various AES ciphersuites <xref target="RFC3268"/> got merged into the TLS Version 1.2 specification.</t>

<t>All three TLS specifications list a mandatory-to-implement ciphersuite: for TLS Version 1.0 this was TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA, for TLS Version 1.1 it was TLS_RSA_WITH_3DES_EDE_CBC_SHA, and for TLS Version 1.2 it is TLS_RSA_WITH_AES_128_CBC_SHA. There is, however, an important qualification to these compliance statements, namely that they are only valid in the absence of an application profile standard specifying otherwise.</t>

<t>All TLS versions offer a separation between authentication and key exchange and bulk data protection. The former is more costly performance- and message-wise. The details of the authentication and key exchange, using the TLS Handshake, vary with the chosen ciphersuite. With new ciphersuites the TLS feature-set can easily be enhanced, in case the already large collection of ciphersuites, see <xref target="TLS-IANA"/>, does not match the requirements.</t>

<t>Once the TLS Handshake has been successfully completed the necessary keying material and parameters are setup for usage with the TLS Record Layer, which is responsible for bulk data protection. The TLS Record Layer could be compared with the IPsec AH and IPsec ESP while the Handshake protocol can be compared with the Internet Key Exchange Version 2 (IKEv2). The provided security of the TLS Record Layer depends also, but not only, on the chosen ciphersuite algorithms; NULL encryption ciphersuites, like those specified in RFC 4785 <xref target="RFC4785"/>, offer only integrity- without confidentiality-protection. Example ciphersuites for the TLS Record Layer are RC4 with SHA-1, AES-128 with SHA-1, AES-256 with SHA-1, RC4 with SHA-1, RC4 with MD5</t>

<t>It is worth mentioning that TLS may also be used without the TLS Record Layer. This has, for example, been exercised with the work on the framework for establishing a Secure Real-time Transport Protocol (SRTP) security context using the Datagram Transport Layer Security (DTLS <xref target="RFC4347"/>) protocol (DTLS-SRTP <xref target="RFC5763"/>).</t>

</section> 

  <!-- ////////////////////////////////////////////////////////////////////////////////// -->

<section anchor="relationships" title="Communication Relationships">

<t>A security solution is strongly influenced by the communication relationships <xref target="RFC4101"/>, which will have an impact on the code size. Having a good understanding of these relationships will be essential.</t>

<t>Consider the following scenario where a smart meter transmits its energy readings to other parties. The public utility has to ensure that the meter readings it obtained can be attributed to a specific meter in a household. It is simply not acceptable for public utility to have any meter readings in transit or by a rogue endpoint (particularly if the attack leads to a disadvantage, for example financial loss, for the utility). Users in a household may want to ensure that only certain parties are able to read their meter; privacy concerns come to mind.</t>

<t>In this example, a sensor may only ever need to talk to servers of a specific utility or even only to a single pre-configured server. Clearly, some information has to be pre-provisioned into the device to ensure the desired behavior to talk only to selected servers. The meter may come pre-configured with the domain name and certificate belonging to the utility. The device may, however, also be configured to accept one or multiple server certificates. It may even be pre-provisioned with the server's raw public key, or a shared secret instead of relying on certificates.</t>

<t>Lowering the flexibility decreases the implementation overhead. TLS-PSK <xref target="RFC4279"/>, if shared secrets are used, or raw public keys used with TLS <xref target="I-D.ietf-tls-oob-pubkey"/> require fewer lines of code than employing X.509 certificate, as it will be explained later in this document. A decision for constraining the client-side TLS implementation, for example by offering only a single ciphersuite, has to be made in awareness of what functionality will be available on the TLS server-side. In certain communication environments it may be easy to influence both communication partners while in other cases the existing deployment needs to be taken into consideration.</t>

<t>To illustrate another example, consider an Internet radio, which allows a user to connect to available radio stations. A device like this will be more demanding than an IP-enabled scale that only connects to the single Web server offered by the device manufacturer. A threat assessment may even lead to the conclusion that TLS support is not necessary at all.</t>

<t>Consider the following extension to our earlier scenario where the meter is attached to a home WLAN network and the interworking with WLAN security mechanisms need to be taken care of. On top of the link layer authentication, a transport layer or application layer security mechanism needs to be implemented. Quite likely the security mechanisms will be different due to the different credential requirements. While there is a possibility for re-use of cryptographic libraries (such as the SHA-1, MD5, or HMAC) the overall code footprint will very likely be larger.</t>

</section> 

  <!-- ////////////////////////////////////////////////////////////////////////////////// -->

<section title="Design Decisions">

<t>To evaluate the required TLS functionality a couple of high level design decisions have to be made:
<list style="symbols">
<t>What type of protection for the data traffic is required? Is confidentiality protection in addition to integrity protection required? Many TLS ciphersuites also provide a variant for NULL encryption. If confidentiality protection is required, a carefully chosen set of algorithms may have a positive impact on the code size. For example, the RC4 stream cipher code size is 1,496 bytes compared to 7,096 bytes for AES usage. Re-use of crypto-libraries (within TLS but also among the entire protocol stack) will also help to reduce the overall code size.</t>
<t>What functionality is available in hardware? For example, certain hardware platforms offer support for a random number generator as well as cryptographic algorithms (e.g., AES). These functions can be re-used and allow to reduce the amount of required code.</t>
<t>What credentials for client and server authentication are required: passwords, pre-shared secrets, certificates, raw public keys (or a mixture of them)? Is certificate handling necessary? If not, then the ASN.1 library as well as the certificate parsing and processing can be omitted. If pre-shared secrets are used then the big integer implementation can be omitted.</t>
<t>What TLS version and what TLS features, such as session resumption, can or have to be used?</t>
<t>Is necessary to design only the client-side TLS stack, or to provide the server-side implementation as well?</t>
<t>Is it possible to hardwire credentials into the code rather than loading them from storage? If so, then no file handling or parsing of the credentials is needed and the credentials are already available in form that they can be used within the TLS implementation.</t>
</list> 
</t>
</section> 

  <!-- ////////////////////////////////////////////////////////////////////////////////// -->

<section title="Conclusion">

<t>The IAB published a document, RFC 5218 <xref target="RFC5218"/>, on the success criteria for protocols. A "wildly successful" protocol far exceeds its original goals, in terms of purpose (being used in scenarios far beyond the initial design), in terms of scale (being deployed on a scale much greater than originally envisaged), or both.
TLS is an example of such a wildly successful protocol. It can be tailored to fit the needs of a specific deployment environment. This customization property offers the basis for a relatively small code footprint. The communication model and the security goals will, however, ultimately decide about the resulting code size; this is not only true for TLS but for every security solution.</t>

<t>More flexibility and more features will translate to a bigger footprint. Generic complaints about the large size of TLS stacks are not useful and should be accompanied by a description of the assumed functionality. To support the author's opinion this position paper provides information about the amount of required code for various functions and considers most recent work from the IETF TLS working group for the support of raw public keys.</t>

<t>The author is convinced that TLS is a suitable security protocol (with the standardized extensions) for usage in many smart object deployments. Only minor extensions, as currently being developed in the IETF TLS working group, are needed to support an even larger set of use cases. There are, however, cases where the security goals ask for a security solution other than TLS. With the wide range of embedded applications it is impractical to design for a single security architecture or even a single communication architecture.</t> 


</section>

    <!-- ////////////////////////////////////////////////////////////////////////////////// -->

    <section anchor="sec-cons" title="Security Considerations">
   
<t>This document discusses various design aspects for reducing the footprint of TLS implementations. As such, it is entirely about security.</t>

    </section> 

    <!-- ////////////////////////////////////////////////////////////////////////////////// -->
	
<section title="IANA Considerations">

<t>This document does not contain actions for IANA.</t>

</section> 

    <!-- ////////////////////////////////////////////////////////////////////////////////// -->
   
<section title="Acknowledgements">
<t>The author would like to thank the participants of the Smart Object Security workshop, March 2012. </t>
</section> 

    <!-- ////////////////////////////////////////////////////////////////////////////////// -->
  </middle>

  <!-- ////////////////////////////////////////////////////////////////////////////////// -->

  <back>
    <references title="Normative References">
    &RFC2246;
&RFC4346;
&RFC5246;
&RFC4347;
    </references>
    <references title="Informative References">
&RFC6066;
&RFC3268;
&RFC5763;
&RFC4785;
&RFC4279;
&I-D.ietf-tls-oob-pubkey;
&RFC5218;
&RFC4101;

<reference anchor="TLS-IANA">
        <front>
          <title>Transport Layer Security (TLS) Parameters: http://www.iana.org/assignments/tls-parameters/tls-parameters.xml</title>
          <author fullname="IANA" initials="" surname="IANA">
            <organization>IANA</organization>
          </author>
          <date month="Oct" year="2012"/>
        </front>
      </reference>

    </references>

  </back>
</rfc>
