Cryptography Exam Assistance
Cryptography Exam Assistance
I have my cryptography and network security paper tomorrow answer all my questions just like a
student would
Memory updated
Got it! I’ll answer your questions like a fellow student. Fire away! What's your first question?
Eva has acquired the ciphertext that Alice has secretly sent to the
Bob. Classify the attacks in the following scenarios and also justify
your answer :
(I) Eva wants to retrieve the original plaintext by applying all
possible key combinations.
(II) Eva is analysing the different cipher text to predict the
plaintext.
(ii) Differentiate between a block cipher and a stream cipher.
(I) Eva wants to retrieve the original plaintext by applying all possible key
combinations.
Justification: In a brute-force attack, the attacker (Eva) tries all possible key combinations to decrypt
the ciphertext and retrieve the original plaintext. Since modern encryption uses a large key space (e.g.,
AES-256 uses 2^256 possible keys), this method is computationally expensive but theoretically
possible.
Justification: In a ciphertext-only attack, the attacker has access to multiple ciphertexts but doesn't
know the corresponding plaintext or keys. The attacker uses statistical analysis or other techniques to
deduce patterns in the ciphertexts, hoping to predict or infer the original plaintext. This is one of the
more challenging forms of attack since no plaintext or key information is available to the attacker.
Common
AES, DES, Blowfish RC4, Salsa20, ChaCha20
Algorithms
Use Playfair cipher to encrypt the message "Instrument", with the key
"Encryption".
To encrypt the message "Instrument" using the Playfair cipher with the key "Encryption", here’s
how you go about it:
E N C R Y
P T I O A
B D F G H
K L M Q S
U V W X Z
1. Message: "Instrument".
Split the plaintext into digraphs (pairs of two letters). If a pair has the same letters, we add
an 'X' between them. If there's a single letter left at the end, we append an 'X'.
"Instrument" becomes: IN ST RU ME NT.
The Playfair cipher has three main rules for encrypting digraphs:
Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 2/15
1. Same row: If both letters are in the same row, replace each with the letter immediately to its
right (wrap around if necessary).
2. Same column: If both letters are in the same column, replace each with the letter immediately
below (wrap around if necessary).
3. Rectangle: If the letters form a rectangle, replace them with the letters on the same row but in
the opposite corners.
1. IN:
'I' is at (2,3) and 'N' is at (1,2).
Form a rectangle: replace 'I' with 'C' and 'N' with 'T'.
IN → CT.
2. ST:
'S' is at (4,5) and 'T' is at (2,2).
Form a rectangle: replace 'S' with 'A' and 'T' with 'L'.
ST → AL.
3. RU:
'R' is at (1,4) and 'U' is at (5,1).
Form a rectangle: replace 'R' with 'E' and 'U' with 'O'.
RU → EO.
4. ME:
'M' is at (3,3) and 'E' is at (1,1).
Form a rectangle: replace 'M' with 'C' and 'E' with 'I'.
ME → CI.
5. NT:
'N' is at (1,2) and 'T' is at (2,2).
Same column rule: replace 'N' with 'T' and 'T' with 'D'.
NT → TD.
Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 3/15
Let's encrypt the plaintext "MOREMONEY" using the Hill cipher with the given key matrix:
The Hill cipher is a polyalphabetic substitution cipher based on linear algebra. We divide the plaintext
into groups of letters and multiply them with a matrix (the key). Each letter corresponds to a number,
where A = 0, B = 1, ..., Z = 25.
Plaintext: MOREMONEY
Letter M O R E M O N E Y
Value 12 14 17 4 12 14 13 4 24
Since the Hill cipher uses matrix multiplication, and our key matrix is 3x3, we divide the plaintext into
triplets of 3 letters.
Triplets:
21 18 21
K = 17 17 5
2 2 19
Each triplet is treated as a column vector, and we multiply the key matrix by each triplet vector. After
that, we take each result modulo 26 (since we are dealing with the English alphabet which has 26
letters).
Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 4/15
861 mod 26 3
527 mod 26 = 7
375 mod 26 11
594 mod 26 22
342 mod 26 = 4
298 mod 26 12
849 mod 26 17
409 mod 26 = 19
490 mod 26 22
Ciphertext: DHLWEMRTW
Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 5/15
AES (Advanced Encryption Standard) is a symmetric key encryption algorithm that works with block
sizes of 128 bits (16 bytes) and supports key sizes of 128, 192, and 256 bits. The encryption process in
AES involves a series of transformations, applied in multiple rounds (10 rounds for 128-bit key, 12
rounds for 192-bit key, and 14 rounds for 256-bit key).
1. SubBytes (Substitution)
Operation: Each byte in the 16-byte state (block) is replaced using a substitution box (S-box),
which is a fixed lookup table.
Purpose: Provides non-linearity to the algorithm and enhances security by making the
relationship between the input and output complex.
Details: The S-box is derived from the multiplicative inverse over the finite field GF(2^8) and is
further transformed using an affine transformation.
Operation: Each row of the 4x4 state matrix is shifted to the left by a different number of bytes:
Row 1 (top row) is unchanged.
Row 2 is shifted by 1 byte.
Row 3 is shifted by 2 bytes.
Row 4 is shifted by 3 bytes.
Purpose: Creates diffusion by mixing up the bytes within the state, making the output more
dependent on multiple parts of the input.
Operation: Each column of the 4x4 state matrix is treated as a polynomial and multiplied by a
fixed polynomial (modulo x^4 + 1) in the finite field GF(2^8).
Purpose: Provides diffusion by spreading out the influence of each byte over the entire column,
ensuring that changes in one byte affect other bytes in the column.
Details: The matrix multiplication ensures that each output byte is a combination of all input
bytes of the column.
Operation: A round key, derived from the main AES key through the key expansion process, is
XORed with the state.
Purpose: Adds the key into the mix and is the only step that involves the secret key. It ensures
that encryption can only be reversed with knowledge of the correct key.
Details: The key is added in an XOR operation, which combines the key with the data in a
reversible way.
Operation: The original key is expanded into multiple round keys (one for each round of AES).
This process involves applying the following steps:
RotWord: A word (4 bytes) is rotated left.
SubWord: Each byte of the word is substituted using the S-box.
Rcon (Round Constant): A round constant is XORed with the first word of the key.
Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 6/15
Purpose: The expanded keys are used in each round of AES to provide unique round keys,
ensuring that each round behaves differently even with the same input.
1. Initial Round:
AddRoundKey: The plaintext is XORed with the first round key.
3. Final Round:
SubBytes
ShiftRows
AddRoundKey (Note: No MixColumns in the final round).
Summary:
These transformations together ensure that AES achieves confusion and diffusion, making it resistant
to cryptanalysis like differential and linear attacks.
Block ciphers, such as AES and DES, process fixed-size blocks of data (e.g., 64 or 128 bits). To encrypt
larger data sizes, different modes of operation are used. Each mode defines how blocks are
processed and linked to maintain security. Here are the most common modes:
How it works: Each plaintext block is encrypted independently using the same key.
Advantages: Simple and fast, allows for parallel encryption of blocks.
Disadvantages: Identical plaintext blocks produce identical ciphertext blocks, which reveals
patterns in the data, making it vulnerable to attacks (like when encrypting images or repetitive
data).
Use case: Generally not recommended for sensitive data due to pattern leakage.
How it works: Turns a block cipher into a self-synchronizing stream cipher. The IV is encrypted,
and the result is XORed with the plaintext to produce the ciphertext. The output is fed back into
the encryption process.
Advantages: Can encrypt data in smaller increments (e.g., bytes instead of blocks). It’s useful for
real-time communication (e.g., network streams).
Disadvantages: Like CBC, encryption is sequential and cannot be parallelized. Requires a unique
IV.
Use case: Suitable for scenarios where data arrives in small chunks, like network traffic.
How it works: Similar to CFB, but instead of feeding the ciphertext back into the encryption
process, it feeds the encrypted output (key stream). This makes the ciphertext independent of
previous ciphertext blocks.
Advantages: Precomputes the key stream, so encryption can be parallelized. No error
propagation: a bit error in transmission only affects the corresponding bit.
Disadvantages: Requires a unique IV for each encryption session. Any IV reuse will compromise
security.
Use case: Suitable for secure communication systems where error propagation must be avoided,
such as satellite links.
How it works: Turns a block cipher into a stream cipher by encrypting successive values of a
counter. The counter value is combined with the plaintext (typically using XOR) to produce
ciphertext.
Advantages: Supports parallel encryption of blocks since each block is independent. No error
propagation. Also works efficiently in both hardware and software.
Disadvantages: Requires a unique nonce or counter for each encryption to ensure security.
Use case: Widely used in high-speed network encryption, disk encryption (e.g., in modern
storage systems), and in protocols like TLS.
Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 8/15
Each mode has its strengths and weaknesses, and the choice of mode depends on the application’s
need for security, speed, error handling, and data size.
(i) In the context of statistical cryptanalysis, what do you understand by the terms diffusion and
confusion, and how they are introduced in block cipher ?
(ii) Differentiate between random and pseudo-random numbers.
Diffusion and confusion are two fundamental concepts in the design of secure cryptographic
algorithms, particularly in block ciphers. They help ensure that the relationship between the plaintext,
ciphertext, and key is complex and non-linear, making it difficult for attackers to deduce the key or
plaintext from the ciphertext.
Diffusion
Definition: Diffusion refers to the property of a cipher where the influence of a single plaintext
bit is spread out over many ciphertext bits. In other words, changing a single bit in the plaintext
should result in a significant and unpredictable change in the ciphertext.
Purpose: The goal is to ensure that small changes in the plaintext produce large changes in the
ciphertext, thus minimizing the chances of successful statistical attacks.
Implementation in Block Ciphers:
Diffusion is typically achieved through linear transformations, such as the MixColumns
step in the AES cipher. This transformation mixes the input bytes in such a way that each
output byte depends on multiple input bytes, effectively distributing the information
throughout the ciphertext.
Confusion
Definition: Confusion refers to the property of a cipher that makes the relationship between the
key and the ciphertext as complex as possible. The goal is to ensure that the key cannot be easily
deduced from the ciphertext.
Purpose: It obscures the connection between the plaintext and the ciphertext, making it difficult
for an attacker to uncover any relationship between the two, especially when using known-
plaintext or chosen-plaintext attacks.
Implementation in Block Ciphers:
Confusion is achieved through non-linear transformations, such as the SubBytes step in
AES. The use of an S-box, which substitutes bytes in a non-linear manner, creates confusion
by making the mapping from plaintext to ciphertext complex and non-linear.
Random Numbers
Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 9/15
Definition: True random numbers are generated from inherently random physical processes,
such as radioactive decay, thermal noise, or atmospheric noise.
Characteristics:
Unpredictability: True random numbers are unpredictable and cannot be reproduced.
Uniform Distribution: They typically follow a uniform distribution over the desired range.
Source: Their generation often involves hardware-based random number generators
(RNGs) that measure physical phenomena.
Use Cases: Useful in applications requiring high levels of security and unpredictability, such as
cryptographic keys, secure communications, and gaming.
Pseudo-Random Numbers
Summary:
Diffusion spreads out the influence of plaintext changes, while confusion obscures the
relationship between plaintext, ciphertext, and keys in block ciphers.
Random numbers are generated from physical processes and are unpredictable, whereas
pseudo-random numbers are algorithmically generated, predictable if the seed is known, and
typically used in non-security-critical applications.
(i) Discuss the criteria defined by NIST for selecting the AES.
(ii) Explain the linear congruential generator for generating pseudo random numbers. Further
exemplify the importance of selecting the values a, c and m in the same.
The National Institute of Standards and Technology (NIST) established several criteria for the selection
of the Advanced Encryption Standard (AES). The selection process involved a thorough evaluation of
various candidate algorithms based on several important factors:
1. Security:
Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 10/15
The algorithm must provide strong security against known types of attacks, including
brute-force attacks and various cryptanalytic techniques.
It should be resistant to linear and differential cryptanalysis.
2. Implementation:
AES should be implementable in both hardware and software environments efficiently.
The algorithm should be efficient in terms of speed and resource usage, including memory
requirements.
3. Flexibility:
It should support multiple key lengths (128, 192, and 256 bits) to allow for varying levels of
security.
The algorithm must be adaptable to various platforms, from constrained devices (like smart
cards) to high-performance systems (like servers).
4. Simplicity:
The design should be straightforward and easy to understand to facilitate analysis and
implementation.
A simpler design reduces the risk of errors in implementation.
5. Performance:
The algorithm should provide high performance for both encryption and decryption
processes.
It should be optimized for various computational environments and should not significantly
slow down overall system performance.
6. Availability:
The algorithm must be publicly available, promoting widespread use and ensuring
transparency for security evaluations.
It should not rely on proprietary techniques or hardware.
7. Robustness:
The design must be robust against the discovery of vulnerabilities over time.
It should be able to withstand future developments in cryptanalysis and computational
power.
NIST conducted a competition to select AES, and the Rijndael algorithm was chosen as the winner in
2001 based on its strong security features and compliance with the above criteria.
The Linear Congruential Generator (LCG) is one of the simplest and oldest methods for generating
pseudo-random numbers. It operates based on a linear recurrence relation. The general formula for
generating a sequence of pseudo-random numbers is given by:
Xn+1 = (a ⋅ Xn + c) mod m
Where:
Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 11/15
Xn is the current random number (seed or state).
a is the multiplier.
c is the increment (also known as the additive constant).
m is the modulus.
n is the sequence index (iteration).
Key Parameters:
Seed (X0 ): The initial value for the generator, which influences the entire sequence of generated
numbers.
Multiplier (a): A constant that controls how the current value is transformed into the next value.
Increment (c): Adds a constant value to the product of the multiplier and the current value.
Modulus (m): Determines the range of output values, which typically is m = 2k for some
integer k .
The modulus determines the range of generated numbers. If m is too small, the sequence
will repeat quickly, reducing randomness.
Commonly, m is chosen as a power of 2, making the computation efficient using bitwise
operations.
Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 12/15
Using these values, the LCG can generate pseudo-random numbers effectively, producing a sequence
with a long period and a uniform distribution.
Summary
NIST Criteria for AES: Focus on security, performance, implementation, simplicity, flexibility, and
availability.
Linear Congruential Generator: A method for generating pseudo-random numbers based on a
linear recurrence relation, where the choice of parameters a, c, and m is critical for achieving
good randomness and a long period.
(a) Analyse and explain the process of key distribution for two parties A and B via KDC, where A
and B both share a secret key with KDC.
(b) Discuss Blum Blum Shub generator approach to generate pseudo-random number. Generate
the random number sequence X1, X2, X3, X4 by using the Blum Blum Shub generator where p =
11, q = 19, and x0 =100.
Key Distribution Center (KDC) is a trusted third party that facilitates secure communication between
two parties, A and B, by distributing session keys for encryption. Here’s an analysis of the key
distribution process:
1. Initial Setup:
Both parties, A and B, must share a secret key with the KDC. Let’s denote these keys as
KAKDC for A and KBKDC for B. These keys are established through a secure means
Example:
3. KDC Responds:
Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 13/15
Upon receiving the request, the KDC generates a session key KAB for A and B. It encrypts
For B: EKDC (KAB ) (the same session key is encrypted with B's key)
The encrypted session key for B, which is sent as part of the response to A:
EKDC (KAB )
Example:
B receives the message and decrypts it using its shared key KBKDC :
6. Secure Communication:
After successfully retrieving the session key, A and B can now communicate securely using
the session key KAB for encryption and decryption of their messages.
The KDC acts as a trusted intermediary for establishing a secure session key.
A and B share their respective keys with the KDC and request a session key.
The KDC generates and securely distributes the session key, enabling A and B to communicate
securely.
The Blum Blum Shub (BBS) generator is a cryptographically secure pseudo-random number
generator based on number theory. It uses the properties of prime factorization and modular
arithmetic.
Xn+1 = Xn2
mod M
Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 14/15
where M = p × q (the product of two distinct primes).
The initial value X0 must be chosen such that X0 is coprime to M .
The least significant bit of each generated Xn is typically used as the random bit.
Parameters:
M = p × q = 11 × 19 = 209
1. Calculate X1 :
2. Calculate X2 :
3. Calculate X3 :
4. Calculate X4 :
X1 = 109
X2 = 95
X3 = 37
X4
= 146
The Blum Blum Shub generator produces a sequence of pseudo-random numbers based on
squaring the previous number modulo the product of two distinct primes.
The choice of primes and the initial seed is critical to ensure the security and randomness of the
generated numbers.
ChatGPT can make mistakes. Check important info.
Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 15/15