Assignment Cyber Security Solved
Assignment Cyber Security Solved
Entropy in the context of data compression (and information theory) refers to the measure of the
average amount of information produced by a source of data. It quantifies the minimum number
of bits required to encode a source symbol.
Key Points:
Lower entropy implies less randomness and better opportunities for compression.
Entropy provides the theoretical limit for lossless data compression.
Lossless compression is a method of data compression where the original data can be
reconstructed exactly from the compressed data without any loss of information.
Key Characteristics:
Applications:
Text files, executable files, and medical images where accuracy is critical.
Data compression is the process of reducing the size of data for storage or transmission
purposes. The goal is to represent data in a form that takes up less space while preserving its
integrity.
Types:
1. Lossless Compression: Exact reconstruction of original data (e.g., ZIP files, PNG
images).
2. Lossy Compression: Approximate reconstruction with some data loss (e.g., JPEG,
MP3).
Advantages:
Mathematically:
Example:
If the original data is 10 MB and the compressed data is 2 MB, the compression ratio is:
102=5:1\frac{10}{2} = 5:1
A binary code represents data using two symbols: 0 and 1. Each symbol is called a "bit."
Properties:
Binary codes are the foundation of all digital systems, including computers and
communication devices.
Characters or symbols are represented using a unique sequence of bits.
Binary codes are critical in data compression, error detection, and digital communication.
6. Discuss Huffman Code.
Huffman Coding is a popular lossless data compression algorithm that assigns variable-length
binary codes to input symbols based on their frequencies.
Steps:
Advantages:
7. Define distortion.
Distortion refers to the loss of quality or information when compressing data, particularly in
lossy compression methods.
Rice Coding is a type of entropy coding used for lossless data compression, particularly when
the symbols follow a geometric distribution.
Steps of Implementation:
Advantages:
A Minimum Variance Huffman Code ensures that the variance (difference in code lengths) of
the assigned binary codes is minimized.
Steps:
Advantages:
Encoding Process:
Decoding Process:
Advantages:
Adaptive quantization is a quantization technique where the step size or the quantization levels
are adjusted dynamically based on the input signal characteristics. This is particularly useful for
signals with varying amplitude ranges.
Key Approaches:
Scalar Quantization:
o Quantization applied to individual signal samples independently.
o It uses uniform or non-uniform quantization.
o Example: Dividing the range of amplitudes into fixed steps.
Vector Quantization (VQ):
o Instead of quantizing individual samples, blocks (vectors) of samples are
quantized.
o A codebook containing representative vectors is used for compression.
Difference:
1. Symbols with higher frequencies are assigned shorter codes, reducing the average code
length.
2. Huffman coding produces an optimum prefix code where no code is a prefix of another,
ensuring unique decodability.
Approaches:
1. Forward Adaptation:
o Quantizer parameters are adjusted using the current input signal statistics.
o
Requires the transmitter and receiver to share updated parameters.
2. Backward Adaptation:
o Adjust quantization levels based on previous quantized outputs.
o Example: Delta modulation.
RLE is particularly efficient for images with large continuous white or black regions.
A Uniform Quantizer divides the input signal range into equal step sizes.
Data Compression reduces the size of data for efficient storage and transmission.
Why Needed:
Golomb Code: A variable-length code for run-lengths of 1’s or 0’s. It is optimal for
sources with geometric distributions.
Tunstall Codes: A variable-to-fixed-length code used for lossless compression.
22. Quantization
Example: For a signal range 0-10, divide it into 4 levels: 0-2.5, 2.5-5, etc.
Symbol Frequencies:
A:15, B:6, C:7, D:12, E:25, F:4, G:6, H:10, I:15.
Huffman Tree:
(Construct step-by-step based on least frequencies).
i. Decoding Message: Given binary string → Follow the tree to decode it.
1. Compression Ratio
2. Encoding/Decoding Time
3. Distortion (for lossy compression).
Let's calculate the entropy for the given probabilities in Question 34.
Given Probabilities:
Case 1:
P(a1)=12P(a_1) = \frac{1}{2}
P(a2)=14P(a_2) = \frac{1}{4}
P(a3)=18P(a_3) = \frac{1}{8}
P(a4)=18P(a_4) = \frac{1}{8}
Case 2:
P(a1)=0.505P(a_1) = 0.505
P(a2)=14P(a_2) = \frac{1}{4}
P(a3)=18P(a_3) = \frac{1}{8}
P(a4)=0.12P(a_4) = 0.12
Entropy Formula:
Where:
These values represent the average number of bits required to encode each symbol in the
respective distributions using an optimal encoding scheme.
Here are detailed explanations for each of the topics you requested:
Steganography is the practice of hiding information in a way that prevents detection. Unlike
cryptography, where the existence of the message is obvious, steganography aims to conceal the
message entirely.
Example:
Image Steganography: A secret message can be hidden in the least significant bits
(LSBs) of an image file. The color values in the image are altered slightly so that they are
imperceptible to the human eye but can be recovered by someone who knows the
method.
2. Explain Cryptanalysis
Euclid’s Algorithm is used to compute the greatest common divisor (GCD) of two numbers by
repeatedly applying the division algorithm.
Steps:
DES (Data Encryption Standard) is a symmetric-key block cipher that encrypts data in 64-bit
blocks using a 56-bit key.
Steps:
1. Initial Permutation (IP): The 64-bit input data is permuted using a predefined table.
2. Rounds: The data is divided into two 32-bit halves, and for 16 rounds, the right half is
passed through a series of operations involving a subkey derived from the main key.
3. Final Permutation (FP): After 16 rounds, a final permutation is applied to obtain the
ciphertext.
Diagram:
Input Block -> IP -> Round 1 -> Round 2 -> ... -> Round 16 -> Final
Permutation -> Ciphertext
5. Explain RSA Algorithm with Steps
RSA is an asymmetric encryption algorithm where the public key and private key are used for
encryption and decryption, respectively.
Encryption:
Given plaintext M=77M = 77, the ciphertext CC is computed as:
Decryption:
Types:
1. Symmetric Key Cryptography: Both sender and receiver share the same secret key.
o Example: AES, DES.
2. Asymmetric Key Cryptography: Public and private keys are used.
o Example: RSA, ECC.
3. Hash Functions: Used to verify data integrity.
o Example: SHA-256.
7. Define Block Cipher and Discuss Two Block Cipher Modes of Operation
Two Modes:
Fermat’s Little Theorem: If pp is a prime number and aa is an integer not divisible by pp, then:
Chinese Remainder Theorem (CRT) states that if n1,n2,…,nkn_1, n_2, \dots, n_k are pairwise
coprime integers, then there exists a unique solution modulo N=n1n2…nkN = n_1 n_2 \dots n_k
to the system of simultaneous congruences.
Given:
Solve using CRT (you can compute this using a systematic method or algorithm).
10. Find the Value of ϕ(12)\phi(12)
Euler's Totient Function ϕ(n)\phi(n) is the count of integers up to nn that are coprime with nn.
The GCD is 2.
Substitution Cipher: Each letter of the plaintext is replaced with another letter or
symbol.
o Example: Caesar Cipher.
Transposition Cipher: The positions of the characters in the plaintext are shifted or
rearranged.
o Example: Rail Fence Cipher
Cryptanalysis refers to the study of methods to break cryptographic codes and systems. The aim
is to retrieve the original message without knowing the key by exploiting vulnerabilities in the
algorithm.
You intercepted C=8C = 8, and the public key is e=13e = 13, n=33n = 33.
� Here are the detailed explanations and solutions for the topics you've mentioned:
Monoalphabetic Ciphers:
In a monoalphabetic cipher, each letter of the plaintext is substituted with one letter from
the ciphertext alphabet.
It uses a fixed substitution for each letter, which means the same plaintext letter is always
encrypted to the same ciphertext letter.
Example: Caesar Cipher, where each letter is shifted by a fixed number (e.g., a shift of 3:
A → D, B → E, etc.).
Polyalphabetic Ciphers:
17. Explain Chinese Remainder Theorem (CRT) and Solve the System of
Congruences
The solution for XX exists and is unique modulo N=n1n2⋯nkN = n_1 n_2 \cdots n_k.
Given System:
Solve this system using the method of successive substitution or through the generalized solution
formula provided by CRT.
Euler’s Totient Function ϕ(n)\phi(n) counts the number of integers less than nn that are
coprime with nn.
For a product of two distinct primes pp and qq, we have:
ϕ(pq)=(p−1)(q−1)\phi(pq) = (p-1)(q-1)
Proof:
pp and qq are primes, so their only divisors are 1 and the prime number itself.
The number of integers less than pqpq that are divisible by pp is pqp=q\frac{pq}{p} = q,
and the number divisible by qq is pqq=p\frac{pq}{q} = p.
The number of integers divisible by both pp and qq is pqpq=1\frac{pq}{pq} = 1.
Using the inclusion-exclusion principle:
ϕ(pq)=pq−(p+q−1)=(p−1)(q−1)\phi(pq) = pq - (p + q - 1) = (p-1)(q-1)
The most security-critical component of the DES round function is the S-boxes (Substitution
boxes).
The S-boxes provide confusion, a cryptographic property that makes the relationship between the
plaintext and ciphertext as complex as possible. The non-linear nature of the S-boxes is crucial
for the security of DES, as they scramble the bits of the data and make it difficult to reverse the
encryption without the key.
20. Discuss the Design of S-Box of AES and How It Differs from DES S-Boxes
The S-box in AES is more complex and provides better security. DES S-boxes are fixed
and vulnerable to attacks based on known plaintext, while AES S-boxes are more
resistant to such attacks.
AES S-boxes are derived from mathematical properties in finite fields, while DES S-
boxes were designed manually to meet security criteria.
21. Define a Group and Ring. Prove that the Order of Any Subgroup of Finite
Group Divides the Order of the Group
Ring: A ring is a set RR with two operations, addition and multiplication, where:
Proof:
If HH is a subgroup of a finite group GG, then by Lagrange’s Theorem, the order of HH divides
the order of GG. Specifically, ∣G∣=∣H∣×k|G| = |H| \times k, where kk is the number of distinct
cosets of HH in GG.
Confusion: The goal of confusion is to make the relationship between the plaintext and
ciphertext as complex as possible. It is achieved by the use of substitution (like S-boxes).
Diffusion: Diffusion spreads the influence of each plaintext bit over many ciphertext bits,
achieved through permutation or transposition (like the P-layer in DES). The idea is that
changing one bit of the plaintext should result in changes in many bits of the ciphertext.
Ciphertext: PHHW PH
To decrypt:
We previously computed:
The GCD is 2.
26. Explain the Concept of Block Cipher and Stream Cipher in Cryptography
Block Cipher:
Stream Cipher:
The Playfair Cipher is a digraph substitution cipher. The plaintext is divided into pairs of letters
(digraphs), and each pair is encrypted according to a 5x5 key matrix.
Steps:
1. Create the 5x5 matrix using the key "playfair" (eliminate duplicate letters).
2. Encrypt each digraph based on the matrix rules (same row, same column, or rectangle
rules).
28. Block Level Diagram for DES Round and Complementation Proof
The proof involves showing that if the plaintext and key are complemented, the resulting
ciphertext is also complemented.
AES Algorithm:
AES is a symmetric block cipher that operates on 128-bit blocks using key sizes of 128,
192, or 256 bits.
It uses multiple rounds of substitution (S-box), permutation (ShiftRows), and mixing
(MixColumns).
AES is more secure due to its larger key sizes and more rounds of encryption.
DES uses a 56-bit key, while AES uses keys of 128, 192, or 256 bits.
30. State and Prove Fermat’s Theorem
Fermat’s Little Theorem states that if pp is a prime number and aa is an integer not divisible by
pp, then:
31. RSA Algorithm and Private Key Calculation for A (p=13, q=17, public
key=35)