RFC 4106
The Use of Galois/Counter Mode (GCM) in IPsec Encapsulating Security Payload (ESP)
The Use of Galois/Counter Mode (GCM) in IPsec Encapsulating Security Payload (ESP) ๐
Okay bestie, here's the deal ๐. This is RFC 4106, a Standards Track doc dated June 2005 ๐ฆ. It was written by J. Viega (Secure Software, Inc.) and D. McGrew (Cisco Systems, Inc.) for the Network Working Group. The title block doesn't list anything it obsoletes or updates, so no drama there โจ.
Status of This Memo ๐
This is an Internet standards track protocol for the Internet community, and the authors are asking for discussion and suggestions for improvements ๐ . To check where it stands in standardization, look at the current edition of "Internet Official Protocol Standards" (STD 1). Distribution of this memo is unlimited ๐.
Copyright Notice ยฉ๏ธ
Copyright (C) The Internet Society (2005).
Abstract ๐ฆ
This memo is about using the Advanced Encryption Standard (AES) in Galois/Counter Mode (GCM) as an IPsec Encapsulating Security Payload (ESP) mechanism. The goal is confidentiality and data origin authentication, and it's giving efficiency ๐ฅ. It can be implemented efficiently in hardware for speeds of 10 gigabits per second and above, and it's also a great fit for software implementations ๐.
Table of Contents ๐๏ธ
1. Introduction ....................................................2
1.1. Conventions Used in This Document ..........................2
2. AES-GCM .........................................................3
3. ESP Payload Data ................................................3
3.1. Initialization Vector (IV) .................................3
3.2. Ciphertext .................................................4
4. Nonce Format ....................................................4
5. AAD Construction ................................................5
6. Integrity Check Value (ICV) .....................................5
7. Packet Expansion ................................................6
8. IKE Conventions .................................................6
8.1. Keying Material and Salt Values ............................6
8.2. Phase 1 Identifier .........................................6
8.3. Phase 2 Identifier .........................................7
8.4. Key Length Attribute .......................................7
9. Test Vectors ....................................................7
10. Security Considerations ........................................7
11. Design Rationale ...............................................8
12. IANA Considerations ............................................8
13. Acknowledgements ...............................................9
14. Normative References ...........................................9
15. Informative References .........................................9
1. Introduction โจ
Okay so this doc is all about using AES in GCM mode (AES-GCM) as an IPsec ESP mechanism for confidentiality and data origin authentication. We're calling this method AES-GCM-ESP ๐ . It's efficient and secure, and it's built for high-speed hardware too. That means AES-GCM-ESP lets IPsec connections really make use of emerging 10-gigabit and 40-gigabit network devices ๐.
Counter mode (CTR) has basically become the fave encryption method for high-speed implementations ๐. Compared to conventional modes like Cipher Block Chaining (CBC) and Cipher Block Chaining Message Authentication Code (CBC-MAC), CTR can run efficiently at high data rates because it can be pipelined ๐ง. The ESP CTR protocol explains how to use this mode with IPsec ESP [RFC3686].
Here's the tea ๐ซ. CTR gives you no data origin authentication ๐ญ, so the ESP CTR standard needs a data origin authentication algorithm alongside it. That's a problem, because none of the standard data origin authentication algorithms can be implemented efficiently at high data rates. GCM fixes this, because under the hood it combines CTR mode with a secure, parallelizable, and efficient authentication mechanism ๐.
This document doesn't dig into the implementation details of GCM. Those live in [GCM], along with test vectors ๐ธ.
1.1. Conventions Used in This Document ๐
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 [RFC2119].
2. AES-GCM ๐
GCM is a block cipher mode of operation that provides both confidentiality and data origin authentication ๐. The GCM authenticated encryption operation takes four inputs: a secret key, an initialization vector (IV), a plaintext, and an input for additional authenticated data (AAD). It gives back two outputs: a ciphertext whose length matches the plaintext, and an authentication tag. Below, we walk through how the IV, plaintext, and AAD get formed from the ESP fields, and how the ESP packet is built from the ciphertext and authentication tag โจ.
ESP also defines an IV, but to keep things clear we call the AES-GCM IV a nonce in the context of AES-GCM-ESP ๐ง . The same nonce and key combination MUST NOT be used more than once.
Reusing a nonce/key combination wrecks the security guarantees of AES-GCM mode ๐, so it can be tricky to use this mode safely with statically configured keys. For safety's sake, implementations MUST use an automated key management system, such as the Internet Key Exchange (IKE) [RFC2409], to make sure this requirement is met ๐ซถ.
3. ESP Payload Data ๐
The ESP Payload Data is made up of an eight-octet initialization vector (IV), followed by the ciphertext. The payload field, as defined in [RFC2406], is laid out as shown in Figure 1, along with the ICV associated with the payload ๐.
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Initialization Vector |
| (8 octets) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
~ Ciphertext (variable) ~
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 1: ESP Payload Encrypted with AES-GCM.
3.1. Initialization Vector (IV) ๐ฒ
The AES-GCM-ESP IV field MUST be eight octets. For a given key, the IV MUST NOT repeat. The most natural way to do this is with a counter, but anything that guarantees uniqueness works too, such as a linear feedback shift register (LFSR) ๐. Note that the encrypter can use any IV generation method that meets the uniqueness requirement, and it doesn't need to coordinate with the decrypter ๐.
3.2. Ciphertext ๐
The plaintext input to AES-GCM is formed by concatenating the plaintext data described by the Next Header field with the Padding, the Pad Length, and the Next Header field. The Ciphertext field holds the ciphertext output from the AES-GCM algorithm. The length of the ciphertext is identical to that of the plaintext ๐ท.
Implementations that don't try to hide the length of the plaintext SHOULD use the minimum amount of padding required, which will be less than four octets ๐ช.
4. Nonce Format ๐งฉ
The nonce passed to the GCM-AES encryption algorithm has the following layout ๐ :
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Salt |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Initialization Vector |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 2: Nonce Format
The components of the nonce are as follows ๐:
- Salt: The salt is a four-octet value that gets assigned at the beginning of the security association, and then stays constant for the life of that security association ๐ง. The salt SHOULD be unpredictable (i.e., chosen at random) before it is selected, but it doesn't need to be secret. We describe how to set the salt for a Security Association established via the Internet Key Exchange in Section 8.1.
- Initialization Vector: The IV field is described in Section 3.1.
5. AAD Construction ๐ก๏ธ
The authentication of data integrity and data origin for the SPI and (Extended) Sequence Number fields is provided without encryption โจ. This is done by including those fields in the AES-GCM Additional Authenticated Data (AAD) field. Two formats of the AAD are defined: one for 32-bit sequence numbers, and one for 64-bit extended sequence numbers. The format with 32-bit sequence numbers is shown in Figure 3, and the format with 64-bit extended sequence numbers is shown in Figure 4 ๐ฆ.
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| SPI |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 32-bit Sequence Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 3: AAD Format with 32-bit Sequence Number
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| SPI |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 64-bit Extended Sequence Number |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 4: AAD Format with 64-bit Extended Sequence Number
6. Integrity Check Value (ICV) ๐
The ICV consists solely of the AES-GCM Authentication Tag ๐ท๏ธ. Implementations MUST support a full-length 16-octet ICV, and MAY support 8 or 12 octet ICVs, and MUST NOT support other ICV lengths. Although ESP doesn't require an ICV to be present, AES-GCM-ESP intentionally doesn't allow a zero-length ICV ๐ โโ๏ธ. That's because GCM provides no integrity protection whatsoever when used with a zero-length Authentication Tag ๐ฑ.
Zero-length ICVs are a no-go here. Without a tag, GCM gives you no integrity protection at all.
7. Packet Expansion ๐ฆ
The IV adds an additional eight octets to the packet, and the ICV adds an additional 8, 12, or 16 octets ๐. These are the only sources of packet expansion, other than the 10-13 octets taken up by the ESP SPI, Sequence Number, Padding, Pad Length, and Next Header fields (if the minimal amount of padding is used) ๐งฎ.
8. IKE Conventions ๐ค
This section describes the conventions used to generate keying material and salt values for use with AES-GCM-ESP, using the Internet Key Exchange (IKE) [RFC2409] protocol ๐. It also defines the identifiers and attributes needed to negotiate a security association using AES-GCM-ESP โจ.
8.1. Keying Material and Salt Values โจ
okay so IKE needs a pseudo-random function (PRF) to make keying material ๐ and it just keeps calling that PRF over and over until it has enough, called KEYMAT ๐ซถ the KEYMAT is pulled out of the output string without caring about where the boundaries are, which is very on-brand for it ๐
the KEYMAT for AES-GCM-ESP MUST be four octets longer than the AES key needs ๐ here's how it gets split up:
AES-GCM-ESP with a 128 bit key the KEYMAT requested for each AES-GCM key is 20 octets ๐ the first 16 octets are the 128-bit AES key, and the last four are the salt value used in the nonce โจ
AES-GCM-ESP with a 192 bit key the KEYMAT requested for each AES-GCM key is 28 octets ๐ธ the first 24 octets are the 192-bit AES key, and the last four are the salt value in the nonce ๐ฆ
AES-GCM-ESP with a 256 bit key the KEYMAT requested for each AES GCM key is 36 octets ๐ the first 32 octets are the 256-bit AES key, and the last four are the salt value in the nonce ๐
8.2. Phase 1 Identifier ๐ง
ok real talk, this doc does NOT spell out how to use AES-GCM for IKE Phase 1 ๐ if you want AES-GCM there, you'd need a separate spec and a new Encryption Algorithm Identifier to be assigned ๐ in the meantime, implementations SHOULD use a Phase 1 cipher that's at least as strong as AES-GCM ๐ช and using AES CBC [RFC3602] with the same key size AES-GCM-ESP uses is RECOMMENDED ๐
8.3. Phase 2 Identifier ๐
for IKE Phase 2 negotiations, IANA gave out three ESP Transform Identifiers for AES-GCM with an eight-byte explicit IV ๐ซถ
18 for AES-GCM with an 8 octet ICV;
19 for AES-GCM with a 12 octet ICV; and
20 for AES-GCM with a 16 octet ICV.
8.4. Key Length Attribute ๐
since AES has three key lengths, the Key Length attribute MUST be specified in the IKE Phase 2 exchange [RFC2407] ๐ญ and it MUST have a value of 128, 192, or 256 โจ
9. Test Vectors ๐งช
Appendix B of [GCM] has test vectors that will help implementers get AES-GCM mode working ๐ซถ๐ฅ
10. Security Considerations ๐
this section is SERIOUS bestie, read it all ๐ญ๐จ
GCM is provably secure against adversaries that can adaptively choose plaintexts, ciphertexts, ICVs, and the AAD field ๐ก๏ธ this holds under standard cryptographic assumptions (roughly, that the output of the underlying cipher, under a randomly chosen key, is indistinguishable from a randomly selected output) ๐ง basically, if you use GCM within its intended parameters, breaking GCM would mean breaking the underlying block cipher ๐ the proof of security is in [GCM] if you want to nerd out ๐ค
the most important security consideration is that the IV never repeats for a given key ๐จ part of how that's handled is by NOT allowing AES-GCM with statically configured keys, which is covered in Section 2 ๐ โโ๏ธ
when IKE is used to establish fresh keys between two peer entities, separate keys get established for the two traffic flows ๐ฆ but if a different mechanism is used to establish fresh keys (one that only establishes a single key to encrypt packets), then there's a high probability the peers will pick the same IV values for some packets ๐ฑ so to avoid counter block collisions, ESP implementations that let the same key be used for encrypting and decrypting packets with the same peer MUST make sure the two peers assign different salt values to the security association (SA) ๐
another thing: like with any encryption mode, the security of all data protected under a given security association goes down a tiny bit with each message ๐
to protect against this, implementations MUST generate a fresh key before encrypting 2^64 blocks of data with a given key ๐ and it's worth noting that it's impossible to hit this limit when using 32-bit Sequence Numbers ๐
also, for each message, GCM calls the block cipher once for each full 16-octet block in the payload, once for any remaining octets in the payload, and one more time for computing the ICV ๐งฎ
last one: smaller ICV values are more likely to be subject to forgery attacks ๐ฉ so implementations SHOULD use as large a size as reasonable ๐ช
11. Design Rationale ๐
this spec was designed to be as similar as reasonable to the AES-CCM ESP [CCM-ESP] and AES-CTR ESP [RFC3686] mechanisms ๐ฏโโ๏ธ while still promoting simple, efficient implementations in both hardware and software โก the design and implementation experience from those standards got reused, which is iconic of them ๐
the major difference with CCM is that the CCM ESP mechanism requires an 11-octet nonce, whereas the GCM ESP mechanism requires using a 12-octet nonce ๐ง GCM is specially optimized for the 12-octet nonce case, so it's fast ๐๏ธ nonces of other lengths would add unnecessary complexity and delays, especially in hardware ๐ค the extra octet of nonce is used to make the salt bigger ๐ง
12. IANA Considerations ๐
IANA has assigned three ESP Transform Identifiers for AES-GCM with an eight-byte explicit IV ๐ฆ
18 for AES-GCM with an 8 octet ICV;
19 for AES-GCM with a 12 octet ICV; and
20 for AES-GCM with a 16 octet ICV.
13. Acknowledgements ๐ซถ
this work is closely modeled after Russ Housley's AES-CCM transform [CCM-ESP] ๐ portions of this document are directly copied from that work in progress, and the authors thank Russ for his support ๐ฅน
also, the GCM mode of operation was originally conceived as an improvement to Carter-Wegman Counter (CWC) mode [CWC] ๐ง CWC was the first unencumbered block cipher mode able to support high-speed authenticated encryption ๐
14. Normative References ๐
- [GCM] McGrew, D. and J. Viega, "The Galois/Counter Mode of Operation (GCM)", Submission to NIST. http://csrc.nist.gov/CryptoToolkit/modes/proposedmodes/gcm/gcm-spec.pdf, January 2004.
- [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997.
- [RFC2406] Kent, S. and R. Atkinson, "IP Encapsulating Security Payload (ESP)", RFC 2406, November 1998.
- [RFC2407] Piper, D., "The Internet IP Security Domain of Interpretation for ISAKMP", RFC 2407, November 1998.
- [RFC3602] Frankel, S., Glenn, R. and S. Kelly, "The AES-CBC Cipher Algorithm and Its Use with IPsec", RFC 3602, September 2003.
15. Informative References ๐ธ
- [CCM-ESP] Housley, R., "Using AES CCM Mode With IPsec ESP", Work In Progress.
- [CWC] Kohno, T., Viega, J. and D. Whiting, "CWC: A high-performance conventional authenticated encryption mode", Fast Software Encryption. http://eprint.iacr.org/2003/106.pdf, February 2004.
- [RFC2409] Harkins, D. and D. Carrel, "The Internet Key Exchange (IKE)", RFC 2409, November 1998.
- [RFC3686] Housley, R., "Using Advanced Encryption Standard (AES) Counter Mode With IPsec Encapsulating Security Payload (ESP)", RFC 3686, January 2004.
Authors' Addresses ๐
John Viega
Secure Software, Inc.
4100 Lafayette Center Dr., Suite 100
Chantilly, VA 20151
US
Phone: (703) 814 4402
EMail: viega@securesoftware.com
David A. McGrew
Cisco Systems, Inc.
510 McCarthy Blvd.
Milpitas, CA 95035
US
Phone: (408) 525 8651
EMail: mcgrew@cisco.com
URI: http://www.mindspring.com/~dmcgrew/dam.htm
Full Copyright Statement โ๏ธ
Copyright (C) The Internet Society (2005).
This document is subject to the rights, licenses and restrictions contained in BCP 78, and except as set forth therein, the authors retain all their rights.
This document and the information contained herein are provided on an "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
Intellectual Property ๐งพ
The IETF takes no position regarding the validity or scope of any Intellectual Property Rights or other rights that might be claimed to pertain to the implementation or use of the technology described in this document or the extent to which any license under such rights might or might not be available; nor does it represent that it has made any independent effort to identify any such rights. Information on the procedures with respect to rights in RFC documents can be found in BCP 78 and BCP 79.
Copies of IPR disclosures made to the IETF Secretariat and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementers or users of this specification can be obtained from the IETF on-line IPR repository at http://www.ietf.org/ipr.
The IETF invites any interested party to bring to its attention any copyrights, patents or patent applications, or other proprietary rights that may cover technology that may be required to implement this standard. Please address the information to the IETF at ietf-ipr@ietf.org.
Acknowledgement ๐
Funding for the RFC Editor function is currently provided by the Internet Society. ๐ซถโจ
๐ฆ where this page comes from
- ietf: rfc4106 2005-06
- ๐ girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms