Documentation Index
Fetch the complete documentation index at: https://roadtocybersec.com/llms.txt
Use this file to discover all available pages before exploring further.
Cryptography
Cryptography is the mathematical foundation that makes digital security possible. Every time you visit a website over HTTPS, send an encrypted message, or log in with a password, cryptography is working behind the scenes.Symmetric Encryption
In symmetric encryption, the same key is used for both encrypting and decrypting data.| Algorithm | Key Size | Status | Use Case |
|---|---|---|---|
| AES-256 | 256 bits | Industry standard | File/disk encryption, VPNs, TLS |
| ChaCha20-Poly1305 | 256 bits | Modern alternative | Mobile/IoT (faster in software) |
| 3DES | 168 bits | Deprecated | Legacy systems only |
| DES | 56 bits | Broken | Never use |
The Key Distribution Problem
Symmetric encryption is fast, but has a fundamental challenge: how do you securely share the key? If you send it over the same channel as the data, an attacker who intercepts the channel gets both. This is why asymmetric encryption was invented.Asymmetric Encryption (Public Key Cryptography)
Uses a mathematically linked pair of keys: a Public Key (shared openly) and a Private Key (kept secret). Data encrypted with the public key can only be decrypted with the private key.| Algorithm | Based On | Key Size | Status |
|---|---|---|---|
| RSA | Integer factorization | 2048-4096 bits | Widely used, being phased out |
| ECDSA/ECDH | Elliptic Curve math | 256-384 bits | Preferred (same security, smaller keys) |
| Ed25519 | Edwards-curve | 256 bits | Modern, fast; used in SSH, Signal, WireGuard |
The Hybrid Approach
In practice, modern systems use both: asymmetric encryption to securely exchange a symmetric session key, then symmetric encryption (AES/ChaCha20) for the actual data. Best of both worlds.The TLS 1.3 Handshake
TLS powers HTTPS. The TLS 1.3 handshake completes in a single round trip:Client Hello
Browser sends supported cipher suites, TLS version, random number, and its Diffie-Hellman key share.
Server Hello
Server selects cipher suite, sends its key share and digital certificate (signed by a Certificate Authority).
Key Derivation
Both sides independently compute the same shared secret via Diffie-Hellman, without transmitting it.
TLS 1.3 removed insecure cipher suites (RSA key exchange, CBC mode, SHA-1) and introduced 0-RTT resumption for repeat connections. If your server still supports TLS 1.0/1.1, it is vulnerable to known attacks.
Diffie-Hellman Key Exchange
Allows two parties to establish a shared secret over an insecure channel without transmitting the secret itself. Simplified analogy: Alice and Bob each pick a private color, agree on a shared base color, each mix their private color with the base and exchange results. Each mixes the received color with their private color, arriving at the same final color. An eavesdropper cannot reverse-engineer the private colors from the intermediate mixtures. In practice, this uses modular exponentiation (classic DH) or elliptic curve point multiplication (ECDH).Hashing
A one-way function that produces a fixed-size output from any input.Properties of Secure Hash Functions
- Deterministic: Same input → same hash
- One-way: Cannot reverse hash to recover input
- Avalanche effect: Tiny input change → completely different hash
- Collision resistant: Infeasible to find two inputs producing the same hash
Algorithm Comparison
| Algorithm | Output | Status | Use Case |
|---|---|---|---|
| MD5 | 128 bits | Broken | Never use for security |
| SHA-1 | 160 bits | Broken | Never use for security |
| SHA-256 | 256 bits | Secure | File integrity, blockchain, signatures |
| bcrypt | 184 bits | Secure | Password storage |
| Argon2 | Variable | Best for passwords | Winner of Password Hashing Competition (2015) |
Password Hashing
Passwords must be hashed with a slow, salted algorithm:- Salt: Random value added before hashing, which ensures identical passwords produce different hashes.
- Work factor: Deliberately slow (~100ms per hash), making brute-force impractical.
Digital Signatures
Combine hashing + asymmetric encryption for authentication and integrity.Sign
Sender hashes the document (SHA-256), encrypts the hash with their Private Key. The encrypted hash = digital signature.
Certificate Chains
Digital certificates are signed by Certificate Authorities (CAs). Your browser trusts a website because it traces a chain of trust back to a Root CA pre-installed in the OS/browser.Post-Quantum Cryptography
Quantum computers will eventually break RSA and Elliptic Curve cryptography using Shor’s algorithm. Data captured today could be decrypted later (“harvest now, decrypt later”).NIST Post-Quantum Standards (2024)
| Algorithm | Type | Purpose |
|---|---|---|
| ML-KEM (Kyber) | Lattice-based | Key exchange |
| ML-DSA (Dilithium) | Lattice-based | Digital signatures |
| SLH-DSA (SPHINCS+) | Hash-based | Signatures (stateless) |
The quantum threat is not imminent (breaking RSA-2048 requires ~4,000+ stable qubits; current quantum computers have ~1,000), but migration takes years. Organizations with sensitive data should plan now.
Key Takeaways
- Symmetric = fast, asymmetric = solves key distribution: Modern systems use both.
- TLS 1.3 is the baseline: Disable TLS 1.0/1.1.
- Never MD5 or SHA-1 for security: SHA-256 for integrity, Argon2 for passwords.
- Salt + slow hashing for passwords: Never store plaintext.
- Watch quantum developments: Post-quantum standards exist; plan migration.