CIS3362 FE 2021 Solqq
CIS3362 FE 2021 Solqq
1) (5 pts) Decrypt the following ciphertext produced by the shift cipher: KPRPIXDCIXBT.
…this last one, VACA, looks promising, let's try it! (So the
encryption key was +15, to decrypt, subtract 15 or add 11.)
K(10) + 11 = 21 (V)
P(15) + 11 = 26 ≡ 0 mod 26 (A)
R(17) + 11 = 28 ≡ 2 mod 26 (C)
P(15) + 11 = 26 ≡ 0 mod 26 (A)
I(8) + 11 = 19 (T)
X(23) + 11 = 34 ≡ 8 mod 26 (I)
D(3) + 11 = 14 (O)
C(2) + 11 = 13 (N)
I(8) + 11 = 19 (T)
X(23) + 11 = 34 ≡ 8 mod 26 (I)
B(1) + 11 = 12 (M)
T(19) + 11 = 30 ≡ 4 mod 26 (E)
2) (5 pts) A bin of candy has 30 Snickers bars, 25 Reece's Pieces packages, 50 Twix bars and 20
Skittles packages. Serena takes two of the items from the bin at random. What is the probability
that she gets two of the same type of candy? Please express your answer as a fraction in lowest
terms.
This is the same definition of index of coincidence! (Or you can just apply your knowledge of
probability…)
79 = 2 x 28 + 23
28 = 1 x 23 + 5
23 = 4 x 5 + 3
5 =1x3 +2
3 =1x2 +1
3-2=1
3 - (5 - 3) = 1
2x3-1x5=1
2(23 - 4 x 5) - 1 x 5 = 1
2 x 23 - 8 x 5 - 1 x 5 = 1
2 x 23 - 9 x 5 = 1
2 x 23 - 9(28 - 23) = 1
2 x 23 - 9 x 28 + 9 x 23 = 1
11 x 23 - 9 x 28 = 1
11(79 - 2 x 28) - 9 x 28 = 1
11 x 79 - 22 x 28 - 9 x 28 = 1
11 x 79 - 31 x 28 = 1
Taking this equation mod 79 we find that -31 x 28 ≡ 1 (mod 79), so 28-1 ≡ -31 ≡ 48 (mod 79).
V I/J R G N
A B C D E
F H K L M
O P Q S T
U W X Y Z
MI SX SI SX SI PX PI MA DN ES SX
and encrypt:
HN QY PG QY PG QW WB FE EG DT QY
Grading: 2 pts for square, 1 pt for all the padding chars in the right place, 2 pts for correct
application of all the rules (Award a whole number of points, only giving full credit if the answer
is completely correct. So, most minor errors will get 4 of 5.)
13 8
5) (5 pts) What is the corresponding decryption key for the encryption key ( ) for the Hill
2 17
cipher using an alphabet of size 26?
The determinant of the matrix is 13 x 17 - 2 x 8 = 221 - 16 = 205 ≡ -3 (mod 26). The inverse of
this value mod 26 is -9 ≡ 17 (mod 26). (Just use the provided look up chart for inverses mod 26.
Either look up the inverse of 3 or 23 and use accordingly.)
17 −8 289 −136
It follows the corresponding decryption matrix is 17 ( )=( ), mapping each
−2 13 −34 221
𝟑 𝟐𝟎
of these values mod 26 we get ( ).
𝟏𝟖 𝟏𝟑
Grading: 2 pts for determinant, 1 pt for its inverse mod 26, 1 pt for plugging into the formula, 1 pt
for reducing
Fall 2021 CIS 3362 Final Exam (12/8/2021) Part B Solutions
6) (8 pts) Let the input to the S-boxes in DES be 9FC 65B 05A D38, in hex. What is the output
produced by the S-boxes. Express your result in hex.
9 F C 6 5 B 0 5 A D 3 8 converted to binary is
1001 1111 1100 0110 0101 1011 0000 0101 1010 1101 0011 1000
Now, split into groups of size 6 and give as inputs to the corresponding S-boxes:
7) (5 pts) How many bits are each of the following pieces of data in the DES algorithm:
3𝐴 𝐵𝐶 𝐶𝐷 12
(2𝐶 65 96 4𝐹 )
97 𝐹3 𝐴0 62
𝐵2 𝐶9 7𝐸 𝐷3
02 03 01 01
Note that the fixed matrix multiplier for the Mix Columns step in AES is (01 02 03 01).
01 01 02 03
03 01 01 02
03 x BC = 02 x BC + 01 x BC
02 x C9 = 1 1001 0010
= 1001 0010
+ 1 1011
---------
1000 1001 (89)
Grading: 2 pts to write out correct product, 3 pts for first term, 2 pts for second term, 2 pts to XOR,
1 pt to convert to hex. Max 3 pts out of 10 if the wrong initial product is written out.
Fall 2021 CIS 3362 Final Exam (12/8/2021) Part C Solution
9) (10 pts) Define 𝜙𝑘 (𝑛) to be the Euler Phi Function composed with itself k times. For example,
𝜙3 (𝑛) = 𝜙(𝜙(𝜙(𝑛))) and 𝜙5 (𝑛) = 𝜙(𝜙 (𝜙 (𝜙(𝜙(𝑛))))). Define f(n) to be the minimum value
of k such that 𝜙𝑘 (𝑛) = 1. For example, f(5) = 3 since 𝜙(𝜙(5)) = 2 and 𝜙 (𝜙(𝜙(5))) = 1. Find
the smallest value of n such that f(n) = 5. (Note: 𝜙(1) = 1.) (Note: Full credit will only be given
with ample proof.)
The key observation to solving this problem quickly is to note that if f(φ(n)) = k, then f(n) = k+1.
Thus, we can just calculate the values of f(n) in ascending order, noting that f(1) = 0. This table
can be filled out from left to right:
n 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
φ(n) 1 1 2 2 4 2 6 4 6 4 10 4 12 6 8 8 16
f(n) 0 1 2 2 3 2 3 3 3 3 4 3 4 3 4 4 5
Note: We use the usual formula for φ(n) when making the calculations above. The numbers are
small enough that we can prime factorize each value of n mentally and plug into the formula for φ
accordingly. As an example, 12 = 22 x 3, so φ(12) = (22 - 21)(31 - 30) = 2 x 2 = 4.
Note: Points may be awarded on a discretionary basis for answers that aren't correct but
show some progress towards a solution or understanding of the question being posed.
10) (10 pts) In an RSA system, n = 527 and e = 197. Determine both φ(n) and d. (Put a box around
both answers and clearly mark them.) Full credit will only be given if work for the Extended
Euclidean Algorithm is show.
First, we must prime factorize 527. We can do this by guess and check with the calculator, or
Fermat Factoring. √527 is pretty close to 23, so let's try
We must find d = 197-1 mod 480 via the Extended Euclidean Algorithm:
480 = 2 x 197 + 86
197 = 2 x 86 + 25
86 = 3 x 25 + 11
25 = 2 x 11 + 3
11 = 3 x 3 + 2
3 =1x2 +1
3-2=1
3 - (11 - 3 x 3) = 1
3 - 1 x 11 + 3 x 3 = 1
4 x 3 - 1 x 11 = 1
4(25 - 2 x 11) - 1 x 11 = 1
4 x 25 - 8 x 11 - 1 x 11 = 1
4 x 25 - 9 x 11 = 1
4 x 25 - 9(86 - 3 x 25) = 1
4 x 25 - 9 x 86 + 27 x 25 = 1
31 x 25 - 9 x 86 = 1
31(197 - 2 x 86) - 9 x 86 = 1
31 x 197 - 62 x 86 - 9 x 86 = 1
31 x 197 - 71 x 86 = 1
31 x 197 - 71 (480 - 2 x 197) = 1
31 x 197 - 71 x 480 + 142 x 197 = 1
173 x 197 - 71 x 480 = 1
Take this equation mod 480 to yield 173 x 197 ≡ 1 (mod 480). It follows that d = 173.
BK0 = 21
/ \
BK1 = 6 BK2 = 13
/ \ / \
A=3 B=6 C=2 D=7
Imagine that user B wants to sponsor a new user E to create a new shared key BK3 in the tree
structure where B is currently located using new secret keys B = 10 and E = 14. In this process,
the blind keys BK3, BK1 and BK0 each need to be recalculated, respectively. Write down the
modular exponentiation calculation to figure out each of the blind keys, in sequence, and show the
result of each (as an integer in between 0 and 22, inclusive.)
First we calculate BK3 = 510(14) = 5140 ≡ 522(6)+8 ≡ (522)658 ≡ 1658 ≡ 16 (mod 23), via Fermat's
formula and use of the calculator. (Note: 58 = 390625 ≡ 16 (mod 23).)
Next, we recalculate BK1 using the secret keys for A and BK3. So we get:
Grading: 3 pts per value, try to give credit for correct work after an error, if possible. (So if there's
only one error but it cascades to change the other 2 values, just take off a point for that error.)
Fall 2021 CIS 3362 Final Exam (12/8/2021) Part D Solutions
12) (10 pts) Consider the elliptic curve E47(10, 17). Let the point P on the curve be (24, 13) and
the point Q on the curve be (35, 7). Calculate P + Q.
𝑦𝑄 − 𝑦𝑃 7 − 13
𝜆= = = (11−1 )(−6) 𝑚𝑜𝑑 47
𝑥𝑄 − 𝑥𝑃 35 − 24
47 = 4 x 11 + 3
11 = 3 x 3 + 2
3 =1x2+1
3-1x2=1
3 - (11 - 3 x 3) = 1
4 x 3 - 1 x 11 = 1
4(47 - 4 x 11) - 1 x 11 = 1
4 x 47 - 16 x 11 - 1 x 11 = 1
4 x 47 - 17 x 11 = 1, take this equation mod 47 to yield that -17 x 11 ≡ 1 (mod 47)
It follows that 11-1 ≡ -17 (mod 47), now, complete solving for lambda:
xP+Q = (𝜆2 − 𝑥𝑃 − 𝑥𝑄 ) = 82 − 24 − 35 = 5
Grading: 2 pts lambda set up, 3 pts EEA, 1 pt lambda value, 2 pts plug in for x, 2 pts plug in for
y.
13) (5 pts) Why is the following hash function, which produces an 8 bit output, a bad hash
function?
#include <string.h>
int f(char* word) {
int len = strlen(word);
int res = (int)word[0];
for (int i=1; i<len; i++)
res = (res & ((int)word[i]));
return res;
}
Not each of the 256 possible outputs are equally likely. This is because if you take the bitwise and
of several random characters, it's very unlikely that there will be any 1s (unless the data has a lot
of the same values) because eventually, in most bit locations, you'll see at least one 0, which would
result in that bit being permanently turned to 0 in the output result.
Grading: 1 pt for stating that not all outputs are equally likely, 4 pts for the reasoning.
14) (3 pts) Who is the host of the Kelly Clarkson Show? Kelly Clarkson, give to all