0% found this document useful (0 votes)
13 views5 pages

University of Wollongong Singapore Institute of Management: School of Computing and Information Technology (SCIT)

The document outlines Assignment 1 for CSCI361 at the University of Wollongong, focusing on classical ciphers and cryptanalysis. It includes six tasks requiring implementation of various ciphers, cryptanalysis, and programming in C, C++, or Java, with specific submission guidelines and penalties for late or plagiarized work. Students must submit their work via Moodle and provide detailed reports for each task, including code and analysis.

Uploaded by

jeremiahkanhs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views5 pages

University of Wollongong Singapore Institute of Management: School of Computing and Information Technology (SCIT)

The document outlines Assignment 1 for CSCI361 at the University of Wollongong, focusing on classical ciphers and cryptanalysis. It includes six tasks requiring implementation of various ciphers, cryptanalysis, and programming in C, C++, or Java, with specific submission guidelines and penalties for late or plagiarized work. Students must submit their work via Moodle and provide detailed reports for each task, including code and analysis.

Uploaded by

jeremiahkanhs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

University of Wollongong

Singapore Institute of Management


School of Computing and Information Technology (SCIT)
Lecturers: Professor Willy Susilo and Mr. Japit Sionggo

CSCI361 - Session 1 2020

Assignment 1 (15 marks)


Due: 9 February 2020, 9pm Singapore time. Submission via Moodle only.
Aim: To gain a basic familiarity with classical ciphers, including statistical methods for cryptanalysis
of them, and to understand block cipher.

Objectives
This assignment includes six tasks.

1. Apply cryptanalysis to two ciphertexts; generated using a monoalphabetic substitution cipher


and a polyalphabetic cipher (Vigènere cipher).

2. Code the Playfair cipher.

3. Implement algorithms related to modern block ciphers.

Standard Requirements for Assignments


• Submission must be made via Moodle. No other submission method will attract any marks.

• Submission via email will result in getting ZERO.

• Follow the directions given by the tutor (Mr. Sionggo).

• At the top of your code, you will need to specify the version of the programming language that
you use.

• Students are to give batch / make files for compilation.

1
• Students are to place all compilation and instructions on how to run the program inside a
README.TXT file. The markers will refer to this file when marking.

• Submission filenames are to be the same as the ones given in the assignment specifications, do
not use your own filenames.

• Plaigarised assignments will receive 0 marks immediately.

• DO NOT post this assignment to any forum, or else you will receive 0 marks immediately.

• Penalty for the late assignment is 25% per day.

1 Task One: Cryptanalysis (2 marks)


Obtain two ciphertext files from Mr. Japit Sionggo (don’t miss it!). These files are Ctext-1 and
Ctext-2).
They have been generated using a monoalphabetic cipher and a Vigènere cipher, respectively.
You need to:

• Apply cryptanalysis to each of Ctext-1 and Ctext-2. You can use the krypto program pro-
vided.

• Present a report describing what steps you took to break each cipher, and why. Justify choices
you have made.

• Include graphs (frequency distributions) as appropriate (in your Report1.pdf).

• Provide the plaintext and key for each cipher. You should include them as files Ptext-1.txt,
Key-1.txt, Ptext-2.txt and Key-2.txt, and also give them in your report (Report1.pdf).

• If you use any other tools or software, you must cite them in your report.

• If you only provide the final answer but without any proper analysis, then you will obtain 0.

2 Task Two: The Playfair cipher (3 marks)


Implement the Playfair cipher, in C, C++ or Java. The name of your program should be
Playfair.c or Playfair.cpp or Playfair.java. Include in your report instructions on how to
compile your code.
The command syntax should be as follows:

playfair -e key <plaintext.txt> <ciphertext.txt>


playfair -d key <ciphertext.txt> <plaintext.txt>

2
where the -e option is associated with encryption and the -d option is associated with decryption.
You may assume all input is lower case without punctuation. You should use the same convention
described in the lecture regarding the encryption of diagonally related plaintext pair elements.
Several things to note:

• Your program must be able to cope with special inputs, such as replacing ’i’ with ’j’ (or vice
versa) during the encryption/decryption

• When inserting additional characters during the encryption, you will need to remove them
during the decryption.

• To make your program more robust, you may add important information, such as the length
of the ciphertext. However, this should ensure that you will get the decryption process done
correctly.

• Be careful with the following sample input ‘zzzz’.

You also need to:

• First, generate a random keyfile keyfile.txt.

• Generate the ciphertext file Ctext-3.txt obtained by encrypting Ptext-1.txt under the key
in keyfile.txt.

• In your report, describe the statistical properties of Ctext-3 and discuss how they compare
with those of Ctext-1 and Ctext-2, remembering that Ctext-1 and Ctext-3 are associated
with the same plaintext. Include a comparative graph of the letter frequency distributions.
Write your report in a file called Report2.pdf.

• Discuss a way to decrypt the Playfair cipher without using the key. Show your argument by
decrypting the ciphertext Ctext-3 assuming that you don’t know the key. The discussion will
need to be written in the same file Report2.pdf.

• To test the correctness of your program, one can just simply test with

playfair -d keyfile.txt Ctext-3.txt Output.txt

where the keyfile.txt is in fact empty, and your program should do an automatic decryption
and verify whether the file Output.txt is identical with Ptext-1.txt by executing

diff Output.txt Ptext-1.txt

in Unix/Linux.

3
3 Task Three: Affine Cipher (3 marks)
Consider the Affine Cipher on the alphabet Z26 = {A, B, . . . , Z} with the usual identification A = 0,
B = 1, . . . , Z = 25, and the encryption function with key (a, b):
C = aM + b (mod 26).
1. Which of the following keys are valid? and why? (0.5 marks)
(i) (3, 8) (ii) (8, 3) (iii) (5, 0) (iv) (0, 5) (v) (13, 1)
2. For each of the above valid keys, determine the decryption function formula. (Please show all
your working steps. Without any working steps then you will get 0.) (0.5 marks)
3. Implement the cipher using C++ or Java.
The program should be able to do both encryption and decryption. Lowercase characters
a-z will be encrypted/decrypted to lowercase characters. Uppercase characters A-Z will be
encrypted/decrypted to uppercase characters. Other characters not in the range (a-z,A-Z) will
be unchanged.
The program should accept the following parameters: a flag to indicate encryption or decryp-
tion, a secret key, an input file name, and an output file name. For example:
myProgram -key 3 8 -encrypt -in file1.txt -out file2.txt
myProgram -key 3 8 -decrypt -in file2.txt -out file3.txt
The program should be able to detect invalid key and display an error message if it encounters
an invalid key. (1.5 marks)
4. Test your program (both encryption and decryption) with the keys in question 1 in this part.
(0.5 marks)

4 Task Four: S Box Implementation (2 marks)


Implement the S1 box from DES algorithm in Java or C++. Your program should accept one
parameter, namely the input of S1 box in decimal. Then, your program must display:
• The converted input in binary;
• The output of S-box 1 in binary; and
• The output of S-box 1 in decimal.
See the example below:
$ S-box1 46
The input of S-box1 in binary: 1 0 1 1 1 0
The output of S-box1 in binary: 1 0 1 1
The output of S-box1 in decimal: 11
In the above example, 46 is the input to the S-box 1.

4
5 Task Five: Is this an English text? (2 marks)
In this task, you are to write a program in C++/Java which accepts an input of a text file. Then
your program will need to determine whether the contents of that text file is written in English or
not. Essentially, what you will need to do is to determine the value of the Index of Coincidence.
However, you will need to remember that any monoalphabetic ciphertext will also carry the same
IC. A sample run of the program is as follows:

$ IsEnglish test.txt
This is not an English text.
The IC = 0.043

$ IsEnglish test2.txt
This is an English text.
The IC = 0.070

6 Task Six: 6-bit OFB (3 marks)


This task comprises three parts. Part one. This task is to implement a 6-bit OFB TEA algorithm.
See the code for TEA in the lecture notes. Part two. Encrypt your student number using 6-bit OFB
TEA algorithm as devised above. Part three. Add all the digits of your student number mod 8. Let
the result be c. Then implement c-bit OFB TEA algorithm, and encrypt your student number using
this algorithm. Compare the time needed to encrypt using 6-bit OFB TEA algorithm and c-bit OFB
TEA algorithm, and write your result in Task6Report.PDF. Explain what has happened.
Remark: If the result of the modulo operation is 6, that is c = 6, then you need to implement 7-bit
OFB TEA instead.

Submission
You need to submit one ZIP file and upload it to Moodle. In this ZIP file, you need to create six
subdirectories, in which each subdirectory will have the answer to each task. For each programming
task, write a README file that explains the compiler setting. Ideally, you should make a Makefile
for each of the tasks.

DISCLAIMER: This assignment contains an intellectual property that is owned by the University
of Wollongong. Please do not use it without the permission from the University of Wollongong. If
you have any questions, please contact the author on [email protected].
DISCLAIMER: By submitting your assignment, you DECLARE that the assignment is your
own work and you did not obtain it from any third party or even purchase it from someone else or
ask someone else to do it for you. If you violate this rule, then you may end up failing the subject
entirely.

You might also like