Anda di halaman 1dari 4

# Faculty of Business and Information Technology

## Cryptography and Network Security (INFR 3600U)

Assignment 1 Solution

## b) 550-1 mod 1769

q a1 a2 a3 b1 b2 b3
1 0 1769 0 1 550
3 0 1 550 1 -3 119
4 1 -3 119 -4 13 74
1 -4 13 74 5 -16 45
1 5 -16 45 -9 29 29
1 -9 29 29 14 -45 16
1 14 -45 16 -23 74 13
1 -23 74 13 37 -119 3
4 37 -119 3 -171 550 1

## 550-1 mod 1769 = 550 Check: 550*550 mod 1769 = 1

2. [Marks: 15%] Construct a Playfair matrix with the key largest and encrypt the message
Must see you over Cadogan West. Coming at once.

L A R G E
S T B C D
F H I/J K M
N O P Q U
V W X Y Z

## MUUZ, STTB, SEDL, EYGZ, OUPN, OVNW, ERLG, CATG, DOTU,

GAER, NWOV, ESLD, TCBD, OMUH, INFP, GAER, TOHW, NCQS,
EXRZ
Ciphertext = UZTBDLGZPNNWLGTGTUEROVLDBDUHFPERHWQSRZ
3. [Marks: 20%] You may use a mathematical package (e.g., MATLAB, Maple, FreeMat, GNU
Octave, Scilab). Perform computations modulo 26. Show your work.
9 4
a) Encrypt the message needhelp using the Hill cipher with key = [ ]. Show your
5 7
calculations and the result.

N E E D H E L P
13 4 4 3 7 4 11 15

9 4 13 4 3 22
1 = 1 26 = [ ][ ]=[ ]
5 7 4 3 15 15
9 4 7 11 1 3
2 = 2 26 = [ ][ ]=[ ]
5 7 4 15 11 4

C= D P W P B L D E

b) Show the calculations for the corresponding decryption of the ciphertext to recover the
5 12
original plaintext. Hint: 1 = [ ].
15 25

D P W P B L D E
3 15 22 15 1 11 3 4

5 12 3 22 13 4
1 = 1 1 26 = [ ][ ]=[ ]
15 25 15 15 4 3

5 12 1 3 7 11
2 = 1 2 26 = [ ][ ]=[ ]
15 25 11 4 4 15

P= N E E D H E L P

4. [Marks: 15%] Given the S-box form DES (S5) below, find:

S5 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
00 0010 1100 0100 0001 0111 1010 1011 0110 1000 0101 0011 1111 1101 0000 1110 1001
01 1110 1011 0010 1100 0100 0111 1101 0001 0101 0000 1111 1010 0011 1001 1000 0110
10 0100 0010 0001 1011 1010 1101 0111 1000 1111 1001 1100 0101 0110 0011 0000 1110
11 1011 1000 1100 0111 0001 1110 0010 1101 0110 1111 0000 1001 1010 0100 0101 0011

## b) S(000110) => row = 00, col = 0011 => S(000110) = 0001

5. [Marks: 15%] In round 3 of AES, the input matrix to the Mix Column Transformation block
is as follows:

s0 , 0 s0,1 s0 , 2 s0,3 A1 4C 3D 2F
s s1,3 0 E 72
1,0 s1,1 s1, 2 3E B6
.
s2, 0 s2,1 s2, 2 s2,3 11 95 01 13

s 3, 0 s3,1 s 3, 2 s3,3 80 1A FF 21

Find the value 1,2 of the output matrix of this Mix Column Transformation block.
1,2 = {01} {3} {02} {3} {03} {01} {01} {}

## 3 = 00111101, 3 = 00111110, 01 = 00000001, = 11111111

{01} {3} = 00111101
{02} {3} = 01111100
{03} {01} = 00000010 00000001 = 00000011
{01} {} = 1111111

## 1,2 = 00111101 01111100 00000011 11111111 = 10111101

, = =

6. [Marks: 15%] Suppose that a message has been encrypted using DES in ciphertext block
chaining mode. One bit of ciphertext in block is accidentally transformed from a 0 to a 1
during transmission. How much plaintext will be garbled as a result?

## In CBC mode the ciphertext and the plaintext are related by = (, ) .

Thus, if is accidentally transformed from 0 to 1, then the block will be garbled and
the corresponding bit of the + block would be inverted.

7. [Bonus: 20%] In your submitted answers file, include the work specified in Steps 2 and 3.
Step 1. Prepare the environment and get acquainted. Install OpenSSL in your own Linux/Solaris
system (may use a virtual machine OR visit http://slproweb.com/products/Win32OpenSSL.html
for widow installation). One way to install it is as follows: (a) Download openssl-xxx.gz.tar
from www.openssl.org (b) Type tar -xvf openssl-xxx.gz.tar | gunzip (c)
Move to directory openssl-xxx and type ./config (d) Within the same directory, type
make. For OpenSSL help type openssl -hx or visit www.openssl.org. Use the following
steps to get familiar with OpenSSL:

Step 1.1. Encrypt a file using AES. Type \$openssl enc -aes-256-cbc -in
testFile.txt -out testFile_enc.txt

Step 1.2. Decrypt an AES encrypted file. Type \$openssl enc -d -aes-256-cbc
-in testFile_enc.txt -out testFile_dec.txt

Step 1.3. Encrypt a file using AES and prepare it for email exchange. Type openssl
enc -aes-256-cbc -a -in testFile.txt -out
textFile_encEmail.txt

Step 2. Compare binary vs. Base64 encoding. Observe the type of files obtained in Steps 1.1 and
1.3. In less than 200 words, explain Base64 and why this is a convenient encoding in some cases.

## Base64 is generally convenient for printability and portability.

Step 3. Measure time performance of different modes of operation for AES and DES. Perform
two encryptions of the same large file using the same key but different modes of operation,
namely: electronic codebook and cipher block chaining. Compare the required time for encryption
in both cases. Provide a 50-word rationale for the outcome. Do the same for DES comparing
output feedback mode, cipher block chaining, cipher feedback, and electronic codebook.

## If you use sufficiently large plaintext file to see significant differences in

performance. One way of timing applications in Linux is using the time command.
Any other precise way of time measurement is acceptable. Unacceptable methods
include using an external stopwatch, providing seconds as the minimum time unit,
doing manual second counting, etc. ECB mode is generally faster than any other
mode. Furthermore CBC performs faster than OFB and CFB.