idnits 2.17.1 draft-ietf-ipsecme-chacha20-poly1305-10.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 -- The document date (June 14, 2015) is 3232 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 7539 (Obsoleted by RFC 8439) Summary: 1 error (**), 0 flaws (~~), 1 warning (==), 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 June 14, 2015 5 Expires: December 16, 2015 7 ChaCha20, Poly1305 and their use in IKE & IPsec 8 draft-ietf-ipsecme-chacha20-poly1305-10 10 Abstract 12 This document describes the use of the ChaCha20 stream cipher along 13 with the Poly1305 authenticator, combined into an AEAD algorithm for 14 the Internet Key Exchange protocol (IKEv2) and for IPsec. 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 December 16, 2015. 33 Copyright Notice 35 Copyright (c) 2015 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 . . . . . . . . . . . . . . . . . . . . . . . . 2 51 1.1. Conventions Used in This Document . . . . . . . . . . . . 3 52 2. ChaCha20 & Poly1305 for ESP . . . . . . . . . . . . . . . . . 3 53 2.1. AAD Construction . . . . . . . . . . . . . . . . . . . . 5 54 3. Use in IKEv2 . . . . . . . . . . . . . . . . . . . . . . . . 5 55 4. Negotiation in IKEv2 . . . . . . . . . . . . . . . . . . . . 5 56 5. Security Considerations . . . . . . . . . . . . . . . . . . . 6 57 6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 6 58 7. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 6 59 8. References . . . . . . . . . . . . . . . . . . . . . . . . . 7 60 8.1. Normative References . . . . . . . . . . . . . . . . . . 7 61 8.2. Informative References . . . . . . . . . . . . . . . . . 7 62 Appendix A. ESP Example . . . . . . . . . . . . . . . . . . . . 8 63 Appendix B. IKEv2 Example . . . . . . . . . . . . . . . . . . . 10 64 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 12 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 - [SP800-67]). 3DES also has a 74 64-bit block, which means that the amount of data that can be 75 encrypted before rekeying is required is not great. These reasons 76 make AES not only the best choice, but the only choice. 78 The problem is that if future advances in cryptanalysis reveal a 79 weakness in AES, VPN users will be in an unenviable position. With 80 the only other widely supported cipher being the much slower 3DES, it 81 is not feasible to re-configure IPsec installations away from AES. 82 [standby-cipher] describes this issue and the need for a standby 83 cipher in greater detail. 85 This document proposes the fast and secure ChaCha20 stream cipher as 86 such a standby cipher in an Authenticated Encryption with Associated 87 Data (AEAD) construction with the Poly1305 authenticator for use with 88 the Encapsulated Security Protocol (ESP - [RFC4303]) and the Internet 89 Key Exchange Protocol (IKEv2 - [RFC7296]). The algorithms are 90 described in a separate document ([RFC7539]). This document only 91 describes the IPsec-specific things. 93 1.1. Conventions Used in This Document 95 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 96 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 97 document are to be interpreted as described in [RFC2119]. 99 2. ChaCha20 & Poly1305 for ESP 101 AEAD_CHACHA20_POLY1305 is a combined mode algorithm, or AEAD. The 102 construction follows the AEAD construction in section 2.8 of 103 [RFC7539]: 105 o The Initialization Vector (IV) is 64-bit, and is used as part of 106 the nonce. The IV MUST be unique for each invocation for a 107 particular SA but does not need to be unpredictable. The use of a 108 counter or a linear feedback shift register (LFSR) is RECOMMENDED. 109 o A 32-bit Salt is prepended to the 64-bit IV to form the 96-bit 110 nonce. The salt is fixed per SA and it is not transmitted as part 111 of the ESP packet. 112 o The encryption key is 256-bit. 113 o The Internet Key Exchange protocol generates a bitstring called 114 KEYMAT using a pseudo-random function (PRF). That KEYMAT is 115 divided into keys for encryption, message authentication and 116 whatever else is needed. The KEYMAT requested for each 117 ChaCha20-Poly1305 key is 36 octets. The first 32 octets are the 118 256-bit ChaCha20 key, and the remaining four octets are used as 119 the Salt value in the nonce. 121 The ChaCha20 encryption algorithm requires the following parameters: 122 a 256-bit key, a 96-bit nonce, and a 32-bit initial block counter. 123 For ESP we set these as follows: 125 o The key is set as mentioned above. 126 o The 96-bit nonce is formed from a concatenation of the 32-bit Salt 127 and the 64-bit IV, as described above. 128 o The Initial Block Counter is set to one (1). The reason that one 129 is used for the initial counter rather than zero is that zero is 130 reserved for generating the one-time Poly1305 key (see below) 132 As the ChaCha20 block function is not applied directly to the 133 plaintext, no padding should be necessary. However, in keeping with 134 the specification in RFC 4303, the plaintext always has a pad length 135 octet and a Next Header octet and may require padding octets so as to 136 align the buffer to an integral multiple of 4 octets. 138 The same key and nonce, along with a block counter of zero are passed 139 to the ChaCha20 block function, and the top 256 bits of the result 140 are used as the Poly1305 key. 142 Finally, the Poly1305 function is run on the data to be 143 authenticated, which is, as specified in section 2.8 of [RFC7539] a 144 concatenation of the following in the below order: 146 o The Authenticated Additional Data (AAD) - see Section 2.1. 147 o Zero-octet padding that rounds the length up to 16 octets. This 148 is 4 or 8 octets depending on the length of the AAD. 149 o The ciphertext 150 o Zero octet padding that rounds the total length up to an integral 151 multiple of 16 octets. 152 o The length of the additional authenticated data (AAD) in octets 153 (as a 64-bit integer encoded in little-endian byte order). 154 o The length of the ciphertext in octets (as a 64-bit integer 155 encoded in little-endian byte order). 157 The 128-bit output of Poly1305 is used as the tag. All 16 octets are 158 included in the packet. 160 The encryption algorithm transform ID for negotiating this algorithm 161 in IKE is ENCR_CHACHA20_POLY1305 (number is TBA by IANA). 163 The figure below is copied from RFC 4303: 165 0 1 2 3 166 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 167 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 168 | Security Parameters Index (SPI) | 169 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 170 | Sequence Number | 171 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+--- 172 | IV (optional) | ^ p 173 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | a 174 | Rest of Payload Data (variable) | | y 175 ~ ~ | l 176 | | | o 177 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | a 178 | | TFC Padding * (optional, variable) | v d 179 +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+--- 180 | | Padding (0-255 bytes) | 181 +-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 182 | | Pad Length | Next Header | 183 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 184 | Integrity Check Value-ICV (variable) | 185 ~ ~ 186 | | 187 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 188 o The IV field is 64-bit. It is the final 64 bits of the 96-bit 189 nonce. If the counter method is used for generating unique IVs, 190 then the final 32 bits of the IV will be equal to the Sequence 191 Number field. 192 o The length of the Padding field need not exceed 4 octets. 193 However, neither RFC 4303 nor this specification require using the 194 minimal padding length. 195 o The Integrity Check Value field contains the 16 octet tag. 197 2.1. AAD Construction 199 The construction of the Additional Authenticated Data (AAD) is 200 similar to the one in [RFC4106]. For security associations (SAs) 201 with 32-bit sequence numbers the AAD is 8 octets: a 4-octet SPI 202 followed by 4-octet sequence number ordered exactly as it is in the 203 packet. For SAs with ESN the AAD is 12 octets: a 4-octet SPI 204 followed by an 8-octet sequence number as a 64-bit integer in network 205 byte order. 207 3. Use in IKEv2 209 AEAD algorithms can be used in IKE, as described in [RFC5282]. More 210 specifically: 212 o The Encrypted Payload is as described in section 3 of that 213 document. 214 o The ChaCha20-Poly1305 keying material is derived similar to ESP: 215 36 octets are requested for each of SK_ei and SK_er, of which the 216 first 32 form the key and the last 4 form the salt. No octets are 217 requested for SK_ai and SK_ar. 218 o The IV is 64 bits, as described in Section 2, and is included 219 explicitly in the Encrypted payload. 220 o The sender SHOULD include no padding and set the Pad Length field 221 to zero. The receiver MUST accept any length of padding. 222 o The AAD is as described in section 5.1 of RFC 5282, so it is 32 223 octets (28 for the IKEv2 header + 4 octets for the encrypted 224 payload header) assuming no unencrypted payloads. 226 4. Negotiation in IKEv2 228 When negotiating the ChaCha20-Poly1305 algorithm for use in IKE or 229 IPsec, the value xxx (TBA by IANA) should be used in the transform 230 substructure of the SA payload as the ENCR (type 1) transform ID. As 231 with other AEAD algorithms, INTEG (type 3) transform substructures 232 MUST NOT be specified or just one INTEG transform MAY be included 233 with value NONE (0). 235 5. Security Considerations 237 The ChaCha20 cipher is designed to provide 256-bit security. 239 The Poly1305 authenticator is designed to ensure that forged messages 240 are rejected with a probability of 1-(n/(2^102)) for a 16n-octet 241 message, even after sending 2^64 legitimate messages, so it is SUF- 242 CMA in the terminology of [AE]. 244 The most important security consideration in implementing this draft 245 is the uniqueness of the nonce used in ChaCha20. The nonce should be 246 selected uniquely for a particular key, but unpredictability of the 247 nonce is not required. Counters and LFSRs are both acceptable ways 248 of generating unique nonces. 250 Another issue with implementing these algorithms is avoiding side 251 channels. This is trivial for ChaCha20, but requires some care for 252 Poly1305. Considerations for implementations of these algorithms are 253 in [RFC7539]. 255 The Salt value in used nonce construction in ESP and IKEv2 is derived 256 from the keystream, same as the encryption key. It is never 257 transmitted on the wire, but the security of the algorithm does not 258 depend on its secrecy. Thus implementations that keep keys and other 259 secret material within some security boundary MAY export the Salt 260 from the security boundary. This may be useful if the API provided 261 by the library accepts the nonce as parameter rather than the IV. 263 6. IANA Considerations 265 IANA is requested to assign one value from the IKEv2 "Transform Type 266 1 - Encryption Algorithm Transform IDs" registry, with name 267 ENCR_CHACHA20_POLY1305, and this document as reference for both ESP 268 and IKEv2. 270 7. Acknowledgements 272 All of the algorithms in this document were designed by D. J. 273 Bernstein. The AEAD construction was designed by Adam Langley. The 274 author would also like to thank Adam for helpful comments, as well as 275 Yaron Sheffer for telling me to write the algorithms draft. Thanks 276 also to Martin Willi for pointing out the discrepancy with the final 277 version of the algorithm document, and to Valery Smyslov and Tero 278 Kivinen for helpful comments on this draft. Thanks to Steve Doyle 279 and Martin Willi for pointing out mistakes in my examples. 281 8. References 283 8.1. Normative References 285 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 286 Requirement Levels", BCP 14, RFC 2119, March 1997. 288 [RFC4303] Kent, S., "IP Encapsulating Security Payload (ESP)", RFC 289 4303, December 2005. 291 [RFC5282] Black, D. and D. McGrew, "Using Authenticated Encryption 292 Algorithms with the Encrypted Payload of the Internet Key 293 Exchange version 2 (IKEv2) Protocol", RFC 5282, August 294 2008. 296 [RFC7296] Kivinen, T., Kaufman, C., Hoffman, P., Nir, Y., and P. 297 Eronen, "Internet Key Exchange Protocol Version 2 298 (IKEv2)", RFC 7296, October 2014. 300 [RFC7539] Langley, A. and Y. Nir, "ChaCha20 and Poly1305 for IETF 301 protocols", RFC 7539, May 2015. 303 8.2. Informative References 305 [AE] Bellare, M. and C. Namprempre, "Authenticated Encryption: 306 Relations among notions and analysis of the generic 307 composition paradigm", 2000, 308 . 310 [FIPS-197] 311 National Institute of Standards and Technology, "Advanced 312 Encryption Standard (AES)", FIPS PUB 197, November 2001, 313 . 316 [RFC1761] Callaghan, B. and R. Gilligan, "Snoop Version 2 Packet 317 Capture File Format", RFC 1761, February 1995, 318 . 320 [RFC4106] Viega, J. and D. McGrew, "The Use of Galois/Counter Mode 321 (GCM) in IPsec Encapsulating Security Payload (ESP)", RFC 322 4106, June 2005. 324 [SP800-67] 325 National Institute of Standards and Technology, 326 "Recommendation for the Triple Data Encryption Algorithm 327 (TDEA) Block Cipher", FIPS SP800-67, January 2012, 328 . 331 [standby-cipher] 332 McGrew, D., Grieco, A., and Y. Sheffer, "Selection of 333 Future Cryptographic Standards", draft-mcgrew-standby- 334 cipher (work in progress), January 2013. 336 Appendix A. ESP Example 338 For this example, we will use a tunnel-mode ESP SA using the 339 ChaCha20-Poly1305 algorithm. The keying material is as follows: 341 KEYMAT: 342 000 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f ................ 343 016 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f ................ 344 032 a0 a1 a2 a3 .... 346 Obviously not a great PRF. The first 32 octets are the key and the 347 final four octets (0xa0 0xa1 0xa2 0xa3) are the salt. For the 348 packet, we will use an ICMP packet from 198.51.100.5 to 192.0.2.5: 350 Source Packet: 351 000 45 00 00 54 a6 f2 00 00 40 01 e7 78 c6 33 64 05 E..T....@..x.3d. 352 016 c0 00 02 05 08 00 5b 7a 3a 08 00 00 55 3b ec 10 ......[z:...U;.. 353 032 00 07 36 27 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 ..6'............ 354 048 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 ............ !"# 355 064 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 $%&'()*+,-./0123 356 080 34 35 36 37 4567 358 The SA details are as follows: 360 o The key and Salt are as above. 361 o The SPI is 0x01 0x02 0x03 0x04. 362 o The next sequence number is 5; ESN is not enabled. 363 o The gateway IP address for this side is 203.0.113.153; The peer 364 address is 203.0.113.5. 365 o NAT was not detected. 367 The 64-bit IV is 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17. Putting 368 together the salt and IV we get the nonce: 370 The nonce: 371 000 a0 a1 a2 a3 10 11 12 13 14 15 16 17 ............ 373 The plaintext to encrypt consists of the source IP packet plus the 374 padding: 376 Plaintext (includes padding and pad length): 377 000 45 00 00 54 a6 f2 00 00 40 01 e7 78 c6 33 64 05 E..T....@..x.3d. 378 016 c0 00 02 05 08 00 5b 7a 3a 08 00 00 55 3b ec 10 ......[z:...U;.. 379 032 00 07 36 27 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 ..6'............ 380 048 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 ............ !"# 381 064 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 $%&'()*+,-./0123 382 080 34 35 36 37 01 02 02 04 4567.... 384 With the key, nonce and plaintext available, we can call the ChaCha20 385 function and encrypt the packet, producing the ciphertext: 387 Ciphertext: 388 000 24 03 94 28 b9 7f 41 7e 3c 13 75 3a 4f 05 08 7b $..(..A~<.u:O..{ 389 016 67 c3 52 e6 a7 fa b1 b9 82 d4 66 ef 40 7a e5 c6 g.R.......f.@z.. 390 032 14 ee 80 99 d5 28 44 eb 61 aa 95 df ab 4c 02 f7 .....(D.a....L.. 391 048 2a a7 1e 7c 4c 4f 64 c9 be fe 2f ac c6 38 e8 f3 *..|LOd.../..8.. 392 064 cb ec 16 3f ac 46 9b 50 27 73 f6 fb 94 e6 64 da ...?.F.P's....d. 393 080 91 65 b8 28 29 f6 41 e0 .e.().A. 395 To calculate the tag, we need a one-time Poly1305 key, which we 396 calculate by calling the ChaCha20 function again with the same key 397 and nonce, but a block count of zero. 399 Poly1305 one-time key: 400 000 af 1f 41 2c c1 15 ad ce 5e 4d 0e 29 d5 c1 30 bf ..A,....^M.)..0. 401 016 46 31 21 0e 0f ef 74 31 c0 45 4f e7 0f d7 c2 d1 F1!...t1.EO..... 403 The AAD is constructed by concatenating the SPI to the sequence 404 number: 406 000 01 02 03 04 00 00 00 05 ........ 408 The input to the Poly1305 function is constructed by concatenating 409 and padding the AAD and ciphertext: 411 Poly1305 Input: 412 000 01 02 03 04 00 00 00 05 00 00 00 00 00 00 00 00 ................ 413 016 24 03 94 28 b9 7f 41 7e 3c 13 75 3a 4f 05 08 7b $..(..A~<.u:O..{ 414 032 67 c3 52 e6 a7 fa b1 b9 82 d4 66 ef 40 7a e5 c6 g.R.......f.@z.. 415 048 14 ee 80 99 d5 28 44 eb 61 aa 95 df ab 4c 02 f7 .....(D.a....L.. 416 064 2a a7 1e 7c 4c 4f 64 c9 be fe 2f ac c6 38 e8 f3 *..|LOd.../..8.. 417 080 cb ec 16 3f ac 46 9b 50 27 73 f6 fb 94 e6 64 da ...?.F.P's....d. 418 096 91 65 b8 28 29 f6 41 e0 00 00 00 00 00 00 00 00 .e.().A......... 419 112 08 00 00 00 00 00 00 00 58 00 00 00 00 00 00 00 ........X....... 421 The resulting tag is: 423 Tag: 424 000 76 aa a8 26 6b 7f b0 f7 b1 1b 36 99 07 e1 ad 43 v..&k.....6....C 426 Putting it all together, the resulting packet is as follows: 428 ESP packet: 429 000 45 00 00 8c 23 45 00 00 40 32 de 5b cb 00 71 99 E...#E..@2.[..q. 430 016 cb 00 71 05 01 02 03 04 00 00 00 05 10 11 12 13 ..q............. 431 032 14 15 16 17 24 03 94 28 b9 7f 41 7e 3c 13 75 3a ....$..(..A~<.u: 432 048 4f 05 08 7b 67 c3 52 e6 a7 fa b1 b9 82 d4 66 ef O..{g.R.......f. 433 064 40 7a e5 c6 14 ee 80 99 d5 28 44 eb 61 aa 95 df @z.......(D.a... 434 080 ab 4c 02 f7 2a a7 1e 7c 4c 4f 64 c9 be fe 2f ac .L..*..|LOd.../. 435 096 c6 38 e8 f3 cb ec 16 3f ac 46 9b 50 27 73 f6 fb .8.....?.F.P's.. 436 112 94 e6 64 da 91 65 b8 28 29 f6 41 e0 76 aa a8 26 ..d..e.().A.v..& 437 128 6b 7f b0 f7 b1 1b 36 99 07 e1 ad 43 k.....6....C 439 Appendix B. IKEv2 Example 441 For the IKEv2 example, we'll use the following: 443 o The key is 0x80..0x9f, the same as in Appendix A. 444 o The Salt is 0xa0 0xa1 0xa2 0xa3. 445 o The IV will also be the same as in the previous example. The fact 446 that the IV and Salt are both the same means that the nonce is 447 also the same. 448 o Because the key and nonce are the same, so is the one-time 449 Poly1305 key. 450 o The packet with be an Informational request carrying a single 451 payload: A Notify payload with type SET_WINDOW_SIZE, setting the 452 window size to 10. 453 o iSPI = 0xc0 0xc1 0xc2 0xc3 0xc4 0xc5 0xc6 0xc7. 454 o rSPI = 0xd0 0xd1 0xd2 0xd3 0xd4 0xd5 0xd6 0xd7. 455 o Message ID shall be 9. 457 The Notify Payload: 458 000 00 00 00 0c 00 00 40 01 00 00 00 0a ......@..... 460 Plaintext (with no padding and a zero pad length): 461 000 00 00 00 0c 00 00 40 01 00 00 00 0a 00 ......@...... 463 Ciphertext: 464 000 61 03 94 70 1f 8d 01 7f 7c 12 92 48 89 a..p....|..H. 466 The AAD is constructed by appending the IKE header to the encrypted 467 payload header. Note that the length field in the IKE header and the 468 length field in the encrypted payload header have to be calculated 469 before constructing the AAD: 471 AAD: 472 000 c0 c1 c2 c3 c4 c5 c6 c7 d0 d1 d2 d3 d4 d5 d6 d7 ................ 473 016 2e 20 25 00 00 00 00 09 00 00 00 45 29 00 00 29 . %........E)..) 475 In this case, the length of the AAD is an integral multiple of 16, so 476 when constructing the input to Poly1305 there was no need for 477 padding. The ciphertext is 13 octets long, so it is followed by 478 three zero octets. The input to Poly1305 is 32 octets of AAD, 13 479 octets of ciphertext, 3 octets of zero padding, and two 8-octet 480 length fields in little-endian byte order. 482 Poly1305 Input: 483 000 c0 c1 c2 c3 c4 c5 c6 c7 d0 d1 d2 d3 d4 d5 d6 d7 ................ 484 016 2e 20 25 00 00 00 00 09 00 00 00 45 29 00 00 29 . %........E)..) 485 032 61 03 94 70 1f 8d 01 7f 7c 12 92 48 89 00 00 00 a..p....|..H.... 486 048 20 00 00 00 00 00 00 00 0d 00 00 00 00 00 00 00 ............... 488 Tag: 489 000 6b 71 bf e2 52 36 ef d7 cd c6 70 66 90 63 15 b2 kq..R6....pf.c.. 491 Encrypted Payload: 492 000 29 00 00 29 10 11 12 13 14 15 16 17 61 03 94 70 )..)........a..p 493 016 1f 8d 01 7f 7c 12 92 48 89 6b 71 bf e2 52 36 ef ....|..H.kq..R6. 494 032 d7 cd c6 70 66 90 63 15 b2 ...pf.c.. 496 The IKE Message: 497 000 c0 c1 c2 c3 c4 c5 c6 c7 d0 d1 d2 d3 d4 d5 d6 d7 ................ 498 016 2e 20 25 00 00 00 00 09 00 00 00 45 29 00 00 29 . %........E)..) 499 032 10 11 12 13 14 15 16 17 61 03 94 70 1f 8d 01 7f ........a..p.... 500 048 7c 12 92 48 89 6b 71 bf e2 52 36 ef d7 cd c6 70 |..H.kq..R6....p 501 064 66 90 63 15 b2 f.c.. 503 The below file in the snoop format [RFC1761] contains three packets: 504 The first is the ICMP packet from the example in the Appendix A, the 505 second is the ESP packet from the same appendix, and the third is the 506 IKEv2 packet from this appendix. To convert this text back into a 507 file, you can use a Unix command line tools such as "openssl enc -d 508 -a": 510 c25vb3AAAAAAAAACAAAABAAAAGIAAABiAAAAegAAAABVPq8PAAADVdhs6fUQBHgx 511 wbcpwggARQAAVKbyAABAAed4xjNkBcAAAgUIAFt6OggAAFU77BAABzYnCAkKCwwN 512 Dg8QERITFBUWFxgZGhscHR4fICEiIyQlJicoKSorLC0uLzAxMjM0NTY3AAAAmgAA 513 AJoAAACyAAAAAFU+rw8AAAo62Gzp9RAEeDHBtynCCABFAACMI0UAAEAy3lvLAHGZ 514 ywBxBQECAwQAAAAFEBESExQVFhckA5QouX9BfjwTdTpPBQh7Z8NS5qf6sbmC1Gbv 515 QHrlxhTugJnVKETrYaqV36tMAvcqpx58TE9kyb7+L6zGOOjzy+wWP6xGm1Anc/b7 516 lOZk2pFluCgp9kHgdqqoJmt/sPexGzaZB+GtQwAAAG8AAABvAAAAhwAAAABVPq8P 517 AAARH9hs6fUQBHgxwbcpwggARQAAYSNFAABAEd6nywBxmcsAcQUB9AH0AE0IUcDB 518 wsPExcbH0NHS09TV1tcuICUAAAAACQAAAEUpAAApEBESExQVFhdhA5RwH40Bf3wS 519 kkiJa3G/4lI279fNxnBmkGMVsg== 521 Author's Address 523 Yoav Nir 524 Check Point Software Technologies Ltd. 525 5 Hasolelim st. 526 Tel Aviv 6789735 527 Israel 529 Email: ynir.ietf@gmail.com