CNS
CNS
Ans. The Data Encryption Standard (DES) is a symmetric key block cipher that encrypts data in 64-
bit blocks using a 56-bit key. The DES algorithm operates through 16 rounds of processing. Each
round uses a unique 48-bit subkey derived from the main key.
Ans. AES (Advanced Encryption Standard) is a symmetric key block cipher used for securing data. It
encrypts data in fixed blocks of 128 bits and supports key sizes of 128, 192, or 256 bits. The number
of rounds in AES depends on the key size:
AES-128: 10 rounds
AES-192: 12 rounds
AES-256: 14 rounds
Explanation of Each Step:
1. Initial Round
o SubBytes: Each byte is replaced with a corresponding value from an S-box (non-
linear substitution).
o ShiftRows: Each row of the matrix is shifted to the left by a certain number of
positions.
o AddRoundKey: XOR the result with the round key generated by the key schedule.
Que 3. List various block cipher modes of operation & explain any two/three modes of operation.
Ans. Block ciphers (like AES, DES) operate on fixed-size blocks (e.g., 64-bit, 128-bit). To encrypt
longer messages, modes of operation are used.
Working:
In ECB, each plaintext block is encrypted independently using the same key.
Can be parallelized.
Cons:
Patterns in the plaintext are visible in the ciphertext (same plaintext → same ciphertext).
This can reveal structure in the data, making it insecure for encrypting large amounts of data.
Working:
In CBC, each plaintext block is XORed with the previous ciphertext block before encryption.
The first block uses an Initialization Vector (IV), which is random and unique for each
encryption.
Pros:
Hides patterns in plaintext. Even if the same plaintext is encrypted multiple times,
the ciphertext will differ because of the chaining effect.
Cons:
Ans. The RSA algorithm is a widely-used asymmetric encryption algorithm, which means it uses
two different keys for encryption and decryption:
RSA is based on the mathematical properties of large prime numbers. The algorithm involves the
following key generation, encryption, and decryption steps.
2. Compute n:
n=p×q
This value n will be used in both the public and private keys. It is the modulus for both
encryption and decryption operations.
3. Compute ϕ(n):
ϕ(n)=(p−1)(q−1)
This is Euler's Totient function of n, used to calculate the private key.
6. Public Key:
The public key is (e,n).
7. Private Key:
The private key is (d, n).
1. Convert the plaintext into an integer mmm, where m<nm < nm<n. This can be done
by converting each letter or block of text into numbers.
C=me mod n
o c is the ciphertext.
o n is the modulus.
Steps:
m =cd mod n
o c is the ciphertext.
o n is the modulus.
2. Convert the decrypted integer mmm back into the plaintext message.
Example:
Compute n=p×q=61×53=3233.
Compute ϕ(n)=(61−1)×(53−1)=60×52=3120
So, the public key is (e=17,n=3233) and the private key is (d=2753,n=3233).
Encryption Example:
Decryption Example:
Ciphertext c=855.
Ans.
Example:
Compute n=p×q=61×53=3233.
Compute ϕ(n)=(61−1)×(53−1)=60×52=3120
So, the public key is (e=17,n=3233) and the private key is (d=2753,n=3233).
Encryption Example:
Decryption Example:
Ciphertext c=855.
Ans. Diffie-Hellman is a way for two people to share a secret key over the internet without
sending the key itself. That secret key can later be used to encrypt and decrypt messages.
o A prime number p
4. Alice computes:
A=ga mod p
→ Sends A to Bob
5. Bob computes:
B= gb mod p
→ Sends B to Alice
6. Both now calculate the same secret key:
Alice computes:
Secret = Ba mod p
Bob computes:
Secret= Ab mod p
Example:
Let’s pick small numbers so it's easy to follow:
Public values:
p=23, g=5
Alice picks secret number:
a=6
Bob picks secret number:
b=15
Step 1: Calculate public values
Alice:
A= 56 mod 23 = 15625 mod 23=8
Bob:
B=515mod 23=2
Step 2: Exchange A and B
Alice sends 8 to Bob
Bob sends 2 to Alice
Step 3: Compute shared secret
Alice:
26 mod 23 = 64 mod 23 = 18
Bob:
815 mod 23=18
✅ Shared Secret = 18
Ans. X.509 is a standard used for digital certificates. These certificates are used in public key
infrastructure (PKI) to verify the identity of a person, organization, or website and to secure
communication over the internet (like HTTPS websites).
It helps in ensuring:
Digital signatures
Field Description
Serial Number Unique number assigned by the issuing Certificate Authority (CA)
Signature Algorithm Algorithm used to sign the certificate (e.g., SHA256 with RSA)
Subject The identity the certificate is issued to (e.g., domain name, person’s
name)
Subject Public Key The public key and algorithm used by the subject
Info
Signature The digital signature from the issuer (CA) to verify the certificate’s
authenticity
When you visit https://example.com, your browser checks its X.509 certificate to:
Use the public key inside the certificate to securely exchange data
Ans. The Digital Signature Algorithm (DSA) is a standard developed by NIST (National Institute
of Standards and Technology) to create digital signatures.
It is part of the Digital Signature Standard (DSS) and is used to verify the authenticity and
integrity of digital data.
Purpose:
DSA is not used for encryption—it is only used to sign and verify messages.
How DSA Works?
Prime Numbers:
p: a large prime number
q: a 160-bit prime such that q divides p−1
Generator:
g: a number generated from p and q
It establishes:
Encryption method
SSL has been succeeded by TLS (Transport Layer Security), but the handshake process is very
similar.
Step Description
4. Pre-Master Key Client generates a pre-master key, encrypts it with the server’s
public key, and sends it to the server
5. Session Key Both client and server use the pre-master key + random numbers
Generation to create the same session key
Once this is done, all communication is encrypted using the session key.
Diagram:
Que 10.List & explain 4 general categories of scheme for the distribution of public keys.
But how do users safely obtain each other's public keys? That’s where key distribution schemes
come in.
1. Public Announcement
How it works:
Users publicly post their public keys (e.g., on websites, forums, or emails).
Example:
"Here is my public key: ABC123..."
Issue:
No way to verify if the key is really from the correct person (can be intercepted or
replaced — called a man-in-the-middle attack).
Use Case:
Informal environments, basic key sharing.
How it works:
A trusted directory service stores all public keys and is available to anyone.
Key Feature:
The directory is maintained by a trusted authority and may be digitally signed to prevent
tampering.
Example:
An organization’s secure directory of employees' public keys.
Use Case:
Corporate networks, government institutions.
How it works:
A central authority is responsible for distributing and verifying public keys on request.
Steps:
Benefit:
Reduces risk of impersonation since keys are verified.
Limitation:
The authority becomes a central point of trust and failure.
How it works:
A trusted Certificate Authority (CA) issues a digital certificate, which binds a public key to
the owner's identity.
o Owner’s name
o Public key
o Expiry date
Verification:
Anyone can verify the certificate using the CA’s public key.
Example:
Websites with HTTPS use certificates issued by trusted CAs (like DigiCert, Let's Encrypt,
etc.)
Use Case:
Web security, online banking, secure email, e-commerce.
It’s used in symmetric key cryptography, where both sender and receiver share the same secret
key.
1. Sender:
2. Receiver:
Example
Let’s say:
Message = "Hello"
Ans. Kerberos is a network authentication protocol used to securely identify users and services
in a computer network.
It uses secret-key cryptography and a trusted third party to verify identities and ensure secure
communication — especially in client-server environments.
It prevents:
Unauthorized access
Developed by MIT, Kerberos is widely used in systems like Windows Active Directory and
UNIX/Linux networks.
Component Description
Ticket Granting Server (TGS) | | TGT (Ticket Granting Ticket) | A ticket that allows the
user to request access to services without re-entering credentials | | Session Key | A
secret key for secure communication between the client and server |
The client logs in and sends a request to the Authentication Server (AS) with the
username.
o Creates a TGT
o Encrypts it using the user's secret key (derived from the password)
When the client wants to access a service (e.g., file server), it sends:
o The TGT
The Ticket Granting Server (TGS) verifies the TGT and client identity.
TGS sends back a Service Ticket, encrypted using the server’s secret key.
Used In
2. Deterministic:
Same input = same hash every time.
3. One-Way Function:
It’s easy to compute the hash from input, but impossible to reverse it.
4. Avalanche Effect:
A small change in input drastically changes the output.
5. Collision-Resistant:
It’s hard to find two different inputs that produce the same hash.
SHA-2 224, 256, 384, 512 bits Strong and widely used
1. Preprocessing:
4. Compression Function:
o Each block is processed through a series of logical operations, rotations, and bit-
shifting.
Example:
Input: "hello"
SHA-256 Hash:
2cf24dba5fb0a...3e9d525b
Digital Signatures
SSL/TLS Certificates
Ans. Cipher Block Chaining (CBC) is a mode of operation for block ciphers used in encryption.
It improves the security of Electronic Codebook (ECB) mode by adding a chaining mechanism —
meaning the encryption of each block depends on the previous block.
CBC is used in systems that need secure encryption of data blocks (like files, messages, etc.)
Let’s say:
A random Initialization Vector (IV) is used for the first block only
Steps:
4. And so on...
Decryption:
Example
Let’s say:
M₁ = 1100
IV = 1010
More secure than ECB (blocks produce different ciphertexts even if plaintext is same)
Disadvantages
Ans. Euclid’s Algorithm is an efficient method to find the Greatest Common Divisor (GCD) of two
numbers.
GCD (also called HCF) is the largest number that divides both numbers without leaving a
remainder.
How Euclid’s Algorithm Works
Step 2: A = 18, B = 12
18 ÷ 12 = 1 remainder 6 → GCD(18, 12) = GCD(12, 6)
Step 3: A = 12, B = 6
12 ÷ 6 = 2 remainder 0 → GCD(12, 6) = GCD(6, 0)
Ans. The Feistel structure is a design used in many block ciphers like DES (Data Encryption
Standard).
It splits the data block into two halves and processes them through multiple rounds using a
round function and subkeys, enabling both encryption and decryption using the same structure.
Feistel Encryption Process (Step-by-Step)
o Left half = L₀
o Right half = R₀
Decryption uses the same process, but subkeys Kᵢ are applied in reverse order (Kₙ to K₁).
Ans.
Same key for encryption and decryption Uses a pair of keys: Public Key & Private Key
Faster Slower
Difficult – key must be shared secretly Easier – public key can be openly shared
Examples: AES, DES, Blowfish Examples: RSA, ECC, DSA
Efficient for large data Better for small data (or key exchange)
Used for bulk data encryption Used for secure key exchange, digital
signatures
Same algorithm and same key Public key encrypts, Private key decrypts
Que 18.How can we find out GCD of two numbers using Euclid’s algorithm.
Ans. It’s an efficient way to find the GCD by repeatedly dividing the larger number by the smaller one
and replacing the larger number with the smaller number and the smaller number with the
remainder. Repeat this process until the remainder becomes zero. The last non-zero remainder is
the GCD.
3. A = B * Q + R
6. Step 5: When the remainder becomes 0, the GCD is the last non-zero remainder.
2. 48 ÷ 18 = 2 remainder 12
4. 18 ÷ 12 = 1 remainder 6
Now, A = 12, B = 6.
5. Step 3: Divide 12 by 6.
6. 12 ÷ 6 = 2 remainder 0
Ans. SSL (Secure Sockets Layer) is a cryptographic protocol designed to provide secure
communication over a computer network. It has been replaced by TLS (Transport Layer Security),
but SSL is still often used to refer to the general secure communication protocol.
SSL Architecture is built upon several components that work together to ensure confidentiality,
integrity, and authentication.
o Responsible for setting up a secure connection between the client and the server.
o Establishes cryptographic keys and verifies the identity of the parties involved.
o Defines how data is securely transmitted between the client and server.
o Responsible for ensuring the confidentiality and integrity of the data during
transmission.
o Handles alert messages that notify the parties about the status of the connection
(e.g., warning or error).
o Tells the client and server that the keys have been changed, and data encryption will
begin.
o Ensures the confidentiality of data transmitted between client and server using
symmetric encryption algorithms.
2. Authentication:
o Verifies the identity of the server (and optionally the client) using digital certificates
signed by trusted Certificate Authorities (CAs).
3. Data Integrity:
o Uses Message Authentication Codes (MAC) to verify that the data has not been
altered during transmission.
4. Session Resumption:
o SSL supports session resumption, allowing clients and servers to reuse a previously
established session for subsequent connections.
Ans. AES is a symmetric key block cipher that encrypts data in fixed blocks of 128 bits using key sizes
of 128, 192, or 256 bits. It is widely used for secure data encryption in applications like secure file
storage, VPNs, HTTPS, etc.
Number of rounds:
AES works on a 4x4 matrix of bytes called the State. Each round involves several operations:
1. Key Expansion
The original key is expanded into multiple round keys using a process called Key Schedule.
2. Initial Round
AddRoundKey: XOR each byte of the state with the corresponding byte of the round key.
ShiftRows:
MixColumns:
o The columns of the state are mixed to provide diffusion using mathematical
operations (matrix multiplication).
AddRoundKey:
SubBytes
ShiftRows
AddRoundKey
AES Decryption
InvSubBytes
InvShiftRows
InvMixColumns
AddRoundKey
Process:
1. AddRoundKey (Initial)