upgrade
upgrade

๐ŸงฎComputational Mathematics

Fundamental Cryptographic Algorithms

Study smarter with Fiveable

Get study guides, practice questions, and cheatsheets for all your subjects. Join 500,000+ students with a 96% pass rate.

Get Started

Why This Matters

Cryptographic algorithms are the mathematical backbone of digital securityโ€”every secure login, encrypted message, and verified transaction depends on the computational hardness of specific mathematical problems. You're being tested on understanding why these algorithms work, not just what they do. The core concepts include number-theoretic hardness assumptions (factoring, discrete logarithms), symmetric vs. asymmetric paradigms, and the tradeoffs between security strength, key size, and computational efficiency.

Don't just memorize algorithm names and key lengths. Know which mathematical problem each algorithm relies on, whether it's symmetric or asymmetric, and when you'd choose one over another. Exam questions often ask you to compare algorithms solving similar problems or explain why a particular hardness assumption provides security. Master the underlying mathematics, and you'll be able to reason through any cryptographic scenario they throw at you.


Asymmetric Encryption: Public-Key Systems

Asymmetric cryptography uses mathematically related key pairsโ€”a public key anyone can use and a private key only the owner knows. The security relies on mathematical problems that are easy to compute in one direction but computationally infeasible to reverse.

RSA (Rivest-Shamir-Adleman)

  • Integer factorization hardnessโ€”security depends on the difficulty of factoring the product of two large primes n=pโ‹…qn = p \cdot q
  • Key generation involves computing ฯ•(n)=(pโˆ’1)(qโˆ’1)\phi(n) = (p-1)(q-1) and finding e,de, d such that edโ‰ก1(modฯ•(n))ed \equiv 1 \pmod{\phi(n)}
  • Encryption/decryption uses modular exponentiation: c=memodโ€‰โ€‰nc = m^e \mod n and m=cdmodโ€‰โ€‰nm = c^d \mod n

Elliptic Curve Cryptography (ECC)

  • Elliptic curve discrete logarithm problem (ECDLP)โ€”given points PP and Q=kPQ = kP on a curve, finding kk is computationally infeasible
  • Smaller key sizes provide equivalent security to RSA (256-bit ECC โ‰ˆ 3072-bit RSA), reducing computational overhead
  • Curve equation typically takes the form y2=x3+ax+by^2 = x^3 + ax + b over a finite field Fp\mathbb{F}_p

ElGamal Encryption

  • Discrete logarithm hardnessโ€”based on the same problem as Diffie-Hellman, computing xx from gxmodโ€‰โ€‰pg^x \mod p
  • Semantic security through randomizationโ€”the same plaintext encrypts to different ciphertexts using random kk
  • Ciphertext expansionโ€”output is twice the size of plaintext (c1,c2)=(gk,mโ‹…hk)(c_1, c_2) = (g^k, m \cdot h^k)

Compare: RSA vs. ECCโ€”both provide asymmetric encryption, but RSA relies on factoring while ECC relies on the discrete logarithm problem on elliptic curves. ECC achieves equivalent security with dramatically smaller keys. If an FRQ asks about efficiency in resource-constrained environments, ECC is your go-to example.


Symmetric Encryption: Shared-Key Systems

Symmetric algorithms use the same secret key for encryption and decryption. They're faster than asymmetric methods but require secure key distribution. Security depends on key length and resistance to cryptanalytic attacks.

AES (Advanced Encryption Standard)

  • Block cipher operating on 128-bit blocks with key sizes of 128, 192, or 256 bits
  • Substitution-permutation network (SPN)โ€”alternates SubBytes, ShiftRows, MixColumns, and AddRoundKey operations
  • Current standard for symmetric encryption, resistant to all known practical attacks when properly implemented

DES (Data Encryption Standard)

  • 56-bit effective key lengthโ€”now considered insecure; can be brute-forced in hours with modern hardware
  • Feistel network structure with 16 rounds of permutation and substitution operations
  • Historical significanceโ€”first widely adopted encryption standard, replaced by AES in 2001

Blowfish

  • Variable key length from 32 to 448 bits, encrypting 64-bit blocks
  • Feistel network with 16 rounds and key-dependent S-boxes generated during initialization
  • Fast performance in software, though 64-bit block size limits security for large data volumes

Twofish

  • 128-bit block size with keys up to 256 bitsโ€”designed as Blowfish's successor and AES finalist
  • Complex key schedule using MDS matrices and pseudo-Hadamard transforms for diffusion
  • Precomputed key-dependent S-boxes provide strong resistance to differential and linear cryptanalysis

Compare: DES vs. AESโ€”both are symmetric block ciphers, but DES uses a 56-bit key (insecure) while AES uses 128-256 bit keys (secure). DES uses a Feistel network; AES uses a substitution-permutation network. Know this distinction for questions about algorithm evolution and security margins.

Compare: Blowfish vs. Twofishโ€”Blowfish uses 64-bit blocks while Twofish uses 128-bit blocks. Twofish offers stronger security guarantees for modern applications, but Blowfish remains useful for legacy systems requiring fast encryption.


Key Exchange Protocols

Key exchange algorithms solve the fundamental problem of establishing shared secrets over insecure channels. The mathematics ensures that eavesdroppers cannot compute the shared key even after observing all public communications.

Diffie-Hellman Key Exchange

  • Discrete logarithm problemโ€”given gg, pp, and gamodโ€‰โ€‰pg^a \mod p, computing aa is computationally infeasible
  • Protocol mechanics: Alice sends A=gamodโ€‰โ€‰pA = g^a \mod p, Bob sends B=gbmodโ€‰โ€‰pB = g^b \mod p, both compute K=gabmodโ€‰โ€‰pK = g^{ab} \mod p
  • Foundation for TLS/SSLโ€”enables secure communication without prior key sharing, though vulnerable to man-in-the-middle attacks without authentication

Compare: Diffie-Hellman vs. ElGamalโ€”both rely on the discrete logarithm problem, but Diffie-Hellman is strictly for key exchange while ElGamal provides encryption and signatures. ElGamal essentially "encrypts with" a Diffie-Hellman shared secret.


Cryptographic Hash Functions

Hash functions map arbitrary-length inputs to fixed-length outputs. A secure hash must be preimage-resistant (can't find input from output), second preimage-resistant (can't find different input with same hash), and collision-resistant (can't find any two inputs with same hash).

SHA (Secure Hash Algorithm) Family

  • Fixed output sizesโ€”SHA-1 produces 160 bits (deprecated), SHA-256 produces 256 bits, SHA-3 uses different internal structure (Keccak sponge)
  • Collision resistance is criticalโ€”SHA-1 was broken in 2017; SHA-256 remains secure for all known attacks
  • Applications include Bitcoin mining (SHA-256), digital certificates, and data integrity verification

Digital Signature Schemes

Digital signatures provide authentication, integrity, and non-repudiation. The signer uses a private key to create a signature that anyone can verify using the corresponding public key.

Digital Signature Algorithm (DSA)

  • Discrete logarithm securityโ€”based on the hardness of computing xx from gxmodโ€‰โ€‰pg^x \mod p in a prime-order subgroup
  • Signature generation requires random kk for each signatureโ€”reusing kk completely breaks security
  • Standardized by NISTโ€”widely used in government and financial applications alongside RSA signatures

Compare: RSA signatures vs. DSAโ€”RSA signatures rely on factoring hardness while DSA relies on discrete logarithms. RSA can use the same keys for encryption and signing; DSA is signature-only. Both require careful implementation to avoid side-channel attacks.


Quick Reference Table

ConceptBest Examples
Integer factorization hardnessRSA
Discrete logarithm hardnessDiffie-Hellman, DSA, ElGamal
Elliptic curve discrete logECC
Symmetric block ciphers (secure)AES, Twofish
Symmetric block ciphers (legacy/broken)DES, Blowfish (64-bit block limitation)
Feistel network structureDES, Blowfish, Twofish
Substitution-permutation networkAES
Cryptographic hashingSHA-256, SHA-3

Self-Check Questions

  1. Both RSA and ElGamal are asymmetric encryption schemes. What mathematical hardness assumption does each rely on, and how does this affect their key generation processes?

  2. Compare AES and DES: What structural difference (beyond key length) distinguishes their internal operations, and why is AES considered more secure against modern cryptanalysis?

  3. If you need to establish a shared secret over an insecure channel without any prior key exchange, which algorithm would you use? What additional mechanism would you need to prevent man-in-the-middle attacks?

  4. ECC provides equivalent security to RSA with much smaller keys. Explain the mathematical reason for this efficiency advantage in terms of the best-known attacks against each hardness assumption.

  5. FRQ-style: A system uses SHA-1 for digital signatures and DES for encrypting session keys. Identify two specific vulnerabilities in this design and recommend replacement algorithms with justification.