MODULE 1
MODULE I: INTRODUCTION TO CRYPTOGRAPHY & NETWORK
SECURITY
What is Security?
• Computer Security: A collection of tools and measures to protect data and prevent
unauthorized access, misuse, or damage by hackers.
• Network Security: Protection of data while it is transmitted over networks.
• Internet Security: Measures to safeguard data over interconnected global networks
like the internet.
Model for Network Security
Basic Elements of the Model
• Sender: The party sending the message.
• Recipient: The party receiving the message.
• Information Channel: The communication path (e.g., via the internet).
• Opponent (Attacker): Someone who tries to interfere with or eavesdrop on the
communication.
• Security-related Transformations:
1. Encryption: Converts the message to an unreadable form.
2. Message Authentication Code (MAC): A code added to verify the sender's
identity.
• Secret Information:
Shared secret (like a key) known to both sender and receiver, but not to the
opponent.
• Trusted Third Party:
o Helps distribute secret keys securely.
o Can settle disputes about message authenticity.
MODULE 1
Four Basic Security Tasks
To design a security service, we must:
1. Design a strong transformation algorithm that opponents can't easily defeat.
2. Generate secret information (keys) for use with the algorithm.
3. Develop secure methods for key distribution and sharing.
4. Specify communication protocols for the sender and receiver to follow.
Network Access Security Model
MODULE 1
Basic Elements of the Model
• Opponent (Attacker):
Can be either:
• Human (like a hacker)
• Software (like a virus, worm, or malicious program)
• Access Channel:
The medium or method through which an attacker tries to access the system.
• Gatekeeper Functions:
The first line of defense, which includes:
• Password-based login systems
• Screening software to detect and block malware
• Internal Security Controls:
The second line of defense that:
• Monitors system activity
• Detects intrusions
• Analyses stored data for irregular behaviour
What is Symmetric Encryption?
A symmetric encryption scheme uses the same secret key for both encryption and
decryption of messages.
Five Key Ingredients of Symmetric Encryption
MODULE 1
1. Plaintext
The original, readable message or data to be encrypted.
2. Encryption Algorithm
The process that scrambles the plaintext into ciphertext by performing various
transformations.
3. Secret Key (K)
A value shared between sender and receiver, independent of the plaintext and the
algorithm, used to encrypt and decrypt the message.
4. Ciphertext
The scrambled, unreadable version of the message after encryption. Depends on both
the plaintext and secret key.
5. Decryption Algorithm
The reverse of the encryption algorithm. It takes the ciphertext and the secret key to
recover the original plaintext.
• Encryption: Y = E(K, X)
• Decryption: X = D(K, Y)
Requirements for Secure Symmetric Encryption
1. Strong Encryption Algorithm
Should be tough enough that an attacker cannot decipher the message even with
multiple ciphertexts.
2. Secure Key Exchange and Storage
o Sender and receiver must share the secret key safely and securely.
o If an attacker gets the key, all communication becomes vulnerable.
Symmetric Cryptosystem Model
Component Description
Message Source Produces plaintext message X
Encryption Algorithm Uses key K to convert plaintext into ciphertext
Decryption Algorithm Uses same key K to convert ciphertext back to plaintext
Key Source Generates and securely delivers the key
Cryptanalyst (Attacker) Tries to guess the key or plaintext
• Y = E (K, X)
• X = D (K, Y)
MODULE 1
Characteristics of Cryptographic System
Three Dimensions of Cryptographic Systems
Type of Operations Used
• Substitution: Replace each element in the plaintext (letter, bit, or group) with another
element.
• Transposition: Rearrange the elements of the plaintext.
• Most real-world systems use a combination of both — called product systems.
Number of Keys Used
• Symmetric (Single-Key/Secret-Key/Conventional Encryption):
Same key for both encryption and decryption.
• Asymmetric (Two-Key/Public-Key Encryption):
Different keys for encryption and decryption (public key for encryption, private key
for decryption).
Processing of Plaintext
MODULE 1
• Block Cipher:
Processes fixed-size blocks of data at a time (e.g. 64 bits or 128 bits).
• Stream Cipher:
Encrypts data one bit or one byte at a time in a continuous stream.
Attacking Cryptosystems
The goal is usually to recover the key rather than just one message.
Two Main Types of Attacks
Cryptanalysis (Analytical Attack)
• Uses knowledge of:
➢ The algorithm.
➢ General characteristics of plaintext.
➢ Some plaintext–ciphertext pairs.
• Tries to deduce either:
➢ The plaintext.
➢ Or the encryption key.
Example: Guessing frequent letters like 'E' in English text.
Brute-Force Attack
➢ Tries every possible key until the correct one is found.
➢ On average, half of the possible keys need to be tested before success.
➢ Impractical if the key space is very large (e.g., 128-bit keys).
MODULE 1
Three Characteristics of Cryptographic Systems
1. Type of operations used: Substitution (replacing elements) and transposition
(reordering elements).
2. Number of keys used:
o Symmetric (single key): Same key for encryption & decryption.
o Asymmetric (two keys): Different keys for encryption & decryption.
3. How plaintext is processed:
o Block ciphers: Process fixed-size blocks.
o Stream ciphers: Process data continuously.
Cryptanalysis vs Brute-force
• Cryptanalysis: Exploits algorithm weaknesses or known patterns.
• Brute-force attack: Tries all possible keys until the correct one is found.
Substitution Techniques
• Replace elements of plaintext with ciphertext using a systematic rule.
• Caesar Cipher: Shifts each letter by a fixed number (like 3 positions).
o Encryption:
C=(p+k) mod 26C = (p + k) \mod 26C=(p+k) mod26
o Decryption:
p=(C−k) mod 26p = (C - k) \mod 26p=(C−k) mod26
• Vulnerability: Easy to break with brute-force since only 25 possible shifts exist.
MODULE 1
Monoalphabetic Substitution
• Instead of shifting, letters are substituted using a random arrangement (permutation)
of the alphabet.
• Example:
o Plain: a b c d e
o Cipher: X P Q A J
• Total possible keys = 26! (factorial of 26) ≈ 4 × 10²⁶
(much stronger than Caesar)
Problem: Still vulnerable to frequency analysis because some letters appear more often than
others in English (like ‘e’, ‘t’, ‘a’).
MODULE 1
What is the Playfair Cipher?
It’s a type of substitution cipher that:
➢ Encrypts two letters at a time (called digrams).
➢ Uses a 5×5 matrix of letters made from a keyword.
How to Make the Matrix:
1. Pick a keyword (like monarchy).
2. Write the keyword into a 5×5 grid, skipping any repeating letters.
3. Fill the rest of the grid with the remaining letters of the alphabet.
➢ I and J are considered the same.
Encryption Rules:
1. Same Letter Pair
If a pair has the same letters (like ‘ee’), insert an X between them.
Example: balloon → ba lx lo on
2. Same Row
Replace each letter with the letter to its right (move around if at the end).
Example: AR → RM
3. Same Column
Replace each letter with the one below it (move up if at the bottom).
Example: MU → CM
4. Different Row & Column
Form a rectangle — each letter is replaced by the letter in the same row but in the
other letter’s column.
Example:
➢ BP → find B and P, then swap columns → CM
MODULE 1
Notes:
• Encrypts 2 letters at a time
• Harder to break than simple ciphers (like Caesar)
• Total possible digrams = 26 × 26 = 676 combinations
• I and J are treated as the same letter
Hill Cipher (Uses Matrices & Math)
• Encrypts multiple letters (e.g., 2 or 3 at a time) using matrix multiplication.
• Assigns numbers to letters: a=0, b=1, … z=25
• Example:
➢ Plaintext: 'hi' → (7, 8)
➢ Key Matrix:
Step 1: Convert Letters to Numbers
Assign numbers to letters:
A = 0, B = 1, C = 2, ..., Z = 25
Example: "CAT" → (C=2, A=0, T=19) → (2, 0, 19)
Step 2: Choose a 3×3 Key Matrix (K)
simple key matrix for demonstration:
Step 3: Multiply the Plaintext Vector (P) by Key Matrix (K)
Using matrix multiplication:
MODULE 1
Polyalphabetic Ciphers
What is it?
• A cipher that uses more than one alphabet to encrypt a message.
• It improves on monoalphabetic ciphers by changing the letter substitutions as you
move through the message.
Features:
1. Uses a set of related monoalphabetic ciphers.
2. A key decides which cipher to use for each letter.
MODULE 1
Vigenère Cipher
• A famous and simple polyalphabetic cipher.
• Uses 26 Caesar ciphers (shift ciphers from 0 to 25).
• Each cipher is picked based on a key letter.
➢ How It Works:
1. Choose a keyword (e.g., deceptive).
2. Repeat the keyword to match the length of the message.
3. For each letter:
➢ Convert both the plaintext and key letters to numbers (A=0, B=1, Z=25).
➢ Add their values (mod 26).
➢ Convert back to a letter.
Formula:
Ciphertext letter = (Plaintext letter + Key letter) mod 26
For decryption:
Plaintext letter = (Ciphertext letter - Key letter) mod 26
Example:
• Key: deceptive
• Plaintext: wearediscoveredsaveyourself
• Ciphertext: ZICVTWQNGRZGVTWAVZHCQYGLMGJ
MODULE 1
What is a One-Time Pad?
• It’s a cipher system that gives perfect security.
• Uses a random key as long as the message.
• The key is used only once — then discarded.
• It produces ciphertext that’s completely random, with no patterns for attackers to
exploit.
How It Works:
1. Use a truly random key the same length as the message.
2. Encrypt each letter by adding the key value (like in Vigenère but with a random key,
no repeats).
3. Decrypt with the same key.
4. Discard the key after one use.
Example:
• Ciphertext: ANKYODKYUREPFJBYOJDSPLREYIUNOFDOIUERFPLUYTS
• Key 1 decrypts to:
mr mustard with the candlestick in the hall
• Key 2 decrypts to:
miss scarlet with the knife in the library
MODULE 1
✓ Both seem believable.
✓ Without knowing which key was actually used, a cryptanalyst can’t tell which
plaintext is correct.
➢ Why It’s Unbreakable:
• For any ciphertext, every possible plaintext of the same length has a matching key.
• If keys are truly random, there’s no pattern, no frequency clue — impossible to
crack.
• Even with unlimited computing power, it can’t be broken if properly used.
What is Steganography?
• It’s a method of hiding a message’s existence.
• Unlike cryptography, which scrambles a message, steganography keeps it hidden in
plain sight.
• The message is concealed within something that looks harmless — like a photo, text,
or sound file.
Classic Steganography Techniques:
• First-letter codes: The first letter of each word or sentence spells out a secret
message.
• Character marking: Some letters in a printed text are lightly marked with a pencil
— only visible at a certain angle.
• Invisible ink: Special inks become visible only with heat or chemicals.
• Pin punctures: Tiny holes in certain letters of a text, visible when held against a
light.
• Typewriter correction tape: Typed between regular lines, visible only under strong
light.
Modern Steganography:
• Digital steganography hides data in image, audio, or video files.
• Example:
o A high-resolution image (like a Kodak Photo CD image with 3096 × 6144
pixels and 24-bit color) can have its least significant bits (LSBs) altered to
embed a secret message.
o Least significant bit: The smallest part of the data that doesn’t noticeably
change the image or sound when modified.
o Can hide around 130 KB of text inside a single image without noticeable
quality loss.
• There are tools and software available for this now.
MODULE 1
Traditional Block Cipher Structure:
Stream Cipher Block Cipher
Encrypts one bit or byte at a time Encrypts a block of plaintext bits as a whole
Uses a keystream generator — a key-controlled Uses an encryption algorithm to convert a
algorithm that produces a stream of bits block of plaintext into ciphertext
More commonly used for secure network
Good for continuous, real-time data
communications
Example: Autokeyed Vigenère, Vernam cipher
Example: DES, AES
(one-time pad)
Stream Cipher Example:
• The keystream is generated algorithmically using a shared key.
• It must be unpredictable — no way to guess future bits based on previous ones.
Block Cipher Example:
• Typical block size: 64 bits or 128 bits.
• Both sender and receiver share the same secret key.
• Encrypts data block-by-block rather than bit-by-bit.
• Using certain operation modes, block ciphers can simulate stream ciphers too.
Why the Feistel Cipher Structure?
• A block cipher encrypts an n-bit plaintext into an n-bit ciphertext.
• There are 2ⁿ possible plaintext blocks, so to reverse it (decrypt), each plaintext
should map to a unique ciphertext.
• This is called a reversible (non-singular) mapping.
MODULE 1
Example:
• Reversible Mapping:
00 → 11
01 → 10
10 → 00
11 → 01
• Irreversible Mapping:
00 → 11
01 → 10
10 → 01
11 → 01
➢ Issue: Two plaintexts (10 and 11) map to the same ciphertext (01) — you can’t
reverse it uniquely.
Ideal Block Cipher:
• For n bits, there are 2ⁿ! possible encryption mappings.
• Feistel called this the ideal block cipher.
• Example: A 4-bit block cipher can have 16! different mappings.
Why Not Use Ideal Block Ciphers Directly?
• If block size is small (like 4 bits) → it's like a simple substitution cipher and
vulnerable to statistical attacks.
• If block size is large (like 64 or 128 bits) → too impractical to manage all possible
mappings (for 64 bits: 2⁶⁴! mappings!).
Solution: Feistel Structure
• Feistel’s idea is to break the plaintext block into two halves and process them through
multiple rounds of simple functions.
• This makes strong encryption practical even with large block sizes.
• Forms the basis of famous ciphers like DES.
MODULE 1
The Data Encryption Standard (DES)
What is DES?
• DES (Data Encryption Standard) was the most widely used symmetric encryption
scheme before AES.
• Published by NIST (then NBS) in 1977 as FIPS PUB 46.
• Encrypts 64-bit blocks of data using a 56-bit key.
• DEA (Data Encryption Algorithm) is the actual encryption method used in DES.
DES Structure:
• DES uses a Feistel cipher structure.
• 64-bit plaintext is transformed into 64-bit ciphertext through:
o An initial permutation (IP)
o 16 rounds of processing (each round includes substitution and permutation)
o A final permutation (inverse of IP)
MODULE 1
Important:
• In each round, a new 48-bit subkey (Kᵢ) is generated from the original 56-bit key
through shifting and permuting.
• In decryption, the same steps are used but with subkeys applied in reverse order.
DES Example:
• The process involves breaking the data into left (L) and right (R) halves.
• After each round:
Lᵢ = Rᵢ₋₁
MODULE 1
Strength of DES — Simplified Notes
➢ Concerns About DES Security:
There are two main areas of concern:
• Key Size (56 bits)
• Nature of the Algorithm
➢ The Use of 56-Bit Keys:
• 56-bit keys = 2⁵⁶ ≈ 7.2 × 10¹⁶ possible keys.
• Originally, brute-force attacks seemed impractical.
• Early estimate (1977 Diffie & Hellman):
o With a parallel machine of 1 million devices doing 1 encryption/μs → key
found in 10 hours.
MODULE 1
➢ With modern technology:
• Off-the-shelf multicore processors can test 1 billion keys/sec (10⁹).
• Supercomputers can reach 10¹³ encryptions/sec.
• At 10¹³ keys/sec:
o DES key can be brute-forced in about 1 hour.
o 128-bit AES key would take 5.3 × 10¹⁷ year
Nature of the DES Algorithm:
• Concern over the secret design of the 8 S-boxes.
• Suspicions that hidden weaknesses could allow cryptanalysis.
• Though some patterns were found, no fatal flaw has ever been publicly revealed.
Timing Attacks:
• Gathers info by measuring how long encryption/decryption takes for different inputs.
• DES is fairly resistant, though future side-channel attacks are a theoretical risk.
Block Cipher Design Principles
➢ Number of Rounds:
• More rounds = harder to attack.
• DES uses 16 rounds.
MODULE 1
o Differential cryptanalysis would require 2⁵⁵.¹ operations (comparable to brute
force).
o If it had 15 or fewer rounds, it would be weaker than brute force.
➢ Design of the Function F:
• Provides confusion — makes it difficult to deduce relationships between plaintext,
ciphertext, and key.
• Must be nonlinear.
• Should have:
o Avalanche Effect: one input bit change should flip many output bits.
o Strict Avalanche Criterion (SAC): each output bit should flip with 50%
probability if one input bit changes.
o Bit Independence Criterion (BIC): any two output bits should flip
independently when a single input bit changes.
➢ Key Schedule Algorithm:
• Generates one subkey per round.
• Should maximize:
o Difficulty in deducing subkeys.
o Difficulty in working back to the original key.
• Should also maintain SAC and BIC across subkeys.
— The End —