1 / 53100%
ANALYSIS OF CRYPTOGRAPHIC ALGORITHMS’ TIME AND
SPACE COMPLEXITY
1 SYMMETRIC ENCRYPTION ALGORITHMS
Problem 1. The Advanced Encryption Standard (AES) operates on 128-bit blocks. If the input
message is n bits long, what is the time complexity of encrypting this message using AES in
ECB mode? Express your answer in big O notation.
Solution 1. Step 1: Determine the number of blocks. Number of blocks = ⌈n/128
Step 2: Analyze the time complexity. Each block encryption takes constant time. Total time =
O(Number of blocks) = O(⌈n/128) = O(n)
Therefore, the time complexity of encrypting an n-bit message using AES in ECB mode is O(n).
Problem 2. The Data Encryption Standard (DES) uses a 56-bit key. How many operations
would be required for an exhaustive key search in the worst case? Express your answer in big O
notation.
Solution 2. Step 1: Calculate the total number of possible keys. Number of possible keys =
256
Step 2: In the worst case, we might need to try all possible keys. Worst-case number of
operations = 256
Therefore, the time complexity of an exhaustive key search for DES is O(256).
Problem 3. The RC4 stream cipher has an initialization phase where it creates a 256-byte
state array. What is the space complexity of RC4 in terms of the key size k? Express your
answer in big O notation.
Solution 3. Step 1: Analyze the space requirements. - The state array requires 256 bytes
(constant) - The key of size k bytes is stored
Step 2: Express the total space in big O notation. Space complexity = O(256 + k) = O(k)
Therefore, the space complexity of RC4 is O(k), where k is the key size in bytes.
2 ASYMMETRIC ENCRYPTION ALGORITHMS
Problem 4. In RSA, key generation involves finding two large prime numbers. If we use the
trial division method to test primality up to n for an n-bit number, what is the time complexity
of this primality test? Express your answer in big O notation.
Solution 4. Step 1: Determine the range of numbers to check. For an n-bit number, the
maximum value is 2n 1. We need to check up to 2n 1, which is approximately 2n/2.
Step 2: Calculate the number of operations. Number of operations ≈ 2n/2
Therefore, the time complexity of the trial division primality test for an n-bit number is O(2n/2).
Problem 5. In the Diffie-Hellman key exchange protocol, both parties perform modular
exponentiation. If the modulus is an n-bit number, what is the time complexity of the modular
exponentiation operation using the square-and-multiply algorithm? Express your answer in big
O notation.
Solution 5. Step 1: Analyze the square-and-multiply algorithm. - The algorithm performs n
steps for an n-bit exponent - Each step involves at most two operations: squaring and
multiplication
Step 2: Determine the complexity of each operation. - Squaring and multiplication of n-bit
numbers take O(n2) time using naive multiplication - Using more efficient algorithms like
Karatsuba, it can be reduced to O(nlog23) ≈ O(n1.585)
Step 3: Calculate the overall time complexity. Time complexity = n * O(nlog23) = O(n1+log23) ≈
O(n2.585)
Therefore, the time complexity of modular exponentiation in Diffie-Hellman key exchange is
O(n2.585), where n is the number of bits in the modulus.
Problem 6. Elliptic Curve Cryptography (ECC) operates on points on an elliptic curve. If the
field size is q, what is the space complexity of storing a public key in ECC? Express your answer
in big O notation.
Solution 6. Step 1: Analyze the components of an ECC public key. An ECC public key consists
of: - The elliptic curve parameters (assumed to be fixed and not counted) - A point on the
curve, represented by two coordinates (x, y)
Step 2: Determine the size of each coordinate. Each coordinate is an element of the field of size
q, requiring log_2(q) bits to represent.
Step 3: Calculate the total space required. Space for public key = 2 * log_2(q) bits
Therefore, the space complexity of storing an ECC public key is O(log q).
3 HASH FUNCTIONS
Problem 7. The SHA-256 hash function processes messages in 512-bit blocks. If the input
message is n bits long, what is the time complexity of computing its SHA-256 hash? Express
your answer in big O notation.
Solution 7. Step 1: Determine the number of blocks. Number of blocks = ⌈n/512
Step 2: Analyze the time complexity. Each block processing takes constant time. Total time =
O(Number of blocks) = O(⌈n/512) = O(n)
Therefore, the time complexity of computing the SHA-256 hash of an n-bit message is O(n).
Problem 8. In the Merkle-Damgård construction used in many hash functions, the message is
padded to a multiple of the block size. If the original message is n bits long and the block size is
b bits, what is the maximum length of the padded message? Express your answer in terms of n
and b.
Solution 8. Step 1: Analyze the padding scheme. - The message is padded to a multiple of
the block size - At least 1 bit is always added (the ’1’ bit) - The length of the original message
(n) is appended (usually 64 bits)
Step 2: Calculate the maximum padded length. Maximum padded length = (n + 1 + 64)/b b
This can be simplified to: Maximum padded length = (n + 65)/b⌉ b
Therefore, the maximum length of the padded message is (n + 65)/b⌉ b bits.
The Advanced Encryption Standard (AES) operates on 128-bit blocks. If the input message is n
bits long, what is the time complexity of encrypting this message using AES in ECB mode?
Express your answer in big O notation.
Solution 1. Step 1: Determine the number of blocks. Number of blocks = ⌈n/128
Step 2: Analyze the time complexity. Each block encryption takes constant time. Total time =
O(Number of blocks) = O(⌈n/128) = O(n)
Therefore, the time complexity of encrypting an n-bit message using AES in ECB mode is O(n).
Problem 2. The Data Encryption Standard (DES) uses a 56-bit key. How many operations
would be required for an exhaustive key search in the worst case? Express your answer in big O
notation.
Solution 2. Step 1: Calculate the total number of possible keys. Number of possible keys =
256
Step 2: In the worst case, we might need to try all possible keys. Worst-case number of
operations = 256
Therefore, the time complexity of an exhaustive key search for DES is O(256).
Problem 3. The RC4 stream cipher has an initialization phase where it creates a 256-byte
state array. What is the space complexity of RC4 in terms of the key size k? Express your
answer in big O notation.
Solution 3. Step 1: Analyze the space requirements. - The state array requires 256 bytes
(constant) - The key of size k bytes is stored
Step 2: Express the total space in big O notation. Space complexity = O(256 + k) = O(k)
Therefore, the space complexity of RC4 is O(k), where k is the key size in bytes.
4 ASYMMETRIC ENCRYPTION ALGORITHMS
Problem 4. In RSA, key generation involves finding two large prime numbers. If we use the
trial division method to test primality up to n for an n-bit number, what is the time complexity
of this primality test? Express your answer in big O notation.
Solution 4. Step 1: Determine the range of numbers to check. For an n-bit number, the
maximum value is 2n 1. We need to check up to 2n 1, which is approximately 2n/2.
Step 2: Calculate the number of operations. Number of operations ≈ 2n/2
Therefore, the time complexity of the trial division primality test for an n-bit number is O(2n/2).
Problem 5. In the Diffie-Hellman key exchange protocol, both parties perform modular
exponentiation. If the modulus is an n-bit number, what is the time complexity of the modular
exponentiation operation using the square-and-multiply algorithm? Express your answer in big
O notation.
Solution 5. Step 1: Analyze the square-and-multiply algorithm. - The algorithm performs n
steps for an n-bit exponent - Each step involves at most two operations: squaring and
multiplication
Step 2: Determine the complexity of each operation. - Squaring and multiplication of n-bit
numbers take O(n2) time using naive multiplication - Using more efficient algorithms like
Karatsuba, it can be reduced to O(nlog23) ≈ O(n1.585)
Step 3: Calculate the overall time complexity. Time complexity = n * O(nlog23) = O(n1+log23) ≈
O(n2.585)
Therefore, the time complexity of modular exponentiation in Diffie-Hellman key exchange is
O(n2.585), where n is the number of bits in the modulus.
Problem 6. Elliptic Curve Cryptography (ECC) operates on points on an elliptic curve. If the
field size is q, what is the space complexity of storing a public key in ECC? Express your answer
in big O notation.
Solution 6. Step 1: Analyze the components of an ECC public key. An ECC public key consists
of: - The elliptic curve parameters (assumed to be fixed and not counted) - A point on the
curve, represented by two coordinates (x, y)
Step 2: Determine the size of each coordinate. Each coordinate is an element of the field of size
q, requiring log_2(q) bits to represent.
Step 3: Calculate the total space required. Space for public key = 2 * log_2(q) bits
Therefore, the space complexity of storing an ECC public key is O(log q).
5 HASH FUNCTIONS
Problem 7. The SHA-256 hash function processes messages in 512-bit blocks. If the input
message is n bits long, what is the time complexity of computing its SHA-256 hash? Express
your answer in big O notation.
Solution 7. Step 1: Determine the number of blocks. Number of blocks = ⌈n/512
Step 2: Analyze the time complexity. Each block processing takes constant time. Total time =
O(Number of blocks) = O(⌈n/512) = O(n)
Therefore, the time complexity of computing the SHA-256 hash of an n-bit message is O(n).
Problem 8. In the Merkle-Damgård construction used in many hash functions, the message is
padded to a multiple of the block size. If the original message is n bits long and the block size is
b bits, what is the maximum length of the padded message? Express your answer in terms of n
and b.
Solution 8. Step 1: Analyze the padding scheme. - The message is padded to a multiple of
the block size - At least 1 bit is always added (the ’1’ bit) - The length of the original message
(n) is appended (usually 64 bits)
Step 2: Calculate the maximum padded length. Maximum padded length = (n + 1 + 64)/b b
This can be simplified to: Maximum padded length = (n + 65)/b⌉ b
Therefore, the maximum length of the padded message is (n + 65)/b⌉ b bits.
The Advanced Encryption Standard (AES) operates on 128-bit blocks. If the input message is n
bits long, what is the time complexity of encrypting this message using AES in ECB mode?
Express your answer in big O notation.
Solution 1. Step 1: Determine the number of blocks. Number of blocks = ⌈n/128
Step 2: Analyze the time complexity. Each block encryption takes constant time. Total time =
O(Number of blocks) = O(⌈n/128) = O(n)
Therefore, the time complexity of encrypting an n-bit message using AES in ECB mode is O(n).
Problem 2. The Data Encryption Standard (DES) uses a 56-bit key. How many operations
would be required for an exhaustive key search in the worst case? Express your answer in big O
notation.
Solution 2. Step 1: Calculate the total number of possible keys. Number of possible keys =
256
Step 2: In the worst case, we might need to try all possible keys. Worst-case number of
operations = 256
Therefore, the time complexity of an exhaustive key search for DES is O(256).
Problem 3. The RC4 stream cipher has an initialization phase where it creates a 256-byte
state array. What is the space complexity of RC4 in terms of the key size k? Express your
answer in big O notation.
Solution 3. Step 1: Analyze the space requirements. - The state array requires 256 bytes
(constant) - The key of size k bytes is stored
Step 2: Express the total space in big O notation. Space complexity = O(256 + k) = O(k)
Therefore, the space complexity of RC4 is O(k), where k is the key size in bytes.
6 ASYMMETRIC ENCRYPTION ALGORITHMS
Problem 4. In RSA, key generation involves finding two large prime numbers. If we use the
trial division method to test primality up to n for an n-bit number, what is the time complexity
of this primality test? Express your answer in big O notation.
Solution 4. Step 1: Determine the range of numbers to check. For an n-bit number, the
maximum value is 2n 1. We need to check up to 2n 1, which is approximately 2n/2.
Step 2: Calculate the number of operations. Number of operations ≈ 2n/2
Therefore, the time complexity of the trial division primality test for an n-bit number is O(2n/2).
Problem 5. In the Diffie-Hellman key exchange protocol, both parties perform modular
exponentiation. If the modulus is an n-bit number, what is the time complexity of the modular
exponentiation operation using the square-and-multiply algorithm? Express your answer in big
O notation.
Solution 5. Step 1: Analyze the square-and-multiply algorithm. - The algorithm performs n
steps for an n-bit exponent - Each step involves at most two operations: squaring and
multiplication
Step 2: Determine the complexity of each operation. - Squaring and multiplication of n-bit
numbers take O(n2) time using naive multiplication - Using more efficient algorithms like
Karatsuba, it can be reduced to O(nlog23) ≈ O(n1.585)
Step 3: Calculate the overall time complexity. Time complexity = n * O(nlog23) = O(n1+log23) ≈
O(n2.585)
Therefore, the time complexity of modular exponentiation in Diffie-Hellman key exchange is
O(n2.585), where n is the number of bits in the modulus.
Problem 6. Elliptic Curve Cryptography (ECC) operates on points on an elliptic curve. If the
field size is q, what is the space complexity of storing a public key in ECC? Express your answer
in big O notation.
Solution 6. Step 1: Analyze the components of an ECC public key. An ECC public key consists
of: - The elliptic curve parameters (assumed to be fixed and not counted) - A point on the
curve, represented by two coordinates (x, y)
Step 2: Determine the size of each coordinate. Each coordinate is an element of the field of size
q, requiring log_2(q) bits to represent.
Step 3: Calculate the total space required. Space for public key = 2 * log_2(q) bits
Therefore, the space complexity of storing an ECC public key is O(log q).
7 HASH FUNCTIONS
Problem 7. The SHA-256 hash function processes messages in 512-bit blocks. If the input
message is n bits long, what is the time complexity of computing its SHA-256 hash? Express
your answer in big O notation.
Solution 7. Step 1: Determine the number of blocks. Number of blocks = ⌈n/512
Step 2: Analyze the time complexity. Each block processing takes constant time. Total time =
O(Number of blocks) = O(⌈n/512) = O(n)
Therefore, the time complexity of computing the SHA-256 hash of an n-bit message is O(n).
Problem 8. In the Merkle-Damgård construction used in many hash functions, the message is
padded to a multiple of the block size. If the original message is n bits long and the block size is
b bits, what is the maximum length of the padded message? Express your answer in terms of n
and b.
Solution 8. Step 1: Analyze the padding scheme. - The message is padded to a multiple of
the block size - At least 1 bit is always added (the ’1’ bit) - The length of the original message
(n) is appended (usually 64 bits)
Step 2: Calculate the maximum padded length. Maximum padded length = (n + 1 + 64)/b b
This can be simplified to: Maximum padded length = (n + 65)/b⌉ b
Therefore, the maximum length of the padded message is (n + 65)/b⌉ b bits.
The Advanced Encryption Standard (AES) operates on 128-bit blocks. If the input message is n
bits long, what is the time complexity of encrypting this message using AES in ECB mode?
Express your answer in big O notation.
Solution 1. Step 1: Determine the number of blocks. Number of blocks = ⌈n/128
Step 2: Analyze the time complexity. Each block encryption takes constant time. Total time =
O(Number of blocks) = O(⌈n/128) = O(n)
Therefore, the time complexity of encrypting an n-bit message using AES in ECB mode is O(n).
Problem 2. The Data Encryption Standard (DES) uses a 56-bit key. How many operations
would be required for an exhaustive key search in the worst case? Express your answer in big O
notation.
Solution 2. Step 1: Calculate the total number of possible keys. Number of possible keys =
256
Step 2: In the worst case, we might need to try all possible keys. Worst-case number of
operations = 256
Therefore, the time complexity of an exhaustive key search for DES is O(256).
Problem 3. The RC4 stream cipher has an initialization phase where it creates a 256-byte
state array. What is the space complexity of RC4 in terms of the key size k? Express your
answer in big O notation.
Solution 3. Step 1: Analyze the space requirements. - The state array requires 256 bytes
(constant) - The key of size k bytes is stored
Step 2: Express the total space in big O notation. Space complexity = O(256 + k) = O(k)
Therefore, the space complexity of RC4 is O(k), where k is the key size in bytes.
8 ASYMMETRIC ENCRYPTION ALGORITHMS
Problem 4. In RSA, key generation involves finding two large prime numbers. If we use the
trial division method to test primality up to n for an n-bit number, what is the time complexity
of this primality test? Express your answer in big O notation.
Solution 4. Step 1: Determine the range of numbers to check. For an n-bit number, the
maximum value is 2n 1. We need to check up to 2n 1, which is approximately 2n/2.
Step 2: Calculate the number of operations. Number of operations ≈ 2n/2
Therefore, the time complexity of the trial division primality test for an n-bit number is O(2n/2).
Problem 5. In the Diffie-Hellman key exchange protocol, both parties perform modular
exponentiation. If the modulus is an n-bit number, what is the time complexity of the modular
exponentiation operation using the square-and-multiply algorithm? Express your answer in big
O notation.
Solution 5. Step 1: Analyze the square-and-multiply algorithm. - The algorithm performs n
steps for an n-bit exponent - Each step involves at most two operations: squaring and
multiplication
Step 2: Determine the complexity of each operation. - Squaring and multiplication of n-bit
numbers take O(n2) time using naive multiplication - Using more efficient algorithms like
Karatsuba, it can be reduced to O(nlog23) ≈ O(n1.585)
Step 3: Calculate the overall time complexity. Time complexity = n * O(nlog23) = O(n1+log23) ≈
O(n2.585)
Therefore, the time complexity of modular exponentiation in Diffie-Hellman key exchange is
O(n2.585), where n is the number of bits in the modulus.
Problem 6. Elliptic Curve Cryptography (ECC) operates on points on an elliptic curve. If the
field size is q, what is the space complexity of storing a public key in ECC? Express your answer
in big O notation.
Solution 6. Step 1: Analyze the components of an ECC public key. An ECC public key consists
of: - The elliptic curve parameters (assumed to be fixed and not counted) - A point on the
curve, represented by two coordinates (x, y)
Step 2: Determine the size of each coordinate. Each coordinate is an element of the field of size
q, requiring log_2(q) bits to represent.
Step 3: Calculate the total space required. Space for public key = 2 * log_2(q) bits
Therefore, the space complexity of storing an ECC public key is O(log q).
9 HASH FUNCTIONS
Problem 7. The SHA-256 hash function processes messages in 512-bit blocks. If the input
message is n bits long, what is the time complexity of computing its SHA-256 hash? Express
your answer in big O notation.
Solution 7. Step 1: Determine the number of blocks. Number of blocks = ⌈n/512
Step 2: Analyze the time complexity. Each block processing takes constant time. Total time =
O(Number of blocks) = O(⌈n/512) = O(n)
Therefore, the time complexity of computing the SHA-256 hash of an n-bit message is O(n).
Problem 8. In the Merkle-Damgård construction used in many hash functions, the message is
padded to a multiple of the block size. If the original message is n bits long and the block size is
b bits, what is the maximum length of the padded message? Express your answer in terms of n
and b.
Solution 8. Step 1: Analyze the padding scheme. - The message is padded to a multiple of
the block size - At least 1 bit is always added (the ’1’ bit) - The length of the original message
(n) is appended (usually 64 bits)
Step 2: Calculate the maximum padded length. Maximum padded length = (n + 1 + 64)/b b
This can be simplified to: Maximum padded length = (n + 65)/b⌉ b
Therefore, the maximum length of the padded message is (n + 65)/b⌉ b bits.
The Advanced Encryption Standard (AES) operates on 128-bit blocks. If the input message is n
bits long, what is the time complexity of encrypting this message using AES in ECB mode?
Express your answer in big O notation.
Solution 1. Step 1: Determine the number of blocks. Number of blocks = ⌈n/128
Step 2: Analyze the time complexity. Each block encryption takes constant time. Total time =
O(Number of blocks) = O(⌈n/128) = O(n)
Therefore, the time complexity of encrypting an n-bit message using AES in ECB mode is O(n).
Problem 2. The Data Encryption Standard (DES) uses a 56-bit key. How many operations
would be required for an exhaustive key search in the worst case? Express your answer in big O
notation.
Solution 2. Step 1: Calculate the total number of possible keys. Number of possible keys =
256
Step 2: In the worst case, we might need to try all possible keys. Worst-case number of
operations = 256
Therefore, the time complexity of an exhaustive key search for DES is O(256).
Problem 3. The RC4 stream cipher has an initialization phase where it creates a 256-byte
state array. What is the space complexity of RC4 in terms of the key size k? Express your
answer in big O notation.
Solution 3. Step 1: Analyze the space requirements. - The state array requires 256 bytes
(constant) - The key of size k bytes is stored
Step 2: Express the total space in big O notation. Space complexity = O(256 + k) = O(k)
Therefore, the space complexity of RC4 is O(k), where k is the key size in bytes.
10 ASYMMETRIC ENCRYPTION ALGORITHMS
Problem 4. In RSA, key generation involves finding two large prime numbers. If we use the
trial division method to test primality up to n for an n-bit number, what is the time complexity
of this primality test? Express your answer in big O notation.
Solution 4. Step 1: Determine the range of numbers to check. For an n-bit number, the
maximum value is 2n 1. We need to check up to 2n 1, which is approximately 2n/2.
Step 2: Calculate the number of operations. Number of operations ≈ 2n/2
Therefore, the time complexity of the trial division primality test for an n-bit number is O(2n/2).
Problem 5. In the Diffie-Hellman key exchange protocol, both parties perform modular
exponentiation. If the modulus is an n-bit number, what is the time complexity of the modular
exponentiation operation using the square-and-multiply algorithm? Express your answer in big
O notation.
Solution 5. Step 1: Analyze the square-and-multiply algorithm. - The algorithm performs n
steps for an n-bit exponent - Each step involves at most two operations: squaring and
multiplication
Step 2: Determine the complexity of each operation. - Squaring and multiplication of n-bit
numbers take O(n2) time using naive multiplication - Using more efficient algorithms like
Karatsuba, it can be reduced to O(nlog23) ≈ O(n1.585)
Step 3: Calculate the overall time complexity. Time complexity = n * O(nlog23) = O(n1+log23) ≈
O(n2.585)
Therefore, the time complexity of modular exponentiation in Diffie-Hellman key exchange is
O(n2.585), where n is the number of bits in the modulus.
Problem 6. Elliptic Curve Cryptography (ECC) operates on points on an elliptic curve. If the
field size is q, what is the space complexity of storing a public key in ECC? Express your answer
in big O notation.
Solution 6. Step 1: Analyze the components of an ECC public key. An ECC public key consists
of: - The elliptic curve parameters (assumed to be fixed and not counted) - A point on the
curve, represented by two coordinates (x, y)
Step 2: Determine the size of each coordinate. Each coordinate is an element of the field of size
q, requiring log_2(q) bits to represent.
Step 3: Calculate the total space required. Space for public key = 2 * log_2(q) bits
Therefore, the space complexity of storing an ECC public key is O(log q).
11 HASH FUNCTIONS
Problem 7. The SHA-256 hash function processes messages in 512-bit blocks. If the input
message is n bits long, what is the time complexity of computing its SHA-256 hash? Express
your answer in big O notation.
Solution 7. Step 1: Determine the number of blocks. Number of blocks = ⌈n/512
Step 2: Analyze the time complexity. Each block processing takes constant time. Total time =
O(Number of blocks) = O(⌈n/512) = O(n)
Therefore, the time complexity of computing the SHA-256 hash of an n-bit message is O(n).
Problem 8. In the Merkle-Damgård construction used in many hash functions, the message is
padded to a multiple of the block size. If the original message is n bits long and the block size is
b bits, what is the maximum length of the padded message? Express your answer in terms of n
and b.
Solution 8. Step 1: Analyze the padding scheme. - The message is padded to a multiple of
the block size - At least 1 bit is always added (the ’1’ bit) - The length of the original message
(n) is appended (usually 64 bits)
Step 2: Calculate the maximum padded length. Maximum padded length = (n + 1 + 64)/b b
This can be simplified to: Maximum padded length = (n + 65)/b⌉ b
Therefore, the maximum length of the padded message is (n + 65)/b⌉ b bits.
The Advanced Encryption Standard (AES) operates on 128-bit blocks. If the input message is n
bits long, what is the time complexity of encrypting this message using AES in ECB mode?
Express your answer in big O notation.
Solution 1. Step 1: Determine the number of blocks. Number of blocks = ⌈n/128
Step 2: Analyze the time complexity. Each block encryption takes constant time. Total time =
O(Number of blocks) = O(⌈n/128) = O(n)
Therefore, the time complexity of encrypting an n-bit message using AES in ECB mode is O(n).
Problem 2. The Data Encryption Standard (DES) uses a 56-bit key. How many operations
would be required for an exhaustive key search in the worst case? Express your answer in big O
notation.
Solution 2. Step 1: Calculate the total number of possible keys. Number of possible keys =
256
Step 2: In the worst case, we might need to try all possible keys. Worst-case number of
operations = 256
Therefore, the time complexity of an exhaustive key search for DES is O(256).
Problem 3. The RC4 stream cipher has an initialization phase where it creates a 256-byte
state array. What is the space complexity of RC4 in terms of the key size k? Express your
answer in big O notation.
Solution 3. Step 1: Analyze the space requirements. - The state array requires 256 bytes
(constant) - The key of size k bytes is stored
Step 2: Express the total space in big O notation. Space complexity = O(256 + k) = O(k)
Therefore, the space complexity of RC4 is O(k), where k is the key size in bytes.
12 ASYMMETRIC ENCRYPTION ALGORITHMS
Problem 4. In RSA, key generation involves finding two large prime numbers. If we use the
trial division method to test primality up to n for an n-bit number, what is the time complexity
of this primality test? Express your answer in big O notation.
Solution 4. Step 1: Determine the range of numbers to check. For an n-bit number, the
maximum value is 2n 1. We need to check up to 2n 1, which is approximately 2n/2.
Step 2: Calculate the number of operations. Number of operations ≈ 2n/2
Therefore, the time complexity of the trial division primality test for an n-bit number is O(2n/2).
Problem 5. In the Diffie-Hellman key exchange protocol, both parties perform modular
exponentiation. If the modulus is an n-bit number, what is the time complexity of the modular
exponentiation operation using the square-and-multiply algorithm? Express your answer in big
O notation.
Solution 5. Step 1: Analyze the square-and-multiply algorithm. - The algorithm performs n
steps for an n-bit exponent - Each step involves at most two operations: squaring and
multiplication
Step 2: Determine the complexity of each operation. - Squaring and multiplication of n-bit
numbers take O(n2) time using naive multiplication - Using more efficient algorithms like
Karatsuba, it can be reduced to O(nlog23) ≈ O(n1.585)
Step 3: Calculate the overall time complexity. Time complexity = n * O(nlog23) = O(n1+log23) ≈
O(n2.585)
Therefore, the time complexity of modular exponentiation in Diffie-Hellman key exchange is
O(n2.585), where n is the number of bits in the modulus.
Problem 6. Elliptic Curve Cryptography (ECC) operates on points on an elliptic curve. If the
field size is q, what is the space complexity of storing a public key in ECC? Express your answer
in big O notation.
Solution 6. Step 1: Analyze the components of an ECC public key. An ECC public key consists
of: - The elliptic curve parameters (assumed to be fixed and not counted) - A point on the
curve, represented by two coordinates (x, y)
Step 2: Determine the size of each coordinate. Each coordinate is an element of the field of size
q, requiring log_2(q) bits to represent.
Step 3: Calculate the total space required. Space for public key = 2 * log_2(q) bits
Therefore, the space complexity of storing an ECC public key is O(log q).
13 HASH FUNCTIONS
Problem 7. The SHA-256 hash function processes messages in 512-bit blocks. If the input
message is n bits long, what is the time complexity of computing its SHA-256 hash? Express
your answer in big O notation.
Solution 7. Step 1: Determine the number of blocks. Number of blocks = ⌈n/512
Step 2: Analyze the time complexity. Each block processing takes constant time. Total time =
O(Number of blocks) = O(⌈n/512) = O(n)
Therefore, the time complexity of computing the SHA-256 hash of an n-bit message is O(n).
Problem 8. In the Merkle-Damgård construction used in many hash functions, the message is
padded to a multiple of the block size. If the original message is n bits long and the block size is
b bits, what is the maximum length of the padded message? Express your answer in terms of n
and b.
Solution 8. Step 1: Analyze the padding scheme. - The message is padded to a multiple of
the block size - At least 1 bit is always added (the ’1’ bit) - The length of the original message
(n) is appended (usually 64 bits)
Step 2: Calculate the maximum padded length. Maximum padded length = (n + 1 + 64)/b b
This can be simplified to: Maximum padded length = (n + 65)/b⌉ b
Therefore, the maximum length of the padded message is (n + 65)/b⌉ b bits.
The Advanced Encryption Standard (AES) operates on 128-bit blocks. If the input message is n
bits long, what is the time complexity of encrypting this message using AES in ECB mode?
Express your answer in big O notation.
Solution 1. Step 1: Determine the number of blocks. Number of blocks = ⌈n/128
Step 2: Analyze the time complexity. Each block encryption takes constant time. Total time =
O(Number of blocks) = O(⌈n/128) = O(n)
Therefore, the time complexity of encrypting an n-bit message using AES in ECB mode is O(n).
Problem 2. The Data Encryption Standard (DES) uses a 56-bit key. How many operations
would be required for an exhaustive key search in the worst case? Express your answer in big O
notation.
Solution 2. Step 1: Calculate the total number of possible keys. Number of possible keys =
256
Step 2: In the worst case, we might need to try all possible keys. Worst-case number of
operations = 256
Therefore, the time complexity of an exhaustive key search for DES is O(256).
Problem 3. The RC4 stream cipher has an initialization phase where it creates a 256-byte
state array. What is the space complexity of RC4 in terms of the key size k? Express your
answer in big O notation.
Solution 3. Step 1: Analyze the space requirements. - The state array requires 256 bytes
(constant) - The key of size k bytes is stored
Step 2: Express the total space in big O notation. Space complexity = O(256 + k) = O(k)
Therefore, the space complexity of RC4 is O(k), where k is the key size in bytes.
14 ASYMMETRIC ENCRYPTION ALGORITHMS
Problem 4. In RSA, key generation involves finding two large prime numbers. If we use the
trial division method to test primality up to n for an n-bit number, what is the time complexity
of this primality test? Express your answer in big O notation.
Solution 4. Step 1: Determine the range of numbers to check. For an n-bit number, the
maximum value is 2n 1. We need to check up to 2n 1, which is approximately 2n/2.
Step 2: Calculate the number of operations. Number of operations ≈ 2n/2
Therefore, the time complexity of the trial division primality test for an n-bit number is O(2n/2).
Problem 5. In the Diffie-Hellman key exchange protocol, both parties perform modular
exponentiation. If the modulus is an n-bit number, what is the time complexity of the modular
exponentiation operation using the square-and-multiply algorithm? Express your answer in big
O notation.
Solution 5. Step 1: Analyze the square-and-multiply algorithm. - The algorithm performs n
steps for an n-bit exponent - Each step involves at most two operations: squaring and
multiplication
Step 2: Determine the complexity of each operation. - Squaring and multiplication of n-bit
numbers take O(n2) time using naive multiplication - Using more efficient algorithms like
Karatsuba, it can be reduced to O(nlog23) ≈ O(n1.585)
Step 3: Calculate the overall time complexity. Time complexity = n * O(nlog23) = O(n1+log23) ≈
O(n2.585)
Therefore, the time complexity of modular exponentiation in Diffie-Hellman key exchange is
O(n2.585), where n is the number of bits in the modulus.
Problem 6. Elliptic Curve Cryptography (ECC) operates on points on an elliptic curve. If the
field size is q, what is the space complexity of storing a public key in ECC? Express your answer
in big O notation.
Solution 6. Step 1: Analyze the components of an ECC public key. An ECC public key consists
of: - The elliptic curve parameters (assumed to be fixed and not counted) - A point on the
curve, represented by two coordinates (x, y)
Step 2: Determine the size of each coordinate. Each coordinate is an element of the field of size
q, requiring log_2(q) bits to represent.
Step 3: Calculate the total space required. Space for public key = 2 * log_2(q) bits
Therefore, the space complexity of storing an ECC public key is O(log q).
15 HASH FUNCTIONS
Problem 7. The SHA-256 hash function processes messages in 512-bit blocks. If the input
message is n bits long, what is the time complexity of computing its SHA-256 hash? Express
your answer in big O notation.
Solution 7. Step 1: Determine the number of blocks. Number of blocks = ⌈n/512
Step 2: Analyze the time complexity. Each block processing takes constant time. Total time =
O(Number of blocks) = O(⌈n/512) = O(n)
Therefore, the time complexity of computing the SHA-256 hash of an n-bit message is O(n).
Problem 8. In the Merkle-Damgård construction used in many hash functions, the message is
padded to a multiple of the block size. If the original message is n bits long and the block size is
b bits, what is the maximum length of the padded message? Express your answer in terms of n
and b.
Solution 8. Step 1: Analyze the padding scheme. - The message is padded to a multiple of
the block size - At least 1 bit is always added (the ’1’ bit) - The length of the original message
(n) is appended (usually 64 bits)
Step 2: Calculate the maximum padded length. Maximum padded length = (n + 1 + 64)/b b
This can be simplified to: Maximum padded length = (n + 65)/b⌉ b
Therefore, the maximum length of the padded message is (n + 65)/b⌉ b bits.
The Advanced Encryption Standard (AES) operates on 128-bit blocks. If the input message is n
bits long, what is the time complexity of encrypting this message using AES in ECB mode?
Express your answer in big O notation.
Solution 1. Step 1: Determine the number of blocks. Number of blocks = ⌈n/128
Step 2: Analyze the time complexity. Each block encryption takes constant time. Total time =
O(Number of blocks) = O(⌈n/128) = O(n)
Therefore, the time complexity of encrypting an n-bit message using AES in ECB mode is O(n).
Problem 2. The Data Encryption Standard (DES) uses a 56-bit key. How many operations
would be required for an exhaustive key search in the worst case? Express your answer in big O
notation.
Solution 2. Step 1: Calculate the total number of possible keys. Number of possible keys =
256
Step 2: In the worst case, we might need to try all possible keys. Worst-case number of
operations = 256
Therefore, the time complexity of an exhaustive key search for DES is O(256).
Problem 3. The RC4 stream cipher has an initialization phase where it creates a 256-byte
state array. What is the space complexity of RC4 in terms of the key size k? Express your
answer in big O notation.
Solution 3. Step 1: Analyze the space requirements. - The state array requires 256 bytes
(constant) - The key of size k bytes is stored
Step 2: Express the total space in big O notation. Space complexity = O(256 + k) = O(k)
Therefore, the space complexity of RC4 is O(k), where k is the key size in bytes.
16 ASYMMETRIC ENCRYPTION ALGORITHMS
Problem 4. In RSA, key generation involves finding two large prime numbers. If we use the
trial division method to test primality up to n for an n-bit number, what is the time complexity
of this primality test? Express your answer in big O notation.
Solution 4. Step 1: Determine the range of numbers to check. For an n-bit number, the
maximum value is 2n 1. We need to check up to 2n 1, which is approximately 2n/2.
Step 2: Calculate the number of operations. Number of operations ≈ 2n/2
Therefore, the time complexity of the trial division primality test for an n-bit number is O(2n/2).
Problem 5. In the Diffie-Hellman key exchange protocol, both parties perform modular
exponentiation. If the modulus is an n-bit number, what is the time complexity of the modular
exponentiation operation using the square-and-multiply algorithm? Express your answer in big
O notation.
Solution 5. Step 1: Analyze the square-and-multiply algorithm. - The algorithm performs n
steps for an n-bit exponent - Each step involves at most two operations: squaring and
multiplication
Step 2: Determine the complexity of each operation. - Squaring and multiplication of n-bit
numbers take O(n2) time using naive multiplication - Using more efficient algorithms like
Karatsuba, it can be reduced to O(nlog23) ≈ O(n1.585)
Step 3: Calculate the overall time complexity. Time complexity = n * O(nlog23) = O(n1+log23) ≈
O(n2.585)
Therefore, the time complexity of modular exponentiation in Diffie-Hellman key exchange is
O(n2.585), where n is the number of bits in the modulus.
Problem 6. Elliptic Curve Cryptography (ECC) operates on points on an elliptic curve. If the
field size is q, what is the space complexity of storing a public key in ECC? Express your answer
in big O notation.
Solution 6. Step 1: Analyze the components of an ECC public key. An ECC public key consists
of: - The elliptic curve parameters (assumed to be fixed and not counted) - A point on the
curve, represented by two coordinates (x, y)
Step 2: Determine the size of each coordinate. Each coordinate is an element of the field of size
q, requiring log_2(q) bits to represent.
Step 3: Calculate the total space required. Space for public key = 2 * log_2(q) bits
Therefore, the space complexity of storing an ECC public key is O(log q).
17 HASH FUNCTIONS
Problem 7. The SHA-256 hash function processes messages in 512-bit blocks. If the input
message is n bits long, what is the time complexity of computing its SHA-256 hash? Express
your answer in big O notation.
Solution 7. Step 1: Determine the number of blocks. Number of blocks = ⌈n/512
Step 2: Analyze the time complexity. Each block processing takes constant time. Total time =
O(Number of blocks) = O(⌈n/512) = O(n)
Therefore, the time complexity of computing the SHA-256 hash of an n-bit message is O(n).
Problem 8. In the Merkle-Damgård construction used in many hash functions, the message is
padded to a multiple of the block size. If the original message is n bits long and the block size is
b bits, what is the maximum length of the padded message? Express your answer in terms of n
and b.
Solution 8. Step 1: Analyze the padding scheme. - The message is padded to a multiple of
the block size - At least 1 bit is always added (the ’1’ bit) - The length of the original message
(n) is appended (usually 64 bits)
Step 2: Calculate the maximum padded length. Maximum padded length = (n + 1 + 64)/b b
This can be simplified to: Maximum padded length = (n + 65)/b⌉ b
Therefore, the maximum length of the padded message is (n + 65)/b⌉ b bits.
The Advanced Encryption Standard (AES) operates on 128-bit blocks. If the input message is n
bits long, what is the time complexity of encrypting this message using AES in ECB mode?
Express your answer in big O notation.
Solution 1. Step 1: Determine the number of blocks. Number of blocks = ⌈n/128
Step 2: Analyze the time complexity. Each block encryption takes constant time. Total time =
O(Number of blocks) = O(⌈n/128) = O(n)
Therefore, the time complexity of encrypting an n-bit message using AES in ECB mode is O(n).
Problem 2. The Data Encryption Standard (DES) uses a 56-bit key. How many operations
would be required for an exhaustive key search in the worst case? Express your answer in big O
notation.
Solution 2. Step 1: Calculate the total number of possible keys. Number of possible keys =
256
Step 2: In the worst case, we might need to try all possible keys. Worst-case number of
operations = 256
Therefore, the time complexity of an exhaustive key search for DES is O(256).
Problem 3. The RC4 stream cipher has an initialization phase where it creates a 256-byte
state array. What is the space complexity of RC4 in terms of the key size k? Express your
answer in big O notation.
Solution 3. Step 1: Analyze the space requirements. - The state array requires 256 bytes
(constant) - The key of size k bytes is stored
Step 2: Express the total space in big O notation. Space complexity = O(256 + k) = O(k)
Therefore, the space complexity of RC4 is O(k), where k is the key size in bytes.
18 ASYMMETRIC ENCRYPTION ALGORITHMS
Problem 4. In RSA, key generation involves finding two large prime numbers. If we use the
trial division method to test primality up to n for an n-bit number, what is the time complexity
of this primality test? Express your answer in big O notation.
Solution 4. Step 1: Determine the range of numbers to check. For an n-bit number, the
maximum value is 2n 1. We need to check up to 2n 1, which is approximately 2n/2.
Step 2: Calculate the number of operations. Number of operations ≈ 2n/2
Therefore, the time complexity of the trial division primality test for an n-bit number is O(2n/2).
Problem 5. In the Diffie-Hellman key exchange protocol, both parties perform modular
exponentiation. If the modulus is an n-bit number, what is the time complexity of the modular
exponentiation operation using the square-and-multiply algorithm? Express your answer in big
O notation.
Solution 5. Step 1: Analyze the square-and-multiply algorithm. - The algorithm performs n
steps for an n-bit exponent - Each step involves at most two operations: squaring and
multiplication
Step 2: Determine the complexity of each operation. - Squaring and multiplication of n-bit
numbers take O(n2) time using naive multiplication - Using more efficient algorithms like
Karatsuba, it can be reduced to O(nlog23) ≈ O(n1.585)
Step 3: Calculate the overall time complexity. Time complexity = n * O(nlog23) = O(n1+log23) ≈
O(n2.585)
Therefore, the time complexity of modular exponentiation in Diffie-Hellman key exchange is
O(n2.585), where n is the number of bits in the modulus.
Problem 6. Elliptic Curve Cryptography (ECC) operates on points on an elliptic curve. If the
field size is q, what is the space complexity of storing a public key in ECC? Express your answer
in big O notation.
Solution 6. Step 1: Analyze the components of an ECC public key. An ECC public key consists
of: - The elliptic curve parameters (assumed to be fixed and not counted) - A point on the
curve, represented by two coordinates (x, y)
Step 2: Determine the size of each coordinate. Each coordinate is an element of the field of size
q, requiring log_2(q) bits to represent.
Step 3: Calculate the total space required. Space for public key = 2 * log_2(q) bits
Therefore, the space complexity of storing an ECC public key is O(log q).
19 HASH FUNCTIONS
Problem 7. The SHA-256 hash function processes messages in 512-bit blocks. If the input
message is n bits long, what is the time complexity of computing its SHA-256 hash? Express
your answer in big O notation.
Solution 7. Step 1: Determine the number of blocks. Number of blocks = ⌈n/512
Step 2: Analyze the time complexity. Each block processing takes constant time. Total time =
O(Number of blocks) = O(⌈n/512) = O(n)
Therefore, the time complexity of computing the SHA-256 hash of an n-bit message is O(n).
Problem 8. In the Merkle-Damgård construction used in many hash functions, the message is
padded to a multiple of the block size. If the original message is n bits long and the block size is
b bits, what is the maximum length of the padded message? Express your answer in terms of n
and b.
Solution 8. Step 1: Analyze the padding scheme. - The message is padded to a multiple of
the block size - At least 1 bit is always added (the ’1’ bit) - The length of the original message
(n) is appended (usually 64 bits)
Step 2: Calculate the maximum padded length. Maximum padded length = (n + 1 + 64)/b b
This can be simplified to: Maximum padded length = (n + 65)/b⌉ b
Therefore, the maximum length of the padded message is (n + 65)/b⌉ b bits.
The Advanced Encryption Standard (AES) operates on 128-bit blocks. If the input message is n
bits long, what is the time complexity of encrypting this message using AES in ECB mode?
Express your answer in big O notation.
Solution 1. Step 1: Determine the number of blocks. Number of blocks = ⌈n/128
Step 2: Analyze the time complexity. Each block encryption takes constant time. Total time =
O(Number of blocks) = O(⌈n/128) = O(n)
Therefore, the time complexity of encrypting an n-bit message using AES in ECB mode is O(n).
Problem 2. The Data Encryption Standard (DES) uses a 56-bit key. How many operations
would be required for an exhaustive key search in the worst case? Express your answer in big O
notation.
Solution 2. Step 1: Calculate the total number of possible keys. Number of possible keys =
256
Step 2: In the worst case, we might need to try all possible keys. Worst-case number of
operations = 256
Therefore, the time complexity of an exhaustive key search for DES is O(256).
Problem 3. The RC4 stream cipher has an initialization phase where it creates a 256-byte
state array. What is the space complexity of RC4 in terms of the key size k? Express your
answer in big O notation.
Solution 3. Step 1: Analyze the space requirements. - The state array requires 256 bytes
(constant) - The key of size k bytes is stored
Step 2: Express the total space in big O notation. Space complexity = O(256 + k) = O(k)
Therefore, the space complexity of RC4 is O(k), where k is the key size in bytes.
20 ASYMMETRIC ENCRYPTION ALGORITHMS
Problem 4. In RSA, key generation involves finding two large prime numbers. If we use the
trial division method to test primality up to n for an n-bit number, what is the time complexity
of this primality test? Express your answer in big O notation.
Solution 4. Step 1: Determine the range of numbers to check. For an n-bit number, the
maximum value is 2n 1. We need to check up to 2n 1, which is approximately 2n/2.
Step 2: Calculate the number of operations. Number of operations ≈ 2n/2
Therefore, the time complexity of the trial division primality test for an n-bit number is O(2n/2).
Problem 5. In the Diffie-Hellman key exchange protocol, both parties perform modular
exponentiation. If the modulus is an n-bit number, what is the time complexity of the modular
exponentiation operation using the square-and-multiply algorithm? Express your answer in big
O notation.
Solution 5. Step 1: Analyze the square-and-multiply algorithm. - The algorithm performs n
steps for an n-bit exponent - Each step involves at most two operations: squaring and
multiplication
Step 2: Determine the complexity of each operation. - Squaring and multiplication of n-bit
numbers take O(n2) time using naive multiplication - Using more efficient algorithms like
Karatsuba, it can be reduced to O(nlog23) ≈ O(n1.585)
Step 3: Calculate the overall time complexity. Time complexity = n * O(nlog23) = O(n1+log23) ≈
O(n2.585)
Therefore, the time complexity of modular exponentiation in Diffie-Hellman key exchange is
O(n2.585), where n is the number of bits in the modulus.
Problem 6. Elliptic Curve Cryptography (ECC) operates on points on an elliptic curve. If the
field size is q, what is the space complexity of storing a public key in ECC? Express your answer
in big O notation.
Solution 6. Step 1: Analyze the components of an ECC public key. An ECC public key consists
of: - The elliptic curve parameters (assumed to be fixed and not counted) - A point on the
curve, represented by two coordinates (x, y)
Step 2: Determine the size of each coordinate. Each coordinate is an element of the field of size
q, requiring log_2(q) bits to represent.
Step 3: Calculate the total space required. Space for public key = 2 * log_2(q) bits
Therefore, the space complexity of storing an ECC public key is O(log q).
21 HASH FUNCTIONS
Problem 7. The SHA-256 hash function processes messages in 512-bit blocks. If the input
message is n bits long, what is the time complexity of computing its SHA-256 hash? Express
your answer in big O notation.
Solution 7. Step 1: Determine the number of blocks. Number of blocks = ⌈n/512
Step 2: Analyze the time complexity. Each block processing takes constant time. Total time =
O(Number of blocks) = O(⌈n/512) = O(n)
Therefore, the time complexity of computing the SHA-256 hash of an n-bit message is O(n).
Problem 8. In the Merkle-Damgård construction used in many hash functions, the message is
padded to a multiple of the block size. If the original message is n bits long and the block size is
b bits, what is the maximum length of the padded message? Express your answer in terms of n
and b.
Solution 8. Step 1: Analyze the padding scheme. - The message is padded to a multiple of
the block size - At least 1 bit is always added (the ’1’ bit) - The length of the original message
(n) is appended (usually 64 bits)
Step 2: Calculate the maximum padded length. Maximum padded length = (n + 1 + 64)/b b
This can be simplified to: Maximum padded length = (n + 65)/b⌉ b
Therefore, the maximum length of the padded message is (n + 65)/b⌉ b bits.
The Advanced Encryption Standard (AES) operates on 128-bit blocks. If the input message is n
bits long, what is the time complexity of encrypting this message using AES in ECB mode?
Express your answer in big O notation.
Solution 1. Step 1: Determine the number of blocks. Number of blocks = ⌈n/128
Step 2: Analyze the time complexity. Each block encryption takes constant time. Total time =
O(Number of blocks) = O(⌈n/128) = O(n)
Therefore, the time complexity of encrypting an n-bit message using AES in ECB mode is O(n).
Problem 2. The Data Encryption Standard (DES) uses a 56-bit key. How many operations
would be required for an exhaustive key search in the worst case? Express your answer in big O
notation.
Solution 2. Step 1: Calculate the total number of possible keys. Number of possible keys =
256
Step 2: In the worst case, we might need to try all possible keys. Worst-case number of
operations = 256
Therefore, the time complexity of an exhaustive key search for DES is O(256).
Problem 3. The RC4 stream cipher has an initialization phase where it creates a 256-byte
state array. What is the space complexity of RC4 in terms of the key size k? Express your
answer in big O notation.
Solution 3. Step 1: Analyze the space requirements. - The state array requires 256 bytes
(constant) - The key of size k bytes is stored
Step 2: Express the total space in big O notation. Space complexity = O(256 + k) = O(k)
Therefore, the space complexity of RC4 is O(k), where k is the key size in bytes.
22 ASYMMETRIC ENCRYPTION ALGORITHMS
Problem 4. In RSA, key generation involves finding two large prime numbers. If we use the
trial division method to test primality up to n for an n-bit number, what is the time complexity
of this primality test? Express your answer in big O notation.
Solution 4. Step 1: Determine the range of numbers to check. For an n-bit number, the
maximum value is 2n 1. We need to check up to 2n 1, which is approximately 2n/2.
Step 2: Calculate the number of operations. Number of operations ≈ 2n/2
Therefore, the time complexity of the trial division primality test for an n-bit number is O(2n/2).
Problem 5. In the Diffie-Hellman key exchange protocol, both parties perform modular
exponentiation. If the modulus is an n-bit number, what is the time complexity of the modular
exponentiation operation using the square-and-multiply algorithm? Express your answer in big
O notation.
Solution 5. Step 1: Analyze the square-and-multiply algorithm. - The algorithm performs n
steps for an n-bit exponent - Each step involves at most two operations: squaring and
multiplication
Step 2: Determine the complexity of each operation. - Squaring and multiplication of n-bit
numbers take O(n2) time using naive multiplication - Using more efficient algorithms like
Karatsuba, it can be reduced to O(nlog23) ≈ O(n1.585)
Step 3: Calculate the overall time complexity. Time complexity = n * O(nlog23) = O(n1+log23) ≈
O(n2.585)
Therefore, the time complexity of modular exponentiation in Diffie-Hellman key exchange is
O(n2.585), where n is the number of bits in the modulus.
Problem 6. Elliptic Curve Cryptography (ECC) operates on points on an elliptic curve. If the
field size is q, what is the space complexity of storing a public key in ECC? Express your answer
in big O notation.
Solution 6. Step 1: Analyze the components of an ECC public key. An ECC public key consists
of: - The elliptic curve parameters (assumed to be fixed and not counted) - A point on the
curve, represented by two coordinates (x, y)
Step 2: Determine the size of each coordinate. Each coordinate is an element of the field of size
q, requiring log_2(q) bits to represent.
Step 3: Calculate the total space required. Space for public key = 2 * log_2(q) bits
Therefore, the space complexity of storing an ECC public key is O(log q).
23 HASH FUNCTIONS
Problem 7. The SHA-256 hash function processes messages in 512-bit blocks. If the input
message is n bits long, what is the time complexity of computing its SHA-256 hash? Express
your answer in big O notation.
Solution 7. Step 1: Determine the number of blocks. Number of blocks = ⌈n/512
Step 2: Analyze the time complexity. Each block processing takes constant time. Total time =
O(Number of blocks) = O(⌈n/512) = O(n)
Therefore, the time complexity of computing the SHA-256 hash of an n-bit message is O(n).
Problem 8. In the Merkle-Damgård construction used in many hash functions, the message is
padded to a multiple of the block size. If the original message is n bits long and the block size is
b bits, what is the maximum length of the padded message? Express your answer in terms of n
and b.
Solution 8. Step 1: Analyze the padding scheme. - The message is padded to a multiple of
the block size - At least 1 bit is always added (the ’1’ bit) - The length of the original message
(n) is appended (usually 64 bits)
Step 2: Calculate the maximum padded length. Maximum padded length = (n + 1 + 64)/b b
This can be simplified to: Maximum padded length = (n + 65)/b⌉ b
Therefore, the maximum length of the padded message is (n + 65)/b⌉ b bits.
The Advanced Encryption Standard (AES) operates on 128-bit blocks. If the input message is n
bits long, what is the time complexity of encrypting this message using AES in ECB mode?
Express your answer in big O notation.
Solution 1. Step 1: Determine the number of blocks. Number of blocks = ⌈n/128
Step 2: Analyze the time complexity. Each block encryption takes constant time. Total time =
O(Number of blocks) = O(⌈n/128) = O(n)
Therefore, the time complexity of encrypting an n-bit message using AES in ECB mode is O(n).
Problem 2. The Data Encryption Standard (DES) uses a 56-bit key. How many operations
would be required for an exhaustive key search in the worst case? Express your answer in big O
notation.
Solution 2. Step 1: Calculate the total number of possible keys. Number of possible keys =
256
Step 2: In the worst case, we might need to try all possible keys. Worst-case number of
operations = 256
Therefore, the time complexity of an exhaustive key search for DES is O(256).
Problem 3. The RC4 stream cipher has an initialization phase where it creates a 256-byte
state array. What is the space complexity of RC4 in terms of the key size k? Express your
answer in big O notation.
Solution 3. Step 1: Analyze the space requirements. - The state array requires 256 bytes
(constant) - The key of size k bytes is stored
Step 2: Express the total space in big O notation. Space complexity = O(256 + k) = O(k)
Therefore, the space complexity of RC4 is O(k), where k is the key size in bytes.
24 ASYMMETRIC ENCRYPTION ALGORITHMS
Problem 4. In RSA, key generation involves finding two large prime numbers. If we use the
trial division method to test primality up to n for an n-bit number, what is the time complexity
of this primality test? Express your answer in big O notation.
Solution 4. Step 1: Determine the range of numbers to check. For an n-bit number, the
maximum value is 2n 1. We need to check up to 2n 1, which is approximately 2n/2.
Step 2: Calculate the number of operations. Number of operations ≈ 2n/2
Therefore, the time complexity of the trial division primality test for an n-bit number is O(2n/2).
Problem 5. In the Diffie-Hellman key exchange protocol, both parties perform modular
exponentiation. If the modulus is an n-bit number, what is the time complexity of the modular
exponentiation operation using the square-and-multiply algorithm? Express your answer in big
O notation.
Solution 5. Step 1: Analyze the square-and-multiply algorithm. - The algorithm performs n
steps for an n-bit exponent - Each step involves at most two operations: squaring and
multiplication
Step 2: Determine the complexity of each operation. - Squaring and multiplication of n-bit
numbers take O(n2) time using naive multiplication - Using more efficient algorithms like
Karatsuba, it can be reduced to O(nlog23) ≈ O(n1.585)
Step 3: Calculate the overall time complexity. Time complexity = n * O(nlog23) = O(n1+log23) ≈
O(n2.585)
Therefore, the time complexity of modular exponentiation in Diffie-Hellman key exchange is
O(n2.585), where n is the number of bits in the modulus.
Problem 6. Elliptic Curve Cryptography (ECC) operates on points on an elliptic curve. If the
field size is q, what is the space complexity of storing a public key in ECC? Express your answer
in big O notation.
Solution 6. Step 1: Analyze the components of an ECC public key. An ECC public key consists
of: - The elliptic curve parameters (assumed to be fixed and not counted) - A point on the
curve, represented by two coordinates (x, y)
Step 2: Determine the size of each coordinate. Each coordinate is an element of the field of size
q, requiring log_2(q) bits to represent.
Step 3: Calculate the total space required. Space for public key = 2 * log_2(q) bits
Therefore, the space complexity of storing an ECC public key is O(log q).
25 HASH FUNCTIONS
Problem 7. The SHA-256 hash function processes messages in 512-bit blocks. If the input
message is n bits long, what is the time complexity of computing its SHA-256 hash? Express
your answer in big O notation.
Solution 7. Step 1: Determine the number of blocks. Number of blocks = ⌈n/512
Step 2: Analyze the time complexity. Each block processing takes constant time. Total time =
O(Number of blocks) = O(⌈n/512) = O(n)
Therefore, the time complexity of computing the SHA-256 hash of an n-bit message is O(n).
Problem 8. In the Merkle-Damgård construction used in many hash functions, the message is
padded to a multiple of the block size. If the original message is n bits long and the block size is
b bits, what is the maximum length of the padded message? Express your answer in terms of n
and b.
Solution 8. Step 1: Analyze the padding scheme. - The message is padded to a multiple of
the block size - At least 1 bit is always added (the ’1’ bit) - The length of the original message
(n) is appended (usually 64 bits)
Step 2: Calculate the maximum padded length. Maximum padded length = (n + 1 + 64)/b b
This can be simplified to: Maximum padded length = (n + 65)/b⌉ b
Therefore, the maximum length of the padded message is (n + 65)/b⌉ b bits.
The Advanced Encryption Standard (AES) operates on 128-bit blocks. If the input message is n
bits long, what is the time complexity of encrypting this message using AES in ECB mode?
Express your answer in big O notation.
Solution 1. Step 1: Determine the number of blocks. Number of blocks = ⌈n/128
Step 2: Analyze the time complexity. Each block encryption takes constant time. Total time =
O(Number of blocks) = O(⌈n/128) = O(n)
Therefore, the time complexity of encrypting an n-bit message using AES in ECB mode is O(n).
Problem 2. The Data Encryption Standard (DES) uses a 56-bit key. How many operations
would be required for an exhaustive key search in the worst case? Express your answer in big O
notation.
Solution 2. Step 1: Calculate the total number of possible keys. Number of possible keys =
256
Step 2: In the worst case, we might need to try all possible keys. Worst-case number of
operations = 256
Therefore, the time complexity of an exhaustive key search for DES is O(256).
Problem 3. The RC4 stream cipher has an initialization phase where it creates a 256-byte
state array. What is the space complexity of RC4 in terms of the key size k? Express your
answer in big O notation.
Solution 3. Step 1: Analyze the space requirements. - The state array requires 256 bytes
(constant) - The key of size k bytes is stored
Step 2: Express the total space in big O notation. Space complexity = O(256 + k) = O(k)
Therefore, the space complexity of RC4 is O(k), where k is the key size in bytes.
26 ASYMMETRIC ENCRYPTION ALGORITHMS
Problem 4. In RSA, key generation involves finding two large prime numbers. If we use the
trial division method to test primality up to n for an n-bit number, what is the time complexity
of this primality test? Express your answer in big O notation.
Solution 4. Step 1: Determine the range of numbers to check. For an n-bit number, the
maximum value is 2n 1. We need to check up to 2n 1, which is approximately 2n/2.
Step 2: Calculate the number of operations. Number of operations ≈ 2n/2
Therefore, the time complexity of the trial division primality test for an n-bit number is O(2n/2).
Problem 5. In the Diffie-Hellman key exchange protocol, both parties perform modular
exponentiation. If the modulus is an n-bit number, what is the time complexity of the modular
exponentiation operation using the square-and-multiply algorithm? Express your answer in big
O notation.
Solution 5. Step 1: Analyze the square-and-multiply algorithm. - The algorithm performs n
steps for an n-bit exponent - Each step involves at most two operations: squaring and
multiplication
Step 2: Determine the complexity of each operation. - Squaring and multiplication of n-bit
numbers take O(n2) time using naive multiplication - Using more efficient algorithms like
Karatsuba, it can be reduced to O(nlog23) ≈ O(n1.585)
Step 3: Calculate the overall time complexity. Time complexity = n * O(nlog23) = O(n1+log23) ≈
O(n2.585)
Therefore, the time complexity of modular exponentiation in Diffie-Hellman key exchange is
O(n2.585), where n is the number of bits in the modulus.
Problem 6. Elliptic Curve Cryptography (ECC) operates on points on an elliptic curve. If the
field size is q, what is the space complexity of storing a public key in ECC? Express your answer
in big O notation.
Solution 6. Step 1: Analyze the components of an ECC public key. An ECC public key consists
of: - The elliptic curve parameters (assumed to be fixed and not counted) - A point on the
curve, represented by two coordinates (x, y)
Step 2: Determine the size of each coordinate. Each coordinate is an element of the field of size
q, requiring log_2(q) bits to represent.
Step 3: Calculate the total space required. Space for public key = 2 * log_2(q) bits
Therefore, the space complexity of storing an ECC public key is O(log q).
27 HASH FUNCTIONS
Problem 7. The SHA-256 hash function processes messages in 512-bit blocks. If the input
message is n bits long, what is the time complexity of computing its SHA-256 hash? Express
your answer in big O notation.
Solution 7. Step 1: Determine the number of blocks. Number of blocks = ⌈n/512
Step 2: Analyze the time complexity. Each block processing takes constant time. Total time =
O(Number of blocks) = O(⌈n/512) = O(n)
Therefore, the time complexity of computing the SHA-256 hash of an n-bit message is O(n).
Problem 8. In the Merkle-Damgård construction used in many hash functions, the message is
padded to a multiple of the block size. If the original message is n bits long and the block size is
b bits, what is the maximum length of the padded message? Express your answer in terms of n
and b.
Solution 8. Step 1: Analyze the padding scheme. - The message is padded to a multiple of
the block size - At least 1 bit is always added (the ’1’ bit) - The length of the original message
(n) is appended (usually 64 bits)
Step 2: Calculate the maximum padded length. Maximum padded length = (n + 1 + 64)/b b
This can be simplified to: Maximum padded length = (n + 65)/b⌉ b
Therefore, the maximum length of the padded message is (n + 65)/b⌉ b bits.
The Advanced Encryption Standard (AES) operates on 128-bit blocks. If the input message is n
bits long, what is the time complexity of encrypting this message using AES in ECB mode?
Express your answer in big O notation.
Solution 1. Step 1: Determine the number of blocks. Number of blocks = ⌈n/128
Step 2: Analyze the time complexity. Each block encryption takes constant time. Total time =
O(Number of blocks) = O(⌈n/128) = O(n)
Therefore, the time complexity of encrypting an n-bit message using AES in ECB mode is O(n).
Problem 2. The Data Encryption Standard (DES) uses a 56-bit key. How many operations
would be required for an exhaustive key search in the worst case? Express your answer in big O
notation.
Solution 2. Step 1: Calculate the total number of possible keys. Number of possible keys =
256
Step 2: In the worst case, we might need to try all possible keys. Worst-case number of
operations = 256
Therefore, the time complexity of an exhaustive key search for DES is O(256).
Problem 3. The RC4 stream cipher has an initialization phase where it creates a 256-byte
state array. What is the space complexity of RC4 in terms of the key size k? Express your
answer in big O notation.
Solution 3. Step 1: Analyze the space requirements. - The state array requires 256 bytes
(constant) - The key of size k bytes is stored
Step 2: Express the total space in big O notation. Space complexity = O(256 + k) = O(k)
Therefore, the space complexity of RC4 is O(k), where k is the key size in bytes.
28 ASYMMETRIC ENCRYPTION ALGORITHMS
Problem 4. In RSA, key generation involves finding two large prime numbers. If we use the
trial division method to test primality up to n for an n-bit number, what is the time complexity
of this primality test? Express your answer in big O notation.
Solution 4. Step 1: Determine the range of numbers to check. For an n-bit number, the
maximum value is 2n 1. We need to check up to 2n 1, which is approximately 2n/2.
Step 2: Calculate the number of operations. Number of operations ≈ 2n/2
Therefore, the time complexity of the trial division primality test for an n-bit number is O(2n/2).
Problem 5. In the Diffie-Hellman key exchange protocol, both parties perform modular
exponentiation. If the modulus is an n-bit number, what is the time complexity of the modular
exponentiation operation using the square-and-multiply algorithm? Express your answer in big
O notation.
Solution 5. Step 1: Analyze the square-and-multiply algorithm. - The algorithm performs n
steps for an n-bit exponent - Each step involves at most two operations: squaring and
multiplication
Step 2: Determine the complexity of each operation. - Squaring and multiplication of n-bit
numbers take O(n2) time using naive multiplication - Using more efficient algorithms like
Karatsuba, it can be reduced to O(nlog23) ≈ O(n1.585)
Step 3: Calculate the overall time complexity. Time complexity = n * O(nlog23) = O(n1+log23) ≈
O(n2.585)
Therefore, the time complexity of modular exponentiation in Diffie-Hellman key exchange is
O(n2.585), where n is the number of bits in the modulus.
Problem 6. Elliptic Curve Cryptography (ECC) operates on points on an elliptic curve. If the
field size is q, what is the space complexity of storing a public key in ECC? Express your answer
in big O notation.
Solution 6. Step 1: Analyze the components of an ECC public key. An ECC public key consists
of: - The elliptic curve parameters (assumed to be fixed and not counted) - A point on the
curve, represented by two coordinates (x, y)
Step 2: Determine the size of each coordinate. Each coordinate is an element of the field of size
q, requiring log_2(q) bits to represent.
Step 3: Calculate the total space required. Space for public key = 2 * log_2(q) bits
Therefore, the space complexity of storing an ECC public key is O(log q).
29 HASH FUNCTIONS
Problem 7. The SHA-256 hash function processes messages in 512-bit blocks. If the input
message is n bits long, what is the time complexity of computing its SHA-256 hash? Express
your answer in big O notation.
Solution 7. Step 1: Determine the number of blocks. Number of blocks = ⌈n/512
Step 2: Analyze the time complexity. Each block processing takes constant time. Total time =
O(Number of blocks) = O(⌈n/512) = O(n)
Therefore, the time complexity of computing the SHA-256 hash of an n-bit message is O(n).
Problem 8. In the Merkle-Damgård construction used in many hash functions, the message is
padded to a multiple of the block size. If the original message is n bits long and the block size is
b bits, what is the maximum length of the padded message? Express your answer in terms of n
and b.
Solution 8. Step 1: Analyze the padding scheme. - The message is padded to a multiple of
the block size - At least 1 bit is always added (the ’1’ bit) - The length of the original message
(n) is appended (usually 64 bits)
Step 2: Calculate the maximum padded length. Maximum padded length = (n + 1 + 64)/b b
This can be simplified to: Maximum padded length = (n + 65)/b⌉ b
Therefore, the maximum length of the padded message is (n + 65)/b⌉ b bits.
The Advanced Encryption Standard (AES) operates on 128-bit blocks. If the input message is n
bits long, what is the time complexity of encrypting this message using AES in ECB mode?
Express your answer in big O notation.
Solution 1. Step 1: Determine the number of blocks. Number of blocks = ⌈n/128
Step 2: Analyze the time complexity. Each block encryption takes constant time. Total time =
O(Number of blocks) = O(⌈n/128) = O(n)
Therefore, the time complexity of encrypting an n-bit message using AES in ECB mode is O(n).
Problem 2. The Data Encryption Standard (DES) uses a 56-bit key. How many operations
would be required for an exhaustive key search in the worst case? Express your answer in big O
notation.
Solution 2. Step 1: Calculate the total number of possible keys. Number of possible keys =
256
Step 2: In the worst case, we might need to try all possible keys. Worst-case number of
operations = 256
Therefore, the time complexity of an exhaustive key search for DES is O(256).
Problem 3. The RC4 stream cipher has an initialization phase where it creates a 256-byte
state array. What is the space complexity of RC4 in terms of the key size k? Express your
answer in big O notation.
Solution 3. Step 1: Analyze the space requirements. - The state array requires 256 bytes
(constant) - The key of size k bytes is stored
Step 2: Express the total space in big O notation. Space complexity = O(256 + k) = O(k)
Therefore, the space complexity of RC4 is O(k), where k is the key size in bytes.
30 ASYMMETRIC ENCRYPTION ALGORITHMS
Problem 4. In RSA, key generation involves finding two large prime numbers. If we use the
trial division method to test primality up to n for an n-bit number, what is the time complexity
of this primality test? Express your answer in big O notation.
Solution 4. Step 1: Determine the range of numbers to check. For an n-bit number, the
maximum value is 2n 1. We need to check up to 2n 1, which is approximately 2n/2.
Step 2: Calculate the number of operations. Number of operations ≈ 2n/2
Therefore, the time complexity of the trial division primality test for an n-bit number is O(2n/2).
Problem 5. In the Diffie-Hellman key exchange protocol, both parties perform modular
exponentiation. If the modulus is an n-bit number, what is the time complexity of the modular
exponentiation operation using the square-and-multiply algorithm? Express your answer in big
O notation.
Solution 5. Step 1: Analyze the square-and-multiply algorithm. - The algorithm performs n
steps for an n-bit exponent - Each step involves at most two operations: squaring and
multiplication
Step 2: Determine the complexity of each operation. - Squaring and multiplication of n-bit
numbers take O(n2) time using naive multiplication - Using more efficient algorithms like
Karatsuba, it can be reduced to O(nlog23) ≈ O(n1.585)
Step 3: Calculate the overall time complexity. Time complexity = n * O(nlog23) = O(n1+log23) ≈
O(n2.585)
Therefore, the time complexity of modular exponentiation in Diffie-Hellman key exchange is
O(n2.585), where n is the number of bits in the modulus.
Problem 6. Elliptic Curve Cryptography (ECC) operates on points on an elliptic curve. If the
field size is q, what is the space complexity of storing a public key in ECC? Express your answer
in big O notation.
Solution 6. Step 1: Analyze the components of an ECC public key. An ECC public key consists
of: - The elliptic curve parameters (assumed to be fixed and not counted) - A point on the
curve, represented by two coordinates (x, y)
Step 2: Determine the size of each coordinate. Each coordinate is an element of the field of size
q, requiring log_2(q) bits to represent.
Step 3: Calculate the total space required. Space for public key = 2 * log_2(q) bits
Therefore, the space complexity of storing an ECC public key is O(log q).
31 HASH FUNCTIONS
Problem 7. The SHA-256 hash function processes messages in 512-bit blocks. If the input
message is n bits long, what is the time complexity of computing its SHA-256 hash? Express
your answer in big O notation.
Solution 7. Step 1: Determine the number of blocks. Number of blocks = ⌈n/512
Step 2: Analyze the time complexity. Each block processing takes constant time. Total time =
O(Number of blocks) = O(⌈n/512) = O(n)
Therefore, the time complexity of computing the SHA-256 hash of an n-bit message is O(n).
Problem 8. In the Merkle-Damgård construction used in many hash functions, the message is
padded to a multiple of the block size. If the original message is n bits long and the block size is
b bits, what is the maximum length of the padded message? Express your answer in terms of n
and b.
Solution 8. Step 1: Analyze the padding scheme. - The message is padded to a multiple of
the block size - At least 1 bit is always added (the ’1’ bit) - The length of the original message
(n) is appended (usually 64 bits)
Step 2: Calculate the maximum padded length. Maximum padded length = (n + 1 + 64)/b b
This can be simplified to: Maximum padded length = (n + 65)/b⌉ b
Therefore, the maximum length of the padded message is (n + 65)/b⌉ b bits.
The Advanced Encryption Standard (AES) operates on 128-bit blocks. If the input message is n
bits long, what is the time complexity of encrypting this message using AES in ECB mode?
Express your answer in big O notation.
Solution 1. Step 1: Determine the number of blocks. Number of blocks = ⌈n/128
Step 2: Analyze the time complexity. Each block encryption takes constant time. Total time =
O(Number of blocks) = O(⌈n/128) = O(n)
Therefore, the time complexity of encrypting an n-bit message using AES in ECB mode is O(n).
Problem 2. The Data Encryption Standard (DES) uses a 56-bit key. How many operations
would be required for an exhaustive key search in the worst case? Express your answer in big O
notation.
Solution 2. Step 1: Calculate the total number of possible keys. Number of possible keys =
256
Step 2: In the worst case, we might need to try all possible keys. Worst-case number of
operations = 256
Therefore, the time complexity of an exhaustive key search for DES is O(256).
Problem 3. The RC4 stream cipher has an initialization phase where it creates a 256-byte
state array. What is the space complexity of RC4 in terms of the key size k? Express your
answer in big O notation.
Solution 3. Step 1: Analyze the space requirements. - The state array requires 256 bytes
(constant) - The key of size k bytes is stored
Step 2: Express the total space in big O notation. Space complexity = O(256 + k) = O(k)
Therefore, the space complexity of RC4 is O(k), where k is the key size in bytes.
32 ASYMMETRIC ENCRYPTION ALGORITHMS
Problem 4. In RSA, key generation involves finding two large prime numbers. If we use the
trial division method to test primality up to n for an n-bit number, what is the time complexity
of this primality test? Express your answer in big O notation.
Solution 4. Step 1: Determine the range of numbers to check. For an n-bit number, the
maximum value is 2n 1. We need to check up to 2n 1, which is approximately 2n/2.
Step 2: Calculate the number of operations. Number of operations ≈ 2n/2
Therefore, the time complexity of the trial division primality test for an n-bit number is O(2n/2).
Problem 5. In the Diffie-Hellman key exchange protocol, both parties perform modular
exponentiation. If the modulus is an n-bit number, what is the time complexity of the modular
exponentiation operation using the square-and-multiply algorithm? Express your answer in big
O notation.
Solution 5. Step 1: Analyze the square-and-multiply algorithm. - The algorithm performs n
steps for an n-bit exponent - Each step involves at most two operations: squaring and
multiplication
Step 2: Determine the complexity of each operation. - Squaring and multiplication of n-bit
numbers take O(n2) time using naive multiplication - Using more efficient algorithms like
Karatsuba, it can be reduced to O(nlog23) ≈ O(n1.585)
Step 3: Calculate the overall time complexity. Time complexity = n * O(nlog23) = O(n1+log23) ≈
O(n2.585)
Therefore, the time complexity of modular exponentiation in Diffie-Hellman key exchange is
O(n2.585), where n is the number of bits in the modulus.
Problem 6. Elliptic Curve Cryptography (ECC) operates on points on an elliptic curve. If the
field size is q, what is the space complexity of storing a public key in ECC? Express your answer
in big O notation.
Solution 6. Step 1: Analyze the components of an ECC public key. An ECC public key consists
of: - The elliptic curve parameters (assumed to be fixed and not counted) - A point on the
curve, represented by two coordinates (x, y)
Step 2: Determine the size of each coordinate. Each coordinate is an element of the field of size
q, requiring log_2(q) bits to represent.
Step 3: Calculate the total space required. Space for public key = 2 * log_2(q) bits
Therefore, the space complexity of storing an ECC public key is O(log q).
33 HASH FUNCTIONS
Problem 7. The SHA-256 hash function processes messages in 512-bit blocks. If the input
message is n bits long, what is the time complexity of computing its SHA-256 hash? Express
your answer in big O notation.
Solution 7. Step 1: Determine the number of blocks. Number of blocks = ⌈n/512
Step 2: Analyze the time complexity. Each block processing takes constant time. Total time =
O(Number of blocks) = O(⌈n/512) = O(n)
Therefore, the time complexity of computing the SHA-256 hash of an n-bit message is O(n).
Problem 8. In the Merkle-Damgård construction used in many hash functions, the message is
padded to a multiple of the block size. If the original message is n bits long and the block size is
b bits, what is the maximum length of the padded message? Express your answer in terms of n
and b.
Solution 8. Step 1: Analyze the padding scheme. - The message is padded to a multiple of
the block size - At least 1 bit is always added (the ’1’ bit) - The length of the original message
(n) is appended (usually 64 bits)
Step 2: Calculate the maximum padded length. Maximum padded length = (n + 1 + 64)/b b
This can be simplified to: Maximum padded length = (n + 65)/b⌉ b
Therefore, the maximum length of the padded message is (n + 65)/b⌉ b bits.
The Advanced Encryption Standard (AES) operates on 128-bit blocks. If the input message is n
bits long, what is the time complexity of encrypting this message using AES in ECB mode?
Express your answer in big O notation.
Solution 1. Step 1: Determine the number of blocks. Number of blocks = ⌈n/128
Step 2: Analyze the time complexity. Each block encryption takes constant time. Total time =
O(Number of blocks) = O(⌈n/128) = O(n)
Therefore, the time complexity of encrypting an n-bit message using AES in ECB mode is O(n).
Problem 2. The Data Encryption Standard (DES) uses a 56-bit key. How many operations
would be required for an exhaustive key search in the worst case? Express your answer in big O
notation.
Solution 2. Step 1: Calculate the total number of possible keys. Number of possible keys =
256
Step 2: In the worst case, we might need to try all possible keys. Worst-case number of
operations = 256
Therefore, the time complexity of an exhaustive key search for DES is O(256).
Problem 3. The RC4 stream cipher has an initialization phase where it creates a 256-byte
state array. What is the space complexity of RC4 in terms of the key size k? Express your
answer in big O notation.
Solution 3. Step 1: Analyze the space requirements. - The state array requires 256 bytes
(constant) - The key of size k bytes is stored
Step 2: Express the total space in big O notation. Space complexity = O(256 + k) = O(k)
Therefore, the space complexity of RC4 is O(k), where k is the key size in bytes.
34 ASYMMETRIC ENCRYPTION ALGORITHMS
Problem 4. In RSA, key generation involves finding two large prime numbers. If we use the
trial division method to test primality up to n for an n-bit number, what is the time complexity
of this primality test? Express your answer in big O notation.
Solution 4. Step 1: Determine the range of numbers to check. For an n-bit number, the
maximum value is 2n 1. We need to check up to 2n 1, which is approximately 2n/2.
Step 2: Calculate the number of operations. Number of operations ≈ 2n/2
Therefore, the time complexity of the trial division primality test for an n-bit number is O(2n/2).
Problem 5. In the Diffie-Hellman key exchange protocol, both parties perform modular
exponentiation. If the modulus is an n-bit number, what is the time complexity of the modular
exponentiation operation using the square-and-multiply algorithm? Express your answer in big
O notation.
Solution 5. Step 1: Analyze the square-and-multiply algorithm. - The algorithm performs n
steps for an n-bit exponent - Each step involves at most two operations: squaring and
multiplication
Step 2: Determine the complexity of each operation. - Squaring and multiplication of n-bit
numbers take O(n2) time using naive multiplication - Using more efficient algorithms like
Karatsuba, it can be reduced to O(nlog23) ≈ O(n1.585)
Step 3: Calculate the overall time complexity. Time complexity = n * O(nlog23) = O(n1+log23) ≈
O(n2.585)
Therefore, the time complexity of modular exponentiation in Diffie-Hellman key exchange is
O(n2.585), where n is the number of bits in the modulus.
Problem 6. Elliptic Curve Cryptography (ECC) operates on points on an elliptic curve. If the
field size is q, what is the space complexity of storing a public key in ECC? Express your answer
in big O notation.
Solution 6. Step 1: Analyze the components of an ECC public key. An ECC public key consists
of: - The elliptic curve parameters (assumed to be fixed and not counted) - A point on the
curve, represented by two coordinates (x, y)
Step 2: Determine the size of each coordinate. Each coordinate is an element of the field of size
q, requiring log_2(q) bits to represent.
Step 3: Calculate the total space required. Space for public key = 2 * log_2(q) bits
Therefore, the space complexity of storing an ECC public key is O(log q).
35 HASH FUNCTIONS
Problem 7. The SHA-256 hash function processes messages in 512-bit blocks. If the input
message is n bits long, what is the time complexity of computing its SHA-256 hash? Express
your answer in big O notation.
Solution 7. Step 1: Determine the number of blocks. Number of blocks = ⌈n/512
Step 2: Analyze the time complexity. Each block processing takes constant time. Total time =
O(Number of blocks) = O(⌈n/512) = O(n)
Therefore, the time complexity of computing the SHA-256 hash of an n-bit message is O(n).
Problem 8. In the Merkle-Damgård construction used in many hash functions, the message is
padded to a multiple of the block size. If the original message is n bits long and the block size is
b bits, what is the maximum length of the padded message? Express your answer in terms of n
and b.
Solution 8. Step 1: Analyze the padding scheme. - The message is padded to a multiple of
the block size - At least 1 bit is always added (the ’1’ bit) - The length of the original message
(n) is appended (usually 64 bits)
Step 2: Calculate the maximum padded length. Maximum padded length = (n + 1 + 64)/b b
This can be simplified to: Maximum padded length = (n + 65)/b⌉ b
Therefore, the maximum length of the padded message is (n + 65)/b⌉ b bits.
The Advanced Encryption Standard (AES) operates on 128-bit blocks. If the input message is n
bits long, what is the time complexity of encrypting this message using AES in ECB mode?
Express your answer in big O notation.
Solution 1. Step 1: Determine the number of blocks. Number of blocks = ⌈n/128
Step 2: Analyze the time complexity. Each block encryption takes constant time. Total time =
O(Number of blocks) = O(⌈n/128) = O(n)
Therefore, the time complexity of encrypting an n-bit message using AES in ECB mode is O(n).
Problem 2. The Data Encryption Standard (DES) uses a 56-bit key. How many operations
would be required for an exhaustive key search in the worst case? Express your answer in big O
notation.
Solution 2. Step 1: Calculate the total number of possible keys. Number of possible keys =
256
Step 2: In the worst case, we might need to try all possible keys. Worst-case number of
operations = 256
Therefore, the time complexity of an exhaustive key search for DES is O(256).
Problem 3. The RC4 stream cipher has an initialization phase where it creates a 256-byte
state array. What is the space complexity of RC4 in terms of the key size k? Express your
answer in big O notation.
Solution 3. Step 1: Analyze the space requirements. - The state array requires 256 bytes
(constant) - The key of size k bytes is stored
Step 2: Express the total space in big O notation. Space complexity = O(256 + k) = O(k)
Therefore, the space complexity of RC4 is O(k), where k is the key size in bytes.
36 ASYMMETRIC ENCRYPTION ALGORITHMS
Problem 4. In RSA, key generation involves finding two large prime numbers. If we use the
trial division method to test primality up to n for an n-bit number, what is the time complexity
of this primality test? Express your answer in big O notation.
Solution 4. Step 1: Determine the range of numbers to check. For an n-bit number, the
maximum value is 2n 1. We need to check up to 2n 1, which is approximately 2n/2.
Step 2: Calculate the number of operations. Number of operations ≈ 2n/2
Therefore, the time complexity of the trial division primality test for an n-bit number is O(2n/2).
Problem 5. In the Diffie-Hellman key exchange protocol, both parties perform modular
exponentiation. If the modulus is an n-bit number, what is the time complexity of the modular
exponentiation operation using the square-and-multiply algorithm? Express your answer in big
O notation.
Solution 5. Step 1: Analyze the square-and-multiply algorithm. - The algorithm performs n
steps for an n-bit exponent - Each step involves at most two operations: squaring and
multiplication
Step 2: Determine the complexity of each operation. - Squaring and multiplication of n-bit
numbers take O(n2) time using naive multiplication - Using more efficient algorithms like
Karatsuba, it can be reduced to O(nlog23) ≈ O(n1.585)
Step 3: Calculate the overall time complexity. Time complexity = n * O(nlog23) = O(n1+log23) ≈
O(n2.585)
Therefore, the time complexity of modular exponentiation in Diffie-Hellman key exchange is
O(n2.585), where n is the number of bits in the modulus.
Problem 6. Elliptic Curve Cryptography (ECC) operates on points on an elliptic curve. If the
field size is q, what is the space complexity of storing a public key in ECC? Express your answer
in big O notation.
Solution 6. Step 1: Analyze the components of an ECC public key. An ECC public key consists
of: - The elliptic curve parameters (assumed to be fixed and not counted) - A point on the
curve, represented by two coordinates (x, y)
Step 2: Determine the size of each coordinate. Each coordinate is an element of the field of size
q, requiring log_2(q) bits to represent.
Step 3: Calculate the total space required. Space for public key = 2 * log_2(q) bits
Therefore, the space complexity of storing an ECC public key is O(log q).
37 HASH FUNCTIONS
Problem 7. The SHA-256 hash function processes messages in 512-bit blocks. If the input
message is n bits long, what is the time complexity of computing its SHA-256 hash? Express
your answer in big O notation.
Solution 7. Step 1: Determine the number of blocks. Number of blocks = ⌈n/512
Step 2: Analyze the time complexity. Each block processing takes constant time. Total time =
O(Number of blocks) = O(⌈n/512) = O(n)
Therefore, the time complexity of computing the SHA-256 hash of an n-bit message is O(n).
Problem 8. In the Merkle-Damgård construction used in many hash functions, the message is
padded to a multiple of the block size. If the original message is n bits long and the block size is
b bits, what is the maximum length of the padded message? Express your answer in terms of n
and b.
Solution 8. Step 1: Analyze the padding scheme. - The message is padded to a multiple of
the block size - At least 1 bit is always added (the ’1’ bit) - The length of the original message
(n) is appended (usually 64 bits)
Step 2: Calculate the maximum padded length. Maximum padded length = (n + 1 + 64)/b b
This can be simplified to: Maximum padded length = (n + 65)/b⌉ b
Therefore, the maximum length of the padded message is (n + 65)/b⌉ b bits.
The Advanced Encryption Standard (AES) operates on 128-bit blocks. If the input message is n
bits long, what is the time complexity of encrypting this message using AES in ECB mode?
Express your answer in big O notation.
Solution 1. Step 1: Determine the number of blocks. Number of blocks = ⌈n/128
Step 2: Analyze the time complexity. Each block encryption takes constant time. Total time =
O(Number of blocks) = O(⌈n/128) = O(n)
Therefore, the time complexity of encrypting an n-bit message using AES in ECB mode is O(n).
Problem 2. The Data Encryption Standard (DES) uses a 56-bit key. How many operations
would be required for an exhaustive key search in the worst case? Express your answer in big O
notation.
Solution 2. Step 1: Calculate the total number of possible keys. Number of possible keys =
256
Step 2: In the worst case, we might need to try all possible keys. Worst-case number of
operations = 256
Therefore, the time complexity of an exhaustive key search for DES is O(256).
Problem 3. The RC4 stream cipher has an initialization phase where it creates a 256-byte
state array. What is the space complexity of RC4 in terms of the key size k? Express your
answer in big O notation.
Solution 3. Step 1: Analyze the space requirements. - The state array requires 256 bytes
(constant) - The key of size k bytes is stored
Step 2: Express the total space in big O notation. Space complexity = O(256 + k) = O(k)
Therefore, the space complexity of RC4 is O(k), where k is the key size in bytes.
38 ASYMMETRIC ENCRYPTION ALGORITHMS
Problem 4. In RSA, key generation involves finding two large prime numbers. If we use the
trial division method to test primality up to n for an n-bit number, what is the time complexity
of this primality test? Express your answer in big O notation.
Solution 4. Step 1: Determine the range of numbers to check. For an n-bit number, the
maximum value is 2n 1. We need to check up to 2n 1, which is approximately 2n/2.
Step 2: Calculate the number of operations. Number of operations ≈ 2n/2
Therefore, the time complexity of the trial division primality test for an n-bit number is O(2n/2).
Problem 5. In the Diffie-Hellman key exchange protocol, both parties perform modular
exponentiation. If the modulus is an n-bit number, what is the time complexity of the modular
exponentiation operation using the square-and-multiply algorithm? Express your answer in big
O notation.
Solution 5. Step 1: Analyze the square-and-multiply algorithm. - The algorithm performs n
steps for an n-bit exponent - Each step involves at most two operations: squaring and
multiplication
Step 2: Determine the complexity of each operation. - Squaring and multiplication of n-bit
numbers take O(n2) time using naive multiplication - Using more efficient algorithms like
Karatsuba, it can be reduced to O(nlog23) ≈ O(n1.585)
Step 3: Calculate the overall time complexity. Time complexity = n * O(nlog23) = O(n1+log23) ≈
O(n2.585)
Therefore, the time complexity of modular exponentiation in Diffie-Hellman key exchange is
O(n2.585), where n is the number of bits in the modulus.
Problem 6. Elliptic Curve Cryptography (ECC) operates on points on an elliptic curve. If the
field size is q, what is the space complexity of storing a public key in ECC? Express your answer
in big O notation.
Solution 6. Step 1: Analyze the components of an ECC public key. An ECC public key consists
of: - The elliptic curve parameters (assumed to be fixed and not counted) - A point on the
curve, represented by two coordinates (x, y)
Step 2: Determine the size of each coordinate. Each coordinate is an element of the field of size
q, requiring log_2(q) bits to represent.
Step 3: Calculate the total space required. Space for public key = 2 * log_2(q) bits
Therefore, the space complexity of storing an ECC public key is O(log q).
39 HASH FUNCTIONS
Problem 7. The SHA-256 hash function processes messages in 512-bit blocks. If the input
message is n bits long, what is the time complexity of computing its SHA-256 hash? Express
your answer in big O notation.
Solution 7. Step 1: Determine the number of blocks. Number of blocks = ⌈n/512
Step 2: Analyze the time complexity. Each block processing takes constant time. Total time =
O(Number of blocks) = O(⌈n/512) = O(n)
Therefore, the time complexity of computing the SHA-256 hash of an n-bit message is O(n).
Problem 8. In the Merkle-Damgård construction used in many hash functions, the message is
padded to a multiple of the block size. If the original message is n bits long and the block size is
b bits, what is the maximum length of the padded message? Express your answer in terms of n
and b.
Solution 8. Step 1: Analyze the padding scheme. - The message is padded to a multiple of
the block size - At least 1 bit is always added (the ’1’ bit) - The length of the original message
(n) is appended (usually 64 bits)
Step 2: Calculate the maximum padded length. Maximum padded length = (n + 1 + 64)/b b
This can be simplified to: Maximum padded length = (n + 65)/b⌉ b
Therefore, the maximum length of the padded message is (n + 65)/b⌉ b bits.
The Advanced Encryption Standard (AES) operates on 128-bit blocks. If the input message is n
bits long, what is the time complexity of encrypting this message using AES in ECB mode?
Express your answer in big O notation.
Solution 1. Step 1: Determine the number of blocks. Number of blocks = ⌈n/128
Step 2: Analyze the time complexity. Each block encryption takes constant time. Total time =
O(Number of blocks) = O(⌈n/128) = O(n)
Therefore, the time complexity of encrypting an n-bit message using AES in ECB mode is O(n).
Problem 2. The Data Encryption Standard (DES) uses a 56-bit key. How many operations
would be required for an exhaustive key search in the worst case? Express your answer in big O
notation.
Solution 2. Step 1: Calculate the total number of possible keys. Number of possible keys =
256
Step 2: In the worst case, we might need to try all possible keys. Worst-case number of
operations = 256
Therefore, the time complexity of an exhaustive key search for DES is O(256).
Problem 3. The RC4 stream cipher has an initialization phase where it creates a 256-byte
state array. What is the space complexity of RC4 in terms of the key size k? Express your
answer in big O notation.
Solution 3. Step 1: Analyze the space requirements. - The state array requires 256 bytes
(constant) - The key of size k bytes is stored
Step 2: Express the total space in big O notation. Space complexity = O(256 + k) = O(k)
Therefore, the space complexity of RC4 is O(k), where k is the key size in bytes.
40 ASYMMETRIC ENCRYPTION ALGORITHMS
Problem 4. In RSA, key generation involves finding two large prime numbers. If we use the
trial division method to test primality up to n for an n-bit number, what is the time complexity
of this primality test? Express your answer in big O notation.
Solution 4. Step 1: Determine the range of numbers to check. For an n-bit number, the
maximum value is 2n 1. We need to check up to 2n 1, which is approximately 2n/2.
Step 2: Calculate the number of operations. Number of operations ≈ 2n/2
Therefore, the time complexity of the trial division primality test for an n-bit number is O(2n/2).
Problem 5. In the Diffie-Hellman key exchange protocol, both parties perform modular
exponentiation. If the modulus is an n-bit number, what is the time complexity of the modular
exponentiation operation using the square-and-multiply algorithm? Express your answer in big
O notation.
Solution 5. Step 1: Analyze the square-and-multiply algorithm. - The algorithm performs n
steps for an n-bit exponent - Each step involves at most two operations: squaring and
multiplication
Step 2: Determine the complexity of each operation. - Squaring and multiplication of n-bit
numbers take O(n2) time using naive multiplication - Using more efficient algorithms like
Karatsuba, it can be reduced to O(nlog23) ≈ O(n1.585)
Step 3: Calculate the overall time complexity. Time complexity = n * O(nlog23) = O(n1+log23) ≈
O(n2.585)
Therefore, the time complexity of modular exponentiation in Diffie-Hellman key exchange is
O(n2.585), where n is the number of bits in the modulus.
Problem 6. Elliptic Curve Cryptography (ECC) operates on points on an elliptic curve. If the
field size is q, what is the space complexity of storing a public key in ECC? Express your answer
in big O notation.
Solution 6. Step 1: Analyze the components of an ECC public key. An ECC public key consists
of: - The elliptic curve parameters (assumed to be fixed and not counted) - A point on the
curve, represented by two coordinates (x, y)
Step 2: Determine the size of each coordinate. Each coordinate is an element of the field of size
q, requiring log_2(q) bits to represent.
Step 3: Calculate the total space required. Space for public key = 2 * log_2(q) bits
Therefore, the space complexity of storing an ECC public key is O(log q).
41 HASH FUNCTIONS
Problem 7. The SHA-256 hash function processes messages in 512-bit blocks. If the input
message is n bits long, what is the time complexity of computing its SHA-256 hash? Express
your answer in big O notation.
Solution 7. Step 1: Determine the number of blocks. Number of blocks = ⌈n/512
Step 2: Analyze the time complexity. Each block processing takes constant time. Total time =
O(Number of blocks) = O(⌈n/512) = O(n)
Therefore, the time complexity of computing the SHA-256 hash of an n-bit message is O(n).
Problem 8. In the Merkle-Damgård construction used in many hash functions, the message is
padded to a multiple of the block size. If the original message is n bits long and the block size is
b bits, what is the maximum length of the padded message? Express your answer in terms of n
and b.
Solution 8. Step 1: Analyze the padding scheme. - The message is padded to a multiple of
the block size - At least 1 bit is always added (the ’1’ bit) - The length of the original message
(n) is appended (usually 64 bits)
Step 2: Calculate the maximum padded length. Maximum padded length = (n + 1 + 64)/b b
This can be simplified to: Maximum padded length = (n + 65)/b⌉ b
Therefore, the maximum length of the padded message is (n + 65)/b⌉ b bits.
The Advanced Encryption Standard (AES) operates on 128-bit blocks. If the input message is n
bits long, what is the time complexity of encrypting this message using AES in ECB mode?
Express your answer in big O notation.
Solution 1. Step 1: Determine the number of blocks. Number of blocks = ⌈n/128
Step 2: Analyze the time complexity. Each block encryption takes constant time. Total time =
O(Number of blocks) = O(⌈n/128) = O(n)
Therefore, the time complexity of encrypting an n-bit message using AES in ECB mode is O(n).
Problem 2. The Data Encryption Standard (DES) uses a 56-bit key. How many operations
would be required for an exhaustive key search in the worst case? Express your answer in big O
notation.
Solution 2. Step 1: Calculate the total number of possible keys. Number of possible keys =
256
Step 2: In the worst case, we might need to try all possible keys. Worst-case number of
operations = 256
Therefore, the time complexity of an exhaustive key search for DES is O(256).
Problem 3. The RC4 stream cipher has an initialization phase where it creates a 256-byte
state array. What is the space complexity of RC4 in terms of the key size k? Express your
answer in big O notation.
Solution 3. Step 1: Analyze the space requirements. - The state array requires 256 bytes
(constant) - The key of size k bytes is stored
Step 2: Express the total space in big O notation. Space complexity = O(256 + k) = O(k)
Therefore, the space complexity of RC4 is O(k), where k is the key size in bytes.
42 ASYMMETRIC ENCRYPTION ALGORITHMS
Problem 4. In RSA, key generation involves finding two large prime numbers. If we use the
trial division method to test primality up to n for an n-bit number, what is the time complexity
of this primality test? Express your answer in big O notation.
Solution 4. Step 1: Determine the range of numbers to check. For an n-bit number, the
maximum value is 2n 1. We need to check up to 2n 1, which is approximately 2n/2.
Step 2: Calculate the number of operations. Number of operations ≈ 2n/2
Therefore, the time complexity of the trial division primality test for an n-bit number is O(2n/2).
Problem 5. In the Diffie-Hellman key exchange protocol, both parties perform modular
exponentiation. If the modulus is an n-bit number, what is the time complexity of the modular
exponentiation operation using the square-and-multiply algorithm? Express your answer in big
O notation.
Solution 5. Step 1: Analyze the square-and-multiply algorithm. - The algorithm performs n
steps for an n-bit exponent - Each step involves at most two operations: squaring and
multiplication
Step 2: Determine the complexity of each operation. - Squaring and multiplication of n-bit
numbers take O(n2) time using naive multiplication - Using more efficient algorithms like
Karatsuba, it can be reduced to O(nlog23) ≈ O(n1.585)
Step 3: Calculate the overall time complexity. Time complexity = n * O(nlog23) = O(n1+log23) ≈
O(n2.585)
Therefore, the time complexity of modular exponentiation in Diffie-Hellman key exchange is
O(n2.585), where n is the number of bits in the modulus.
Problem 6. Elliptic Curve Cryptography (ECC) operates on points on an elliptic curve. If the
field size is q, what is the space complexity of storing a public key in ECC? Express your answer
in big O notation.
Solution 6. Step 1: Analyze the components of an ECC public key. An ECC public key consists
of: - The elliptic curve parameters (assumed to be fixed and not counted) - A point on the
curve, represented by two coordinates (x, y)
Step 2: Determine the size of each coordinate. Each coordinate is an element of the field of size
q, requiring log_2(q) bits to represent.
Step 3: Calculate the total space required. Space for public key = 2 * log_2(q) bits
Therefore, the space complexity of storing an ECC public key is O(log q).
43 HASH FUNCTIONS
Problem 7. The SHA-256 hash function processes messages in 512-bit blocks. If the input
message is n bits long, what is the time complexity of computing its SHA-256 hash? Express
your answer in big O notation.
Solution 7. Step 1: Determine the number of blocks. Number of blocks = ⌈n/512
Step 2: Analyze the time complexity. Each block processing takes constant time. Total time =
O(Number of blocks) = O(⌈n/512) = O(n)
Therefore, the time complexity of computing the SHA-256 hash of an n-bit message is O(n).
Problem 8. In the Merkle-Damgård construction used in many hash functions, the message is
padded to a multiple of the block size. If the original message is n bits long and the block size is
b bits, what is the maximum length of the padded message? Express your answer in terms of n
and b.
Solution 8. Step 1: Analyze the padding scheme. - The message is padded to a multiple of
the block size - At least 1 bit is always added (the ’1’ bit) - The length of the original message
(n) is appended (usually 64 bits)
Step 2: Calculate the maximum padded length. Maximum padded length = (n + 1 + 64)/b b
This can be simplified to: Maximum padded length = (n + 65)/b⌉ b
Therefore, the maximum length of the padded message is (n + 65)/b⌉ b bits.
The Advanced Encryption Standard (AES) operates on 128-bit blocks. If the input message is n
bits long, what is the time complexity of encrypting this message using AES in ECB mode?
Express your answer in big O notation.
Solution 1. Step 1: Determine the number of blocks. Number of blocks = ⌈n/128
Step 2: Analyze the time complexity. Each block encryption takes constant time. Total time =
O(Number of blocks) = O(⌈n/128) = O(n)
Therefore, the time complexity of encrypting an n-bit message using AES in ECB mode is O(n).
Problem 2. The Data Encryption Standard (DES) uses a 56-bit key. How many operations
would be required for an exhaustive key search in the worst case? Express your answer in big O
notation.
Solution 2. Step 1: Calculate the total number of possible keys. Number of possible keys =
256
Step 2: In the worst case, we might need to try all possible keys. Worst-case number of
operations = 256
Therefore, the time complexity of an exhaustive key search for DES is O(256).
Problem 3. The RC4 stream cipher has an initialization phase where it creates a 256-byte
state array. What is the space complexity of RC4 in terms of the key size k? Express your
answer in big O notation.
Solution 3. Step 1: Analyze the space requirements. - The state array requires 256 bytes
(constant) - The key of size k bytes is stored
Step 2: Express the total space in big O notation. Space complexity = O(256 + k) = O(k)
Therefore, the space complexity of RC4 is O(k), where k is the key size in bytes.
44 ASYMMETRIC ENCRYPTION ALGORITHMS
Problem 4. In RSA, key generation involves finding two large prime numbers. If we use the
trial division method to test primality up to n for an n-bit number, what is the time complexity
of this primality test? Express your answer in big O notation.
Solution 4. Step 1: Determine the range of numbers to check. For an n-bit number, the
maximum value is 2n 1. We need to check up to 2n 1, which is approximately 2n/2.
Step 2: Calculate the number of operations. Number of operations ≈ 2n/2
Therefore, the time complexity of the trial division primality test for an n-bit number is O(2n/2).
Problem 5. In the Diffie-Hellman key exchange protocol, both parties perform modular
exponentiation. If the modulus is an n-bit number, what is the time complexity of the modular
exponentiation operation using the square-and-multiply algorithm? Express your answer in big
O notation.
Solution 5. Step 1: Analyze the square-and-multiply algorithm. - The algorithm performs n
steps for an n-bit exponent - Each step involves at most two operations: squaring and
multiplication
Step 2: Determine the complexity of each operation. - Squaring and multiplication of n-bit
numbers take O(n2) time using naive multiplication - Using more efficient algorithms like
Karatsuba, it can be reduced to O(nlog23) ≈ O(n1.585)
Step 3: Calculate the overall time complexity. Time complexity = n * O(nlog23) = O(n1+log23) ≈
O(n2.585)
Therefore, the time complexity of modular exponentiation in Diffie-Hellman key exchange is
O(n2.585), where n is the number of bits in the modulus.
Problem 6. Elliptic Curve Cryptography (ECC) operates on points on an elliptic curve. If the
field size is q, what is the space complexity of storing a public key in ECC? Express your answer
in big O notation.
Solution 6. Step 1: Analyze the components of an ECC public key. An ECC public key consists
of: - The elliptic curve parameters (assumed to be fixed and not counted) - A point on the
curve, represented by two coordinates (x, y)
Step 2: Determine the size of each coordinate. Each coordinate is an element of the field of size
q, requiring log_2(q) bits to represent.
Step 3: Calculate the total space required. Space for public key = 2 * log_2(q) bits
Therefore, the space complexity of storing an ECC public key is O(log q).
45 HASH FUNCTIONS
Problem 7. The SHA-256 hash function processes messages in 512-bit blocks. If the input
message is n bits long, what is the time complexity of computing its SHA-256 hash? Express
your answer in big O notation.
Solution 7. Step 1: Determine the number of blocks. Number of blocks = ⌈n/512
Step 2: Analyze the time complexity. Each block processing takes constant time. Total time =
O(Number of blocks) = O(⌈n/512) = O(n)
Therefore, the time complexity of computing the SHA-256 hash of an n-bit message is O(n).
Problem 8. In the Merkle-Damgård construction used in many hash functions, the message is
padded to a multiple of the block size. If the original message is n bits long and the block size is
b bits, what is the maximum length of the padded message? Express your answer in terms of n
and b.
Solution 8. Step 1: Analyze the padding scheme. - The message is padded to a multiple of
the block size - At least 1 bit is always added (the ’1’ bit) - The length of the original message
(n) is appended (usually 64 bits)
Step 2: Calculate the maximum padded length. Maximum padded length = (n + 1 + 64)/b b
This can be simplified to: Maximum padded length = (n + 65)/b⌉ b
Therefore, the maximum length of the padded message is (n + 65)/b⌉ b bits.
The Advanced Encryption Standard (AES) operates on 128-bit blocks. If the input message is n
bits long, what is the time complexity of encrypting this message using AES in ECB mode?
Express your answer in big O notation.
Solution 1. Step 1: Determine the number of blocks. Number of blocks = ⌈n/128
Step 2: Analyze the time complexity. Each block encryption takes constant time. Total time =
O(Number of blocks) = O(⌈n/128) = O(n)
Therefore, the time complexity of encrypting an n-bit message using AES in ECB mode is O(n).
Problem 2. The Data Encryption Standard (DES) uses a 56-bit key. How many operations
would be required for an exhaustive key search in the worst case? Express your answer in big O
notation.
Solution 2. Step 1: Calculate the total number of possible keys. Number of possible keys =
256
Step 2: In the worst case, we might need to try all possible keys. Worst-case number of
operations = 256
Therefore, the time complexity of an exhaustive key search for DES is O(256).
Problem 3. The RC4 stream cipher has an initialization phase where it creates a 256-byte
state array. What is the space complexity of RC4 in terms of the key size k? Express your
answer in big O notation.
Solution 3. Step 1: Analyze the space requirements. - The state array requires 256 bytes
(constant) - The key of size k bytes is stored
Step 2: Express the total space in big O notation. Space complexity = O(256 + k) = O(k)
Therefore, the space complexity of RC4 is O(k), where k is the key size in bytes.
46 ASYMMETRIC ENCRYPTION ALGORITHMS
Problem 4. In RSA, key generation involves finding two large prime numbers. If we use the
trial division method to test primality up to n for an n-bit number, what is the time complexity
of this primality test? Express your answer in big O notation.
Solution 4. Step 1: Determine the range of numbers to check. For an n-bit number, the
maximum value is 2n 1. We need to check up to 2n 1, which is approximately 2n/2.
Step 2: Calculate the number of operations. Number of operations ≈ 2n/2
Therefore, the time complexity of the trial division primality test for an n-bit number is O(2n/2).
Problem 5. In the Diffie-Hellman key exchange protocol, both parties perform modular
exponentiation. If the modulus is an n-bit number, what is the time complexity of the modular
exponentiation operation using the square-and-multiply algorithm? Express your answer in big
O notation.
Solution 5. Step 1: Analyze the square-and-multiply algorithm. - The algorithm performs n
steps for an n-bit exponent - Each step involves at most two operations: squaring and
multiplication
Step 2: Determine the complexity of each operation. - Squaring and multiplication of n-bit
numbers take O(n2) time using naive multiplication - Using more efficient algorithms like
Karatsuba, it can be reduced to O(nlog23) ≈ O(n1.585)
Step 3: Calculate the overall time complexity. Time complexity = n * O(nlog23) = O(n1+log23) ≈
O(n2.585)
Therefore, the time complexity of modular exponentiation in Diffie-Hellman key exchange is
O(n2.585), where n is the number of bits in the modulus.
Problem 6. Elliptic Curve Cryptography (ECC) operates on points on an elliptic curve. If the
field size is q, what is the space complexity of storing a public key in ECC? Express your answer
in big O notation.
Solution 6. Step 1: Analyze the components of an ECC public key. An ECC public key consists
of: - The elliptic curve parameters (assumed to be fixed and not counted) - A point on the
curve, represented by two coordinates (x, y)
Step 2: Determine the size of each coordinate. Each coordinate is an element of the field of size
q, requiring log_2(q) bits to represent.
Step 3: Calculate the total space required. Space for public key = 2 * log_2(q) bits
Therefore, the space complexity of storing an ECC public key is O(log q).
47 HASH FUNCTIONS
Problem 7. The SHA-256 hash function processes messages in 512-bit blocks. If the input
message is n bits long, what is the time complexity of computing its SHA-256 hash? Express
your answer in big O notation.
Solution 7. Step 1: Determine the number of blocks. Number of blocks = ⌈n/512
Step 2: Analyze the time complexity. Each block processing takes constant time. Total time =
O(Number of blocks) = O(⌈n/512) = O(n)
Therefore, the time complexity of computing the SHA-256 hash of an n-bit message is O(n).
Problem 8. In the Merkle-Damgård construction used in many hash functions, the message is
padded to a multiple of the block size. If the original message is n bits long and the block size is
b bits, what is the maximum length of the padded message? Express your answer in terms of n
and b.
Solution 8. Step 1: Analyze the padding scheme. - The message is padded to a multiple of
the block size - At least 1 bit is always added (the ’1’ bit) - The length of the original message
(n) is appended (usually 64 bits)
Step 2: Calculate the maximum padded length. Maximum padded length = (n + 1 + 64)/b b
This can be simplified to: Maximum padded length = (n + 65)/b⌉ b
Therefore, the maximum length of the padded message is (n + 65)/b⌉ b bits.
The Advanced Encryption Standard (AES) operates on 128-bit blocks. If the input message is n
bits long, what is the time complexity of encrypting this message using AES in ECB mode?
Express your answer in big O notation.
Solution 1. Step 1: Determine the number of blocks. Number of blocks = ⌈n/128
Step 2: Analyze the time complexity. Each block encryption takes constant time. Total time =
O(Number of blocks) = O(⌈n/128) = O(n)
Therefore, the time complexity of encrypting an n-bit message using AES in ECB mode is O(n).
Problem 2. The Data Encryption Standard (DES) uses a 56-bit key. How many operations
would be required for an exhaustive key search in the worst case? Express your answer in big O
notation.
Solution 2. Step 1: Calculate the total number of possible keys. Number of possible keys =
256
Step 2: In the worst case, we might need to try all possible keys. Worst-case number of
operations = 256
Therefore, the time complexity of an exhaustive key search for DES is O(256).
Problem 3. The RC4 stream cipher has an initialization phase where it creates a 256-byte
state array. What is the space complexity of RC4 in terms of the key size k? Express your
answer in big O notation.
Solution 3. Step 1: Analyze the space requirements. - The state array requires 256 bytes
(constant) - The key of size k bytes is stored
Step 2: Express the total space in big O notation. Space complexity = O(256 + k) = O(k)
Therefore, the space complexity of RC4 is O(k), where k is the key size in bytes.
48 ASYMMETRIC ENCRYPTION ALGORITHMS
Problem 4. In RSA, key generation involves finding two large prime numbers. If we use the
trial division method to test primality up to n for an n-bit number, what is the time complexity
of this primality test? Express your answer in big O notation.
Solution 4. Step 1: Determine the range of numbers to check. For an n-bit number, the
maximum value is 2n 1. We need to check up to 2n 1, which is approximately 2n/2.
Step 2: Calculate the number of operations. Number of operations ≈ 2n/2
Therefore, the time complexity of the trial division primality test for an n-bit number is O(2n/2).
Problem 5. In the Diffie-Hellman key exchange protocol, both parties perform modular
exponentiation. If the modulus is an n-bit number, what is the time complexity of the modular
exponentiation operation using the square-and-multiply algorithm? Express your answer in big
O notation.
Solution 5. Step 1: Analyze the square-and-multiply algorithm. - The algorithm performs n
steps for an n-bit exponent - Each step involves at most two operations: squaring and
multiplication
Step 2: Determine the complexity of each operation. - Squaring and multiplication of n-bit
numbers take O(n2) time using naive multiplication - Using more efficient algorithms like
Karatsuba, it can be reduced to O(nlog23) ≈ O(n1.585)
Step 3: Calculate the overall time complexity. Time complexity = n * O(nlog23) = O(n1+log23) ≈
O(n2.585)
Therefore, the time complexity of modular exponentiation in Diffie-Hellman key exchange is
O(n2.585), where n is the number of bits in the modulus.
Problem 6. Elliptic Curve Cryptography (ECC) operates on points on an elliptic curve. If the
field size is q, what is the space complexity of storing a public key in ECC? Express your answer
in big O notation.
Solution 6. Step 1: Analyze the components of an ECC public key. An ECC public key consists
of: - The elliptic curve parameters (assumed to be fixed and not counted) - A point on the
curve, represented by two coordinates (x, y)
Step 2: Determine the size of each coordinate. Each coordinate is an element of the field of size
q, requiring log_2(q) bits to represent.
Step 3: Calculate the total space required. Space for public key = 2 * log_2(q) bits
Therefore, the space complexity of storing an ECC public key is O(log q).
49 HASH FUNCTIONS
Problem 7. The SHA-256 hash function processes messages in 512-bit blocks. If the input
message is n bits long, what is the time complexity of computing its SHA-256 hash? Express
your answer in big O notation.
Solution 7. Step 1: Determine the number of blocks. Number of blocks = ⌈n/512
Step 2: Analyze the time complexity. Each block processing takes constant time. Total time =
O(Number of blocks) = O(⌈n/512) = O(n)
Therefore, the time complexity of computing the SHA-256 hash of an n-bit message is O(n).
Problem 8. In the Merkle-Damgård construction used in many hash functions, the message is
padded to a multiple of the block size. If the original message is n bits long and the block size is
b bits, what is the maximum length of the padded message? Express your answer in terms of n
and b.
Solution 8. Step 1: Analyze the padding scheme. - The message is padded to a multiple of
the block size - At least 1 bit is always added (the ’1’ bit) - The length of the original message
(n) is appended (usually 64 bits)
Step 2: Calculate the maximum padded length. Maximum padded length = (n + 1 + 64)/b b
This can be simplified to: Maximum padded length = (n + 65)/b⌉ b
Therefore, the maximum length of the padded message is (n + 65)/b⌉ b bits.
Students also viewed