⦿ Privacy & Anonymity

Encryption at Rest vs Encryption in Transit

Encryption at rest and encryption in transit are two complementary defenses that protect data at different points in its life. Encryption at rest secures information while it is stored on a disk or in a database; encryption in transit secures it while it moves across a network. Because they address different threats, understanding how each works, and why neither alone is sufficient, is fundamental to designing a secure system.

Two States of Data, Two Threat Models

Data generally exists in three states: at rest (stored), in transit (moving over a network), and in use (loaded in memory and being processed). Encryption at rest and encryption in transit protect the first two, and each targets a distinct attacker.

  • Encryption at rest defends against someone who obtains the storage medium: a stolen laptop, a discarded hard drive, a copied database file, or a compromised backup.
  • Encryption in transit defends against someone who intercepts the network: an eavesdropper on shared Wi-Fi, a malicious router, or an attacker performing a man-in-the-middle attack.

A system can implement one without the other, which is exactly why they must be considered separately.

How Encryption at Rest Works

Encryption at rest uses fast symmetric cryptography, almost always AES, to encrypt stored data. It appears at several layers:

  • Full-disk encryption (FDE) encrypts an entire volume beneath the file system. Technologies in this category protect a device if it is lost or stolen while powered off.
  • File- or folder-level encryption protects specific items, allowing different keys for different data.
  • Database and application-level encryption encrypts particular columns or records, so sensitive fields stay protected even inside an otherwise accessible database.

The Key Management Challenge

Encryption at rest is only as strong as its key handling. If the decryption key sits on the same disk in plaintext, an attacker who steals the disk gets both. Real systems address this with:

  • Envelope encryption, where data is encrypted with a data encryption key (DEK), and that DEK is itself encrypted by a key encryption key (KEK) held in a separate, guarded system.
  • Key management services (KMS) and hardware security modules (HSM) that store master keys in tamper-resistant hardware and never expose them directly.

Envelope encryption works roughly as follows:

DEK          = random_key()                 # data encryption key
ciphertext   = AES_GCM_encrypt(DEK, data)    # encrypt the data with the DEK
wrapped_DEK  = AES_GCM_encrypt(KEK, DEK)     # KEK lives in a KMS or HSM
# store ciphertext and wrapped_DEK together; the KEK never leaves the KMS

This structure also makes key rotation inexpensive, because rotating the KEK only requires re-wrapping the small DEK rather than re-encrypting all of the underlying data.

A subtle limitation is that once a system is running and unlocked, data at rest is decrypted for use, so encryption at rest does little against an attacker who already has live access to a running, authenticated system.

How Encryption in Transit Works

Encryption in transit protects data as it travels between systems, most commonly using TLS (Transport Layer Security), the protocol behind HTTPS. A TLS connection is established through a handshake that:

  1. Authenticates the server using a certificate, so the client knows it is talking to the real destination and not an impostor.
  2. Performs a key exchange, typically ephemeral elliptic-curve Diffie-Hellman, to agree on a shared session key.
  3. Encrypts the session with a fast authenticated cipher such as AES-GCM or ChaCha20-Poly1305, protecting both confidentiality and integrity.

Some deployments also use mutual TLS, in which the client presents a certificate too, so both ends authenticate each other rather than only the server. Using ephemeral keys gives the connection perfect forward secrecy, so a later theft of the server's long-term key cannot decrypt previously recorded sessions. Other transit protections include VPNs and SSH, which build encrypted tunnels for broader categories of traffic.

Why You Need Both, and Where the Gap Remains

The two protections are not alternatives; they cover different moments in a data flow. Consider a message sent to a cloud service:

  • In transit, TLS stops network eavesdroppers from reading it on the way.
  • At rest, disk or database encryption stops someone who later steals the storage from reading it.

Without transit encryption, the message is exposed on the wire. Without rest encryption, it is exposed on stolen media. A complete design applies both.

Yet a gap remains: with only these two protections, the service provider itself can read your data, because it holds the keys and processes plaintext in memory. Closing that gap requires end-to-end encryption, where only the endpoints hold keys, or confidential computing approaches that keep data encrypted even while it is in use inside a hardware-protected enclave.

Key Takeaways

  • Encryption at rest protects stored data against stolen disks, databases, and backups, usually with AES-based symmetric encryption.
  • Encryption in transit protects moving data against network eavesdroppers and man-in-the-middle attacks, most commonly with TLS.
  • They defend different threat models, so a secure system needs both rather than choosing one.
  • Encryption at rest depends on strong key management: envelope encryption, KMS, and HSMs keep keys separate from the data they protect.
  • Neither hides data from the service provider; only end-to-end encryption or confidential computing addresses data exposed during processing.
encryption-at-restencryption-in-transittlskey-managementdata-protection

Frequently asked questions

What is the difference between encryption at rest and in transit?

Encryption at rest protects data while it is stored on disks, databases, or backups, guarding against theft of the physical media or unauthorized access to storage. Encryption in transit protects data while it moves across networks between systems, guarding against interception and eavesdropping. They address different stages of a data's lifecycle and are typically used together.

What is encryption at rest?

Encryption at rest is the practice of encrypting stored data so that it is unreadable without the proper key, whether it sits on a hard drive, in a database, or in cloud storage. If a device is stolen or a storage system is breached, the data remains protected as ciphertext. It is commonly implemented through full-disk encryption or database-level encryption.

What is encryption in transit?

Encryption in transit protects data as it travels over networks, most commonly using the TLS protocol that secures HTTPS web traffic. It prevents attackers positioned on the network from reading or tampering with data as it moves between a client and a server. Without it, credentials and other sensitive information could be intercepted in plain text.

Do I need both encryption at rest and in transit?

Yes, the two protect against different threats and neither is a substitute for the other. Encryption in transit stops interception on the network but leaves stored data exposed if a server is breached, while encryption at rest protects storage but does nothing for data moving across the wire. Using both provides defense in depth across the entire data lifecycle.

Does encryption at rest protect against a hacked server?

Encryption at rest mainly protects against theft of the physical media or offline access to storage, such as a stolen drive or a copied backup. It offers limited protection against an attacker who compromises a running server, because that system usually already holds the keys needed to decrypt the data for normal operation. Additional controls like access management and key isolation are needed to address that threat.

Try it hands-on

K0G is an open toolkit of browser-based security utilities — hashing, encoding, JWT, certificates, crypto and more, all running locally in your browser.

Explore the tools →