Articles & BlogBy 10 min read

Galois/Counter Mode, almost always written GCM, is a way of using a block cipher such as AES so that it does two jobs at once. It hides the data, and it attaches a short seal that lets the receiver detect any change made along the way. If you have loaded a web page today, GCM very likely protected it: the specification for TLS 1.3, the protocol behind HTTPS, makes AES in this mode the one cipher every implementation must support.

Most people will never configure it. It is still worth twenty minutes of your attention, for two reasons. First, GCM is the clearest example of an idea that took the industry years to absorb: secret data that can be silently altered is not secure. Second, GCM has one rule that must never be broken, and understanding that rule explains a whole class of real failures. This guide builds on Block Ciphers and Stream Ciphers: Two Ways to Scramble Data, which explains blocks, counter mode and XOR.

The back of a folded letter from 1855, cream colored paper closed with a dark red wax seal pressed with a crest, with a boxed postmark stamped below itA wax seal did not hide a letter. It showed whether anyone had opened it. GCM's tag does that job for data, and does it far better. Photo by the postal authorities of the Russian Empire, public domain, via Wikimedia Commons.

Why is hiding the data not enough?

Suppose a message is encrypted in plain counter mode. The cipher produces a stream of unpredictable bits, the keystream, and each bit of the message is XORed with it. (XOR compares two bits and writes 1 if they differ.) An eavesdropper sees noise and learns nothing.

Now suppose the attacker does not want to read the message. They want to change it. The US National Institute of Standards and Technology (NIST) describes the weakness this way: counter mode ciphertext is "malleable in the sense that flipping any of its bits will induce the corresponding bits of the plaintext to flip upon decryption."

Here is a worked example. A payment instruction reads PAY $100. Computers store the character 1 as the number 31 in hexadecimal and the character 9 as 39. Those two values differ by a single bit. An attacker who can guess where the amount sits in the message flips that one bit in the ciphertext. They never learn the key and never decrypt anything. At the far end, the message decrypts perfectly to PAY $900.

The receiver has no way to know. Decryption does not fail, because any string of bits decrypts to something. This is the gap that every encryption mode covered in the companion guide leaves open.

What is authenticated encryption?

The fix is to send a second thing with the ciphertext: a short value, computed with the secret key, that depends on every bit of the message. It is called an authentication tag. The receiver recomputes the tag from what arrived and compares. If even one bit was altered, the tags will not match, and the message is rejected.

A cipher that does both jobs in one operation is called authenticated encryption. The full name of the modern kind is authenticated encryption with associated data, or AEAD. The "associated data" part is practical. Some information has to travel in the clear so the network can use it, for example an address or a record number. It cannot be hidden, yet it must not be altered either. An AEAD cipher covers it with the same tag, so the header and the body are sealed together.

Older systems built this from two separate tools and left the programmer to combine them. AEAD modes replaced that step with one operation. TLS 1.3 allows nothing else: its specification says the symmetric ciphers that remain "are all Authenticated Encryption with Associated Data (AEAD) algorithms."

How does GCM work, in plain words?

GCM is the best known AEAD mode. NIST standardized it in November 2007 as SP 800-38D, which names McGrew and Viega as its designers. The name describes its two halves.

The Counter half hides the data. The sender picks a starting value called a nonce, attaches a counter that goes up by one for each block, and encrypts each of those values with AES. The outputs form the keystream, which is XORed with the message. That is ordinary counter mode.

The Galois half makes the tag. A Galois field is a set of values with its own rules for adding and multiplying, set up so that the result of any operation is always another value in the set. GCM treats each 128-bit block as one element of such a field. The fields are named after the French mathematician Évariste Galois, and they suit computers well because the arithmetic maps neatly onto bits.

The tag is built like this.

  1. The sender creates a secret multiplier by encrypting a block of all zeros with the key. NIST calls it the hash subkey.
  2. Starting from zero, the sender takes the first block of the header, adds it in, and multiplies the running total by the secret multiplier. Then the next block, add and multiply, and so on through the header and all of the ciphertext.
  3. A final block holding the two lengths goes through the same step.
  4. The result is masked with one more block of keystream, so it reveals nothing about the multiplier. That is the tag.

A diagram of Galois/Counter Mode in three steps. Step one, counter mode hides the data: a 96 bit nonce plus a counter goes into AES with the key, producing keystream, which is XORed with the plaintext to give the ciphertext. Step two, Galois field math seals it: the header that is sent in the clear and the ciphertext both feed a multiply and add step, block by block, which produces a tag of up to 128 bits. Step three, the receiver checks the tag before decrypting anything. If one bit changed in the header, the ciphertext or the tag, the tags do not match and the whole message is thrown away.The counter half makes the data unreadable. The Galois half makes it unalterable.

Because every block is multiplied through, changing any bit anywhere changes the tag in a way an attacker cannot predict without the multiplier. And the design is fast. The counter blocks can be computed in parallel, and the field multiplication is cheap. Hiding and sealing happen in a single pass over the data.

The receiver runs the tag calculation first. Only if the tags match does it decrypt. If they do not, it returns an error and nothing else, not even a partial message.

What is a nonce, and why must it never repeat?

Nonce is short for "number used once." GCM needs a fresh one for every message encrypted under a given key. It is not secret and is usually sent along with the ciphertext. NIST recommends a length of 96 bits.

The one unbreakable rule of GCM is in the name: once. NIST's document is blunt about it. It calls the uniqueness of the nonce almost as important as keeping the key secret.

Watch out

If the same key and nonce are ever used for two different messages, two things go wrong at once. The keystream repeats, so an attacker can XOR the two ciphertexts and cancel it out. Worse, the repeated values give away enough about the secret multiplier that an attacker can start forging valid tags. One repeat can undo both halves of the protection.

How do systems avoid a repeat? There are two approaches.

Count. Keep a counter and use the next number each time. TLS 1.3 does this. Each side numbers its records with a 64-bit sequence number starting at zero, and the nonce is built from that number, so no two records under the same key can collide. Counting is the safer method wherever a device can reliably remember where it left off.

Pick at random. Generate 96 random bits per message. This is simple, and it puts a ceiling on how many messages one key may protect, because random numbers eventually collide. NIST's limit is that the chance of a repeat must stay below 1 in 2 to the 32nd power, and to hold that line a key used with random nonces may encrypt at most 2 to the 32nd messages. That is 4,294,967,296.

It sounds like plenty. For example, a server that encrypts 10,000 messages a second under one key reaches the limit in just under five days. A family's home devices will never come close. A company running a large service has to plan for it by changing keys on a schedule.

Where neither approach can be trusted, for example when many machines share a key and cannot coordinate, there is a cousin of GCM designed to fail gently. AES-GCM-SIV, described in RFC 8452 from April 2019, is "nonce misuse resistant," which the document explains as not failing "catastrophically if a nonce is repeated."

How long is the tag, and does it matter?

The tag is the seal, and its length sets the odds that a forger gets lucky. NIST's 2007 document allows five lengths: 128, 120, 112, 104 or 96 bits. It also permits 64 and 32 bits "for certain applications," with extra restrictions.

With a full 128-bit tag, a blind guess is right about one time in 2 to the 128th power, a number with 39 digits. Shorter tags save a few bytes per message and cost security faster than you might expect, because in GCM an attacker's odds also improve with the length of the message. NIST's own text concedes that GCM "is not well-suited for use with short tag lengths or very long messages."

SettingValue in GCMWhy it matters
Nonce length96 bits recommendedThe simplest and best studied case
Tag length128 bits is the usual choiceShorter tags are easier to forge
Longest single messageJust under 64 gigabytesThe counter would run out beyond that
Messages per key, random noncesAt most 2 to the 32ndKeeps the chance of a repeat tiny

As a rule of thumb, use the full 128-bit tag unless a standard you are following says otherwise. The sixteen bytes are cheap.

Where is GCM used?

GCM spread because it is fast and does both jobs in one pass. The internet's engineers wrote it into one protocol after another.

  • IPsec, used by many VPNs, in RFC 4106 from June 2005.
  • TLS 1.2, in RFC 5288 from August 2008.
  • SSH, the standard tool for logging in to remote machines, in RFC 5647 from August 2009.
  • TLS 1.3, where AES-128 in GCM is the mandatory cipher and AES-256 in GCM is recommended.

It is not the only AEAD in use. ChaCha20-Poly1305 does the same two jobs with different internals and is preferred on devices without AES hardware. And GCM is not the usual choice for encrypting drives, in part because a tag and a nonce for every sector would take space a drive does not have. Modern Encryption: A Map of What Protects You Today shows where each one sits.

What does this mean for you? For a family, GCM is working whenever the browser shows a padlock, and there is nothing to set. Keeping browsers and devices updated is the whole job. For a company that writes software, the lessons are specific. Use the AEAD function your cryptography library provides, and do not assemble one from parts. Let the library or the protocol manage nonces, or use a counter that survives a restart. Never ignore a failed tag check or pass along data that failed it. And rotate keys before the message limits come into view.

What is NIST changing?

The standard is nearly twenty years old, and NIST has it under review. The steps so far, all from NIST's own notices:

  • August 2021: NIST's review board opened SP 800-38D for public comment.
  • March 5, 2024: NIST announced its decision to revise it. The planned changes include removing support for tags shorter than 96 bits, formally approving the nonce construction TLS 1.3 uses, and clarifying the nonce guidance.
  • January 6, 2025: A first call for comments ahead of a draft.
  • June 1, 2026: A second call, open through July 31, 2026. It asks whether all the remaining tag sizes are still needed. It also proposes a wider variant, called wGCM in the notice, built on a version of the cipher with 256-bit blocks, which would allow longer nonces and far more messages per key.

As of November 12, 2026, no draft of the revised document has been published. NIST's notice says so directly. Nothing in the review suggests that GCM as deployed today is broken. The direction is to trim the risky options and raise the limits.

What to remember

  • GCM encrypts and seals in one pass. The counter half hides the data, and the Galois half produces a tag that exposes any change.
  • Encryption without a tamper check lets an attacker alter a message without reading it.
  • The tag also covers data sent in the clear, such as headers.
  • A nonce must never repeat under the same key. One repeat can expose messages and allow forgeries.
  • With random 96-bit nonces, one key should protect no more than about 4.3 billion messages.
  • Use 128-bit tags. NIST plans to remove the options below 96 bits.

If the pieces feeding into GCM are still hazy, Symmetric and Asymmetric Encryption: One Key or Two explains where the shared key comes from in the first place. And for what could one day threaten that key agreement while leaving GCM itself standing, read Quantum Computing and the Risk to Encryption.