idnits 2.17.1 draft-nir-ipsecme-chacha20-poly1305-01.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == Line 192 has weird spacing: '...e2fe7cc dcd9b...' -- The document date (February 4, 2014) is 3733 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) ** Obsolete normative reference: RFC 5996 (Obsoleted by RFC 7296) Summary: 1 error (**), 0 flaws (~~), 2 warnings (==), 1 comment (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group Y. Nir 3 Internet-Draft Check Point 4 Intended status: Standards Track February 4, 2014 5 Expires: August 8, 2014 7 ChaCha20 and Poly1305 and their use in IPsec 8 draft-nir-ipsecme-chacha20-poly1305-01 10 Abstract 12 This document describes the use of the ChaCha20 stream cipher in 13 IPsec, as well as the use of the Poly1305 authenticator, both as 14 stand-alone algorithms, and as a combined mode AEAD algorithm. 16 Status of this Memo 18 This Internet-Draft is submitted in full conformance with the 19 provisions of BCP 78 and BCP 79. 21 Internet-Drafts are working documents of the Internet Engineering 22 Task Force (IETF). Note that other groups may also distribute 23 working documents as Internet-Drafts. The list of current Internet- 24 Drafts is at http://datatracker.ietf.org/drafts/current/. 26 Internet-Drafts are draft documents valid for a maximum of six months 27 and may be updated, replaced, or obsoleted by other documents at any 28 time. It is inappropriate to use Internet-Drafts as reference 29 material or to cite them other than as "work in progress." 31 This Internet-Draft will expire on August 8, 2014. 33 Copyright Notice 35 Copyright (c) 2014 IETF Trust and the persons identified as the 36 document authors. All rights reserved. 38 This document is subject to BCP 78 and the IETF Trust's Legal 39 Provisions Relating to IETF Documents 40 (http://trustee.ietf.org/license-info) in effect on the date of 41 publication of this document. Please review these documents 42 carefully, as they describe your rights and restrictions with respect 43 to this document. Code Components extracted from this document must 44 include Simplified BSD License text as described in Section 4.e of 45 the Trust Legal Provisions and are provided without warranty as 46 described in the Simplified BSD License. 48 Table of Contents 50 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 3 51 1.1. Conventions Used in This Document . . . . . . . . . . . . . 3 52 2. Algorithms for ESP & AH . . . . . . . . . . . . . . . . . . . . 3 53 2.1. ENCR_ChaCha20 for ESP . . . . . . . . . . . . . . . . . . . 3 54 2.2. AUTH_Poly1305 for ESP and AH . . . . . . . . . . . . . . . 4 55 2.2.1. Example One-Time Key Derivation . . . . . . . . . . . . 5 56 2.3. ESP_ChaCha20-Poly1305 for ESP . . . . . . . . . . . . . . . 5 57 2.3.1. AAD Construction . . . . . . . . . . . . . . . . . . . 6 58 3. Security Considerations . . . . . . . . . . . . . . . . . . . . 6 59 4. IANA Considerations . . . . . . . . . . . . . . . . . . . . . . 7 60 5. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 7 61 6. References . . . . . . . . . . . . . . . . . . . . . . . . . . 7 62 6.1. Normative References . . . . . . . . . . . . . . . . . . . 7 63 6.2. Informative References . . . . . . . . . . . . . . . . . . 8 64 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 8 66 1. Introduction 68 The Advanced Encryption Standard (AES - [FIPS-197]) has become the 69 gold standard in encryption. Its efficient design, wide 70 implementation, and hardware support allow for high performance in 71 many areas, including IPsec VPNs. On most modern platforms, AES is 72 anywhere from 4x to 10x as fast as the previous most-used cipher, 73 3-key Data Encryption Standard (3DES - [FIPS-46]), which makes it not 74 only the best choice, but the only choice. 76 The problem is that if future advances in cryptanalysis reveal a 77 weakness in AES, VPN users will be in an unenviable position. With 78 the only other widely supported cipher being the much slower 3DES, it 79 is not feasible to re-configure IPsec implementations to use 3DES. 80 [standby-cipher] describes this issue and the need for a standby 81 cipher in greater detail. 83 This document proposes the ChaCha20 stream cipher as such a standby 84 cipher with or without the Poly1305 authenticator. These algorithms 85 are described in a separate document ([chacha_poly]). This document 86 only describes the IPsec-specific things. 88 1.1. Conventions Used in This Document 90 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 91 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 92 document are to be interpreted as described in [RFC2119]. 94 2. Algorithms for ESP & AH 96 This document defines three algorithms for use with the Encapsulated 97 Security Protocol (ESP - [RFC4303]) and Authentication Header (AH - 98 [RFC4302]): 99 o ChaCha20 for use as an encryption algorithms for ESP. 100 o Poly1305-MAC for use as a message authentication algorithm for ESP 101 and AH. 102 o ChaCha20-Poly1305-ESP as an AEAD algorithm for ESP. 104 2.1. ENCR_ChaCha20 for ESP 106 The algorithm for ChaCha20 is described in section 2.4 of 107 [chacha_poly]. In ESP the following parameters are used: 108 o The IV is 64-bit. Since this is used for the nonce in the 109 ChaCha20 function, this IV MUST NOT repeat. The most natural way 110 to implement this is with a counter, but anything that guarantees 111 uniqueness can be used, such as a linear feedback shift register 112 (LFSR). Note that the encrypter can use any IV generation method 113 that meets the uniqueness requirement, without coordinating with 114 the decrypter. 115 o The Internet Key Exchange protocol (IKE - [RFC5996]) generates a 116 bitstring called KEYMAT that is generated from a PRF. That KEYMAT 117 is divided into keys for encryption, message authentication and 118 whatever else is needed. For the ChaCha20 algorithm, 256 bits are 119 used for the key. TBD: do we want an extra 32 bits as salt for 120 the nonce like in GCM? 121 o The ChaCha20 encryption algorithm is called with the 256-bit key, 122 one (1) for the initial counter. The packet IV is prepended by a 123 32-bit sender ID value to form the 96-bit nonce. For regular 124 IPsec, the Sender ID is set to zero. For multi-sender SAs, such 125 as described in [RFC6054], there sender ID can be set to a 126 different value for each sender. The reason that one (1) is used 127 for the initial counter rather than zero is that one is used for 128 encryption in the AEAD algorithm (because zero is reserved for 129 generating the one-time Poly1305 key), so one was used here for 130 consistency. 131 o As ChaCha20 is not a block cipher, no padding should be necessary. 132 However, in keeping with the specification in RFC 4303, the ESP 133 does have padding, so as to align the buffer to an integral 134 multiple of 4 octets. 136 The encryption algorithm transform ID for negotiating this algorithm 137 in IKE is TBA by IANA. 139 2.2. AUTH_Poly1305 for ESP and AH 141 You cannot use a part of the keying material directly, because 142 Poly1305 requires an unpredictable and non-repeating key for each 143 authenticated message. So the Poly1305 key for each message is 144 generated as in section 2.6 of [chacha_poly]: 145 o The key for AUTH_Poly1305 is 256-bits. 146 o To determine the per-packet Poly1305 key, the ChaCha20 block 147 function is called with the following parameters: 148 * The AUTH_Poly1305 256-bit key is used as the key. 149 * The nonce is set from the sequence number (in the order as it 150 appears in the packet). 32 or 64 zero bits are prepended 151 depending on whether ESN is enabled or not, forming a 96-bit 152 nonce. 153 * Zero is used for the block counter. 154 o The 512-bit result is then truncated. The top 256 bits are used 155 as the one-time key for Poly1305 to calculate the message 156 authentication code (MAC). 157 o The 128-bit output serves as the MAC for the packet. All 16 bytes 158 are included in the packet. 160 The integrity algorithm transform ID for negotiating this algorithm 161 in IKE is TBA by IANA. 163 2.2.1. Example One-Time Key Derivation 165 Suppose our 256-bit MAC key and sequence number are as follows: 167 AUTH_Poly1305 Key: 168 000 7b ac 2b 25 2d b4 47 af 09 b6 7a 55 a4 e9 55 84|{.+%-.G...zU..U. 169 016 0a e1 d6 73 10 75 d9 eb 2a 93 75 78 3e d5 53 ff|...s.u..*.ux>.S. 171 ESN: off 172 Sequence Number: 40 (represented on the packet as 00:00:00:28) 174 So the ChaCha20 block function (section 2.3 of [chacha_poly]) is 175 called with the following parameters: 176 o The AUTH_Poly1305 key. 177 o The 96-bit nonce 00:00:00:00:00:00:00:00:00:00:00:28. 178 o The block count parameter set to zero (0). 180 Note in the following ChaCha20 block, that the sequence number 181 (bottom right) is reversed. This is because the sequence number is 182 big-endian in the ESP packet, but is treated as a sequence of 32-bit 183 little-endian numbers in ChaCha20. 185 Set up ChaCha20 block: 186 61707865 3320646e 79622d32 6b206574 187 252bac7b af47b42d 557ab609 8455e9a4 188 73d6e10a ebd97510 7875932a ff53d53e 189 00000000 00000000 00000000 28000000 191 After running the ChaCha20 block operation: 192 0c15e292 6e2fe7cc dcd9bd92 f60a30b3 193 4094c018 b0ba041d 88ed8acf 09f9bba5 194 a29dbf3d e1a6acdc 011e3fe8 d953dff5 195 32989c29 12be0248 0c267749 e55f2037 197 The Poly1305 one-time key (256 bits): 198 000 92 e2 15 0c cc e7 2f 6e 92 bd d9 dc b3 30 0a f6 ....../n.....0.. 199 016 18 c0 94 40 1d 04 ba b0 cf 8a ed 88 a5 bb f9 09 ...@............ 201 2.3. ESP_ChaCha20-Poly1305 for ESP 203 ESP_ChaCha20-Poly1305 is a combined mode algorithm, or AEAD. The 204 construction follows the AEAD construction in section 2.7 of 205 [chacha_poly]: 207 o As in Section 2.1, the IV is 64-bit, and is used as part of the 208 nonce. 209 o Also as in Section 2.1, a 32-bit sender ID (zero for regular 210 IPsec) is prepended to the 64-bit IV to form the nonce. 211 o Also as in Section 2.1, the encryption key is 256-bit. 212 o As in Section 2.2, the nonce, along with a block counter of zero 213 is passed to the ChaCha20 block function, and the top part of the 214 result used as the Poly1305 key. However, unlike AUTH_Poly1305, 215 the nonce passed to the block function here does not depend on the 216 ESP sequence number, but is the same nonce that is used in 217 ChaCha20, including the 32-bit Sender ID bits, and the key passed 218 is the same as the encryption key. 219 o The ChaCha20 encryption function is then called with the nonce, 220 the key, and an initial counter of zero. 221 o Finally, the Poly1305 function is run on the data to be 222 authenticated, which is, as specified in section 2.7 of 223 [chacha_poly] a concatenation of the following: 224 * The Authenticated Additional Data (AAD) - see Section 2.3.1. 225 * The AAD length in bytes as a 32-bit network order quantity. 226 * The ciphertext 227 * The length of the ciphertext as a 32-bit network order 228 quantity. 229 o The 128-bit output of Poly1305 is used as the tag. All 16 bytes 230 are included in the packet. 232 The encryption algorithm transform ID for negotiating this algorithm 233 in IKE is TBA by IANA. 235 2.3.1. AAD Construction 237 The construction of the Additional Authenticated Data (AAD) is 238 similar to the one in [RFC4106]. For security associations (SAs) 239 with 32-bit sequence numbers the AAD is 8 bytes: 4-byte SPI followed 240 by 4-byte sequence number ordered exactly as it is in the packet. 241 For SAs with ESN the AAD is 12 bytes: 4-byte SPI followed by an 242 8-byte sequence number as a 64-bit network order integer. 244 3. Security Considerations 246 The ChaCha20 cipher is designed to provide 256-bit security. 248 The Poly1305 authenticator is designed to ensure that forged messages 249 are rejected with a probability of 1-(n/(2^102)) for a 16n-byte 250 message, even after sending 2^64 legitimate messages, so it is SUF- 251 CMA in the terminology of [AE]. 253 The most important security consideration in implementing this draft 254 is the uniqueness of the nonce used in ChaCha20. This is trivial in 255 AUTH_Poly1305, because the packet sequence number is used as a nonce, 256 but is required for ChaCha20 as well. As said in Section 2.1, the 257 nonce should be selected uniquely for a particular key. counters and 258 LFSRs are both acceptable ways of generating unique nonces, as is 259 encrypting a counter using a 64-bit cipher such as DES. Note that it 260 is not acceptable to use a truncation of a counter encrypted with a 261 128-bit or 256-bit cipher, because such a truncation may repeat after 262 a short time. 264 4. IANA Considerations 266 IANA is requested to assign two values from the IKEv2 "Transform Type 267 1 - Encryption Algorithm Transform IDs" registry, as follows: 268 o ENCR_ChaCha20 269 o ESP_ChaCha20-Poly1305 271 IANA is also requested to assign one value from the IKEv2 "Transform 272 Type 3 - Integrity Algorithm Transform IDs" registry with name 273 "AUTH_Poly1305". 275 5. Acknowledgements 277 All of the algorithms in this document were designed by D. J. 278 Bernstein. The AEAD construction was designed by Adam Langley. The 279 author would also like to thank Adam for helpful comments, as well as 280 Yaron Sheffer for telling me to write the algorithms draft. 282 6. References 284 6.1. Normative References 286 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 287 Requirement Levels", BCP 14, RFC 2119, March 1997. 289 [RFC4302] Kent, S., "IP Authentication Header", RFC 4302, 290 December 2005. 292 [RFC4303] Kent, S., "IP Encapsulating Security Payload (ESP)", 293 RFC 4303, December 2005. 295 [RFC5996] Kaufman, C., Hoffman, P., Nir, Y., and P. Eronen, 296 "Internet Key Exchange Protocol Version 2 (IKEv2)", 297 RFC 5996, September 2010. 299 [RFC6054] McGrew, D. and B. Weis, "Using Counter Modes with 300 Encapsulating Security Payload (ESP) and Authentication 301 Header (AH) to Protect Group Traffic", RFC 6054, 302 November 2010. 304 [chacha_poly] 305 Langley, A. and Y. Nir, "ChaCha20 and Poly1305 for IETF 306 protocols", draft-nir-cfrg-chacha20-poly1305-01 (work in 307 progress), January 2014. 309 6.2. Informative References 311 [AE] Bellare, M. and C. Namprempre, "Authenticated Encryption: 312 Relations among notions and analysis of the generic 313 composition paradigm", 314 . 316 [FIPS-197] 317 National Institute of Standards and Technology, "Advanced 318 Encryption Standard (AES)", FIPS PUB 197, November 2001, < 319 http://csrc.nist.gov/publications/fips/fips197/ 320 fips-197.pdf>. 322 [FIPS-46] National Institute of Standards and Technology, "Data 323 Encryption Standard", FIPS PUB 46-2, December 1993, 324 . 326 [RFC4106] Viega, J. and D. McGrew, "The Use of Galois/Counter Mode 327 (GCM) in IPsec Encapsulating Security Payload (ESP)", 328 RFC 4106, June 2005. 330 [standby-cipher] 331 McGrew, D., Grieco, A., and Y. Sheffer, "Selection of 332 Future Cryptographic Standards", 333 draft-mcgrew-standby-cipher (work in progress). 335 Author's Address 337 Yoav Nir 338 Check Point Software Technologies Ltd. 339 5 Hasolelim st. 340 Tel Aviv 6789735 341 Israel 343 Email: ynir@checkpoint.com