Logo
Back to Blog
Security August 15, 2026 7 min read

AES-GCM vs AES-CBC: Why the Mode Matters More Than the Key Size

O

OmniWebKit Team

Security Tooling

Share:
Article Cover Image

Two AES tools produce output that looks identical, and one of them will let an attacker silently change your message. The difference is not the key size everyone argues about. It is the mode, and it decides whether tampering gets noticed at all.

Here is the short version. Use GCM for anything new. CBC hides your data and does nothing to prove it arrived unchanged, and that gap has broken real systems for twenty years.

What is an authentication tag, and why does it change everything?

An authentication tag is a short checksum that only someone with the key could have produced. GCM generates one over the whole message and stores it alongside the ciphertext, sixteen bytes on the end.

When you decrypt, that tag is checked first. If a single bit anywhere has changed, the check fails and you get nothing back. Not a partial message, not garbage — nothing.

CBC has no equivalent. It will happily decrypt something an attacker modified and hand you the result, and depending on what changed, the result may look almost right. That is the part people underestimate: silent corruption is more dangerous than a loud failure.

The trade is that you cannot tell a wrong key from a modified message, because both fail the same check. Our decrypt a string and see tool is built around that limit rather than pretending it away.

Which AES mode to use, and when the answer is not GCM

Pick GCM unless something stops you. That covers new applications, browser tools, APIs, and anything where you control both ends.

Three situations genuinely force CBC. A file format that specifies it. An existing system whose stored data you cannot re-encrypt. A hardware device with no GCM support, which still exists in industrial and payment equipment.

In those cases, add authentication separately and apply it to the ciphertext rather than the plaintext. Getting that order wrong reintroduces the exact problem you were avoiding, which is a large part of why the industry stopped assembling this by hand.

One more caveat we would rather state than bury. GCM is unforgiving about its starting value: reuse one with the same key and the damage is far worse than the equivalent mistake in CBC. Every tool should generate a fresh random one per message, and ours does.

Is AES-256 better than AES-128 in any way that matters?

Barely, and not in the way the marketing implies. Both are out of reach of brute force by an enormous margin, and no realistic increase in computing power changes that.

AES-128 arguably has the cleaner internal structure of the two, which surprises people. AES-256 uses more rounds and a more complex key schedule, and that schedule has attracted more theoretical criticism than anything in the 128-bit version.

We use 256 anyway. It costs almost nothing on modern hardware, it satisfies procurement checklists, and it removes an argument we would rather not have. What it does not do is make up for a short password, which is the actual weak point in every tool of this kind.

If a page leads with the key size and says nothing about the mode or the key derivation, that tells you something about how carefully the rest was built. We go through the other signals worth checking in how much any of this protects you.

Padding: the quiet reason CBC keeps failing

CBC works on fixed sixteen-byte blocks, so anything not a multiple of sixteen has to be padded out. That padding has to be removed on the way back, and the removal step is where the trouble lives.

If a system reveals whether the padding was valid — through an error message, a status code, or just by responding faster — an attacker can use that single bit of information repeatedly. Thousands of guesses later they have your plaintext without ever knowing the key.

This is not a museum piece. Padding oracle attacks have broken TLS implementations, framework session cookies and enterprise software within the last decade, repeatedly, in systems built by people who knew what they were doing.

GCM has no padding. It encrypts a stream of any length directly, so the entire class of attack has nowhere to live. That, more than raw speed, is the argument.

Speed, and why the benchmark you read is probably irrelevant

GCM is usually faster on modern processors, because both the encryption and the authentication run on dedicated instructions and can work in parallel.

For the work most people do, none of it matters. We measured the actual AES step on a 2.6 MB file in a browser: three milliseconds. The key derivation in front of it took sixty-seven, more than twenty times longer, and that step is deliberately slow.

So the honest ranking is: your password first, the key stretching second, the cipher mode third, and the key size a distant fourth. Almost every article on this topic gets that order backwards.

What this means for the tools on this site

Our text and file encryption both use AES-256-GCM through the browser's own Web Crypto, with the key stretched from your password by PBKDF2. Nothing here is a custom construction, which is deliberate — bespoke cryptography is where things break.

The tag is why encrypt text in your browser can promise that a modified message will be rejected rather than quietly mangled. It is also why file decryption reports a truncated download as truncated, instead of blaming your password.

Worth separating from all of this: hashing is not encryption and has no key. If you want a fingerprint of a file rather than a locked copy, generate a SHA-256 hash does that job and nothing else.

The choice in one line

Use GCM, generate a fresh nonce every time, and spend your remaining attention on the password instead of the key size.

Modes are the part of cryptography where careful people still make mistakes, which is why using a mode that removes whole categories of mistake is worth more than any number of extra bits. And once the message is encrypted, the hard problem is getting the key to the other end — a question no cipher mode can help with.

Frequently Asked Questions

If GCM is better, why is CBC still everywhere?

+
Age and inertia. CBC arrived decades earlier, so it is baked into file formats, payment systems and libraries that cannot change without breaking everything built on them. New designs should use GCM; existing systems often cannot switch without a migration nobody has funded.

Does the authentication tag make the ciphertext bigger?

+
Yes, by sixteen bytes. On a paragraph that is invisible, and on millions of tiny records it adds up. We have never seen a case where the size mattered more than knowing the data was untouched.

What actually happens if a GCM starting value is reused?

+
It is much worse than reusing one in CBC, which is the trap people fall into. Reusing a nonce with the same key can leak the relationship between two messages and, in some cases, expose the key used for authentication itself. That is why every run here generates a fresh random one.

Can I tell from the ciphertext which mode was used?

+
Not from the bytes alone, because both look like noise. You can often tell from the length: CBC output is always a multiple of sixteen bytes, while GCM output is the plaintext length plus the tag. That is a hint, not proof.

Is AES-256 twice as strong as AES-128?

+
No, and the difference is not the interesting one. Both are far beyond brute force with current or foreseeable hardware, and AES-128 actually has a slightly cleaner structure. We use 256 because it costs almost nothing and removes an argument, not because 128 is broken.

What is a padding oracle, in plain terms?

+
It is an attack where the system reveals whether the padding on a CBC message was valid, and an attacker uses thousands of those yes-or-no answers to work out the plaintext without the key. It has broken real systems repeatedly. GCM has no padding, so the whole category disappears.

Why does GCM refuse to give me partial data when decryption fails?

+
Because releasing unverified plaintext is exactly how those oracle attacks work. The tag is checked before anything is returned, so a failure gives you nothing to analyse. It feels unhelpful in the moment and it is the correct behaviour.

Is ChaCha20-Poly1305 better than AES-GCM?

+
It is comparable and it wins in one specific situation: devices with no hardware AES support, where it runs considerably faster. Every browser we care about has AES acceleration, so we use what the platform does best.

Does the mode affect how strong my password needs to be?

+
Not at all, and this is where people misplace their effort. The mode decides whether tampering is caught; the password decides whether anyone gets in at all. A weak password with GCM is still a weak password.

Can I mix modes, encrypting with one and checking with another?

+
You can bolt a separate authentication step onto CBC, and it is called encrypt-then-MAC. Done correctly it is sound, and it is done incorrectly often enough that the industry moved to modes with it built in. Fewer moving parts, fewer ways to get it wrong.

Tags

#Encryption#AES#Cryptography#Web Crypto