Internet Engineering Task Force A. Malhotra Internet-Draft S. Goldberg Intended status: Standards Track Boston University Expires: January 9, 2017 July 8, 2016 Message Authentication Codes for the Network Time Protocol draft-aanchal4-ntp-mac-00 Abstract The Network Time Protocol (NTP) RFC 5905 [RFC5905] 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 [BCK] and [RFC6151], 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. Status of This Memo This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79. Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet- Drafts is at http://datatracker.ietf.org/drafts/current/. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." This Internet-Draft will expire on January 9, 2017. Copyright Notice Copyright (c) 2016 IETF Trust and the persons identified as the document authors. All rights reserved. This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents Malhotra & Goldberg Expires January 9, 2017 [Page 1] Internet-Draft MACs for NTP July 2016 carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License. Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 1.1. Requirements Language . . . . . . . . . . . . . . . . . . 2 2. MAC Algorithms . . . . . . . . . . . . . . . . . . . . . . . 2 3. Performance Requirements . . . . . . . . . . . . . . . . . . 3 4. Performance Results . . . . . . . . . . . . . . . . . . . . . 3 5. Recommendation . . . . . . . . . . . . . . . . . . . . . . . 5 6. Security Considerations . . . . . . . . . . . . . . . . . . . 5 7. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 5 8. References . . . . . . . . . . . . . . . . . . . . . . . . . 5 8.1. Normative References . . . . . . . . . . . . . . . . . . 5 8.2. Informative References . . . . . . . . . . . . . . . . . 6 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 6 1. Introduction 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 [BCK] and [RFC6151], 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. 1.1. Requirements Language 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 RFC 2119 [RFC2119]. 2. MAC Algorithms We consider five diverse MAC algorithms, which encompass hash-based HMAC-MD5 and HMAC-SHA224 [RFC2104], block cipher-based CMAC-AES [RFC4493], and universal hashing-based Galois MAC (GMAC) [RFC4543] and Poly1305(ChaCha20) as in section 2.6 of [RFC7539]. For completeness we also benchmark the legacy MD5(key||message) from [RFC5905]. Malhotra & Goldberg Expires January 9, 2017 [Page 2] Internet-Draft MACs for NTP July 2016 +--------------------+--------------+----------------+--------------+ | Algorithm | Input Key | Output Tag | Security | | | Length | Length (Bytes) | Level (bits) | | | (Bytes) | | | +--------------------+--------------+----------------+--------------+ | legacy MD5 | 16 | 16 | NA | | HMAC-MD5 | 16 | 16 | NA | | HMAC-SHA224 | 16 | 28 | 112 | | CMAC(AES) | 16 | 16 | 128 | | GMAC(AES) | 16 | 16 | 128 | | Poly1305(ChaCha20) | 32 | 16 | 128 | +--------------------+--------------+----------------+--------------+ 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. 3. Performance Requirements 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). Throughput is another important consideration. NTP servers may have to deal with thousands of client requests per second. A study [NIST] 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. 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. 4. Performance Results 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. Malhotra & Goldberg Expires January 9, 2017 [Page 3] Internet-Draft MACs for NTP July 2016 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. 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. This table shows throughput in terms of number of 48-byte NTP payload processed per second. +--------------------+-------------+-----------------+ | Algorithm | with AES-NI | without AES-NI | +--------------------+-------------+-----------------+ | legacy MD5 | 3118K | 3165K | | HMAC-MD5 | 2742K | 2749K | | HMAC-SHA224 | 1265K | 1267K | | CMAC(AES) | 7567K | 4388K | | GMAC(AES) | 16612K | 4627K | | Poly1305(ChaCha20) | 2598K | 2398K | +--------------------+-------------+-----------------+ This table shows latency in terms of number of CPU cycles per byte (cpb) when processing a 48-byte NTP payload. +--------------------+-------------+-----------------+ | Algorithm | with AES-NI | without AES-NI | +--------------------+-------------+-----------------+ | legacy MD5 | 16.03 | 15.7 | | HMAC-MD5 | 18.2 | 18.1 | | HMAC-SHA224 | 39.4 | 39 | | CMAC(AES) | 6.6 | 11.3 | | GMAC(AES) | 3.009 | 10.8 | | Poly1305(ChaCha20) | 14.4 | 15 | +--------------------+-------------+-----------------+ TODO: Test on other types of hardware. Malhotra & Goldberg Expires January 9, 2017 [Page 4] Internet-Draft MACs for NTP July 2016 5. Recommendation We suggest that use of GMAC(AES) because it has the best latency and throughput performance. 6. Security Considerations The MD5 (key||message) "message authentication code" specified in [RFC5905] is vulnerable to length extension attacks, and uses the insecure MD5 hash function, and therefore should be deprecated. The output of HMAC-SHA224 is 28 bytes, but we truncate it to 16 bytes as in section 4 of [RFC7630] to fit into the NTP packet. As noted in section 6 of [RFC2104] 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. TO DO: Not finished yet. Following factors will be considered for security comparison. 1. Output length of tag. 2. Input Key length. 3. Strength of the underlying cryptographic hash function or cipher. 4. Size and number of messages MACd using the same key. 7. Acknowledgements The authors wish to acknowledge useful discussions with Harlan Stenn, Mayank Varia, Daniel Franke, Ethan Heilman, and Leen Alshenibr. 8. References 8.1. Normative References [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- Hashing for Message Authentication", RFC 2104, DOI 10.17487/RFC2104, February 1997, . [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997, . Malhotra & Goldberg Expires January 9, 2017 [Page 5] Internet-Draft MACs for NTP July 2016 [RFC4493] Song, JH., Poovendran, R., Lee, J., and T. Iwata, "The AES-CMAC Algorithm", RFC 4493, DOI 10.17487/RFC4493, June 2006, . [RFC4543] McGrew, D. and J. Viega, "The Use of Galois Message Authentication Code (GMAC) in IPsec ESP and AH", RFC 4543, DOI 10.17487/RFC4543, May 2006, . [RFC5905] Mills, D., Martin, J., Ed., Burbank, J., and W. Kasch, "Network Time Protocol Version 4: Protocol and Algorithms Specification", RFC 5905, DOI 10.17487/RFC5905, June 2010, . [RFC6151] Turner, S. and L. Chen, "Updated Security Considerations for the MD5 Message-Digest and the HMAC-MD5 Algorithms", RFC 6151, DOI 10.17487/RFC6151, March 2011, . [RFC7539] Nir, Y. and A. Langley, "ChaCha20 and Poly1305 for IETF Protocols", RFC 7539, DOI 10.17487/RFC7539, May 2015, . [RFC7630] Merkle, J., Ed. and M. Lochter, "HMAC-SHA-2 Authentication Protocols in the User-based Security Model (USM) for SNMPv3", RFC 7630, DOI 10.17487/RFC7630, October 2015, . 8.2. Informative References [BCK] Bellare, M., Canetti, R., and H. Krawczyk, "Keyed Hash Functions and Message Authentication", in Proceedings of Crypto'96, 1996. [NIST] Sherman, J. and J. Levine, "Usage Analysis of the NIST Internet Time Service", in Journal of Research of the National Institute of Standards and Technology, 2016. Authors' Addresses Aanchal Malhotra Boston University 111 Cummington St Boston, MA 02215 US Email: aanchal4@bu.edu Malhotra & Goldberg Expires January 9, 2017 [Page 6] Internet-Draft MACs for NTP July 2016 Sharon Goldberg Boston University 111 Cummington St Boston, MA 02215 US Email: goldbe@cs.bu.edu Malhotra & Goldberg Expires January 9, 2017 [Page 7]