🔐 Cryptography - data at rest, transmission and use
Seven themes on what directly protects data in each state: what are primitive and whose problem each solves, how data is protected on disk, network and during processing, how keys are managed and what changes with post-quantity standards.
Data Life Cycle
Three situations, three threat models, three controls
There is no point encrypting the disk if the same data travels over the network without TLS, and there is no point in TLS if the backup is lying open. Protection is planned for all three conditions, not one.
Cryptography Is Not Purpose
This is a control that transfers risk from data to keys. If the key is stored next to encrypted data, the risk is not reduced, only shifted.
Three objectives
Confidentiality (nobody else reads), integrity (nobody changes unnoticed), authenticity (known who sent). Encryption itself gives only the first.
Most frequent error
The cryptographic code itself is written. Algorithms are public and tested; vulnerabilities arise in introduction - random source, repeated noncirculation, time leak.
Building blocks
Primitives - Who solves the problem
In practice, they are combined: the session key is asymmetrically agreed, the symmetrical encryption of data flows, while the AEAD ensures confidentiality and integrity. It works for TLS.
Used
- AEAD mode:
AES-256-GCMorChaCha20-Poly1305 - Passwords:
Argon2id(this site also uses it) - For accidental use:
secretsmodule Python - Library
cryptography, not own written code
Do not use
AES-ECB- the same blocks give the same encryptionMD5,SHA-1- collisions are practical- Mixed function passwords without salt and without cost
randommodule a2 - expected
Data on disk and database
Envelope encryption - key hierarchy
Why two levels: key rotation means to decrypt only DEK, not all data. One million records remain in place, one small value changes.
Full disc
Protects against stolen equipment. When the system is running, the data is open - therefore it does not protect against entering the server.
Field level
Encrypt specific fields (personal data, health data). Also protects against DB administrator, but broken search and handling.
Spare copies
The most frequently forgotten place. The copy shall be the same data without access control. The copies of this site are encrypted by age and stored outside the server.
Network data
TLS 1.3 - what it gives and what does not give
Forward secret (PFS) means that the private key of a later stolen server does not decrypt the previously recorded traffic - each session has its own temporary key. It is commonly called a future mystery, but the industry uses the original term.
What TLS does NOT protect
Metadata: with which server speaks, how much and how often. Content is closed, there is no fact of communication.
Final points
TLS ends at the server. If the data behind it goes between microservices, only the first step is protected - therefore mTLS internal network.
Certificate proves domain
Normal certificate confirms domain control, not that the owner is honest. The phishing page also has a valid lock.
The Challenge
Data at the time of processing - what can be done with them
The state of use is the only one where there is no universal solution. Fairly for most systems: minimizing and tokenisation solves most, and only then is it worth looking at the enclaves.
Attestation
The value of the reliable environment is the remote assay: the code can prove who works directly in it. Without it, the enclave is just another black box.
Transfer of Confidence
The enclave transfers trust from the cloud maintainer to the processor manufacturer. It is a change, not an elimination - and it has been vulnerable to side-channel attacks.
In practice
This site uses the simplest layer: card data never reaches the server (payments are processed by Klix), so they do not need to be protected in the condition of use.
Where cryptography in practice falls
Key Life Cycle (NIST SP 800-57)
An identified leak of mystery means rotation, not deletion of history. What has once been public must be regarded as known.
One key, one goal
The same key for encryption and signing weakens both. Separate keys also mean that a single compromise does not open everything.
Shared knowledge
No man knows the root key completely. It is divided into parts and renewal requires a number of people - protection from one weak point.
Crypto-agility
System in which the cryptographic algorithm can be changed without overwrite. It became a practical requirement precisely because of the post-quantum transition.
Standard landscape
What has been confirmed and what changes
FIPS 203 (ML-KEM, key encapsulation), FIPS 204 (ML-DSA, signatures) and FIPS 205 (SLH-DSA, interface-based signatures) were approved by NIST on 13 August 2024.
Algorithms
FIPS 197 (AES), FIPS 180-4 (SHA-2), FIPS 202 (SHA-3), FIPS 186-5 (signatures). The transition periods are set by the NIST SP 800-131A.
Application
NIST SP 800-175B (as to use), SP 800-57 (keys), ISO/IEC 19790 (module requirements), OWASP USS section 6 (development of testing requirements).
Legal
Article 21 (2) (h) of the NIS2 requires a cryptographic policy. eIDAS regulates trust services and qualified e-signatures in the EU.
Abbreviations
All signs used in the guide in one place.
- AEAD
- Authenticated Entry with Associated Data - encryption and at the same time ensuring integrity.
- AES
- Advanced Entry Standard - symmetrical block code (FIPS 197).
- DEK
- Data Encryption Key - a key to encrypt the data itself.
- FIPS
- Federal Information Processing Standards - U.S. federal standards; cryptography de facto international.
- HKDF
- HMAC-based Key Derivation Function - derived keys from an already secret value.
- HMAC
- Hash-based Message Authentication Code - integrity with a common secret key.
- HSM
- Hardware Security Module - hardware that does not leave the key.
- KEK
- Key Encryption Key - a key to encrypt other keys.
- KMS
- Key Management Service - key management service.
- ML-DSA
- Module-Lattice-Based Digital Signature Algorithm - post-quantity signature (FIPS 204).
- ML-KEM
- Module-Lattice-Based Key-Encapsulation Mechanism - post-quantum key exchange (FIPS 203).
- MPC
- Multi-Party Computation - several parties invoice a joint result without revealing their data.
- PFS
- Perfect Forward Secrety - later stolen key does not decipher the earlier traffic; the industry uses the English term.
- PQC
- Post-Quantum Cryptography - algorithms that are also resistant to quantum computers.
- SLH-DSA
- Stateless Hash-Based Digital Signature Algorithm - post-quantity signature (FIPS 205).
- TEE
- Trusted Executive Environment - hardware enclave for data during use.
- TLS
- Transport Layer Security - encrypted network channel; version 1.3 is current.