pk.org: Computer Security/Lecture Notes

Public Key Cryptography and Integrity -- Study Guide

Paul Krzyzanowski – 2025-09-19

Part 1: Public Key Cryptography

Public key cryptography

One-way functions

Trapdoor functions

Origins

Why not use public key for everything?

RSA and ECC

RSA basics
- Security based on difficulty of factoring large numbers.
- Key generation: choose primes \(p, q\); compute \(n = pq\), and exponents \(e, d\).
- Encryption: \(C = P^e \bmod n\); Decryption: \(P = C^d \bmod n\).

Elliptic Curve Cryptography (ECC)
- Uses algebra on elliptic curves instead of integers.
- Provides the same security as RSA with much smaller key sizes.
- Widely used in practice, especially in TLS and mobile devices.
- Limitations
- Raw RSA is insecure; requires padding (e.g., OAEP).
- Mainly used for exchanging keys or signatures, not bulk data.
- ECC has become a preferred alternative in many systems because it provides equivalent security with much shorter key lengths.**


Part 2: Hash Functions

Hash function
- Maps arbitrary input to fixed-size output.
- Goal: provide fingerprints of data for comparison or verification.

Properties
- Deterministic, fast, preimage-resistant, collision-resistant, avalanche effect.

SHA family
- Widely used cryptographic hash functions (SHA-2, SHA-3).

Applications
- Integrity checks, digital signatures, password storage.

Entropy
- Shannon entropy measures unpredictability in data.
- Goal: ciphertext and keys should appear random (high entropy).


Part 3: Integrity Mechanisms

Message Authentication Codes (MACs)

AEAD (Authenticated Encryption with Associated Data)

Digital Signatures

Why hashes are involved

MACs vs. Signatures


Part 4: Diffie-Hellman Key Exchange

Core question : How can two parties who have never met agree on a shared secret?

Basic process

Security: Relies on hardness of the discrete logarithm problem.

Elliptic Curve Diffie-Hellman (ECDH)

Limitation: Provides secrecy but not authentication (man-in-the-middle possible).


Part 5: Putting It All Together

Hybrid cryptosystem

Long-term keys

Ephemeral keys (Session keys)

Forward secrecy

Digital certificates (X.509v3)

Root certificates and trust stores

Certificate verification process

  1. Receive certificate and intermediates.
  2. Check validity dates.
  3. Build chain to a root.
  4. Verify signatures at each link.
  5. Ensure root is in trust store.
  6. Confirm hostname matches certificate subject.
  7. Optionally check revocation.
  8. Verify server controls corresponding to the private key.

Protocols in practice


Part 6 - Quantum Attacks and Post-Quantum Cryptography


Key Takeaways