Cryptography
Cryptography
1
2.Cryptography and Its Role in Secure Communication
1. Concept of Cryptography:
Cryptography is the science and art of converting plain text into an
unreadable format called ciphertext, and vice versa, using mathematical
algorithms. Its primary aim is to ensure secure communication over
potentially insecure channels.
• Plaintext: Original message
• Ciphertext: Encrypted message
• Encryption: Process of converting plaintext into ciphertext
• Decryption: Reversing ciphertext back into plaintext using a key
2. Importance of Cryptography in Secure Communication:
Cryptography plays a critical role in protecting data and ensuring privacy
and trust. Its importance includes:
3. Cryptographic Services:
These are the security services that cryptography provides:
2
Service Description Example
3
3.(i) 72 mod 5
We divide 72 by 5:
• 72÷5=1472 \div 5 = 14 remainder 2
• So,
72mod 5=272 \mod 5 = \boxed{2}
(ii) 36 mod 12
We divide 36 by 12:
• 36÷12=336 \div 12 = 3 remainder 0
• So,
36mod 12=036 \mod 12 = \boxed{0}
Final Answers:
• (i) 2\boxed{2}
• (ii) 0\boxed{0}
• (iii) 10\boxed{10}
4
4.Diference Bet Substitution Cipher & Transposition Cipher
In classical cryptography, substitution and transposition are two basic
types of encryption techniques. Both aim to hide the original content of a
message but use different methods.
Caesar Cipher,
Rail Fence Cipher,
3. Example Monoalphabetic Cipher,
Columnar Transposition
Vigenère Cipher
Depends on a key to
8. Key Depends on a key to
determine the
Dependency substitute characters
permutation order
Vulnerable to frequency
More resistant to
9. Cryptanalysis analysis and known
frequency analysis
plaintext attacks
5
Aspect Substitution Cipher Transposition Cipher
Often used in
Forms the base of many
10. Use in combination with
modern symmetric
Modern Crypto substitution in block
encryption systems
ciphers
Illustrative Example:
Substitution Cipher (Caesar Cipher):
Plaintext: HELLO
Key: Shift by 3
Ciphertext: KHOOR
Transposition Cipher (Rail Fence - 2 rails):
Plaintext: HELLO
Step 1 (Zigzag):
H L O
EL
Step 2: Read line by line → HLOEL
6
5.Ring and the difference betn Ring and Commutative Ring
Definition of Ring
A Ring is an algebraic structure consisting of a non-empty set RR
equipped with two binary operations:
• Addition (+)
• Multiplication (×)
Multiplication is
Multiplication may not be
2. Commutativity commutative:
commutative: ab≠baab ≠ ba
ab=baab = ba
Matrix ring
Set of integers
3. Example Mn(R)M_n(\mathbb{R})
Z\mathbb{Z}
(matrices of order nn)
7
Aspect Ring Commutative Ring
More specific –
Less restrictive – more includes extra
5. Structure
general property
(commutativity)
8
6. What is DES (Data Encryption Standard)?
DES (Data Encryption Standard) is a symmetric key block cipher
encryption algorithm developed by IBM in the early 1970s and adopted
as a federal standard by NIST in 1977.
• It encrypts data in 64-bit blocks using a 56-bit key.
• DES uses the same key for both encryption and decryption.
• It is now considered insecure due to advances in computing power
but was foundational in cryptography.
Feature Description
2. Key Generation:
• From the 56-bit key, 16 subkeys (each 48-bit) are generated for the
16 rounds.
• Key scheduling involves permutations and left shifts.
9
1. Divide 64-bit data into Left (L) and Right (R) halves
2. For each round ii:
o Li=Ri−1L_i = R_{i-1}
o Ri=Li−1⊕f(Ri−1,Ki)R_i = L_{i-1} \oplus f(R_{i-1}, K_i)
where:
o ff is the round function
o KiK_i is the round key
3. The function ff includes:
o Expansion of 32 bits to 48 bits
o XOR with subkey
o Substitution using S-boxes
o Permutation (P-box)
Encryption Output:
A 64-bit ciphertext is generated.
For decryption, the same steps are followed in reverse order using the
subkeys in reverse.
10
7.Field Using a Set of Residues
Definition of a Field:
A field is an algebraic structure (F,+,×)(F, +, \times) where:
• FF is a non-empty set
• Addition (+) and multiplication (×) are defined on FF
• Both operations satisfy the usual properties: associativity,
commutativity, distributivity
• There exist additive and multiplicative identities (0 and 1)
• Every element has an additive inverse
• Every non-zero element has a multiplicative inverse
11
4. Multiplicative Identity:
1 acts as the multiplicative identity since a×1≡a(modp)a \times 1
\equiv a \pmod{p}.
5. Additive Inverse:
For every a∈Zpa \in \mathbb{Z}_p, there exists an −a-a such that
a+(−a)≡0(modp)a + (-a) \equiv 0 \pmod{p}.
6. Multiplicative Inverse:
For every non-zero a∈Zpa \in \mathbb{Z}_p, there exists an
inverse a−1a^{-1} such that a×a−1≡1(modp)a \times a^{-1} \equiv
1 \pmod{p}. This is true because pp is prime.
7. Distributive Law:
Multiplication distributes over addition modulo pp.
Example Calculation:
In Z7\mathbb{Z}_7:
• Addition: 5+4≡2(mod7)5 + 4 \equiv 2 \pmod{7} because 5+4=95 +
4 = 9 and 9mod 7=29 \mod 7 = 2.
• Multiplicative inverse of 3 is 5 since 3×5=15≡1(mod7)3 \times 5 =
15 \equiv 1 \pmod{7}.
Applications:
• Used in cryptography, such as RSA and ECC.
• Basis of arithmetic in computer science and coding theory.
• Helps in designing error-correcting codes.
12
8.Chinese Remainder Theorem (CRT)
The Chinese Remainder Theorem states that:
Given a system of simultaneous congruences:
{x≡a1(modm1)x≡a2(modm2)⋮x≡ak(modmk)\begin{cases} x \equiv a_1
\pmod{m_1} \\ x \equiv a_2 \pmod{m_2} \\ \vdots \\ x \equiv a_k
\pmod{m_k} \end{cases}
where m1,m2,…,mkm_1, m_2, \ldots, m_k are pairwise coprime (i.e.,
gcd(mi,mj)=1\gcd(m_i, m_j) = 1 for all i≠ji \neq j),
then there exists a unique solution xx modulo M=m1m2⋯mkM = m_1
m_2 \cdots m_k.
In other words, there is a unique integer xx, 0≤x<M0 \leq x < M, that
simultaneously satisfies all the given congruences.
Explanation:
• CRT allows us to solve multiple modular equations simultaneously.
• It guarantees the existence and uniqueness of the solution under
the condition of pairwise coprime moduli.
Example:
Solve for xx:
{x≡2(mod3)x≡3(mod5)x≡2(mod7)\begin{cases} x \equiv 2 \pmod{3} \\ x
\equiv 3 \pmod{5} \\ x \equiv 2 \pmod{7} \end{cases}
• m1=3,m2=5,m3=7m_1=3, m_2=5, m_3=7 are pairwise coprime.
• The solution is unique modulo 3×5×7=1053 \times 5 \times 7 =
105.
By applying CRT, the solution is x=23x = 23 (for example).
14
9.Digital Signature
A digital signature is a cryptographic technique that provides a secure
and authentic way to verify the origin and integrity of a digital message
or document. It acts like a handwritten signature or a stamped seal but
offers far more inherent security.
• It ensures that a message is genuinely from the claimed sender
(authentication).
• It guarantees that the message has not been altered (integrity).
• It provides non-repudiation, meaning the sender cannot deny
sending the message.
15
If not, the message may have been altered or the signature forged.
Property Explanation
16
10.RSA Algorithm: Overview
RSA is a widely used asymmetric key cryptosystem for secure data
transmission. It uses a public key for encryption and a private key for
decryption.
Keys:
• Public key: (e,n)=(7,77)(e, n) = (7, 77)
• Private key: (d,n)=(43,77)(d, n) = (43, 77)
17
Encryption:
Given plaintext M=9M = 9, encrypt to ciphertext CC using:
C=Memod n=97mod 77C = M^e \mod n = 9^7 \mod 77
Calculate 97mod 779^7 \mod 77:
• 91=9mod 77=99^1 = 9 \mod 77 = 9
• 92=9×9=81mod 77=49^2 = 9 \times 9 = 81 \mod 77 = 4
• 94=(92)2=42=16mod 77=169^4 = (9^2)^2 = 4^2 = 16 \mod 77 =
16
• 97=94×92×91=16×4×9=576mod 779^7 = 9^{4} \times 9^{2} \times
9^{1} = 16 \times 4 \times 9 = 576 \mod 77
Calculate 576mod 77576 \mod 77:
• 77×7=53977 \times 7 = 539
• 576−539=37576 - 539 = 37
So,
C=37C = 37
Decryption:
To recover plaintext MM from ciphertext CC, use:
M=Cdmod n=3743mod 77M = C^d \mod n = 37^{43} \mod 77
Calculating 3743mod 7737^{43} \mod 77 directly is tedious, but we can
use modular exponentiation or repeated squaring.
Let's do modular exponentiation by repeated squaring:
• 371≡37mod 7737^1 \equiv 37 \mod 77
• 372=37×37=1369mod 7737^2 = 37 \times 37 = 1369 \mod 77
Calculate 1369mod 771369 \mod 77:
• 77×17=130977 \times 17 = 1309
• 1369−1309=601369 - 1309 = 60
So, 372≡6037^2 \equiv 60
18
11.Requirements of Hash Functions
A hash function takes an input (message) and produces a fixed-size
string of bytes, typically called a hash value or message digest. For
cryptographic applications, hash functions must satisfy the following
properties:
1. Deterministic
• For the same input, the hash function must always produce the
same output.
2. Fast Computation
• The hash value should be computed quickly for any given input.
3. Pre-image Resistance (One-way property)
• Given a hash value hh, it should be computationally infeasible to
find any input xx such that hash(x)=h\text{hash}(x) = h.
• This ensures the hash function is one-way.
4. Second Pre-image Resistance
• Given an input xx, it should be computationally infeasible to find
another input x′≠xx' \neq x such that hash(x)=hash(x′)\text{hash}(x)
= \text{hash}(x').
5. Collision Resistance
• It should be computationally infeasible to find any two distinct
inputs xx and yy such that hash(x)=hash(y)\text{hash}(x) =
\text{hash}(y).
6. Avalanche Effect
• A small change in the input should produce a completely different
hash value (changing even one bit of input should change about
half the bits of the output).
7. Fixed Output Length
• The output hash length is fixed, regardless of input size.
19
12.ElGamal Cryptosystem
ElGamal is a public-key cryptosystem based on the difficulty of solving
the discrete logarithm problem. It consists of three phases: key
generation, encryption, and decryption.
1. Key Generation (by Alice)
• Choose a large prime number pp.
• Choose a primitive root gg modulo pp (i.e., gg is a generator of the
multiplicative group Zp∗\mathbb{Z}_p^*).
• Choose a private key aa where 1≤a≤p−21 \leq a \leq p-2.
• Compute the public key component y=gamod py = g^a \mod p.
• Public key: (p,g,y)(p, g, y)
• Private key: aa
2. Encryption (by Bob)
To encrypt a message MM (where M∈Zp∗M \in \mathbb{Z}_p^*) using
Alice’s public key (p,g,y)(p, g, y):
• Choose a random kk such that 1≤k≤p−21 \leq k \leq p-2.
• Compute:
c1=gkmod pc_1 = g^k \mod p c2=M×ykmod pc_2 = M \times y^k \mod p
• The ciphertext is the pair:
(c1,c2)(c_1, c_2)
3. Decryption (by Alice)
Using her private key aa, Alice recovers MM from ciphertext (c1,c2)(c_1,
c_2) as:
M=c2×(c1a)−1mod pM = c_2 \times (c_1^a)^{-1} \mod p
Where (c1a)−1(c_1^a)^{-1} is the modular inverse of c1ac_1^a modulo
pp.
Given Data:
20
• Prime modulus p=19p = 19
• Primitive root g=2g = 2
• Alice's private key a=5a = 5
• Bob’s public key y=8y = 8 (note: usually y=gamod py = g^a \mod
p, but here it is given)
• Message M=9M = 9
Step 1: Calculate Alice’s Public Key
Usually, Alice computes:
y=gamod p=25mod 19y = g^a \mod p = 2^5 \mod 19
Calculate:
• 25=322^5 = 32
• 32mod 19=32−19=1332 \mod 19 = 32 - 19 = 13
So, Alice’s public key is y=13y = 13.
Step 2: Encrypt Message M=9M = 9 Using Bob’s Public Key y=8y = 8
Bob wants to encrypt message M=9M = 9 using:
• p=19p = 19,
• g=2g = 2,
• y=8y = 8.
Bob selects a random integer kk, say k=7k = 7 (you can choose any
1≤k≤171 \leq k \leq 17).
Calculate:
• c1=gkmod p=27mod 19c_1 = g^k \mod p = 2^7 \mod 19
• c2=M×ykmod p=9×87mod 19c_2 = M \times y^k \mod p = 9 \times
8^7 \mod 19
21
13.E-mail Architecture
E-mail (Electronic Mail) architecture refers to the structure and
components that allow users to send, receive, and manage messages
over a network (like the Internet). It consists of clients, servers,
protocols, and storage systems working together.
Simple Mail
Used to send e-mail from client to server or
SMTP Transfer
between servers.
Protocol
22
Protocol Full Form Role
23
14.S/MIME: Summary of Cryptographic Algorithms
S/MIME is a standard for public key encryption and digital signing of
MIME data. It is used to ensure confidentiality, authentication, message
integrity, and non-repudiation in email communication.
S/MIME uses a combination of:
1. Symmetric Encryption Algorithms (for message encryption)
• Purpose: To encrypt the actual email content (message body)
efficiently.
• Algorithms used:
o AES (Advanced Encryption Standard)
o Triple DES (3DES)
o RC2 (historical use)
24
3. Hash Functions (for message digest in digital signatures)
• Purpose:
To create a unique digest of the message to ensure data integrity.
• Algorithms used:
o SHA-1 (legacy)
o SHA-256, SHA-384, SHA-512 (preferred in modern use)
The hash is computed over the message and then signed by the
sender.
Summary Table
25
15.SSL Architecture (Secure Sockets Layer)
SSL is a cryptographic protocol that provides secure communication
over a computer network, especially the Internet. It ensures
confidentiality, authentication, and data integrity between client and
server.
SSL has been succeeded by TLS (Transport Layer Security), but the
architecture remains conceptually similar.
Objectives of SSL:
• Encrypt data for confidentiality
• Authenticate both parties (typically server-side)
• Detect tampering for integrity
• Prevent replay attacks
26
o Exchange of protocol version, cipher suites
o Server authentication (digital certificate)
o Key exchange (e.g., RSA or Diffie-Hellman)
o Symmetric session key generation
Protocol Purpose
27
16.Pretty Good Privacy (PGP) is a data encryption and decryption
program that provides cryptographic privacy and authentication for
securing e-mail communication. It uses a combination of symmetric
encryption, asymmetric encryption, hashing, and compression.
Message Generation in PGP (Sender Side)
Steps:
1. Message Creation:
o The user creates a plaintext message (M).
2. Hashing (Message Digest):
o A hash function (e.g., SHA-1) is applied to the message to
create a message digest (MD).
MD = H(M)
3. Digital Signature Generation:
o The message digest is encrypted with the sender’s private
key to create a digital signature.
Signature = Encrypt(MD, PrivateKey_sender)
4. Append Signature:
o The digital signature is attached to the original message to
form a signed message.
5. Compression (Optional):
o The signed message is compressed to reduce size and
improve efficiency.
6. Symmetric Key Generation:
o A random symmetric session key is generated.
7. Encryption (Message Encryption):
o The compressed message is encrypted using the symmetric
session key.
8. Encrypt the Session Key:
28
o The symmetric key is encrypted using the recipient’s public
key.
9. Output the Final Package:
o The final PGP message contains:
▪ Encrypted message
▪ Encrypted session key
▪ Sender's public key ID
▪ Signature
29
↓
Encrypt Message with Symmetric Key
↓
Encrypt Symmetric Key with Recipient's Public Key
↓
Final PGP Package
Steps:
1. Receive PGP Message:
o The receiver receives the PGP message package.
2. Decrypt Symmetric Key:
o The encrypted session key is decrypted using the recipient's
private key.
3. Decrypt Message:
o The encrypted message is decrypted using the recovered
symmetric key.
4. Decompression:
o The decrypted message is decompressed to retrieve the
original signed message.
5. Separate Message and Signature:
o The message and the digital signature are separated.
6. Hash the Message:
o A hash function is applied to the message to produce a new
message digest.
7. Verify Signature:
o The digital signature is decrypted using the sender’s public
key to retrieve the original message digest.
30
8. Compare Digests:
o If the calculated digest matches the one from the signature,
authenticity and integrity are verified.
31
17.What is a Firewall?
A firewall is a network security system—either hardware, software, or a
combination of both—that monitors and controls incoming and outgoing
network traffic based on predefined security rules.
Type Description
32
18.Purpose of Encapsulating Security Payload
Encapsulating Security Payload (ESP) is a protocol within the IPsec
(Internet Protocol Security) suite that provides confidentiality, data
integrity, and authentication for IP packets.
1. Confidentiality (Encryption):
• ESP encrypts the payload (e.g., TCP/UDP segment) using
symmetric encryption algorithms like AES or 3DES.
• This prevents unauthorized users from reading the data during
transmission.
33
ESP Packet Structure (Simplified)
[IP Header] [ESP Header] [Encrypted Payload + ESP Trailer] [ESP
Authentication Data (optional)]
• ESP Header: Contains SPI (Security Parameters Index) and
sequence number
• Encrypted Payload: Contains original transport layer segment
(TCP/UDP), encrypted
• ESP Authentication Data: MAC to verify integrity (optional)
34
19.(i) Virus
A computer virus is a type of malicious software (malware) designed to
replicate itself and spread from one computer to another, often without
the user's knowledge. It attaches itself to legitimate programs or files and
executes when the host file is run.
Key Features:
• Requires user action (e.g., opening an infected file) to activate.
• Can corrupt or delete data, slow down systems, or crash them.
• Spreads via infected files, USBs, emails, or downloads.
Example:
• ILOVEYOU virus, which spread through email and caused
widespread damage.
(ii) Adware
Adware (short for advertising-supported software) is software that
automatically displays or downloads advertisements when a user is
online. While not always malicious, some adware can track user
behavior and compromise privacy.
Key Features:
• Displays unwanted pop-ups or banners.
• Often bundled with free software.
• May collect personal data (e.g., browsing history) for targeted ads.
Risks:
• Slows down system performance.
• May lead to more dangerous malware if not handled properly.
Solution:
• Use reliable antivirus or adware removal tools to clean the system.
35
An Intrusion Detection System (IDS) is a security tool used to
monitor and analyze network or system activity to identify suspicious
behavior, policy violations, or unauthorized access attempts.
Component Function
36
• May produce false positives if the baseline is not well-defined.
3. Stateful Protocol Analysis
• Understands the protocol behavior (e.g., TCP/IP) and detects
deviations from expected usage patterns.
• More context-aware than simple pattern matching.
4. Heuristic-Based Detection
• Uses rules, AI, or fuzzy logic to detect malicious activity.
• Balances between signature and anomaly detection.
• Useful for evolving threats and adaptive systems.
Types of IDS
Type Description
37