UNIT 1: FUNDAMENTALS OF CRYPTOGRAPHY - EXAM-FOCUSED SHORT NOTES
I. INTRODUCTION & FOUNDATIONAL CONCEPTS
Security Goals & Services
| Goal | Purpose | Example |
|---|---|---|
| Confidentiality | Prevent unauthorized access to data. | Encryption. |
| Integrity | Detect unauthorized data modification. | Hash functions, MACs. |
| Authentication | Verify identity (Entity) or data origin (Data Origin). | Digital signatures, MACs. |
| Non-repudiation | Prevent sender from denying a sent message. | Digital signatures. |
| Authorization | Grant access rights to resources. | Access control lists (post-authentication). |
[!TIP] Exam Distinction: Authentication (Who/What sent it?) is different from Authorization (What are they allowed to do?). AuthN comes before AuthZ.
Basic Terminology
-
Plaintext (P): Original readable message.
-
Ciphertext (C): Encrypted, unreadable message.
-
Encryption: Process
C = E(K, P)converting P to C using keyK. -
Decryption: Process
P = D(K, C)recovering P from C. -
Cipher: The algorithm for encryption/decryption.
-
Key: Secret parameter controlling cipher operation.
-
Cryptography: Design of cryptographic systems (secure communication).
-
Cryptanalysis: Breaking/analyzing cryptographic systems.
-
Cryptology: Unified field of cryptography + cryptanalysis.
Classification of Security Attacks
| Attack Type | Nature | Goal | Example |
|---|---|---|---|
| Passive | Eavesdropping, monitoring. | Learn/use information. | Traffic analysis, snooping. |
| Active | Modifying, injecting data. | Alter system operation. | Replay, MITM, DoS. |
Specific Attacks:
-
Brute Force Attack: Try all possible keys. Key defense: Large key space.
-
Cryptanalysis: Exploit algorithmic weaknesses (e.g., frequency analysis on Caesar).
-
Man-in-the-Middle (MITM): Attacker intercepts & relays/modifies communication between two parties. Critical vulnerability in unauthenticated key exchange (like basic DH).
Fundamental Principles
-
Kerckhoffs's Principle: A cryptosystem should be secure even if everything about the system, except the key, is public knowledge. Security must rely solely on the key's secrecy.
-
Perfect Secrecy (Shannon): Ciphertext gives no information about the plaintext.
-
Characterization:
H(P|C) = H(P)(Conditional entropy of P given C equals unconditional entropy of P). -
Requirements (One-Time Pad - OTP):
-
Key space size ≥ Message space size.
-
Key is truly random.
-
Key is used exactly once.
-
-
Practical Limitation: Key distribution & management nightmare for long messages.
-
-
Computational Secrecy: Security based on the computational infeasibility of breaking the cipher with bounded resources (time/memory). Modern cryptography (AES, RSA) achieves this, not perfect secrecy.
Pseudorandomness (PRGs)
-
Pseudorandom Generator (PRG): A deterministic algorithm
Gthat stretches a short, random seedsinto a long pseudorandom stringG(s)that "looks random" to any efficient adversary. -
Properties: Unpredictability, Indistinguishability from true random.
-
Applications (Exam Focus):
-
Key Generation: Generating long session keys from a short master key.
-
Stream Ciphers:
C = P ⊕ G(k)(practical OTP variant). Security relies on PRG strength. -
Salt Generation: For password hashing.
-
II. CLASSICAL CRYPTOGRAPHY (Historical Context)
Substitution Ciphers
| Cipher | Mechanism | Security | Example |
|---|---|---|---|
| Caesar | Shift each letter by fixed k (mod 26). |
Very Weak. Only 25 keys. Broken by brute force/frequency analysis. | A→D (shift 3). |
| Monoalphabetic | Random permutation of alphabet. | Weak. 26! keys, but preserves letter frequencies. Broken by frequency analysis. | A→Q, B→M, ... |
| Polyalphabetic (Vigenère) | Multiple Caesar shifts based on keyword. | Stronger. Hides frequencies. Vulnerable to Kasiski/Index of Coincidence to find keyword length. | Key LEMON: A+L, B+E, C+M, ... |
Transposition Ciphers
-
Rail Fence: Write plaintext in zigzag across "rails", read row-by-row.
- Example:
WE ARE DISCOVERED. FLEE AT ONCE→WECRL TEERD SOEEF EAOCA IVDEN.
- Example:
-
Columnar Transposition:
-
Write plaintext in rows of fixed length (key length).
-
Permute columns based on keyword order.
-
Read ciphertext column-by-column (in permuted order).
-
Polygraphic Substitution Ciphers
-
Playfair Cipher (Digraph):
-
Rules: Same letter in digraph → insert filler (e.g.,
X). Same row → shift right. Same column → shift down. Different row/col → rectangle corners. -
Example: Plaintext
BALLOON→ DigraphsBA LX LO ON. Encrypt using 5x5 matrix (I/J merged).
-
-
Hill Cipher (Matrix-based):
-
C = (K * P) mod 26whereKis invertiblem x mmatrix,Pis plaintext vector. -
Vulnerability: Susceptible to known-plaintext attack. If attacker gets
mplaintext-ciphertext pairs, can solve forK.
-
III. SYMMETRIC-KEY CRYPTOGRAPHY (Secret Key)
Stream Ciphers
-
One-Time Pad (OTP):
C_i = P_i ⊕ K_i.-
Achieves Perfect Secrecy if
Kis truly random, same length asP, and never reused. -
Practical Limitation: Key distribution & storage for large data.
-
-
Types:
-
Synchronous: Keystream generated independently of plaintext/ciphertext. Sync loss is catastrophic.
-
Self-Synchronizing: Keystream depends on previous
nciphertext bits. Automatically resynchronizes.
-
Block Ciphers
-
Definition: Operates on fixed-size blocks (e.g., 64-bit DES, 128-bit AES) using a key.
-
Design Principles:
-
Confusion: Make relationship between key and ciphertext complex (Substitution).
-
Diffusion: Spread plaintext statistics over ciphertext (Permutation/Transposition).
-
-
Structure: Multiple rounds of confusion/diffusion operations.
Data Encryption Standard (DES)
-
Block Size: 64 bits. Key Size: 56 bits (effective, +8 parity).
-
Structure: Feistel Network.
-
Encryption & Decryption use same structure (just reverse key schedule).
-
Key Schedule: 56-bit key → 16 subkeys (48-bit each).
-
-
Weaknesses: Small key size (brute-force feasible with specialized hardware). Triple-DES (3DES) was a stopgap (apply DES 3 times with 2/3 keys).
Advanced Encryption Standard (AES)
-
Block Size: 128 bits. Key Sizes: 128, 192, 256 bits (10, 12, 14 rounds respectively).
-
Structure: Substitution-Permutation Network (SPN), not Feistel.
-
Encryption Rounds (per block):
-
AddRoundKey: XOR state with round key.
-
SubBytes: Non-linear substitution (S-box).
-
ShiftRows: Cyclic shift rows (diffusion).
-
MixColumns: Mix columns (diffusion) – omitted in last round.
-
-
Decryption: Inverse operations in reverse order (InvSubBytes, InvShiftRows, InvMixColumns, AddRoundKey).
AES vs. DES Comparison
| Feature | DES | AES |
|---|---|---|
| Block Size | 64 bits | 128 bits |
| Key Size | 56 bits | 128/192/256 bits |
| Structure | Feistel Network | Substitution-Permutation Network |
| Design | Confusion & Diffusion (Feistel) | Full confusion & diffusion per round |
| Security | Broken (brute-force) | Considered secure (no practical attacks) |
| Performance | Slower in software | Fast in software & hardware |
Modes of Operation for Block Ciphers
-
Purpose: Encrypt data longer than block size & provide semantic security (ciphertexts should look random, no patterns).
-
Electronic Codebook (ECB):
-
Operation:
C_i = E(K, P_i). Each block encrypted independently. -
Diagram:
DiagramCANVAS: Draw two identical plaintext blocks P1 and P2. Show both going into E(K) box separately, producing identical ciphertext blocks C1 and C2. -
MAJOR DRAWBACK: Pattern preservation. Identical plaintext blocks → identical ciphertext blocks. Completely insecure for multi-block messages. Never use for more than one block.
-
-
Cipher Block Chaining (CBC):
-
C_i = E(K, P_i ⊕ C_{i-1}), withC_0 = IV(random, non-secret). -
Provides diffusion across blocks. Requires padding for non-multiple-of-block-size messages.
-
-
Counter (CTR) Mode:
-
C_i = P_i ⊕ E(K, Nonce || Counter). -
Turns block cipher into stream cipher. Parallelizable encryption/decryption. No padding needed.
-
Message Authentication
-
Need: To verify integrity (message not altered) and data origin (who sent it). Separate from encryption.
-
Message Authentication Code (MAC):
-
T = MAC(K, M)generates a fixed-length tagT. -
Secure MAC Property: Unforgeability. Adversary cannot produce valid
(M, T)for newMeven after seeing tags for chosen messages. -
Construction from Block Cipher: CBC-MAC (use CBC with final block as tag, fixed IV=0). Secure for fixed-length messages.
-
-
Authenticated Encryption (AE): Combines confidentiality (encryption) + integrity/authentication (MAC) in a single, efficient, secure primitive. Examples: AES-GCM, ChaCha20-Poly1305.
IV. PUBLIC-KEY CRYPTOGRAPHY (Asymmetric)
Core Concepts & Comparison
| Aspect | Symmetric Key | Public Key |
|---|---|---|
| Keys | Single shared secret key. | Key pair: Public (K_pub) & Private (K_priv). |
| Purpose | Bulk data encryption/decryption. | Key exchange, digital signatures, encryption of small data (like keys). |
| Scalability | O(n) keys for n users (pairwise). |
O(n) keys total (each user has one pair). |
| Speed | Very fast (hardware/software). | Slow (orders of magnitude slower). |
-
One-Way Function: Easy to compute
f(x), hard to invertf^{-1}(y).- Example: Multiplication (
x*y) vs. Factoring (n→x,y).
- Example: Multiplication (
-
Trapdoor One-Way Function: One-way function with a secret trapdoor making inversion easy.
- Example (RSA):
f(x)=x^e mod nis easy. Inversion (e-th root modn) is hard unless you knowφ(n)(the trapdoor from factoringn=pq).
- Example (RSA):
Mathematical Foundations
-
Modular Arithmetic:
-
a ≡ b mod n⇔n | (a-b). -
Modular Inverse:
a^{-1}such thata * a^{-1} ≡ 1 mod n. Exists iffgcd(a,n)=1. Computed via Extended Euclidean Algorithm.
-
-
Fermat's Little Theorem: If
pprime &anot divisible byp, thena^{p-1} ≡ 1 mod p. -
Euler's Theorem: If
gcd(a,n)=1, thena^{φ(n)} ≡ 1 mod n. (φ(n)= Euler's totient). -
Computational Hard Problems:
-
Integer Factorization Problem (IFP): Given
n = p*q(large primes), findp,q. Basis for RSA. -
Discrete Logarithm Problem (DLP): Given
g, g^x mod p, findx. Basis for DH, DSA, ElGamal. -
Elliptic Curve DLP (ECDLP): Given points
P, Qon elliptic curveEwhereQ = x*P(scalar multiplication), findx. Basis for ECC. Much harder per bit → smaller keys.
-
Key Public-Key Algorithms
Diffie-Hellman Key Exchange (DHKE)
-
Problem: Establish shared secret
Kover insecure channel. -
Steps (with example
p=23, g=5):-
Public Parameters: Agree on prime
pand generatorg(ofZ_p^*). -
Alice: Chooses private
a(e.g.,6). ComputesA = g^a mod p = 5^6 mod 23 = 8. SendsA. -
Bob: Chooses private
b(e.g.,15). ComputesB = g^b mod p = 5^15 mod 23 = 19. SendsB. -
Shared Secret:
K = B^a mod p = 19^6 mod 23 = 2(Alice).K = A^b mod p = 8^15 mod 23 = 2(Bob).
-
-
Security: Relies on Computational Diffie-Hellman (CDH) assumption. Hard to compute
g^{ab}fromg^a, g^b. -
Key Exchange Problem & MITM Attack:
-
Problem: No authentication. Attacker
Mcan interceptAandB, establish separate keys with Alice and Bob. -
MITM Steps:
-
Alice →
A→ M →A'→ Bob. -
Bob →
B→ M →B'→ Alice. -
M computes
K_AM = (A')^a,K_MB = (B')^b. -
M decrypts/re-encrypts all traffic between Alice & Bob.
-
-
Defense: Use authenticated DH (sign parameters with digital signatures) or use protocols like STS.
-
RSA Algorithm
-
Key Generation:
-
Choose large primes
p, q. Computen = p*q,φ(n) = (p-1)(q-1). -
Choose
esuch that1 < e < φ(n)andgcd(e, φ(n)) = 1. -
Compute
d = e^{-1} mod φ(n)(using Extended Euclid). -
Public Key:
(e, n). Private Key:(d, n).
-
-
Encryption:
C = M^e mod n(for messageM < n). -
Decryption:
M = C^d mod n. -
Worked Example (Dec 2023):
p=5, q=11, e=3, M=9-
n = 55,φ(n)=40. -
d = 3^{-1} mod 40 = 27(since3*27=81 ≡ 1 mod 40). -
C = 9^3 mod 55 = 729 mod 55 = 14. -
M = 14^{27} mod 55. (Compute via successive squaring:14^2=196≡31, 14^4≡31^2≡961≡26, ...→ Result: 9).
-
-
Security Basis: Integer Factorization Problem. If you can factor
n, you getφ(n)and computed. -
Disadvantages/Limitations:
-
Slow (modular exponentiation).
-
Vulnerable to chosen-ciphertext attacks (e.g., Bleichenbacher).
-
No forward secrecy (if private key compromised, all past ciphertexts decryptable).
-
Requires large keys (2048+ bits) for security.
-
Elliptic Curve Cryptography (ECC)
-
Basic Concept: Points
(x,y)on curvey^2 = x^3 + ax + bover finite fieldF_p. -
ECDLP: Given
P, Q=x*P(scalar multiplication), findx. Harder than classic DLP → smaller keys (256-bit ECC ≈ 3072-bit RSA). -
Encryption/Key Exchange (ECIES/ECDH - High-level):
-
ECDH: Analogous to DH. Private key is integer
d, public key isQ = d*G(base pointG). Shared secret:S = d_A * Q_B = d_B * Q_A. -
EC Encryption: To encrypt
Mfor recipient with public keyQ:-
Generate random
k. -
Compute
R = k*G,S = k*Q. -
Ciphertext =
(R, M ⊕ H(S))(whereHis hash).
-
-
-
Advantage: Smaller key sizes, faster computations for equivalent security.
Digital Signatures
-
Purpose: Provide Authentication, Integrity, Non-repudiation.
-
Process:
Sig = Sign(K_priv, M). VerifyVerify(K_pub, M, Sig). -
RSA Digital Signature:
Sig = M^d mod n. Verify:Sig^e mod n == M. -
Digital Signature Standard (DSS/DSA):
-
Based on DLP.
-
Signing: Uses private key + random
k.r = (g^k mod p) mod q,s = (H(M) + x*r) * k^{-1} mod q. -
Verification: Uses public key. Checks
v == rwherevcomputed from(r,s)andH(M).
-
-
Authentication via Signatures: Receiver verifies signature using sender's public key. Only sender's private key could have produced valid signature → authenticates sender.
Hybrid Cryptosystems & SSL/TLS
-
Concept: Use asymmetric crypto to securely exchange a symmetric session key, then use symmetric crypto for bulk data encryption.
-
SSL/TLS Handshake (Simplified):
-
Negotiate cipher suite.
-
Authenticate Server (via certificate with public key).
-
Key Exchange: Client generates premaster secret, encrypts with server's public key (RSA) or uses authenticated DH (DHE/ECDHE).
-
Both derive symmetric session keys from premaster secret.
-
Secure Communication: Symmetric encryption (AES) + MAC (HMAC) for records.
-
-
TLS vs SSL: TLS is the modern, secure successor to SSL (SSL 3.0 is deprecated).
V. HASH FUNCTIONS
Definition & Properties
-
Hash Function
H: Maps arbitrary-length inputMto fixed-length outputh = H(M)(message digest/hash). -
Cryptographic Properties:
-
Pre-image Resistance (One-way): Given
h, hard to find anyMsuch thatH(M)=h. -
Second Pre-image Resistance: Given
M1, hard to findM2 ≠ M1withH(M1)=H(M2). -
Collision Resistance: Hard to find any pair
(M1, M2)withH(M1)=H(M2).
-
-
Important:
H(M)is not reversible (unlike encryption).
Applications
-
Data Integrity: Compare hashes before/after transmission.
-
Password Storage: Store
H(salt || password)instead of plaintext. Salt prevents rainbow table attacks. -
Digital Signatures: Sign
H(M)notM(efficient, handles long messages). -
Message Authentication: HMAC =
H(K ⊕ opad || H(K ⊕ ipad || M)). Construction using hash function.
Hash Function Constructions
-
Merkle-Damgård Construction: (Used in MD5, SHA-1, SHA-2)
-
Pad message to multiple of block size.
-
Process blocks sequentially with compression function
f:h_i = f(h_{i-1}, block_i). -
Final
h_nis hash.
- Vulnerable to length extension attacks.
-
-
Davies-Meyer Construction: Build compression function
ffrom block cipherE.-
f(h_i, m_i) = E(m_i, h_i) ⊕ h_i. -
Used in many SHA variants.
-
Birthday Attack
-
Principle: Based on Birthday Paradox. In a set of ~
√Nrandomly chosen elements from a space of sizeN, probability of a collision is ~50%. -
Implication for Hash Functions:
-
To find a collision for an
n-bit hash (output spaceN=2^n), effort ≈2^{n/2}. -
Example: For
n=128bits, collision requires ~2^{64}operations (feasible with massive resources). Hence, 128-bit hash is not collision-resistant long-term. Use 256+ bits (e.g., SHA-256,2^{128}effort).
-
-
Attack Scenario: Attacker generates many
M_i, computesH(M_i), looks for two with same hash. Can create two documents with same hash (e.g., benign contract vs. fraudulent one).
VI. ADVANCED TOPICS & PROTOCOLS (From Specific Exam Questions)
Random Oracle Model (ROM)
-
Concept: An idealized model where a hash function is treated as a true random function accessible to all parties (the "oracle").
-
Use: Provides a framework for provable security of cryptographic schemes. A scheme secure in ROM is "secure assuming hash functions are ideal."
-
Caveat: Real hash functions are not random oracles, but ROM proofs give strong heuristic confidence.
Interactive Protocols in Cryptography
-
Concept: Multi-round communication where prover convinces verifier of a statement without revealing the secret (Zero-Knowledge Proof - ZKP).
-
Example: Feige-Fiat-Shamir (based on modular square roots). Prover knows
ssuch thatv = s^2 mod n. Proves knowledge ofswithout revealing it. -
Applications: Authentication, e-voting, blockchain (zk-SNARKs).
Transport Layer Security (TLS)
-
Purpose: Provide secure communication over networks (HTTPS).
-
Layers:
-
Record Layer: Provides symmetric encryption & integrity (using session keys).
-
Handshake Protocol: Authenticates server (and optionally client), negotiates cipher suite, performs key exchange (RSA or DHE/ECDHE for forward secrecy).
-
-
Key Evolution from SSL: TLS 1.2/1.3 are current. TLS 1.3 removed insecure features, mandates forward secrecy (ECDHE), and streamlined handshake (1-RTT).
[!TIP] Exam-Winning Strategy:
- Definitions First: Always start with crisp definitions (Perfect Secrecy, MAC, One-way function).
- Diagrams for ECB/Modes: Be ready to draw ECB's pattern flaw and contrast with CBC/CTR.
- Numerical Problems: Practice RSA (key gen, enc, dec) and DH small-number examples (
p=23, g=5). Show all steps.
- Compare & Contrast: AES vs DES, Symmetric vs Asymmetric, ECB vs CBC. Tables are gold.
- Attack Scenarios: Explain MITM on DH and why ECB fails with a simple 2-block example.
- Formulas: Box key ones: Shannon's
H(P|C)=H(P), RSAd=e^{-1} mod φ(n), Birthday complexity2^{n/2}.