draft-ietf-ipsecme-chacha20-poly1305-12.txt   rfc7634.txt 
Network Working Group Y. Nir Internet Engineering Task Force (IETF) Y. Nir
Internet-Draft Check Point Request for Comments: 7634 Check Point
Intended status: Standards Track July 9, 2015 Category: Standards Track August 2015
Expires: January 10, 2016 ISSN: 2070-1721
ChaCha20, Poly1305 and their use in IKE & IPsec ChaCha20, Poly1305, and Their Use
draft-ietf-ipsecme-chacha20-poly1305-12 in the Internet Key Exchange Protocol (IKE) and IPsec
Abstract Abstract
This document describes the use of the ChaCha20 stream cipher along This document describes the use of the ChaCha20 stream cipher along
with the Poly1305 authenticator, combined into an AEAD algorithm for with the Poly1305 authenticator, combined into an AEAD algorithm for
the Internet Key Exchange protocol (IKEv2) and for IPsec. the Internet Key Exchange Protocol version 2 (IKEv2) and for IPsec.
Status of This Memo Status of This Memo
This Internet-Draft is submitted in full conformance with the This is an Internet Standards Track document.
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 This document is a product of the Internet Engineering Task Force
and may be updated, replaced, or obsoleted by other documents at any (IETF). It represents the consensus of the IETF community. It has
time. It is inappropriate to use Internet-Drafts as reference received public review and has been approved for publication by the
material or to cite them other than as "work in progress." Internet Engineering Steering Group (IESG). Further information on
Internet Standards is available in Section 2 of RFC 5741.
This Internet-Draft will expire on January 10, 2016. Information about the current status of this document, any errata,
and how to provide feedback on it may be obtained at
http://www.rfc-editor.org/info/rfc7634.
Copyright Notice Copyright Notice
Copyright (c) 2015 IETF Trust and the persons identified as the Copyright (c) 2015 IETF Trust and the persons identified as the
document authors. All rights reserved. document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of (http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License. described in the Simplified BSD License.
Table of Contents Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1. Conventions Used in This Document . . . . . . . . . . . . 3 1.1. Conventions Used in This Document . . . . . . . . . . . . 3
2. ChaCha20 & Poly1305 for ESP . . . . . . . . . . . . . . . . . 3 2. ChaCha20 and Poly1305 for ESP . . . . . . . . . . . . . . . . 3
2.1. AAD Construction . . . . . . . . . . . . . . . . . . . . 5 2.1. AAD Construction . . . . . . . . . . . . . . . . . . . . 5
3. Use in IKEv2 . . . . . . . . . . . . . . . . . . . . . . . . 5 3. Use in IKEv2 . . . . . . . . . . . . . . . . . . . . . . . . 6
4. Negotiation in IKEv2 . . . . . . . . . . . . . . . . . . . . 5 4. Negotiation in IKEv2 . . . . . . . . . . . . . . . . . . . . 6
5. Security Considerations . . . . . . . . . . . . . . . . . . . 5 5. Security Considerations . . . . . . . . . . . . . . . . . . . 6
6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 6 6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 7
7. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 6 7. References . . . . . . . . . . . . . . . . . . . . . . . . . 7
8. References . . . . . . . . . . . . . . . . . . . . . . . . . 6 7.1. Normative References . . . . . . . . . . . . . . . . . . 7
8.1. Normative References . . . . . . . . . . . . . . . . . . 7 7.2. Informative References . . . . . . . . . . . . . . . . . 8
8.2. Informative References . . . . . . . . . . . . . . . . . 7 Appendix A. ESP Example . . . . . . . . . . . . . . . . . . . . 9
Appendix A. ESP Example . . . . . . . . . . . . . . . . . . . . 8 Appendix B. IKEv2 Example . . . . . . . . . . . . . . . . . . . 11
Appendix B. IKEv2 Example . . . . . . . . . . . . . . . . . . . 10 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 13
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 12 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 13
1. Introduction 1. Introduction
The Advanced Encryption Standard (AES - [FIPS-197]) has become the The Advanced Encryption Standard (AES) [FIPS-197] has become the go-
go-to algorithm for encryption. It is now the most commonly used to algorithm for encryption. It is now the most commonly used
algorithm in many areas, including IPsec virtual private networks algorithm in many areas, including IPsec Virtual Private Networks
(VPN). On most modern platforms AES is anywhere from 4x to 10x as (VPNs). On most modern platforms, AES is anywhere from four to ten
fast as the previous popular cipher, 3-key Data Encryption Standard times as fast as the previously popular cipher, Triple Data
(3DES - [SP800-67]). 3DES also uses a 64-bit block, which means that Encryption Standard (3DES) [SP800-67]. 3DES also uses a 64-bit
the amount of data that can be encrypted before rekeying is required block; this means that the amount of data that can be encrypted
is limited. These reasons make AES not only the best choice, but the before rekeying is required is limited. These reasons make AES not
only viable choice for IPsec. only the best choice, but the only viable choice for IPsec.
The problem is that if future advances in cryptanalysis reveal a The problem is that if future advances in cryptanalysis reveal a
weakness in AES, VPN users will be in an unenviable position. With weakness in AES, VPN users will be in an unenviable position. With
the only other widely supported cipher for IPsec implementations the only other widely supported cipher for IPsec implementations
being the much slower 3DES, it is not feasible to re-configure IPsec being the much slower 3DES, it is not feasible to reconfigure IPsec
installations away from AES. [standby-cipher] describes this issue installations away from AES. [Standby-Cipher] describes this issue
and the need for a standby cipher in greater detail. and the need for a standby cipher in greater detail.
This document proposes the fast and secure ChaCha20 stream cipher as This document proposes the fast and secure ChaCha20 stream cipher as
such a standby cipher in an Authenticated Encryption with Associated such a standby cipher in an Authenticated Encryption with Associated
Data (AEAD) construction with the Poly1305 authenticator for use with Data (AEAD) construction with the Poly1305 authenticator for use with
the Encapsulated Security Protocol (ESP - [RFC4303]) and the Internet the Encapsulated Security Protocol (ESP) [RFC4303] and the Internet
Key Exchange Protocol (IKEv2 - [RFC7296]). The algorithms are Key Exchange Protocol version 2 (IKEv2) [RFC7296]. The algorithms
described in a separate document ([RFC7539]). This document only are described in a separate document ([RFC7539]). This document only
describes the IPsec-specific things. describes the IPsec-specific things.
1.1. Conventions Used in This Document 1.1. Conventions Used in This Document
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in [RFC2119]. document are to be interpreted as described in [RFC2119].
2. ChaCha20 & Poly1305 for ESP 2. ChaCha20 and Poly1305 for ESP
AEAD_CHACHA20_POLY1305 ([RFC7539]) is a combined mode algorithm, or AEAD_CHACHA20_POLY1305 ([RFC7539]) is a combined mode algorithm, or
AEAD. Usage follows the AEAD construction in section 2.8 of RFC AEAD. Usage follows the AEAD construction in Section 2.8 of RFC
7539: 7539:
o The Initialization Vector (IV) is 64-bit, and is used as part of o The Initialization Vector (IV) is 64 bits and is used as part of
the nonce. The IV MUST be unique for each invocation for a the nonce. The IV MUST be unique for each invocation for a
particular SA but does not need to be unpredictable. The use of a particular security association (SA) but does not need to be
counter or a linear feedback shift register (LFSR) is RECOMMENDED. unpredictable. The use of a counter or a linear feedback shift
register (LFSR) is RECOMMENDED.
o A 32-bit Salt is prepended to the 64-bit IV to form the 96-bit o A 32-bit Salt is prepended to the 64-bit IV to form the 96-bit
nonce. The salt is fixed per SA and it is not transmitted as part nonce. The salt is fixed per SA, and it is not transmitted as
of the ESP packet. part of the ESP packet.
o The encryption key is 256-bit.
o The Internet Key Exchange protocol generates a bitstring called o The encryption key is 256 bits.
KEYMAT using a pseudo-random function (PRF). That KEYMAT is
divided into keys for encryption, message authentication and o The Internet Key Exchange Protocol generates a bitstring called
KEYMAT using a pseudorandom function (PRF). That KEYMAT is
divided into keys for encryption, message authentication, and
whatever else is needed. The KEYMAT requested for each whatever else is needed. The KEYMAT requested for each
ChaCha20-Poly1305 key is 36 octets. The first 32 octets are the ChaCha20-Poly1305 key is 36 octets. The first 32 octets are the
256-bit ChaCha20 key, and the remaining four octets are used as 256-bit ChaCha20 key, and the remaining 4 octets are used as the
the Salt value in the nonce. Salt value in the nonce.
The ChaCha20 encryption algorithm requires the following parameters: The ChaCha20 encryption algorithm requires the following parameters:
a 256-bit key, a 96-bit nonce, and a 32-bit initial block counter. a 256-bit key, a 96-bit nonce, and a 32-bit Initial Block Counter.
For ESP we set these as follows: For ESP, we set these as follows:
o The key is set as mentioned above. o The key is set as mentioned above.
o The 96-bit nonce is formed from a concatenation of the 32-bit Salt o The 96-bit nonce is formed from a concatenation of the 32-bit Salt
and the 64-bit IV, as described above. and the 64-bit IV, as described above.
o The Initial Block Counter is set to one (1). The reason that one o The Initial Block Counter is set to one (1). The reason that one
is used for the initial counter rather than zero is that zero is is used for the initial counter rather than zero is that zero is
reserved for generating the one-time Poly1305 key (see below) reserved for generating the one-time Poly1305 key (see below).
As the ChaCha20 block function is not applied directly to the As the ChaCha20 block function is not applied directly to the
plaintext, no padding should be necessary. However, in keeping with plaintext, no padding should be necessary. However, in keeping with
the specification in RFC 4303, the plaintext always has a pad length the specification in RFC 4303, the plaintext always has a pad length
octet and a Next Header octet and may require padding octets so as to octet and a Next Header octet, and it may require padding octets so
align the buffer to an integral multiple of 4 octets. as to align the buffer to an integral multiple of 4 octets.
The same key and nonce, along with a block counter of zero are passed The same key and nonce, along with a block counter of zero, are
to the ChaCha20 block function, and the top 256 bits of the result passed to the ChaCha20 block function, and the top 256 bits of the
are used as the Poly1305 key. result are used as the Poly1305 key.
Finally, the Poly1305 function is run on the data to be Finally, the Poly1305 function is run on the data to be
authenticated, which is, as specified in section 2.8 of [RFC7539] a authenticated, which is, as specified in Section 2.8 of [RFC7539], a
concatenation of the following in the below order: concatenation of the following in the order below:
o The Authenticated Additional Data (AAD); see Section 2.1.
o The Authenticated Additional Data (AAD) - see Section 2.1.
o Zero-octet padding that rounds the length up to 16 octets. This o Zero-octet padding that rounds the length up to 16 octets. This
is 4 or 8 octets depending on the length of the AAD. is 4 or 8 octets depending on the length of the AAD.
o The ciphertext
o Zero octet padding that rounds the total length up to an integral o The ciphertext.
o Zero-octet padding that rounds the total length up to an integral
multiple of 16 octets. multiple of 16 octets.
o The length of the additional authenticated data (AAD) in octets
(as a 64-bit integer encoded in little-endian byte order). o The length of the AAD in octets (as a 64-bit integer encoded in
little-endian byte order).
o The length of the ciphertext in octets (as a 64-bit integer o The length of the ciphertext in octets (as a 64-bit integer
encoded in little-endian byte order). encoded in little-endian byte order).
The 128-bit output of Poly1305 is used as the tag. All 16 octets are The 128-bit output of Poly1305 is used as the tag. All 16 octets are
included in the packet. included in the packet.
The figure below is copied from RFC 4303: The figure below is a copy of Figure 2 in RFC 4303:
0 1 2 3 0 1 2 3
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 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Security Parameters Index (SPI) | | Security Parameters Index (SPI) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Sequence Number | | Sequence Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+--- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+---
| IV (optional) | ^ p | IV (optional) | ^ p
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | a +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | a
skipping to change at page 4, line 49 skipping to change at page 5, line 31
+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+--- +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+---
| | Padding (0-255 bytes) | | | Padding (0-255 bytes) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| | Pad Length | Next Header | | | Pad Length | Next Header |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Integrity Check Value-ICV (variable) | | Integrity Check Value-ICV (variable) |
~ ~ ~ ~
| | | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
o The IV field is 64-bit. It is the final 64 bits of the 96-bit o The IV field is 64 bits. It is the final 64 bits of the 96-bit
nonce. If the counter method is used for generating unique IVs, nonce. If the counter method is used for generating unique IVs,
then the final 32 bits of the IV will be equal to the Sequence then the final 32 bits of the IV will be equal to the Sequence
Number field. Number field.
o The length of the Padding field need not exceed 4 octets. o The length of the Padding field need not exceed 4 octets.
However, neither RFC 4303 nor this specification require using the However, neither RFC 4303 nor this specification require using the
minimal padding length. minimal padding length.
o The Integrity Check Value field contains the 16 octet tag.
o The Integrity Check Value field contains the 16-octet tag.
2.1. AAD Construction 2.1. AAD Construction
The construction of the Additional Authenticated Data (AAD) is The construction of the Additional Authenticated Data (AAD) is
similar to the one in [RFC4106]. For security associations (SAs) similar to the one in [RFC4106]. For security associations (SAs)
with 32-bit sequence numbers the AAD is 8 octets: a 4-octet SPI with 32-bit sequence numbers, the AAD is 8 octets: a 4-octet SPI
followed by 4-octet sequence number ordered exactly as it is in the followed by a 4-octet sequence number ordered exactly as it is in the
packet. For SAs with ESN the AAD is 12 octets: a 4-octet SPI packet. For SAs with an Extended Sequence Number (ESN), the AAD is
followed by an 8-octet sequence number as a 64-bit integer in network 12 octets: a 4-octet SPI followed by an 8-octet sequence number as a
byte order. 64-bit integer in big-endian byte order.
3. Use in IKEv2 3. Use in IKEv2
AEAD algorithms can be used in IKE, as described in [RFC5282]. More AEAD algorithms can be used in IKE, as described in [RFC5282]. More
specifically: specifically:
o The Encrypted Payload is as described in section 3 of that o The Encrypted Payload is as described in Section 3 of RFC 5282.
document.
o The ChaCha20-Poly1305 keying material is derived similar to ESP: o The ChaCha20-Poly1305 keying material is derived similarly to ESP:
36 octets are requested for each of SK_ei and SK_er, of which the 36 octets are requested for each of SK_ei and SK_er, of which the
first 32 form the key and the last 4 form the salt. No octets are first 32 form the key and the last 4 form the salt. No octets are
requested for SK_ai and SK_ar. requested for SK_ai and SK_ar.
o The IV is 64 bits, as described in Section 2, and is included o The IV is 64 bits, as described in Section 2, and is included
explicitly in the Encrypted payload. explicitly in the Encrypted payload.
o The sender SHOULD include no padding and set the Pad Length field o The sender SHOULD include no padding and set the Pad Length field
to zero. The receiver MUST accept any length of padding. to zero. The receiver MUST accept any length of padding.
o The AAD is as described in section 5.1 of RFC 5282, so it is 32
octets (28 for the IKEv2 header + 4 octets for the encrypted o The AAD is as described in Section 5.1 of RFC 5282, so it is 32
payload header) assuming no unencrypted payloads. octets (28 for the IKEv2 header plus 4 octets for the encrypted
payload header), assuming no unencrypted payloads.
4. Negotiation in IKEv2 4. Negotiation in IKEv2
When negotiating the ChaCha20-Poly1305 algorithm for use in IKE or When negotiating the ChaCha20-Poly1305 algorithm for use in IKE or
IPsec, the value ENCR_CHACHA20_POLY1305 (28) should be used in the IPsec, the value ENCR_CHACHA20_POLY1305 (28) should be used in the
transform substructure of the SA payload as the ENCR (type 1) transform substructure of the SA payload as the ENCR (type 1)
transform ID. As with other AEAD algorithms, INTEG (type 3) transform ID. As with other AEAD algorithms, INTEG (type 3)
transform substructures MUST NOT be specified or just one INTEG transform substructures MUST NOT be specified, or just one INTEG
transform MAY be included with value NONE (0). transform MAY be included with value NONE (0).
5. Security Considerations 5. Security Considerations
The ChaCha20 cipher is designed to provide 256-bit security. The ChaCha20 cipher is designed to provide 256-bit security.
The Poly1305 authenticator is designed to ensure that forged messages The Poly1305 authenticator is designed to ensure that forged messages
are rejected with a probability of 1-(n/(2^102)) for a 16n-octet are rejected with a probability of 1-(n/(2^102)) for a 16n-octet
message, even after sending 2^64 legitimate messages, so it is SUF- message, even after sending 2^64 legitimate messages, so it is
CMA in the terminology of [AE]. SUF-CMA (strong unforgeability against chosen-message attacks) in the
terminology of [AE].
The most important security consideration in implementing this draft The most important security consideration in implementing this
is the uniqueness of the nonce used in ChaCha20. The nonce should be document is the uniqueness of the nonce used in ChaCha20. The nonce
selected uniquely for a particular key, but unpredictability of the should be selected uniquely for a particular key, but
nonce is not required. Counters and LFSRs are both acceptable ways unpredictability of the nonce is not required. Counters and LFSRs
of generating unique nonces. are both acceptable ways of generating unique nonces.
Another issue with implementing these algorithms is avoiding side Another issue with implementing these algorithms is avoiding side
channels. This is trivial for ChaCha20, but requires some care for channels. This is trivial for ChaCha20, but requires some care for
Poly1305. Considerations for implementations of these algorithms are Poly1305. Considerations for implementations of these algorithms are
in [RFC7539]. in [RFC7539].
The Salt value in used nonce construction in ESP and IKEv2 is derived The Salt value in used nonce construction in ESP and IKEv2 is derived
from the keystream, same as the encryption key. It is never from the keystream, same as the encryption key. It is never
transmitted on the wire, but the security of the algorithm does not transmitted on the wire, but the security of the algorithm does not
depend on its secrecy. Thus implementations that keep keys and other depend on its secrecy. Thus, implementations that keep keys and
secret material within some security boundary MAY export the Salt other secret material within some security boundary MAY export the
from the security boundary. This may be useful if the API provided Salt from the security boundary. This may be useful if the API
by the library accepts the nonce as parameter rather than the IV. provided by the library accepts the nonce as a parameter rather than
the IV.
6. IANA Considerations 6. IANA Considerations
IANA has assigned the value 28 as a transform identifier for the IANA has assigned the value 28 as a transform identifier for the
algorithm described in this document in the "Transform Type 1 - algorithm described in this document in the "Transform Type 1 -
Encryption Algorithm Transform IDs" registry with name Encryption Algorithm Transform IDs" registry with name
ENCR_CHACHA20_POLY1305 and this document as reference for both ESP ENCR_CHACHA20_POLY1305 and this document as reference for both ESP
and IKEv2. and IKEv2.
7. Acknowledgements 7. References
All of the algorithms in this document were designed by D. J.
Bernstein. The AEAD construction was designed by Adam Langley. The
author would also like to thank Adam for helpful comments, as well as
Yaron Sheffer for telling me to write the algorithms draft. Thanks
also to Martin Willi for pointing out the discrepancy with the final
version of the algorithm document, and to Valery Smyslov and Tero
Kivinen for helpful comments on this draft. Thanks to Steve Doyle
and Martin Willi for pointing out mistakes in my examples.
8. References 7.1. Normative References
8.1. Normative References
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119, March 1997. Requirement Levels", BCP 14, RFC 2119,
DOI 10.17487/RFC2119, March 1997,
<http://www.rfc-editor.org/info/rfc2119>.
[RFC4303] Kent, S., "IP Encapsulating Security Payload (ESP)", RFC [RFC4303] Kent, S., "IP Encapsulating Security Payload (ESP)",
4303, December 2005. RFC 4303, DOI 10.17487/RFC4303, December 2005,
<http://www.rfc-editor.org/info/rfc4303>.
[RFC5282] Black, D. and D. McGrew, "Using Authenticated Encryption [RFC5282] Black, D. and D. McGrew, "Using Authenticated Encryption
Algorithms with the Encrypted Payload of the Internet Key Algorithms with the Encrypted Payload of the Internet Key
Exchange version 2 (IKEv2) Protocol", RFC 5282, August Exchange version 2 (IKEv2) Protocol", RFC 5282,
2008. DOI 10.17487/RFC5282, August 2008,
<http://www.rfc-editor.org/info/rfc5282>.
[RFC7296] Kivinen, T., Kaufman, C., Hoffman, P., Nir, Y., and P. [RFC7296] Kaufman, C., Hoffman, P., Nir, Y., Eronen, P., and T.
Eronen, "Internet Key Exchange Protocol Version 2 Kivinen, "Internet Key Exchange Protocol Version 2
(IKEv2)", RFC 7296, October 2014. (IKEv2)", STD 79, RFC 7296, DOI 10.17487/RFC7296, October
2014, <http://www.rfc-editor.org/info/rfc7296>.
[RFC7539] Langley, A. and Y. Nir, "ChaCha20 and Poly1305 for IETF [RFC7539] Nir, Y. and A. Langley, "ChaCha20 and Poly1305 for IETF
protocols", RFC 7539, May 2015. Protocols", RFC 7539, DOI 10.17487/RFC7539, May 2015,
<http://www.rfc-editor.org/info/rfc7539>.
8.2. Informative References 7.2. Informative References
[AE] Bellare, M. and C. Namprempre, "Authenticated Encryption: [AE] Bellare, M. and C. Namprempre, "Authenticated Encryption:
Relations among notions and analysis of the generic Relations among notions and analysis of the generic
composition paradigm", 2000, composition paradigm", DOI 10.1007/s00145-008-9026-x,
September 2008,
<http://cseweb.ucsd.edu/~mihir/papers/oem.html>. <http://cseweb.ucsd.edu/~mihir/papers/oem.html>.
[FIPS-197] [FIPS-197]
National Institute of Standards and Technology, "Advanced National Institute of Standards and Technology, "Advanced
Encryption Standard (AES)", FIPS PUB 197, November 2001, Encryption Standard (AES)", FIPS PUB 197, November 2001,
<http://csrc.nist.gov/publications/fips/fips197/ <http://csrc.nist.gov/publications/fips/fips197/
fips-197.pdf>. fips-197.pdf>.
[RFC1761] Callaghan, B. and R. Gilligan, "Snoop Version 2 Packet [RFC1761] Callaghan, B. and R. Gilligan, "Snoop Version 2 Packet
Capture File Format", RFC 1761, February 1995, Capture File Format", RFC 1761, DOI 10.17487/RFC1761,
<https://tools.ietf.org/html/rfc1761>. February 1995, <http://www.rfc-editor.org/info/rfc1761>.
[RFC4106] Viega, J. and D. McGrew, "The Use of Galois/Counter Mode [RFC4106] Viega, J. and D. McGrew, "The Use of Galois/Counter Mode
(GCM) in IPsec Encapsulating Security Payload (ESP)", RFC (GCM) in IPsec Encapsulating Security Payload (ESP)",
4106, June 2005. RFC 4106, DOI 10.17487/RFC4106, June 2005,
<http://www.rfc-editor.org/info/rfc4106>.
[SP800-67] [SP800-67]
National Institute of Standards and Technology, National Institute of Standards and Technology,
"Recommendation for the Triple Data Encryption Algorithm "Recommendation for the Triple Data Encryption Algorithm
(TDEA) Block Cipher", FIPS SP800-67, January 2012, (TDEA) Block Cipher", FIPS SP800-67, January 2012,
<http://csrc.nist.gov/publications/nistpubs/800-67-Rev1/ <http://csrc.nist.gov/publications/nistpubs/800-67-Rev1/
SP-800-67-Rev1.pdf>. SP-800-67-Rev1.pdf>.
[standby-cipher] [Standby-Cipher]
McGrew, D., Grieco, A., and Y. Sheffer, "Selection of McGrew, D., Grieco, A., and Y. Sheffer, "Selection of
Future Cryptographic Standards", draft-mcgrew-standby- Future Cryptographic Standards", Work in Progress
cipher (work in progress), January 2013. draft-mcgrew-standby-cipher-00, January 2013.
Appendix A. ESP Example Appendix A. ESP Example
For this example, we will use a tunnel-mode ESP SA using the For this example, we will use a tunnel-mode ESP SA using the
ChaCha20-Poly1305 algorithm. The keying material is as follows: ChaCha20-Poly1305 algorithm. The keying material is as follows:
KEYMAT: KEYMAT:
000 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f ................ 000 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f ................
016 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f ................ 016 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f ................
032 a0 a1 a2 a3 .... 032 a0 a1 a2 a3 ....
Obviously not a great PRF. The first 32 octets are the key and the Obviously not a great PRF. The first 32 octets are the key and the
final four octets (0xa0 0xa1 0xa2 0xa3) are the salt. For the final 4 octets (0xa0 0xa1 0xa2 0xa3) are the salt. For the packet,
packet, we will use an ICMP packet from 198.51.100.5 to 192.0.2.5: we will use an ICMP packet from 198.51.100.5 to 192.0.2.5:
Source Packet: Source Packet:
000 45 00 00 54 a6 f2 00 00 40 01 e7 78 c6 33 64 05 E..T....@..x.3d. 000 45 00 00 54 a6 f2 00 00 40 01 e7 78 c6 33 64 05 E..T....@..x.3d.
016 c0 00 02 05 08 00 5b 7a 3a 08 00 00 55 3b ec 10 ......[z:...U;.. 016 c0 00 02 05 08 00 5b 7a 3a 08 00 00 55 3b ec 10 ......[z:...U;..
032 00 07 36 27 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 ..6'............ 032 00 07 36 27 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 ..6'............
048 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 ............ !"# 048 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 ............ !"#
064 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 $%&'()*+,-./0123 064 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 $%&'()*+,-./0123
080 34 35 36 37 4567 080 34 35 36 37 4567
The SA details are as follows: The SA details are as follows:
skipping to change at page 9, line 13 skipping to change at page 10, line 16
padding: padding:
Plaintext (includes padding and pad length): Plaintext (includes padding and pad length):
000 45 00 00 54 a6 f2 00 00 40 01 e7 78 c6 33 64 05 E..T....@..x.3d. 000 45 00 00 54 a6 f2 00 00 40 01 e7 78 c6 33 64 05 E..T....@..x.3d.
016 c0 00 02 05 08 00 5b 7a 3a 08 00 00 55 3b ec 10 ......[z:...U;.. 016 c0 00 02 05 08 00 5b 7a 3a 08 00 00 55 3b ec 10 ......[z:...U;..
032 00 07 36 27 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 ..6'............ 032 00 07 36 27 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 ..6'............
048 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 ............ !"# 048 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 ............ !"#
064 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 $%&'()*+,-./0123 064 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 $%&'()*+,-./0123
080 34 35 36 37 01 02 02 04 4567.... 080 34 35 36 37 01 02 02 04 4567....
With the key, nonce and plaintext available, we can call the ChaCha20 With the key, nonce, and plaintext available, we can call the
function and encrypt the packet, producing the ciphertext: ChaCha20 function and encrypt the packet, producing the ciphertext:
Ciphertext: Ciphertext:
000 24 03 94 28 b9 7f 41 7e 3c 13 75 3a 4f 05 08 7b $..(..A~<.u:O..{ 000 24 03 94 28 b9 7f 41 7e 3c 13 75 3a 4f 05 08 7b $..(..A~<.u:O..{
016 67 c3 52 e6 a7 fa b1 b9 82 d4 66 ef 40 7a e5 c6 g.R.......f.@z.. 016 67 c3 52 e6 a7 fa b1 b9 82 d4 66 ef 40 7a e5 c6 g.R.......f.@z..
032 14 ee 80 99 d5 28 44 eb 61 aa 95 df ab 4c 02 f7 .....(D.a....L.. 032 14 ee 80 99 d5 28 44 eb 61 aa 95 df ab 4c 02 f7 .....(D.a....L..
048 2a a7 1e 7c 4c 4f 64 c9 be fe 2f ac c6 38 e8 f3 *..|LOd.../..8.. 048 2a a7 1e 7c 4c 4f 64 c9 be fe 2f ac c6 38 e8 f3 *..|LOd.../..8..
064 cb ec 16 3f ac 46 9b 50 27 73 f6 fb 94 e6 64 da ...?.F.P's....d. 064 cb ec 16 3f ac 46 9b 50 27 73 f6 fb 94 e6 64 da ...?.F.P's....d.
080 91 65 b8 28 29 f6 41 e0 .e.().A. 080 91 65 b8 28 29 f6 41 e0 .e.().A.
To calculate the tag, we need a one-time Poly1305 key, which we To calculate the tag, we need a one-time Poly1305 key, which we
skipping to change at page 10, line 26 skipping to change at page 11, line 28
080 ab 4c 02 f7 2a a7 1e 7c 4c 4f 64 c9 be fe 2f ac .L..*..|LOd.../. 080 ab 4c 02 f7 2a a7 1e 7c 4c 4f 64 c9 be fe 2f ac .L..*..|LOd.../.
096 c6 38 e8 f3 cb ec 16 3f ac 46 9b 50 27 73 f6 fb .8.....?.F.P's.. 096 c6 38 e8 f3 cb ec 16 3f ac 46 9b 50 27 73 f6 fb .8.....?.F.P's..
112 94 e6 64 da 91 65 b8 28 29 f6 41 e0 76 aa a8 26 ..d..e.().A.v..& 112 94 e6 64 da 91 65 b8 28 29 f6 41 e0 76 aa a8 26 ..d..e.().A.v..&
128 6b 7f b0 f7 b1 1b 36 99 07 e1 ad 43 k.....6....C 128 6b 7f b0 f7 b1 1b 36 99 07 e1 ad 43 k.....6....C
Appendix B. IKEv2 Example Appendix B. IKEv2 Example
For the IKEv2 example, we'll use the following: For the IKEv2 example, we'll use the following:
o The key is 0x80..0x9f, the same as in Appendix A. o The key is 0x80..0x9f, the same as in Appendix A.
o The Salt is 0xa0 0xa1 0xa2 0xa3. o The Salt is 0xa0 0xa1 0xa2 0xa3.
o The IV will also be the same as in the previous example. The fact o The IV will also be the same as in the previous example. The fact
that the IV and Salt are both the same means that the nonce is that the IV and Salt are both the same means that the nonce is
also the same. also the same.
o Because the key and nonce are the same, so is the one-time o Because the key and nonce are the same, so is the one-time
Poly1305 key. Poly1305 key.
o The packet with be an Informational request carrying a single
payload: A Notify payload with type SET_WINDOW_SIZE, setting the o The packet will be an INFORMATIONAL request carrying a single
payload: a Notify payload with type SET_WINDOW_SIZE, setting the
window size to 10. window size to 10.
o iSPI = 0xc0 0xc1 0xc2 0xc3 0xc4 0xc5 0xc6 0xc7. o iSPI = 0xc0 0xc1 0xc2 0xc3 0xc4 0xc5 0xc6 0xc7.
o rSPI = 0xd0 0xd1 0xd2 0xd3 0xd4 0xd5 0xd6 0xd7. o rSPI = 0xd0 0xd1 0xd2 0xd3 0xd4 0xd5 0xd6 0xd7.
o Message ID shall be 9. o Message ID shall be 9.
The Notify Payload: The Notify Payload:
000 00 00 00 0c 00 00 40 01 00 00 00 0a ......@..... 000 00 00 00 0c 00 00 40 01 00 00 00 0a ......@.....
Plaintext (with no padding and a zero pad length): Plaintext (with no padding and a zero pad length):
000 00 00 00 0c 00 00 40 01 00 00 00 0a 00 ......@...... 000 00 00 00 0c 00 00 40 01 00 00 00 0a 00 ......@......
Ciphertext: Ciphertext:
000 61 03 94 70 1f 8d 01 7f 7c 12 92 48 89 a..p....|..H. 000 61 03 94 70 1f 8d 01 7f 7c 12 92 48 89 a..p....|..H.
skipping to change at page 11, line 11 skipping to change at page 12, line 19
payload header. Note that the length field in the IKE header and the payload header. Note that the length field in the IKE header and the
length field in the encrypted payload header have to be calculated length field in the encrypted payload header have to be calculated
before constructing the AAD: before constructing the AAD:
AAD: AAD:
000 c0 c1 c2 c3 c4 c5 c6 c7 d0 d1 d2 d3 d4 d5 d6 d7 ................ 000 c0 c1 c2 c3 c4 c5 c6 c7 d0 d1 d2 d3 d4 d5 d6 d7 ................
016 2e 20 25 00 00 00 00 09 00 00 00 45 29 00 00 29 . %........E)..) 016 2e 20 25 00 00 00 00 09 00 00 00 45 29 00 00 29 . %........E)..)
In this case, the length of the AAD is an integral multiple of 16, so In this case, the length of the AAD is an integral multiple of 16, so
when constructing the input to Poly1305 there was no need for when constructing the input to Poly1305 there was no need for
padding. The ciphertext is 13 octets long, so it is followed by padding. The ciphertext is 13 octets long, so it is followed by 3
three zero octets. The input to Poly1305 is 32 octets of AAD, 13 zero octets. The input to Poly1305 is 32 octets of AAD, 13 octets of
octets of ciphertext, 3 octets of zero padding, and two 8-octet ciphertext, 3 octets of zero padding, and two 8-octet length fields
length fields in little-endian byte order. in little-endian byte order.
Poly1305 Input: Poly1305 Input:
000 c0 c1 c2 c3 c4 c5 c6 c7 d0 d1 d2 d3 d4 d5 d6 d7 ................ 000 c0 c1 c2 c3 c4 c5 c6 c7 d0 d1 d2 d3 d4 d5 d6 d7 ................
016 2e 20 25 00 00 00 00 09 00 00 00 45 29 00 00 29 . %........E)..) 016 2e 20 25 00 00 00 00 09 00 00 00 45 29 00 00 29 . %........E)..)
032 61 03 94 70 1f 8d 01 7f 7c 12 92 48 89 00 00 00 a..p....|..H.... 032 61 03 94 70 1f 8d 01 7f 7c 12 92 48 89 00 00 00 a..p....|..H....
048 20 00 00 00 00 00 00 00 0d 00 00 00 00 00 00 00 ............... 048 20 00 00 00 00 00 00 00 0d 00 00 00 00 00 00 00 ...............
Tag: Tag:
000 6b 71 bf e2 52 36 ef d7 cd c6 70 66 90 63 15 b2 kq..R6....pf.c.. 000 6b 71 bf e2 52 36 ef d7 cd c6 70 66 90 63 15 b2 kq..R6....pf.c..
skipping to change at page 11, line 38 skipping to change at page 13, line 6
032 d7 cd c6 70 66 90 63 15 b2 ...pf.c.. 032 d7 cd c6 70 66 90 63 15 b2 ...pf.c..
The IKE Message: The IKE Message:
000 c0 c1 c2 c3 c4 c5 c6 c7 d0 d1 d2 d3 d4 d5 d6 d7 ................ 000 c0 c1 c2 c3 c4 c5 c6 c7 d0 d1 d2 d3 d4 d5 d6 d7 ................
016 2e 20 25 00 00 00 00 09 00 00 00 45 29 00 00 29 . %........E)..) 016 2e 20 25 00 00 00 00 09 00 00 00 45 29 00 00 29 . %........E)..)
032 10 11 12 13 14 15 16 17 61 03 94 70 1f 8d 01 7f ........a..p.... 032 10 11 12 13 14 15 16 17 61 03 94 70 1f 8d 01 7f ........a..p....
048 7c 12 92 48 89 6b 71 bf e2 52 36 ef d7 cd c6 70 |..H.kq..R6....p 048 7c 12 92 48 89 6b 71 bf e2 52 36 ef d7 cd c6 70 |..H.kq..R6....p
064 66 90 63 15 b2 f.c.. 064 66 90 63 15 b2 f.c..
The below file in the snoop format [RFC1761] contains three packets: The below file in the snoop format [RFC1761] contains three packets:
The first is the ICMP packet from the example in the Appendix A, the The first is the ICMP packet from the example in Appendix A, the
second is the ESP packet from the same appendix, and the third is the second is the ESP packet from the same appendix, and the third is the
IKEv2 packet from this appendix. To convert this text back into a IKEv2 packet from this appendix. To convert this text back into a
file, you can use a Unix command line tools such as "openssl enc -d file, you can use a Unix command line tool such as
-a": "openssl enc -d -a":
c25vb3AAAAAAAAACAAAABAAAAGIAAABiAAAAegAAAABVPq8PAAADVdhs6fUQBHgx c25vb3AAAAAAAAACAAAABAAAAGIAAABiAAAAegAAAABVPq8PAAADVdhs6fUQBHgx
wbcpwggARQAAVKbyAABAAed4xjNkBcAAAgUIAFt6OggAAFU77BAABzYnCAkKCwwN wbcpwggARQAAVKbyAABAAed4xjNkBcAAAgUIAFt6OggAAFU77BAABzYnCAkKCwwN
Dg8QERITFBUWFxgZGhscHR4fICEiIyQlJicoKSorLC0uLzAxMjM0NTY3AAAAmgAA Dg8QERITFBUWFxgZGhscHR4fICEiIyQlJicoKSorLC0uLzAxMjM0NTY3AAAAmgAA
AJoAAACyAAAAAFU+rw8AAAo62Gzp9RAEeDHBtynCCABFAACMI0UAAEAy3lvLAHGZ AJoAAACyAAAAAFU+rw8AAAo62Gzp9RAEeDHBtynCCABFAACMI0UAAEAy3lvLAHGZ
ywBxBQECAwQAAAAFEBESExQVFhckA5QouX9BfjwTdTpPBQh7Z8NS5qf6sbmC1Gbv ywBxBQECAwQAAAAFEBESExQVFhckA5QouX9BfjwTdTpPBQh7Z8NS5qf6sbmC1Gbv
QHrlxhTugJnVKETrYaqV36tMAvcqpx58TE9kyb7+L6zGOOjzy+wWP6xGm1Anc/b7 QHrlxhTugJnVKETrYaqV36tMAvcqpx58TE9kyb7+L6zGOOjzy+wWP6xGm1Anc/b7
lOZk2pFluCgp9kHgdqqoJmt/sPexGzaZB+GtQwAAAG8AAABvAAAAhwAAAABVPq8P lOZk2pFluCgp9kHgdqqoJmt/sPexGzaZB+GtQwAAAG8AAABvAAAAhwAAAABVPq8P
AAARH9hs6fUQBHgxwbcpwggARQAAYSNFAABAEd6nywBxmcsAcQUB9AH0AE0IUcDB AAARH9hs6fUQBHgxwbcpwggARQAAYSNFAABAEd6nywBxmcsAcQUB9AH0AE0IUcDB
wsPExcbH0NHS09TV1tcuICUAAAAACQAAAEUpAAApEBESExQVFhdhA5RwH40Bf3wS wsPExcbH0NHS09TV1tcuICUAAAAACQAAAEUpAAApEBESExQVFhdhA5RwH40Bf3wS
kkiJa3G/4lI279fNxnBmkGMVsg== kkiJa3G/4lI279fNxnBmkGMVsg==
Acknowledgements
All of the algorithms in this document were designed by D. J.
Bernstein. The AEAD construction was designed by Adam Langley. The
author would also like to thank Adam for helpful comments, as well as
Yaron Sheffer for telling me to write the algorithms document.
Thanks also to Martin Willi for pointing out the discrepancy with the
final version of the algorithm document, and to Valery Smyslov and
Tero Kivinen for helpful comments on this document. Thanks to Steve
Doyle and Martin Willi for pointing out mistakes in my examples.
Author's Address Author's Address
Yoav Nir Yoav Nir
Check Point Software Technologies Ltd. Check Point Software Technologies Ltd.
5 Hasolelim st. 5 Hasolelim St.
Tel Aviv 6789735 Tel Aviv 6789735
Israel Israel
Email: ynir.ietf@gmail.com Email: ynir.ietf@gmail.com
 End of changes. 66 change blocks. 
144 lines changed or deleted 174 lines changed or added

This html diff was produced by rfcdiff 1.42. The latest version is available from http://tools.ietf.org/tools/rfcdiff/