Symmetric Cryptography ยท 2.4

๐ŸŒŠ ChaCha20 and Stream Ciphers

The mobile-friendly alternative to AESโฑ ~2 min

Why ChaCha20 Exists

AES requires hardware acceleration (AES-NI instructions) to be fast. On low-power devices โ€” older phones, embedded systems, IoT devices โ€” AES without hardware support is slow and drains battery. ChaCha20 was designed by Daniel J. Bernstein to be fast in pure software, with no hardware acceleration needed.

PropertyAES-GCMChaCha20-Poly1305
Performance (hardware)Extremely fast with AES-NISlightly slower than AES-NI
Performance (no hardware)Slow โ€” software-only AES is sluggishFast โ€” designed for software
SecurityNo known practical attackNo known practical attack
AuthenticationGCM tag (AEAD)Poly1305 tag (AEAD)
Key size128 or 256 bits256 bits only
Nonce size96 bits (12 bytes)96 bits (12 bytes)
Used inTLS, disk encryption, VPNsTLS 1.3, WireGuard, Signal
๐Ÿ”’ SecurityChaCha20-Poly1305 is a mandatory cipher suite in TLS 1.3. Google uses it as the fallback for HTTPS on Android devices without AES hardware acceleration. The Signal Protocol uses it for end-to-end message encryption.

How ChaCha20 Works

ChaCha20 is a stream cipher based on a 512-bit state โ€” a 4ร—4 matrix of 32-bit words populated with the 256-bit key, a 64-bit counter, a 96-bit nonce, and a constant. The state is scrambled through 20 rounds of 'quarter-round' operations (hence the 20 in the name) and added to the original state to produce a 512-bit keystream block. Each counter value produces a unique keystream block โ€” the counter ensures the keystream never repeats.

๐Ÿ’ก TipChaCha20-Poly1305 is the right choice when: (1) you're on a platform without AES hardware, (2) you want to avoid timing-side-channel attacks from AES table lookups, or (3) you're using WireGuard VPN, which mandates it.
๐Ÿง Quick Checkfirst try = +5 XP

When is ChaCha20 preferred over AES?

โญ 0 XP๐Ÿ”ฅ 0 days