3. Cryptographic Algorithms and Protocols
Learning Objectives
- Distinguish symmetric and asymmetric encryption and explain the trade-offs between them
- Identify common algorithms (AES, DES, RSA, ECC) and what makes each secure or obsolete
- Explain the four key properties of a good hash function
- Describe how digital signatures provide authenticity and non-repudiation
- Explain the role of Public-Key Infrastructure (PKI) in managing trust
- Choose the appropriate cryptographic technique for a given security requirement
Quick Answer
Cryptography is the mathematical foundation that makes modern digital security possible — it's how data stays confidential, verifiable, and trustworthy even when sent across networks controlled by no one you trust. There are two main families of encryption: symmetric (one shared key, fast, used for bulk data like AES) and asymmetric (a public/private key pair, slower, used for secure key exchange and digital signatures like RSA). Alongside these, hash functions create tamper-evident fingerprints of data, and digital signatures combine hashing with asymmetric encryption to prove who sent a message and that it wasn't altered. Together, these building blocks power everything from HTTPS browsing to software update verification to cryptocurrency.
Symmetric Encryption
Symmetric encryption uses the same key for both encrypting and decrypting data. It's fast and computationally cheap, which makes it the right choice for encrypting large amounts of data — but both parties must already share the secret key, which creates a distribution problem: how do you get the key to the other person securely in the first place?
Examples
- AES (Advanced Encryption Standard) — encrypts data in 128-bit blocks with key lengths of 128, 192, or 256 bits. It's the current industry standard, used in everything from Wi-Fi (WPA2/3) to disk encryption.
- DES (Data Encryption Standard) — an older algorithm using a 56-bit key. It's now considered insecure because modern hardware can brute-force a 56-bit key in hours, which is why AES replaced it.
Real-world example: When you encrypt a laptop's hard drive with BitLocker or FileVault, AES does the heavy lifting — encrypting gigabytes of data quickly enough that you don't notice a performance hit.
Why it matters / limitations: Speed makes symmetric encryption ideal for bulk data, but the shared-key requirement is exactly the problem asymmetric encryption was invented to solve.
Common misunderstanding: Students sometimes think "symmetric" means "weaker." Key strength depends on algorithm design and key length, not on whether it's symmetric or asymmetric — AES-256 is extremely strong; it's simply solving a different problem than RSA.
Asymmetric Encryption
Asymmetric (public-key) encryption uses a mathematically linked pair of keys: a public key anyone can use to encrypt data, and a private key, kept secret, that alone can decrypt it. This eliminates the need to secretly share a key in advance — you can publish your public key openly.
Examples
- RSA (Rivest-Shamir-Adleman) — relies on the difficulty of factoring the product of two large prime numbers. Widely used for secure transmission and digital signatures.
- ECC (Elliptic Curve Cryptography) — achieves the same security level as RSA with much smaller key sizes, based on the mathematics of elliptic curves. This makes it faster and better suited to constrained devices like smartphones.
Real-world example: When your browser starts a TLS connection, it uses the server's RSA or ECC public key (from its certificate) to securely agree on a symmetric session key — solving the exact key-distribution problem that pure symmetric encryption can't solve on its own.
Why it matters / limitations: Asymmetric encryption is significantly slower and more computationally intensive than symmetric encryption, which is why real protocols use it briefly (for key exchange or signing) and switch to symmetric encryption for the actual data.
Hash Functions
A hash function takes an input of any size and produces a fixed-size output (a "digest") that acts as a fingerprint of the data. Hashes are one-way — you cannot reconstruct the original input from the hash.
Key Properties
- Deterministic — the same input always produces the same hash.
- Fast computation — quick to compute for any input size.
- Pre-image resistance — infeasible to reverse-engineer the input from the hash.
- Collision resistance — infeasible to find two different inputs producing the same hash.
Examples
- SHA-256 — produces a 256-bit hash, widely used and currently considered secure (e.g., in Bitcoin, TLS, and password storage with proper salting).
- MD5 — produces a 128-bit hash, but is no longer secure because researchers found practical ways to create collisions (two different files producing the same hash).
Real-world example: When you download software, the publisher often lists a SHA-256 checksum. After downloading, you hash the file yourself and compare — if even a single bit differs (due to corruption or tampering), the hash changes completely, alerting you immediately.
Common misunderstanding: Students often confuse hashing with encryption. Encryption is reversible (with the right key); hashing is deliberately irreversible. You hash a password to store it safely — you never "decrypt" a hash back into the original password.
Digital Signatures
Digital signatures let a recipient verify both the authenticity (who sent it) and integrity (it wasn't altered) of a message, using asymmetric encryption applied in reverse.
Process
- The sender computes a hash of the message.
- The sender encrypts that hash with their own private key — this encrypted hash is the signature.
- The recipient decrypts the signature using the sender's public key, recomputes the hash of the received message, and checks that the two match.
Why it matters: Because only the sender's private key could have produced a signature decryptable by their public key, a valid signature proves the message came from them and wasn't modified — this also gives non-repudiation, meaning the sender can't later deny having sent it.
Real-world example: Software vendors sign their updates with digital signatures. Your operating system verifies the signature before installing an update, rejecting anything that wasn't actually signed by the legitimate vendor — a key defense against supply-chain attacks.
Public-Key Infrastructure (PKI)
PKI is the framework that makes public-key cryptography trustworthy at scale by managing the issuance, distribution, and revocation of digital certificates.
- Certificate Authority (CA) — a trusted entity that issues digital certificates, vouching that a given public key really belongs to a given identity.
- Registration Authority (RA) — verifies an applicant's identity before the CA issues a certificate.
- Digital Certificates — electronic documents binding a public key to an identity, signed by the CA.
Why it matters: Without PKI, you'd have no way to know if a public key claiming to belong to "yourbank.com" actually does, or if it belongs to an attacker. PKI is the trust layer that makes HTTPS, code signing, and secure email possible at internet scale.
Key Terms
| Term | Definition | Related Concept |
|---|---|---|
| Symmetric Encryption | Same key for encryption and decryption | AES |
| Asymmetric Encryption | Public/private key pair for encryption and decryption | RSA, ECC |
| AES | Modern symmetric block cipher standard | Symmetric Encryption |
| RSA | Asymmetric algorithm based on prime factorization difficulty | Asymmetric Encryption |
| Hash Function | One-way function producing a fixed-size digest | Collision Resistance |
| Collision Resistance | Property that makes finding two inputs with the same hash infeasible | Hash Function |
| Digital Signature | Cryptographic proof of authenticity and integrity | Non-repudiation |
| Non-repudiation | Guarantee that a sender cannot deny having sent a message | Digital Signature |
| PKI | Framework managing keys and certificates via trusted authorities | Certificate Authority |
| Certificate Authority | Trusted entity that issues and signs digital certificates | PKI |
Common Mistakes
Misconception: Hashing and encryption are basically the same thing. Why it's wrong: Encryption is reversible with the correct key; hashing is deliberately one-way and cannot be reversed to recover the original input. Correct understanding: Use encryption when you need to recover the original data later; use hashing when you only need to verify integrity or store something (like a password) without ever needing the original value back.
Misconception: Asymmetric encryption is always "better" than symmetric encryption because it uses two keys. Why it's wrong: Asymmetric encryption is far slower and more computationally expensive, making it impractical for encrypting large volumes of data directly. Correct understanding: Real systems use asymmetric encryption for key exchange and signatures, then switch to fast symmetric encryption for the bulk data — each serves a different purpose.
Misconception: MD5 and SHA-1 are still fine to use because they're "hash functions like any other." Why it's wrong: Both have documented practical collision vulnerabilities, meaning attackers can construct two different inputs with the same hash, undermining integrity guarantees. Correct understanding: Modern systems should use SHA-256 or stronger; MD5 and SHA-1 should be treated as broken for security purposes (though MD5 may still appear in non-security contexts like checksums for accidental corruption).
Comparison and Connections
| Technique | Key(s) Used | Speed | Primary Purpose | Example |
|---|---|---|---|---|
| Symmetric Encryption | One shared key | Fast | Confidentiality of bulk data | AES |
| Asymmetric Encryption | Public + private key pair | Slow | Key exchange, signatures | RSA, ECC |
| Hashing | None (no key) | Very fast | Integrity verification | SHA-256 |
| Digital Signature | Private key to sign, public key to verify | Moderate | Authenticity + non-repudiation | RSA-signed certificate |
Practice Questions
Recall
-
What is the key difference between symmetric and asymmetric encryption? Look for: symmetric uses one shared key for both encryption and decryption; asymmetric uses a public key to encrypt and a distinct private key to decrypt.
-
List the four key properties a secure hash function must have. Look for: deterministic, fast computation, pre-image resistance, collision resistance.
Understanding
-
Explain why real-world protocols like TLS use both symmetric and asymmetric encryption instead of choosing just one. Look for: asymmetric encryption solves secure key exchange but is slow; symmetric encryption is fast for bulk data but needs a shared key; combining them gets the security benefit of asymmetric exchange with the speed of symmetric encryption for the actual data.
-
Why can't you "decrypt" a hash to recover the original password? Look for: hash functions are one-way by design (pre-image resistance) — they intentionally discard the information needed to reverse the process, unlike encryption which is reversible with the correct key.
Application
-
A company needs to verify that a downloaded software update hasn't been tampered with and truly came from the vendor. Which cryptographic tool should they rely on, and how does it work? Look for: digital signatures — the vendor hashes the update and encrypts the hash with their private key; the user's system decrypts it with the vendor's public key and compares it to a freshly computed hash of the file.
-
Why is DES no longer considered secure while AES is? Look for: DES uses only a 56-bit key, which modern computing power can brute-force in a practical amount of time; AES supports much larger key sizes (128/192/256 bits), making brute-force infeasible with current technology.
Analysis
-
Compare RSA and ECC in terms of their underlying mathematical basis and practical trade-offs. Look for: RSA relies on the difficulty of factoring large primes and needs larger key sizes for equivalent security; ECC relies on elliptic curve math and achieves the same security with smaller keys, making it faster and better for resource-constrained devices.
-
A hash function is found to have a practical collision vulnerability (like MD5). Analyze the security implications for a system that uses it to verify software integrity. Look for: an attacker could craft a malicious file with the same hash as a legitimate one, allowing the malicious file to pass an integrity check undetected — this is why collision-vulnerable hashes must be replaced with stronger ones like SHA-256.
FAQ
Q: Why do we still use symmetric encryption if asymmetric is more secure for key exchange? Asymmetric encryption isn't inherently "more secure" — it solves a different problem (key distribution) at the cost of speed. Symmetric encryption remains essential for encrypting actual bulk data efficiently; the two are complementary, not competitors.
Q: Is a longer encryption key always better? Generally yes, up to a point — longer keys resist brute-force attacks better, but they also cost more computation. Security recommendations (like AES-256 or RSA-2048+) represent a balance between "secure enough for the foreseeable future" and "practical to compute."
Q: What happens if a Certificate Authority is compromised? If an attacker compromises a CA, they could issue fraudulent certificates that appear legitimate, letting them impersonate any website. This is why CAs undergo strict audits, and browsers maintain lists of trusted CAs and can revoke trust if a CA is found compromised.
Q: Can quantum computers break current cryptography? Large-scale quantum computers could theoretically break RSA and ECC by efficiently solving the math problems they rely on (factoring and discrete logarithms), though such machines don't yet exist at the needed scale. This is why researchers are developing "post-quantum cryptography" algorithms designed to resist quantum attacks.
Q: Why do password systems use hashing instead of encryption? Storing passwords hashed (ideally with salting) means that even if the database is breached, attackers don't get usable passwords back — since hashes can't be reversed. If passwords were merely encrypted, a stolen decryption key would expose every password at once.
Quick Revision
- Symmetric encryption: one shared key, fast, used for bulk data (AES); DES is obsolete due to its short 56-bit key.
- Asymmetric encryption: public/private key pair, slower, solves key distribution (RSA, ECC).
- ECC achieves RSA-level security with smaller keys, better for constrained devices.
- Hash functions are one-way; properties needed: deterministic, fast, pre-image resistant, collision resistant.
- SHA-256 is currently secure; MD5 and SHA-1 are broken due to practical collision attacks.
- Digital signatures = hash the message, encrypt the hash with the sender's private key; verify with the sender's public key.
- Digital signatures provide both authenticity and non-repudiation.
- PKI binds public keys to real identities through trusted Certificate Authorities.
- Real protocols (like TLS) combine asymmetric encryption for key exchange with symmetric encryption for bulk data.
- Hashing and encryption solve different problems: integrity/verification vs. confidentiality/reversibility.
- A compromised CA can issue fraudulent certificates, undermining the entire trust chain.
- Quantum computing is a long-term threat to RSA/ECC, driving research into post-quantum cryptography.
Related Topics
Prerequisites: Fundamentals of Cyber Security, Network Security Protocols
Related Topics: Network Security Protocols, Ethical Hacking and Penetration Testing
Next Topics: Ethical Hacking and Penetration Testing, Cyber Law and Digital Forensics