Symmetric encryption

On this page 7

Symmetric encryption is a class of encryption in which the same secret key is used to encrypt and to decrypt data. In cryptography it is the workhorse for protecting data in bulk: disk encryption, database fields, VPN tunnels, TLS connections and encrypted backups all rely on symmetric ciphers such as AES and ChaCha20 for the actual data, because they are fast and compact compared with public-key methods.

Its central challenge is key distribution: both parties must hold the same key, and anyone who obtains it can read and forge the protected data. Practical systems therefore combine symmetric encryption with asymmetric key exchange, key management services and authenticated modes of operation.

How symmetric encryption works

A symmetric cipher is a keyed transformation that turns plaintext into ciphertext and back. Security rests entirely on the secrecy of the key, not of the algorithm, a principle known as Kerckhoffs’s principle: modern ciphers are public, heavily analyzed and standardized.

There are two families. Block ciphers such as AES encrypt fixed-size blocks, 128 bits in the case of AES, and need a mode of operation to process longer messages. Stream ciphers such as ChaCha20 generate a keystream from the key and a nonce and combine it with the data using XOR, which suits software implementations without hardware acceleration.

The table below compares the main algorithms in current and historical use.

AlgorithmTypeKey sizeStatus
AESBlock cipher, 128-bit block128, 192 or 256 bitsGlobal standard, recommended
ChaCha20Stream cipher256 bitsRecommended, fast in software
3DESBlock cipher, 64-bit block112 effective bitsDeprecated, disallowed for new use
DESBlock cipher, 64-bit block56 bitsBroken by brute force
RC4Stream cipher40-2048 bitsBroken, prohibited in TLS
Common symmetric algorithms

Modes of operation and authenticated encryption

A block cipher alone only defines how to encrypt one block. The mode of operation defines how blocks are chained, how the initialization vector or nonce is used, and whether integrity is protected. Choosing the mode is as important as choosing the cipher.

ModeIntegrity protectionMain riskTypical use
ECBNoneIdentical blocks reveal patternsShould not be used for data
CBCNone without a separate MACPadding oracle attacksLegacy protocols and files
CTRNone without a separate MACCatastrophic on nonce reuseBuilding block for GCM
GCMYes, built-in tagNonce reuse leaks the authentication keyTLS, IPsec, cloud storage
ChaCha20-Poly1305Yes, built-in tagNonce reuse breaks confidentialityTLS, WireGuard, mobile
XTSNoneNo tamper detectionFull-disk encryption
Modes of operation compared

Current practice is to use authenticated encryption with associated data, or AEAD, such as AES-GCM or ChaCha20-Poly1305. AEAD modes detect any modification of the ciphertext and reject it, which prevents whole classes of attacks that exploited unauthenticated encryption. A frequent recommendation is never to roll a custom combination of cipher and MAC.

Symmetric versus asymmetric encryption

Symmetric and asymmetric encryption solve complementary problems. Asymmetric encryption, such as RSA or elliptic curve schemes, lets parties who have never met establish trust and agree on keys, but it is slow and limited in message size. Symmetric encryption is orders of magnitude faster and protects the actual data.

PropertySymmetric encryptionAsymmetric encryption
KeysOne shared secret keyPublic and private key pair
SpeedGigabytes per second with hardware supportMuch slower per byte
Key size for about 128-bit security128 bitsAbout 3072-bit RSA or 256-bit ECC
Main useBulk data encryptionKey exchange, signatures
Main problemDistributing the key securelyPerformance, quantum vulnerability
Symmetric and asymmetric encryption compared

Real protocols therefore use hybrid encryption. In TLS 1.3, an elliptic curve Diffie-Hellman key exchange establishes shared secrets, from which session keys are derived for AES-GCM or ChaCha20-Poly1305. End-to-end encryption in messaging follows the same pattern.

Key sizes, performance and quantum resistance

Key length determines resistance to brute-force search. A 128-bit key has about 3.4 times 10 to the power of 38 possible values, which is far beyond any feasible classical search. Grover’s algorithm on a large quantum computer would roughly halve the effective key length, which is why AES-256 is preferred for long-term confidentiality and why symmetric cryptography is considered comparatively robust in post-quantum planning.

Performance depends heavily on hardware. Processors with AES-NI or ARMv8 cryptography extensions encrypt with AES-GCM at several gigabytes per second per core, while on devices without such instructions ChaCha20-Poly1305 is usually faster and easier to implement in constant time.

Implementations must also resist side-channel attacks. Table-based software AES can leak key bits through cache timing, so production systems rely on hardware instructions or constant-time libraries rather than hand-written code. Validated modules, for example under FIPS 140-3, are often required in regulated sectors.

Key management and common mistakes

Strong algorithms fail when keys and nonces are handled poorly. Most real-world breaks of symmetric encryption are implementation and key management errors, not attacks on AES itself.

MistakeConsequenceSafer practice
Reusing a nonce with the same keyPlaintext recovery, forgery in GCMRandom 96-bit nonces with limits, or counters
Hard-coded keys in source codeAnyone with the code can decryptUse a key management service or HSM
Deriving keys from passwords directlyFast offline guessingUse Argon2, scrypt or PBKDF2 first
Using ECB modeVisible data patternsUse an AEAD mode
No key rotationLarge blast radius after compromiseEnvelope encryption with rotating data keys
Frequent mistakes and safer practice

Cloud platforms implement envelope encryption: each object is encrypted with its own data key, and that data key is encrypted with a master key held in a key management service. This limits exposure and makes rotation and access auditing practical.

Understanding it simply

Symmetric encryption works like a lockbox with one key that both locks and unlocks it. Anyone who has a copy of the key can open the box and read what is inside.

It is very fast, so it protects almost everything: phone storage, Wi-Fi traffic and secure websites. The hard part is handing the key to the right person safely. Other techniques handle that step, and then this fast method protects the data itself.

Applied in practice

A hospital stores medical imaging archives in cloud object storage. Each file is encrypted with its own 256-bit AES-GCM data key, generated per object, and the data keys are wrapped by a master key held in a hardware-backed key management service.

When a laptop with a misconfigured synchronization tool exposes a copy of some archive files, the files are unreadable without the wrapped keys. Access logs show that the master key was never used outside approved services. The hospital rotates the master key, re-wraps the data keys without re-encrypting terabytes of images, and documents that no patient data was readable.