<?xml version="1.0" encoding="US-ASCII"?>
<!-- This template is for creating an Internet Draft using xml2rfc,
     which is available here: http://xml.resource.org. -->
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!-- One method to get references from the online citation libraries.
     There has to be one entity for each item to be referenced. 
     An alternate method (rfc include) is described in the references. -->
<!ENTITY RFC5905 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5905.xml">
<!ENTITY RFC7539 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7539.xml">
<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC6151 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6151.xml">
<!ENTITY RFC3552 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3552.xml">
<!ENTITY RFC2104 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2104.xml">
<!ENTITY RFC7630 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7630.xml">
<!ENTITY RFC4493 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4493.xml">
<!ENTITY RFC4543 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4543.xml">
<!ENTITY I-D.narten-iana-considerations-rfc2434bis SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.narten-iana-considerations-rfc2434bis.xml">
]>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<!-- used by XSLT processors -->
<!-- For a complete list and description of processing instructions (PIs), 
     please see http://xml.resource.org/authoring/README.html. -->
<!-- Below are generally applicable Processing Instructions (PIs) that most I-Ds might want to use.
     (Here they are set differently than their defaults in xml2rfc v1.32) -->
<?rfc strict="yes" ?>
<!-- give errors regarding ID-nits and DTD validation -->
<!-- control the table of contents (ToC) -->
<?rfc toc="yes"?>
<!-- generate a ToC -->
<?rfc tocdepth="4"?>
<!-- the number of levels of subsections in ToC. default: 3 -->
<!-- control references -->
<?rfc symrefs="yes"?>
<!-- use symbolic references tags, i.e, [RFC2119] instead of [1] -->
<?rfc sortrefs="yes" ?>
<!-- sort the reference entries alphabetically -->
<!-- control vertical white space 
     (using these PIs as follows is recommended by the RFC Editor) -->
<?rfc compact="yes" ?>
<!-- do not start each main section on a new page -->
<?rfc subcompact="no" ?>
<!-- keep one blank line between list items -->
<!-- end of list of popular I-D processing instructions -->
<rfc category="std" docName="draft-aanchal4-ntp-mac-00" ipr="trust200902">
  <!-- category values: std, bcp, info, exp, and historic
     ipr values: full3667, noModification3667, noDerivatives3667
     you can add the attributes updates="NNNN" and obsoletes="NNNN" 
     they will automatically be output with "(if approved)" -->

  <!-- ***** FRONT MATTER ***** -->

  <front>
    <!-- The abbreviated title is used in the page header - it is only necessary if the 
         full title is longer than 39 characters -->

    <title abbrev="MACs for NTP">
    Message Authentication Codes for the Network Time Protocol
    </title>

    <!-- add 'role="editor"' below for the editors if appropriate -->

    <!-- Another author who claims to be an editor -->


    <author fullname="Aanchal Malhotra" initials="A." surname="Malhotra">
      <organization>Boston University </organization>

      <address>
        <postal>
          <street>111 Cummington St</street>

          <!-- Reorder these if your country does things differently -->

          <city>Boston, MA</city>

          <region/>

          <code>02215</code>

          <country>US</country>
        </postal>

        <phone/>

        <email>aanchal4@bu.edu</email>

        <!-- uri and facsimile elements may also be added -->
      </address>
    </author>

    <author fullname="Sharon Goldberg" initials="S." surname="Goldberg">
      <organization>Boston University</organization>

      <address>
        <postal>
          <street>111 Cummington St</street>

          <!-- Reorder these if your country does things differently -->

          <city>Boston, MA</city>

          <region/>

          <code>02215</code>

          <country>US</country>
        </postal>

        <phone/>

        <email>goldbe@cs.bu.edu</email>

        <!-- uri and facsimile elements may also be added -->
      </address>
    </author>

<!-- other authors -->

    <date year="2016"/>

    <!-- If the month and year are both specified and are the current ones,
         xml2rfc will fill in the current day for you. If only the current
         year is specified, xml2rfc will fill in the current day and month
         for you. If the year is not the current one, it is necessary to
         specify at least a month (xml2rfc assumes day="1" if not specified
         for the purpose of calculating the expiry date).  With drafts it is
         normally sufficient to specify just the year. -->

    <!-- Meta-data Declarations -->

    <area>General</area>

    <workgroup>Internet Engineering Task Force</workgroup>

    <!-- WG name at the upperleft corner of the doc,
         IETF is fine for individual submissions.  
	 If this element is not present, the default is "Network Working
         Group", which is used by the RFC Editor as a nod to the history of
         the IETF. -->

    <keyword>NTP</keyword>

    <!-- Keywords will be incorporated into HTML output
         files in a meta tag but they have no effect on text or nroff
         output. If you submit your draft to the RFC Editor, the
         keywords will be used for the search engine. -->

    <abstract>
      <t>The Network Time Protocol (NTP) <xref target="RFC5905">RFC 5905</xref>
      uses a message authentication code (MAC) to cryptographically 
      authenticate its UDP packets.  Currently, NTP packets are authenticated 
      by appending a 128-bit key to the NTP data, and hashing the result with
      MD5 to obtain a 128-bit tag. However, as discussed in <xref target="BCK"></xref> and
      <xref target="RFC6151"></xref>, this not a secure MAC.  As such,
      this draft considers different secure MAC algorithms for use with NTP,
      and evaluates their performance. Given the security concerns, we also suggest deprecating the use of MD5 as defined in [RFC5905] for authenticating NTP packets.
      </t>
    </abstract>
  </front>

  <middle>
    <section title="Introduction">
      <t>NTP uses a message authentication code (MAC) to authenticate its packets. 
      Currently, NTP packets are authenticated by appending a 128-bit key to
      the NTP data, and hashing the result with MD5 to obtain a 128-bit tag.
      
      However, as discussed in <xref target="BCK"></xref> and
      <xref target="RFC6151"></xref>, this not a secure MAC.  As such,
      this draft considers different secure MAC algorithms for use with NTP,
      and evaluates their performance. Given the security concerns, we also suggest deprecating the use of MD5 as defined in [RFC5905] for authenticating NTP packets.</t>
      
      
      <section title="Requirements Language">
        <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">RFC 2119</xref>.</t>
      </section>
    </section>


    <section title="MAC Algorithms">
      
      <t>
      We consider five diverse MAC algorithms, which encompass hash-based HMAC-MD5 
      and HMAC-SHA224 <xref target="RFC2104"></xref>, 
      block cipher-based CMAC-AES <xref target="RFC4493"></xref>,
      and universal hashing-based Galois MAC (GMAC) <xref target="RFC4543"></xref>
      and Poly1305(ChaCha20) as in section 2.6 of <xref target="RFC7539"></xref>.
      For completeness we also benchmark  the legacy MD5(key||message) from 
      <xref target="RFC5905"></xref>.</t>
      
        <texttable>
                <ttcol>Algorithm </ttcol>
                <ttcol align="right">Input Key Length (Bytes) </ttcol>
                <ttcol align="right">Output Tag Length (Bytes)  </ttcol>
                <ttcol align="right">Security Level (bits)  </ttcol>
                <c>legacy MD5</c>       <c>16</c> <c>16</c> <c>NA</c>
                <c>HMAC-MD5</c>       <c>16</c> <c>16</c><c>NA</c>
                <c>HMAC-SHA224</c>    <c>16</c> <c>28</c> <c>112</c>
                <c>CMAC(AES)</c>      <c>16</c> <c>16 </c><c>128 </c>
                <c>GMAC(AES)</c>      <c>16</c> <c>16</c><c>128</c>
                <c>Poly1305(ChaCha20)</c>  <c>32 </c><c>16 </c><c>128</c>
            </texttable>

      
      <t>
      The choice of algorithms evaluated here is motivated, in part, by standardization
      and availablity of open source implementation. Four out of five algorithms 
      are at least available in the OpenSSL library and are standardized. The Poly1305(ChaCha20) algorithm is implemented
      in LibreSSL, a fork of OpenSSL and also in BoringSSL, Google's 
      implementation of OpenSSL.</t>
      
      
    </section>


    <section title="Performance Requirements">
    
    
      <t>  In order to accurately compute the time,
      NTP ideally requires MAC algorithms to have a constant 
      computational latency.  However, this is generally not possible, 
      since latency depends on the CPU load, temperature, and other 
      uncontrollable factors.  Instead, a MAC algorithm that requires fewer 
      clock cycles for computation is prefered over one that requires more
      clock cycles, as this directly translates to a reduction
      in jitter (i.e., the variance of the latency for computing the MAC).
       </t>
     
        
      <t> Throughput is another important consideration.  NTP servers may have 
      to deal with thousands of client requests per second. A study 
      <xref target="NIST"></xref> on the usage analysis of NIST's NTP stratum 1 
      servers shows these servers caters to 28,000 requests/second on an 
      average, per server.
      </t>
      
      
      
      <t> 
      Most of the Internet is served by stratum 2 and stratum 3 servers, some 
      of which are part of voluntary NTP pool. These machines may be running old
      hardware. So we benchmark performance on a range of software and
      hardware platforms.
     </t>
     
    </section>
    
    
    <section title="Performance Results">
    
      <t>The NTP header is 48 bytes long. We therefore consider the latency 
      and throughput for several secure message
      authentication code (MAC) algorithms when computed over 48-byte messages.
      </t>
    
    <t>We customize the in-built speed utility of OpenSSL-1.0.2g (03 May 2016) version to compute the latency and throughput for each MAC as shown in the tables below. OpenSSL, however, does not implement stream-cipher ChaCha20-based Poly1305 MAC algorithm. To speed test this MAC, we use LibreSSL 2.3.1, a fork of OpenSSL implementation. OpenSSL and LibreSSL are the most widely used cryptographic libraries and are used by the current  NTP implementations.
    </t>
  <t>Since the introduction of New Instruction (NI) set for hardware support in Intel chips, certain MACs like CMAC and GMAC have performance advantage on such machines. Based on this, we perform two different benchmarks once with AES-NI enabled and the other time disabled on an x86_64, Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz with one core CPU.
      </t>
      
      
  <t>
      This table shows throughput in terms of number of 48-byte NTP payload processed per second.</t>
        <texttable>
                <ttcol>Algorithm </ttcol>
                <ttcol align="right">with AES-NI</ttcol>
                <ttcol align="right">without AES-NI </ttcol>
                <c>legacy MD5</c>       <c>3118K</c> <c>3165K</c>
                <c>HMAC-MD5</c>       <c>2742K</c> <c>2749K</c>
                <c>HMAC-SHA224</c>       <c>1265K</c> <c>1267K</c>
                <c>CMAC(AES)</c>       <c>7567K</c> <c>4388K</c>
                <c>GMAC(AES)</c>       <c>16612K</c> <c>4627K</c>
                <c>Poly1305(ChaCha20)</c>       <c>2598K</c> <c>2398K</c>
            </texttable>

        <t> This table shows latency in terms of number of CPU cycles per byte (cpb)
        when processing a 48-byte NTP payload.
        </t>
      
<texttable>
    <ttcol>Algorithm </ttcol>
    <ttcol align="right">with AES-NI</ttcol>
    <ttcol align="right">without AES-NI </ttcol>
    <c>legacy MD5</c>       <c>16.03</c> <c>15.7</c>
    <c>HMAC-MD5</c>       <c>18.2</c> <c>18.1</c>
    <c>HMAC-SHA224</c>       <c>39.4</c> <c>39</c>
    <c>CMAC(AES)</c>       <c>6.6</c> <c>11.3</c>
    <c>GMAC(AES)</c>       <c>3.009</c> <c>10.8</c>
    <c>Poly1305(ChaCha20)</c>       <c>14.4</c> <c>15</c>
</texttable>
 
<t>TODO: Test on other types of hardware.</t>
   
    </section>
    
    <section title="Recommendation">
    
    <t>We suggest that use of GMAC(AES) because it has the best latency and
    throughput performance. 
    </t>
    
    </section>
    
  
    <!-- Possibly a 'Contributors' section ... -->

<!--
    <section anchor="IANA" title="IANA Considerations">
      <t>This memo requests IANA to allocate NTP Extension Field Types
      0x0006 (Suggested REFID, MAC required), 0x2006 (Suggested REFID, MAC
      OPTIONAL) for this purpose.</t>
    </section>
-->

    <section anchor="Security" title="Security Considerations">
      <t>
          The MD5 (key||message) "message authentication code" specified
          in <xref target="RFC5905"></xref> is vulnerable to length extension
          attacks, and uses the insecure MD5 hash function, and therefore
          should be deprecated.
      </t>
      <t> The output of HMAC-SHA224 is 28 bytes, but we truncate it to 16 bytes as in section 4 of <xref target="RFC7630"></xref> to fit into the NTP packet. As noted in section 6 of <xref target="RFC2104"></xref> it is safe to truncate the output of MACs as long as the truncated length is greater than 80-bits and not less than half the length of the hash output.
          </t>
            <t> TO DO: Not finished yet. Following factors will be considered for security comparison.
            <list style="numbers">
                <t>Output length of tag.</t>
                <t>Input Key length.</t>
                <t>Strength of the underlying cryptographic hash function or cipher.</t>
                <t>Size and number of messages MACd using the same key.</t>
            </list>
            </t>
            </section>
    <section anchor="Acknowledgements" title="Acknowledgements">
      <t>The authors wish to acknowledge useful discussions with Harlan Stenn,
      Mayank Varia, Daniel Franke, Ethan Heilman, and Leen Alshenibr.</t>
    </section>

  </middle>

  <!--  *****BACK MATTER ***** -->

  <back>
    <!-- References split into informative and normative -->

    <!-- There are 2 ways to insert reference entries from the citation libraries:
     1. define an ENTITY at the top, and use "ampersand character"RFC2629; here (as shown)
     2. simply use a PI "less than character"?rfc include="reference.RFC.2119.xml"?> here
        (for I-Ds: include="reference.I-D.narten-iana-considerations-rfc2434bis.xml")

     Both are cited textually in the same manner: by using xref elements.
     If you use the PI option, xml2rfc will, by default, try to find included files in the same
     directory as the including file. You can also define the XML_LIBRARY environment variable
     with a value containing a set of directories to search.  These can be either in the local
     filing system or remote ones accessed by http (http://domain/dir/... ).-->

    <references title="Normative References">
      <!--?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml"?-->

      &RFC2119;

      <!--?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.5905.xml"?-->

      &RFC5905;

     
      <!--?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.6151.xml"?-->

      &RFC6151;
      <!--?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.7539.xml"?-->
      
      &RFC7539;
      &RFC2104;
      <!--?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.7539.xml"?-->
      &RFC7630;
      <!--?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.4493.xml"?-->
      
      &RFC4493;
      <!--?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.4543.xml"?-->
      
      &RFC4543;
    </references>

    <!-- Here we use entities that we defined at the beginning. -->

    <references title="Informative References">
      <!--&RFC3552;-->

      <reference anchor="BCK">
            <front>
                <title>Keyed Hash Functions and Message Authentication</title> 
                <author initials="M." surname="Bellare"><organization /></author>
                <author initials="R." surname="Canetti"><organization /></author>
                <author initials="H." surname="Krawczyk"><organization /></author>
                <date year="1996" />
            </front>
            <seriesInfo name="in" value="Proceedings of Crypto'96" />
        </reference>
      
      <reference anchor="NIST">
          <front>
              <title>Usage Analysis of the NIST Internet Time Service</title>
              <author initials="J.A." surname="Sherman"><organization /></author>
              <author initials="J." surname="Levine"><organization /></author>
              <date year="2016" />
          </front>
          <seriesInfo name= "in" value="Journal of Research of the National Institute of Standards and Technology" />
      </reference>
    

    </references>

    <!--
    <section anchor="app-additional" title="Additional Stuff">
      <t>This becomes an Appendix.</t>
    </section>
-->

    <!-- Change Log

v00 2016-07-NN  AM Initial Submission   
                                                                                        -->
  </back>
</rfc>
