{"canonical_url":"https://engineer.company/glossary/encryption/","content_markdown":"# Encryption\n\n## What it is\n\nEncryption, which some NIST publications call enciphering, turns readable data,\nthe plaintext, into ciphertext by running it through a published algorithm\ntogether with a secret value called a key. Decryption, given the right key,\nreturns the plaintext byte for byte. The algorithm is public on purpose: AES,\nthe cipher most systems reach for, won an open NIST competition in 2000 and is\npublished as a free standard. Only the key is secret.\n\nCiphers come in two families. A symmetric cipher uses the same key in both\ndirections. AES, specified in FIPS 197, encrypts data in blocks of 128 bits with\na key of 128, 192 or 256 bits. ChaCha20, from RFC 8439, is a stream cipher about\nthree times as fast as AES on hardware without AES instructions. Symmetric\nciphers are fast enough for a whole disk, but both ends need the same key, and\ngetting it there safely is the hard part.\n\nPublic-key cryptography answers that with a pair of keys, one published and one\nkept private. Two parties can each combine their own private key with the\nother's public key and arrive at the same shared secret without ever sending it.\nPublic-key operations are slow, so real systems use both: a public-key exchange\nagrees a fresh symmetric key, and the symmetric cipher carries the data. TLS,\nthe protocol behind every `https://` address, works this way.\n\nThe modern idea that matters most is authentication. A bare cipher hides content\nbut leaves it open to change: in counter mode, flipping one bit of the\nciphertext flips the same bit of the plaintext, and the receiver decrypts the\naltered message as if it were genuine. Authenticated encryption with associated\ndata, AEAD, adds a tag the receiver checks before trusting a byte. AES-GCM and\nChaCha20-Poly1305 are the common pair, and TLS 1.3, published as RFC 8446 in\n2018, kept AEAD ciphers alone and made every public-key exchange forward-secret,\nso a server key stolen later opens no recorded session.\n\n## Why it matters\n\nData rarely stays on hardware its owner controls. It crosses other people's\nnetworks, sits in someone else's data centre and leaves the building on laptops.\nEncryption is what lets it pass through those places safely: a stolen disk, a\ntapped cable or a leaked bucket yields ciphertext, and ciphertext without the\nkey is noise.\n\nThat moves the problem rather than removing it: once data is encrypted, its\nsafety is the safety of the key. NIST's key-management recommendation, SP\n800-57, compares keys to the combination of a safe: an adversary who knows the\ncombination walks past the strongest safe, and poor key management can easily\ncompromise a strong algorithm. Most of the real work is therefore key work:\nstoring keys apart from the data, limiting how much each one protects, replacing\nthem on a schedule and guarding the recovery copy as closely as the original.\n\nRegulators draw the same line. The GDPR lists the pseudonymisation and\nencryption of personal data among the security measures in article 32. Article\n34 lets a controller skip telling each affected person about a breach when the\nleaked data was unintelligible to anyone not authorised to see it, and\nencryption is the example it gives.\n\nEncryption is applied in two places. Encryption in transit, mostly TLS, protects\ndata on the wire. Encryption at rest protects it in storage. The moment of use\nsits outside both: a server that decrypts a record to work on it holds the\nplaintext and the key at once, so whoever controls that server reads what it\nreads.\n\n## What it looks like in practice\n\nIn transit, the daily work is keeping certificates valid. When\n[a hundred Docker applications needed SSL/TLS certificates](/portfolio/automated-ssl-tls-certs-for-100-docker-apps/),\nan ACME workflow created every certificate, renewed each before it lapsed and\ndeployed it to Ubuntu hosts running Apache and Nginx. The aim was to take the\nperson out of the loop, because the person is the part that forgets, and an\nexpired certificate takes an app down as surely as a broken cipher.\n\nAt rest, the useful question is who holds the key. The company's\n[encrypted off-host backup implementation](/portfolio/backups-that-have-actually-been-restored/)\nwas designed to extend recovery beyond a provider snapshot. It uses restic, which encrypts\nwhat it stores with AES-256 in counter mode and authenticates it with Poly1305-AES, and its\nscripts support sending snapshots over SFTP to storage at another provider. In that design\nthe provider receives ciphertext and the company holds the passphrase in a protected file.\nThat describes the implemented controls, not their operational activation: the record dated\n2026-10-27 says the timers were disabled without a configured repository and records no\ncompleted live restore. Encryption is a property of the proposed storage path; proving that\nthe backup can be recovered requires running the separate restore test.\n\nEven the route the passphrase takes mattered. It is read from a file, because\nthe supervisor processes escapes in environment values, and a passphrase\ncontaining a backslash would have silently differed from the one that created\nthe repository. The implemented monthly restore-test workflow is designed to\nrestore a known file from the repository and compare it with the expected\nresult. Because the test requires the passphrase, a successful run would also\nverify that the key still opens the data.\n\nWhen the platform was about to gain a second host, the same reasoning decided\nhow\n[every operational secret was split per host](/portfolio/split-every-operational-secret-per-host/).\nA backup repository string identifies a location. Separate restic repositories can have distinct master keys even when they use the same passphrase. Someone who obtains that passphrase and can read both repositories' encrypted data and key files can unlock both, so sharing it couples their exposure. Each secret became a map\nkeyed by host, with the argument written beside the configuration. SP 800-57\nmakes the general case: limiting what one key protects limits the damage when it\nleaks.\n\n## Where it goes wrong\n\n**The key exists in one place.** A strong cipher treats an owner who forgot the\npassword exactly like an attacker. The restic documentation puts it plainly:\nonce the password is lost, so is the data, with no way to recover it. Every\nencrypted store needs a second copy of its key, kept where whatever destroys the\nfirst cannot reach it.\n\n**The key sits beside the data.** A database encrypted with a key in the same\nserver's configuration, or a backup whose passphrase lives in the same bucket,\nstops only a thief who takes half the files. Disk encryption is the quieter\nversion: it protects a drive pulled from a machine that is switched off, while a\nrunning server has already unlocked its disk, and an attacker on that server\nreads plaintext.\n\n**Secrecy is taken for integrity.** A system built on a bare cipher mode hides\ncontent and still lets an attacker alter it. Use an AEAD construction and\ndiscard any message whose tag fails before acting on a byte of it.\n\n**A nonce repeats.** AES-GCM and ChaCha20-Poly1305 take a nonce, a value that\nmust stay unique for every message under one key. RFC 8439 calls this the most\nimportant security consideration: two messages with the same nonce share a\nkeystream and a one-time authentication key, which reveals the XOR of the two\nplaintexts. A counter is a safe way to make nonces, as long as one counter owns\nthe key: two processes that share a key and each count from zero produce exactly\nthe repeat the RFC warns about.\n\n**A password stands in for a key.** People choose passwords; ciphers need random\nkeys of a fixed length. A passphrase goes through a key derivation function\nfirst, as restic does with scrypt, which RFC 7914 designs to be memory-hard so\nthat guessing in bulk on custom hardware stays expensive. Stored login passwords\nare a separate case: they belong in such a function as hashes, because a server\nthat can decrypt them can also leak them.\n\n**The metadata stays visible.** Encryption hides content, while size, timing and\nthe addresses at either end remain in view. TLS 1.3 lets a sender pad records to\nhide their size, and padding is optional, so length often says more than the\nowner expects.\n\n## Further reading\n\n- [NIST Glossary: encryption](https://csrc.nist.gov/glossary/term/encryption) —\n  every definition NIST publications use, each with its source document.\n- [FIPS 197: Advanced Encryption Standard (AES)](https://csrc.nist.gov/pubs/fips/197/final)\n  — the AES specification, with its block size and three key lengths.\n- [NIST SP 800-57 Part 1 Rev. 5: Recommendation for Key Management](https://csrc.nist.gov/pubs/sp/800/57/pt1/r5/final)\n  — how keys are made, stored, used and retired, and what follows when one\n  leaks.\n- [RFC 8446: The Transport Layer Security (TLS) Protocol Version 1.3](https://www.rfc-editor.org/rfc/rfc8446)\n  — the protocol behind `https://`, with AEAD-only records and forward-secret\n  key exchange.\n- [RFC 8439: ChaCha20 and Poly1305 for IETF Protocols](https://www.rfc-editor.org/rfc/rfc8439)\n  — a stream cipher, an authenticator and their AEAD pairing, with the nonce\n  rules.\n- [restic: References](https://restic.readthedocs.io/en/stable/100_references.html)\n  — how a real backup tool derives keys from a password, then encrypts and\n  authenticates its data.\n\n\u003chttps://engineer.company/glossary/encryption/\u003e\n","date_modified":"2026-11-12T05:34:23Z","description":"How ciphers and keys protect data at rest and in transit, why authenticated encryption became the default, and the key mistakes that undo a strong cipher.","formats":{"gemtext":"https://engineer.company/glossary/encryption/index.gmi","gopher":"https://engineer.company/glossary/encryption/gophermap","html":"https://engineer.company/glossary/encryption/","json":"https://engineer.company/glossary/encryption/index.json","markdown":"https://engineer.company/glossary/encryption/index.md","pdf":"https://engineer.company/glossary/encryption/index.pdf"},"kind":"page","language":"en","title":"What is encryption?","url":"https://engineer.company/glossary/encryption/","version":1}