Article · Wikipedia archive · Last revised May 27, 2026

Galois/Counter Mode

In cryptography, Galois/Counter Mode (GCM) is a mode of operation for symmetric-key cryptographic block ciphers. The proposal was first published in 2007. The GCM algorithm belongs to the class of authenticated encryption with associated data (AEAD) methods. Given a key , plaintext , and associated data , GCM encrypts to produce ciphertext and an authentication tag . is computed from the ciphertext and the unencrypted associated data. A recipient who knows can use the tag to verify that neither the ciphertext nor the associated data had been modified, and then decrypt the ciphertext to recover the plaintext.

Last revised
May 27, 2026
Read time
≈ 13 min
Length
2,971 w
Citations
51
Source

In cryptography, Galois/Counter Mode (GCM)1 is a mode of operation for symmetric-key cryptographic block ciphers that provides both encryption and message authentication in a single pass. It belongs to the class of authenticated encryption with associated data (AEAD) algorithms. In practice, GCM gives a recipient two guarantees at once: the message content was hidden from anyone without the key, and the data arrived exactly as sent. Encrypted web connections, Wi-Fi security, and virtual private networks rely on this property through protocols such as TLS and WPA3. GCM was designed by David A. McGrew and John Viega, first published in 2005,2 and standardized by NIST in Special Publication 800-38D in November 2007.3 Galois Message Authentication Code (GMAC) is an authentication-only variant that can form an incremental message authentication code.

GCM uses a 128-bit block cipher (commonly AES) run in counter mode for encryption, and uses arithmetic in the Galois field GF(2128) to compute the authentication tag, hence its name. Because successive ciphertext blocks are produced independently, encryption and decryption can be fully parallelized, in contrast to chaining modes such as cipher block chaining (CBC). GCM was designed to be patent-free.4

GCM is widely deployed in network security protocols. It is used in TLS 1.21 and TLS 1.3,5 IEEE 802.1AE (MACsec) Ethernet security, IPsec,6 SSH,7 and other protocols. AES-GCM is included in the NSA's Commercial National Security Algorithm Suite.

Security depends on choosing a unique initialization vector (IV) for every encryption under the same key; reuse of an initialization vector can expose the encryption key and allow forgery. For any given key and initialization vector, GCM is limited to encrypting 239−256 bits of plaintext. The authentication strength of the mode decreases with shorter tag lengths; NIST SP 800-38D recommends tag lengths of at least 96 bits.

Basic operation

GCM operates as a counter mode block cipher to produce ciphertext.2

For authentication, the ciphertext blocks are treated as coefficients of a polynomial evaluated at a key-dependent point H using finite field arithmetic. The result is then encrypted to produce an authentication tag that can be used to verify the integrity of both the ciphertext and the associated data.2

Block diagram of GCM authenticated encryption: a series of incrementing counters is encrypted by a block cipher (top path) and XOR'd with plaintext to produce ciphertext, while the ciphertext blocks and additional authenticated data are multiplied together in GF(2 to the 128) using a key-derived hash subkey H (bottom path) to produce an authentication tag
GCM operation. For simplicity, a case with only a single block of added authenticated data (labeled Auth Data 1) and two blocks of plaintext is shown.
Encryption: A series of 128-bit counters is encrypted using the block cipher E with key K; this can occur in parallel. The results are combined using bitwise XOR with 128-bit plaintext blocks, producing a series of ciphertext blocks.
Authentication: The additional data and these ciphertext blocks are combined using multiplication with a key-dependent constant H in the Galois field GF(2128) to produce the authentication tag. source ↗

Mathematical basis

GCM combines the counter mode of encryption with the Galois mode of authentication. The GF(2128) field used is defined by the polynomial2

x 128 + x 7 + x 2 + x + 1 {\displaystyle x^{128}+x^{7}+x^{2}+x+1} .

Because the GF(2128) multiplications used for authentication can be computed independently, the GHASH function admits parallel implementation, in contrast to chaining modes such as CBC.2

The authentication tag is constructed by feeding blocks of data into the GHASH function and encrypting the result. This GHASH function is defined by

GHASH ( H , A , C ) = X m + n + 1 {\displaystyle \operatorname {GHASH} (H,A,C)=X_{m+n+1}} ,

where H = E k ( 0 128 ) {\displaystyle H=E_{k}(0^{128})} is the hash key, a string of 128 zero bits encrypted using the block cipher; A {\displaystyle A} is data that is only authenticated (not encrypted); C {\displaystyle C} is the ciphertext; m {\displaystyle m} is the number of 128-bit blocks in A {\displaystyle A} (rounded up); n {\displaystyle n} is the number of 128-bit blocks in C {\displaystyle C} (rounded up); and the variable X i {\displaystyle X_{i}} for i = 0 , , m + n + 1 {\displaystyle i=0,\dots ,m+n+1} is defined below.2

First, the authenticated text and the ciphertext are separately zero-padded to multiples of 128 bits and combined into a single message, S i {\displaystyle S_{i}} , defined as

S i = { A i for  i = 1 , , m 1 A m 0 128 v for  i = m C i m for  i = m + 1 , , m + n 1 C n 0 128 u for  i = m + n len ( A ) len ( C ) for  i = m + n + 1 {\displaystyle S_{i}={\begin{cases}A_{i}&{\text{for }}i=1,\ldots ,m-1\\A_{m}^{*}\parallel 0^{128-v}&{\text{for }}i=m\\C_{i-m}&{\text{for }}i=m+1,\ldots ,m+n-1\\C_{n}^{*}\parallel 0^{128-u}&{\text{for }}i=m+n\\\operatorname {len} (A)\parallel \operatorname {len} (C)&{\text{for }}i=m+n+1\end{cases}}} ,

where len ( A ) {\displaystyle \operatorname {len} (A)} and len ( C ) {\displaystyle \operatorname {len} (C)} are the 64-bit representations of the bit lengths of A {\displaystyle A} and C {\displaystyle C} , respectively; v = len ( A ) mod 1 28 {\displaystyle v=\operatorname {len} (A){\bmod {1}}28} is the bit length of the final block of A {\displaystyle A} ; u = len ( C ) mod 1 28 {\displaystyle u=\operatorname {len} (C){\bmod {1}}28} is the bit length of the final block of C {\displaystyle C} ; and {\displaystyle \parallel } denotes concatenation of bit strings.2

Then, X i {\displaystyle X_{i}} is defined as:

X i = j = 1 i S j H i j + 1 = { 0 for  i = 0 ( X i 1 S i ) H for  i = 1 , , m + n + 1 {\displaystyle X_{i}=\sum _{j=1}^{i}S_{j}\cdot H^{i-j+1}={\begin{cases}0&{\text{for }}i=0\\\left(X_{i-1}\oplus S_{i}\right)\cdot H&{\text{for }}i=1,\ldots ,m+n+1\end{cases}}} .2

The second form is an efficient iterative algorithm (each X i {\displaystyle X_{i}} depends on X i 1 {\displaystyle X_{i-1}} ) produced by applying Horner's method to the first. Only the final X m + n + 1 {\displaystyle X_{m+n+1}} is output.2

If it is necessary to parallelize the hash computation, this can be done by interleaving k {\displaystyle k} times:

X i = { 0 for  i 0 ( X i k S i ) H k for  i = 1 , , m + n + 1 k X i = j = 1 k ( X i + j 2 k S i + j k ) H k j + 1 {\displaystyle {\begin{aligned}X'_{i}&={\begin{cases}0&{\text{for }}i\leq 0\\\left(X'_{i-k}\oplus S_{i}\right)\cdot H^{k}&{\text{for }}i=1,\ldots ,m+n+1-k\end{cases}}\\[6pt]X_{i}&=\sum _{j=1}^{k}\left(X'_{i+j-2k}\oplus S_{i+j-k}\right)\cdot H^{k-j+1}\end{aligned}}} .2

If the length of the IV is not 96, the GHASH function is used to calculate Counter 0:

Counter 0 = { I V 0 31 1 for  len ( I V ) = 96 GHASH ( I V 0 s 0 64 len 64 ( I V ) )  with  s = 128 len ( I V ) mod 1 28 otherwise {\displaystyle {\text{Counter 0}}={\begin{cases}IV\parallel 0^{31}\parallel 1&{\text{for }}\operatorname {len} (IV)=96\\\operatorname {GHASH} \!\left(IV\parallel 0^{s}\parallel 0^{64}\parallel \operatorname {len} _{64}(IV)\right){\text{ with }}s=128-\operatorname {len} (IV){\bmod {1}}28&{\text{otherwise}}\end{cases}}} .3

History

GCM was designed by Viega and McGrew as a development based on earlier counter-mode authenticated encryption designs, including Carter–Wegman counter mode (CWC mode).8 McGrew and Viega first published GCM in 2005.2

In November 2007, NIST released Special Publication 800-38D Recommendation for Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC, making GCM and GMAC official standards.3

Deployment

GCM mode is specified for IEEE 802.1AE (MACsec) Ethernet security, WPA3-Enterprise Wi-Fi, IEEE 802.11ad (WiGig), ANSI (INCITS) Fibre Channel Security Protocols (FC-SP), and IEEE P1619.1 tape storage. It is also used in IETF IPsec,69 SSH,7 TLS 1.2,110 and TLS 1.3.5 AES-GCM is included in the NSA Suite B Cryptography and its 2018 successor Commercial National Security Algorithm (CNSA) suite.11

Among VPN implementations, the SoftEther VPN server and client support AES-GCM,12 as does OpenVPN since version 2.4, where AES-GCM cipher suites are available via configuration and cipher negotiation.13

Performance

GCM requires one block cipher operation and one 128-bit multiplication in the Galois field for each block (128 bits) of encrypted and authenticated data. The block cipher operations are pipelined or parallelized; the multiplication operations are pipelined and can be parallelized (either by parallelizing the actual operation, by adapting Horner's method per the original NIST submission, or both).2

Intel has added the PCLMULQDQ instruction, which supports carry-less multiplication used in GCM implementations.14 In 2011, SPARC added the XMULX and XMULXHI instructions, which also perform 64 × 64-bit carry-less multiplication.15 In 2015, SPARC added the XMPMUL instruction, which performs XOR multiplication of much larger values, up to 2048 × 2048-bit input values, producing a 4096-bit result.16 These instructions enable fast multiplication over GF(2n) and can be used with any field representation.

Performance results are published for GCM on a number of platforms. Käsper and Schwabe described a "Faster and Timing-Attack Resistant AES-GCM"17 that achieves 10.68 cycles per byte of AES-GCM authenticated encryption on 64-bit Intel processors. Gueron and Kounavis report 3.54 cycles per byte for the same algorithm when using Intel's AES-NI and PCLMULQDQ instructions on Westmere processors.14 Shay Gueron and Vlad Krasnov achieved 2.47 cycles per byte on third-generation Intel Core processors.18 Appropriate patches were prepared for the OpenSSL and NSS libraries.18

When both authentication and encryption need to be performed on a message, interleaving those operations using instruction-level parallelism can increase performance. This process is called function stitching,19 and while in principle it can be applied to any combination of cryptographic algorithms, GCM supports parallel computation which can simplify optimization on some processors. Manley and Gregg20 show that function stitching can be applied to GCM with good results; they present a program generator that takes an annotated C version of a cryptographic algorithm and generates code that runs well on the target processor.

GCM has been criticized in the embedded world (for example, by Silicon Labs) because parallel processing is not well-suited to cryptographic hardware engines that process one block at a time, reducing throughput on performance-constrained devices.21 Specialized hardware accelerators for ChaCha20-Poly1305 are less complex compared to AES accelerators.22

Security

GCM is proven to be secure in the concrete security model.23 It is secure when it is used with a block cipher that is indistinguishable from a random permutation; however, security depends on choosing a unique initialization vector for every encryption performed with the same key (see stream cipher attack). For any given key and initialization vector value, GCM is limited to encrypting 239−256 bits of plain text (64 GiB). NIST Special Publication 800-38D3 includes guidelines for initialization vector choice and limits the number of possible initialization vector values for a single key. As security assurance degrades with more data processed under the same key, the total number of blocks of plaintext and AD protected during the lifetime of a single key should be limited to 264.3

The authentication strength depends on the length of the authentication tag, as with all symmetric message authentication codes. Using shorter authentication tags with GCM is discouraged. The bit-length of the tag, denoted t, is a security parameter. In general, t may be any one of the following five values: 128, 120, 112, 104, or 96. For certain applications, t may be 64 or 32, but the use of these two tag lengths constrains the length of the input data and the lifetime of the key. Appendix C in NIST SP 800-38D provides guidance for these constraints (for example, if t = 32 and the maximal packet size is 210 bytes, the authentication decryption function should be invoked no more than 211 times; if t = 64 and the maximal packet size is 215 bytes, the authentication decryption function should be invoked no more than 232 times).3

Like any message authentication code, if the adversary chooses a t-bit tag at random, it is expected to be correct for given data with probability 2t. With GCM, however, an adversary can increase their likelihood of success for a message of n blocks by a factor of n, achieving a success probability of approximately n⋅2t. The complement, 1 − n⋅2t, bounds the adversary's failure probability for arbitrarily large t. GCM is not well-suited for use with short tag lengths or long messages.24

Ferguson and Saarinen independently described optimal attacks against GCM authentication that meet the lower bound on its security. Ferguson showed that, if n denotes the total number of blocks in the encoding (the input to the GHASH function), then a targeted ciphertext forgery succeeds with probability approximately n⋅2t. If t is shorter than 128, each successful forgery increases the probability of subsequent forgeries and leaks information about the hash subkey H; eventually H may be fully recovered, at which point authentication assurance is lost entirely.24

Independent of this attack, an adversary may systematically guess many different tags for a given input to authenticated decryption. For this reason, implementations should monitor and, if necessary, limit the number of unsuccessful verification attempts for each key.3

Saarinen described GCM as having weak keys,25 offering analysis into how polynomial hash-based authentication works. More precisely, this work describes a way to forge a GCM message given a valid GCM message, succeeding with probability approximately n⋅2−128 for messages that are n × 128 bits long. This does not improve on prior known attacks; the success probability in observation 1 of this paper matches that of lemma 2 from the INDOCRYPT 2004 analysis (setting w = 128 and l = n × 128).25 Saarinen also described a GCM variant, Sophie Germain Counter Mode (SGCM), based on Sophie Germain primes.

See also

See also

References

References

  1. J. Salowey; A. Choudhury; D. McGrew (August 2008). AES Galois Counter Mode (GCM) Cipher Suites for TLS. Network Working Group. doi:10.17487/RFC5288. RFC 5288. Proposed Standard. Updated by RFC 9325.
  2. McGrew, David A.; Viega, John (2005). "The Galois/Counter Mode of Operation (GCM)" (PDF). p. 5. Retrieved July 20, 2013.
  3. Dworkin, Morris (November 2007). Recommendation for Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC (PDF) (Technical report). National Institute of Standards and Technology. doi:10.6028/NIST.SP.800-38D. 800-38D. Retrieved August 18, 2015.
  4. McGrew, David A.; Viega, John. "The Galois/Counter Mode of Operation (GCM) Intellectual Property Statement" (PDF). Computer Security Resource Center, NIST. Retrieved May 24, 2026.
  5. E. Rescorla (August 2018). The Transport Layer Security (TLS) Protocol Version 1.3. Internet Engineering Task Force TLS workgroup. doi:10.17487/RFC8446. RFC 8446. Proposed Standard. Obsoletes RFC 5077, 5246 and 6961. Updates RFC 5705 and 6066.
  6. J. Viega; D. McGrew (June 2005). The Use of Galois/Counter Mode (GCM) in IPsec Encapsulating Security Payload (ESP). Network Working Group. doi:10.17487/RFC4106. RFC 4106. Proposed Standard.
  7. K. Igoe; J. Solinas (August 2009). AES Galois Counter Mode for the Secure Shell Transport Layer Protocol. IETF Network Working Group. doi:10.17487/RFC5647. RFC 5647. Informational.
  8. Kohno, Tadayoshi; Viega, John; Whiting, Doug (2004). "CWC: A High-Performance Conventional Authenticated Encryption Mode". In Roy, Bimal; Meier, Willi (eds.). Fast Software Encryption. Lecture Notes in Computer Science. Vol. 3017. Berlin, Heidelberg: Springer. pp. 408–426. doi:10.1007/978-3-540-25937-4_26. ISBN 978-3-540-25937-4.
  9. D. McGrew; J. Viega (May 2006). The Use of Galois Message Authentication Code (GMAC) in IPsec ESP and AH. Network Working Group. doi:10.17487/RFC4543. RFC 4543. Proposed Standard.
  10. S. Kanno; M. Kanda (September 2011). Addition of the Camellia Cipher Suites to Transport Layer Security (TLS). Internet Engineering Task Force. doi:10.17487/RFC6367. ISSN 2070-1721. RFC 6367. Informational. Updated by RFC 8996.
  11. "Algorithm Registration – Computer Security Objects Register". CSRC, NIST. May 24, 2016. Retrieved May 24, 2026.
  12. "Why SoftEther VPN – SoftEther VPN Project". Retrieved May 24, 2026.
  13. "Data-Channel Encryption Cipher Negotiation on Access Server". OpenVPN. Retrieved April 13, 2026.
  14. Gueron, Shay; Kounavis, Michael E. (April 2014). "Intel Carry-Less Multiplication Instruction and its Usage for Computing the GCM Mode (Revision 2.02)" (PDF). Retrieved September 1, 2023.
  15. Oracle SPARC Architecture 2011 (PDF). Oracle Corporation. 2011. p. 362. Retrieved May 24, 2026.
  16. Oracle SPARC Architecture 2015 (PDF). Oracle Corporation. 2015. p. 384. Retrieved May 24, 2026.
  17. Käsper, E.; Schwabe, P. (2009). "Faster and Timing-Attack Resistant AES-GCM". In Clavier, C.; Gaj, K. (eds.). Cryptographic Hardware and Embedded Systems - CHES 2009. Lecture Notes in Computer Science. Vol. 5747. Springer. pp. 1–17. doi:10.1007/978-3-642-04138-9_1. ISBN 978-3-642-04138-9.
  18. Gueron, Shay (January 2013). "AES-GCM for Efficient Authenticated Encryption – Ending the Reign of HMAC-SHA-1?" (PDF). Workshop on Real-World Cryptography. Stanford University. Retrieved February 8, 2013.
  19. Gopal, V.; Feghali, W.; Guilford, J.; Ozturk, E.; Wolrich, G.; Dixon, M.; Locktyukhin, M.; Perminov, M. (2010). Fast Cryptographic Computation on Intel Architecture via Function Stitching (PDF) (Technical report). Intel Corporation. Retrieved May 24, 2026.
  20. Manley, Raymond; Gregg, David (2010). "A Program Generator for Intel AES-NI Instructions". In Gong, G.; Gupta, K.C. (eds.). Progress in Cryptology - INDOCRYPT 2010. Lecture Notes in Computer Science. Vol. 6498. Springer. pp. 311–327. doi:10.1007/978-3-642-17401-8_22. ISBN 978-3-642-17400-1.
  21. "IoT Security Part 6: Galois Counter Mode". May 6, 2016. Retrieved October 17, 2023.
  22. Pfau, Johannes; Reuter, Maximilian; Harbaum, Tanja; Hofmann, Klaus; Becker, Jurgen (September 2019). "A Hardware Perspective on the ChaCha Ciphers: Scalable Chacha8/12/20 Implementations Ranging from 476 Slices to Bitrates of 175 Gbit/s". 2019 32nd IEEE International System-on-Chip Conference (SOCC). pp. 294–299. doi:10.1109/SOCC46988.2019.1570548289. ISBN 978-1-7281-3483-3.
  23. McGrew, David A.; Viega, John (2004). "The Security and Performance of the Galois/counter mode (GCM) of Operation". Proceedings of INDOCRYPT 2004. Lecture Notes in Computer Science. Vol. 3348. Springer. CiteSeerX 10.1.1.1.4591. doi:10.1007/978-3-540-30556-9_27. ISBN 978-3-540-30556-9.
  24. Ferguson, Niels (May 20, 2005). "Authentication Weaknesses in GCM" (PDF). Retrieved May 24, 2026.
  25. Saarinen, Markku-Juhani O. (April 20, 2011). "Cycling Attacks on GCM, GHASH and Other Polynomial MACs and Hashes". Cryptology ePrint Archive, Report 2011/202. Retrieved May 24, 2026.
External links