Cryptography Complete Notes
Cryptography Complete Notes
Units Covered: 1 · 2 · 3 · 4 · 5
Includes: All Topics · Key Formulas · Examples · Exam Tips
Confidentiality
Only authorized users can access information
Password-protected files, encryption
Integrity
Data cannot be modified withoutBank
authorization
transaction records, digital signatures
Information
Availability
is accessible when needed by24×7
authorized
online users
banking, cloud services
■ Exam Tip: CIA Triad appears in 5-mark questions every year. Be able to define each with an example.
Trend Description
Cloud Security
Protecting data, apps and services hosted in cloud environments
AI in Security
Using ML/AI for threat detection, anomaly detection, automated response
Multi-Factor AuthenticationCombining
(MFA) passwords with OTPs, biometrics, tokens
Blockchain Security
Immutable, distributed ledger used in secure transactions
IT Act,
Covers
2000 cybercrimes, digital signatures, data protection, e-commerce legality
IT (Amendment)
Added Act,
cyber2008
terrorism, data theft, identity theft, Section 66A (later struck down)
Network Security
Data in transit, network infrastructure
Firewalls, VPNs, IDS/IPS, packet filtering
Application Security
Software and web applications
Authentication, secure coding, input validation
Organizational Security
Broad
Policy
policy covering entire organization
Corporate acceptable use policy
Issue-Specific SecurityFocuses
Policy on one specific security issue
Email security policy
System-Specific SecurityCovers
Policya specific technology/system
Firewall configuration policy
Passive Attacks
The attacker only monitors, observes, or reads data without altering it.
<b>Type</b> <b>Description</b>
Traffic
Analyzing
Analysispatterns of communication (frequency, timing, size) even if encrypted
• Characteristics: Very difficult to detect | Data is not altered | Goal is information theft
Active Attacks
The attacker modifies data, creates false data, or disrupts communication.
<b>Type</b> <b>Description</b>
Replay Attack
Captures and retransmits valid data to cause unauthorized effect
Non-Repudiation
Protection against denial of a previous action by sender/receiver
Availability
Ensuring systems work and services are accessible when needed
Security Mechanisms
Digital Signature
Proves authenticity and integrity – provides non-repudiation
Authentication Exchange
Protocols to verify identity (challenge-response, certificates)
Substitution Techniques
Characters in the plaintext are replaced by other characters according to a rule.
Caesar Cipher
The simplest substitution cipher. Each letter is shifted by a fixed number of positions in the alphabet.
Formula: C = (P + K) mod 26
Decryption: P = (C - K + 26) mod 26
• C = Ciphertext letter (as number 0-25)
• P = Plaintext letter (as number 0-25)
• K = Key (shift value)
Example: Plaintext = HELLO, Key (K) = 3
H(7)+3=10=K, E(4)+3=7=H, L(11)+3=14=O, L(11)+3=14=O, O(14)+3=17=R
Ciphertext = KHOOR
Monoalphabetic Cipher
Uses a single fixed substitution alphabet throughout the message. Every letter maps to a unique different letter.
More secure than Caesar but still breakable via frequency analysis.
Transposition Techniques
Substitution vs Transposition
<b>Aspect</b> <b>Substitution</b> <b>Transposition</b>
1.13 Steganography
Steganography is the practice of hiding secret information within ordinary, non-secret data or a physical object
to avoid detection. Unlike encryption which hides the content, steganography hides the very existence of the
message.
Steganography vs Encryption
<b>Feature</b> <b>Encryption</b> <b>Steganography</b>
Product Cryptosystem
Combines multiple basic encryption operations (substitution + transposition) in multiple rounds to achieve
stronger security. The combination makes the overall system much harder to break than individual components.
• Example: AES uses multiple rounds of SubBytes (substitution) + ShiftRows + MixColumns (diffusion)
■ Exam Tip: Confusion and Diffusion are key concepts – know their definitions and examples.
1.15 Cryptanalysis
Cryptanalysis is the science and art of breaking cryptographic systems without prior knowledge of the key. It is
essential for evaluating cryptographic strength.
Chosen Plaintext
Can(CPA)
choose plaintext & get ciphertext
Deduce key/algorithm Stronger
Chosen Ciphertext
Can(CCA)
choose ciphertext & get plaintext
Find key Strongest attacker
<b>Advantages</b> <b>Disadvantages</b>
Congruence
Two integers a and b are congruent modulo n if they leave the same remainder when divided by n.
a ≡ b (mod n) ■ n | (a - b)
• 17 ≡ 5 (mod 12) [both leave remainder 5 when divided by 12]
• 26 ≡ 0 (mod 13) [26 = 2×13 + 0]
• 38 ≡ 2 (mod 12) [38 = 3×12 + 2]
Ring
A set R with two operations (+ and ×) where:
• (R, +) is an abelian group
• Multiplication is associative: (a×b)×c = a×(b×c)
• Distributive laws hold: a×(b+c) = a×b + a×c
• Example: Integers Z form a ring under addition and multiplication
Field
A ring where every non-zero element has a multiplicative inverse. Fields support addition, subtraction,
multiplication, and division (by non-zero elements).
• Rational numbers Q
• Real numbers R
• Finite (Galois) Fields GF(p) – critical for AES
0+0=0 0×0=0
0+1=1 0×1=0
1+0=1 1×0=0
1 + 1 = 0 (mod 2) 1×1=1
■ Note: AES extensively uses GF(2^8) for its SubBytes and MixColumns operations.
Rounds 2 16
S-DES Components
• Key Generation: P10 permutation → split → LS-1 shifts → P8 gives K1; LS-2 shifts → P8 gives K2
• Encryption: Initial Permutation (IP) → fK1 (with K1) → Switch (SW) → fK2 (with K2) → IP■¹
• fK function: Expansion/Permutation (EP) → XOR with subkey → S-Boxes → P4 permutation
<b>Parameter</b> <b>Value</b>
Well-tested, proven design for its era Key size of 56 bits is too small
Linear Cryptanalysis
Introduced by Matsui (1993). A known plaintext attack that finds linear approximations between plaintext,
ciphertext and key bits.
P[i1,...] XOR C[j1,...] = K[k1,...] with probability p ≠ 1/2
• The larger the bias (|p - 0.5|), the more effective the attack
• Requires 2^43 known plaintexts to break DES
<b>Feature</b> <b>Differential</b> <b>Linear</b>
Data needed 2^47 chosen plaintexts for DES2^43 known plaintexts for DES
Confusion
Makes the relationship between the key and ciphertext as complex as possible. Achieved through substitution
(S-boxes).
Diffusion
Spreads the influence of a single plaintext bit or key bit across many ciphertext bits. Achieved through
permutation (P-boxes, ShiftRows, MixColumns).
• Large block size (e.g., 128 bits)
• Strong key schedule producing independent subkeys
• Multiple rounds (10+ rounds for AES)
• Non-linear S-boxes with good differential and linear resistance
• Efficient software and hardware implementations
CBC CipherEach
Block
block
Chaining
XORed with previous ciphertext before
Files,
encryption
databases
CFBBlock
Cipher
cipher
Feedback
used as a stream cipher; previous ciphertext
Real-time
feeds
data
encryption
streams
OFB Output
Keystream
Feedbackgenerated from IV chain; XORed
Noisy
withchannels
plaintext(satellite)
CTR Counter
Counter value encrypted to High-speed
generate keystream
networking, parallel processing
AES Specifications
<b>Parameter</b> <b>Value</b>
Key Sizes128 bits (10 rounds), 192 bits (12 rounds), 256 bits (14 rounds)
SubBytes
Each byte replaced using S-box lookupConfusion
table (non-linearity)
ShiftRows
Row i of state is cyclically shifted left by Diffusion
i bytes across columns
MixColumns
Each column multiplied by fixed polynomial inDiffusion
GF(2^8) across rows
AddRoundKey
State XORed with round key derived from master key
Key mixing
■ Note: The final round omits MixColumns. The first operation before rounds is AddRoundKey (initial key
whitening).
Rounds 16 10/12/14
<b>Feature</b> <b>Detail</b>
Physical Delivery
Key delivered in person or via courier
Impractical for remote parties
Trusted
Central
Third
Key
Party
Distribution
(KDC) Center generates & distributes
KDC is session
a single keys
point of failure
Public KeyUse
Assisted
PKI to encrypt and exchange symmetric
Requireskeys
public key infrastructure
Diffie-Hellman
Two parties derive shared secret
Vulnerable
over public
to man-in-the-middle
channel without authentication
Pre-shared Key (PSK)Keys agreed upon in advance Impractical for large scale
Key distribution
Hard (secure channel needed)
Easy (public key freely shared)
Key management
Complex (n² keys for n users)
Simple (2n keys for n users)
Primality Testing
Determining if a large number is prime is computationally important.
Integer Factorization
Expressing a composite number as a product of prime factors. The RSA Problem is that factoring n = p×q into
its prime factors p and q is computationally infeasible for large n.
n = p × q (easy to compute)
Given n, find p and q (computationally hard for large primes)
• 15 = 3 × 5
• 21 = 3 × 7
Euler's Theorem
Generalization of Fermat's theorem. If gcd(a, n) = 1:
a^φ(n) ≡ 1 (mod n)
Example: a=3, n=10, φ(10)=4: 3^4=81 ≡ 1 (mod 10) ✓
• This theorem directly proves the correctness of RSA encryption-decryption
Step
Compute
5 private exponent d: e×d ≡ 1 (mod
d=φ(n))
7 (3×7=21≡1 mod 20 ✓)
RSA Security
<b>Security Basis</b> <b>Detail</b>
Key Size RecommendationMinimum 2048 bits; 4096 bits for high security
Padding Required
RSA must use padding (OAEP) – raw RSA is textbook/deterministic
Vulnerabilities
Small e attacks, timing attacks, chosen ciphertext attacks if no padding
Key Generation
Create cryptographically strong keys using approved algorithms
Key Storage
Store securely (HSM – Hardware Security Module, encrypted key stores)
Key Use Use keys only for authorized purposes; monitor usage
Key Revocation
Invalidate compromised or expired keys via CRLs or OCSP
Agree on
1 public parameters: large prime p, generator g (1 < g p=23,
< p) g=5
Alice
2 chooses private key a, computes A = g^a mod
a=6,
p A=5^6 mod 23=8
Bob
3 chooses private key b, computes B = g^b mod
b=15,
p B=5^15 mod 23=19
■ Note: Attacker sees p, g, A=g^a mod p, and B=g^b mod p but cannot compute s without solving DLP.
• Advantage: Perfect forward secrecy (new key each session)
• Vulnerability: Susceptible to man-in-the-middle attack if A and B are not authenticated
ElGamal Encryption
• Public parameters: prime p, generator g
• Private key: x (random integer)
• Public key: y = g^x mod p
• Encryption of M: choose random k, compute C1 = g^k mod p, C2 = M × y^k mod p
• Ciphertext: (C1, C2)
• Decryption: M = C2 × C1^(-x) mod p
■ Note: ElGamal ciphertext is twice the size of the plaintext – a significant disadvantage.
■ Exam Tip: ElGamal vs DH: ElGamal provides encryption; DH provides key agreement only.
Point Addition
P + Q = R (reflection of third Using
intersection)
slope formula with mod p arithmetic
ECC Advantages
• Much smaller key sizes → less storage and bandwidth
• Faster computations → ideal for mobile/IoT devices
• Lower power consumption → important for battery-powered devices
• Used in TLS 1.3, Bitcoin/blockchain, signal protocol
4.1 Introduction
Message Authentication ensures a message comes from a legitimate sender and has not been altered. Integrity
ensures data has not been modified. These are separate from confidentiality – an encrypted message can still
be modified!
Authentication Requirements
<b>Requirement</b> <b>Description</b>
Message Integrity
Assurance that the message has not been modified since sending
MAC Process
• Sender computes: MAC = C(K, M) and sends (M, MAC)
• Receiver receives (M', MAC')
• Receiver independently computes: MAC* = C(K, M')
• If MAC* = MAC' → message authentic and unmodified
• If MAC* ≠ MAC' → message was tampered with or key is wrong
Pre-image Resistance
Given h, infeasible to find M such that H(M)=h
Reveal original message
Avalanche
Small change
Effect
in input causes large change in output Linear
(≈50% cryptanalysis
bits flip)
<b>Algorithm</b>
<b>Output Size</b>
<b>Block Size</b>
<b>Rounds</b> <b>Status</b>
■ Exam Tip: Know SHA-256 output size (256 bits) and SHA-1 (160 bits). SHA-1 is deprecated.
SHA-256 Applications
• TLS/HTTPS certificates and handshakes
• Bitcoin and cryptocurrency transactions
• Code signing and software integrity
• Password hashing (with salt)
• Git version control (commit hashes)
Non-repudiation No Yes
DSA Parameters
• p: large prime (1024-3072 bits)
• q: prime factor of (p-1), 160-256 bits
• g: generator of subgroup of order q
• x: private key (random integer < q)
• y = g^x mod p: public key
DSS Applications
• E-government systems and digital contracts
• Electronic banking and financial transactions
• Code signing for software distribution
• Email signing (S/MIME)
Biometric Authentication
Uses unique biological or behavioral characteristics.
Physiological
Fingerprint, iris scan, face recognition, hand geometry
High
Behavioral
Keystroke dynamics, voice recognition, signature dynamics
Medium
Password Authentication
<b>Type</b> <b>Description</b> <b>Security</b>
One-Time Password
New password
(OTP) for each login (SMS, authenticator app)
High
Challenge-Response Protocol
Server sends a random challenge (nonce); client responds with a value derived from the challenge using the
secret key or password. Password is never transmitted.
• Server sends random challenge C to client
• Client computes response R = H(password || C) or E(Kprivate, C)
• Server independently computes expected R
• If they match: authentication success
4.8 Kerberos
Kerberos is a network authentication protocol based on symmetric key cryptography and a trusted third party.
Developed at MIT in 1988 as part of Project Athena. Provides Single Sign-On (SSO).
Kerberos Architecture
<b>Component</b> <b>Role</b>
Authentication Server
Verifies
(AS) user identity and issues Ticket Granting Ticket (TGT)
Ticket Granting Server (TGS) Issues service tickets based on valid TGT
Signature Algorithm
Algorithm used to sign the certificate (e.g., SHA256withRSA)
Extensions (V3)
Key usage, Subject Alternative Names, CRL Distribution Points
PGP Services
<b>Service</b> <b>Mechanism Used</b>
Confidentiality
CAST-128/AES encryption with session key; RSA encrypts session key
S/MIME Services
• Enveloped Data (Encryption) – Message encrypted with session key; session key encrypted for each recipient
• Signed Data – Message signed with sender's private key
PGP vs S/MIME
<b>Feature</b> <b>PGP</b> <b>S/MIME</b>
IPSec Services
• Data Origin Authentication – Verify packets come from claimed source
• Data Integrity – Detect any modification of packets
• Confidentiality – Encrypt packet contents
• Anti-Replay – Prevent replay of captured packets (using sequence numbers)
• Access Control – Filter IP traffic based on policies
IPSec Protocols
Authentication Header (AH)
<b>AH Property</b> <b>Detail</b>
Protocol Number 51
Protocol Number 50
IPSec Modes
Transport Mode
Payload only (data); IP header visible
Host-to-host communication No
Tunnel Entire
Mode original IP packet (header + payload)
VPNs, gateway-to-gateway
Yes (new IP header added)
Phishing
Fake website mimics legitimate site to steal
User
credentials
awareness, 2FA, HTTPS
SQL Injection
Malicious SQL input manipulates database
Prepared
queries
statements, input validation
Cross-Site
Injects
Scripting
malicious
(XSS)scripts into web pages viewed
Input
bysanitization,
other users CSP headers
Tricks
CSRF
user into executing unwanted actions on
CSRF
authenticated
tokens, SameSite
site cookies
SessionSteals
Hijacking
session cookie to impersonateSecure
authenticated
cookies,
user
HTTPS, session expiry
Clickjacking
Tricks user into clicking hidden malicious elements
X-Frame-Options, CSP
Directory Traversal
Accesses files outside web root via ../
Input
sequences
validation, web server config
SSL/TLS
SSL (Secure Sockets Layer) and its successor TLS (Transport Layer Security) are the cryptographic protocols
that secure HTTPS connections. TLS 1.3 (2018) is the current standard.
Key Exchange
ECDHE or DHE (Elliptic Curve or regular Diffie-Hellman Ephemeral)
Types of Intruders
<b>Type</b> <b>Definition</b> <b>Example</b>
Masquerader
Outside attacker who impersonates a legitimate
Using stolen
user credentials to log in
Misfeasor
Authorized user who misuses their
Employee
privileges
accessing unauthorized HR files
Clandestine
Gains
User
supervisory/admin control to evade
Privilege
logging
escalation to root/admin
Host-Based
Individual
(HIDS)host: system calls, file changes,
Detailed
logs
host-level Overhead
visibility on host; agent needed per system
Network-Based (NIDS)
Network traffic across segments
No host overhead; wide coverage
Cannot see encrypted payloads
Types of Malware
<b>Type</b> <b>Description</b> <b>Propagation</b>
Attaches
Virus
to programs; executes when host runs; may
Host
corrupt
program
files execution
Self-replicating;
Worm spreads across networks without
Network
user action
vulnerabilities, email
Trojan
AppearsHorse
legitimate; performs malicious actions hidden
User downloads/installs
inside
Ransomware
Encrypts user files; demands payment for decryption
Phishing,
key vulnerabilities
Displays
Adware unwanted advertisements; may redirectFree
browser
software bundles
Hides
Rootkitmalware and attacker activity at OS/firmware
Privilege
level escalation
Keylogger
Records all keystrokes to capture passwords
Remote access trojan
Network
Botnet of compromised machines controlled by attacker
Various malware
Execution
Payload executes: deletes files, encrypts data, displays messages
Types of Viruses
<b>Type</b> <b>Target</b> <b>Example</b>
Boot SectorMaster
Virus Boot Record or Volume Boot Record
Stoned, Michelangelo
Macro Virus
Documents with macro support (Word, Excel)
Melissa, Concept
Polymorphic
Changes its
Virus
own code each time to evade signature detection
Storm Worm
Metamorphic Completely
Virus rewrites itself each generation Win32/Simile
Network Virus
Spreads via network shares and protocols Nimda
5.9 Firewalls
A firewall is a network security device (hardware, software, or both) that monitors and controls network traffic
based on predefined security rules. It establishes a barrier between trusted internal networks and untrusted
external networks.
Firewall Functions
• Packet Filtering – Allow or block packets based on IP, port, protocol
• Stateful Inspection – Track active connections; only allow valid responses
• Application Control – Allow/block based on application type
• Logging and Monitoring – Record all traffic decisions for audit
• NAT (Network Address Translation) – Hide internal IP addresses
Types of Firewalls
<b>Type</b> <b>Layer</b> <b>How it Works</b> <b>Advantage</b> <b>Limitation</b>
Stateful Inspection
Tracks
Transport
connection
(L4) state table; validates response
Better than
packets
packet filtering
Limited application awareness
Firewall Limitations
• Cannot prevent attacks originating from inside the network
• Cannot inspect encrypted traffic without SSL/TLS interception
• Does not protect against malware in allowed traffic
• Social engineering attacks bypass firewalls entirely
• Misconfiguration is a major risk – overly permissive rules