COMP2421 Computer Organization Programming Assignment 2
Due Date and Time: Nov 12, 2019 at 11am
Implementing the Round Function in Data Encryption Standard Objectives
The objective of this assignment is to allow students to have advanced practice on MIPS assembly language. After completing the assignment, student should be able to know:
how to convert values among a number of data types;
how to manipulate data in both the registers and the main memory;
how to perform bitwise operations;
how to develop a modular program with a number of sub-routines that facilitate code
reuse;
What you have to do
In Data Encryption Standard (DES), there is a round function, F. The following illustrates the structure of F:
F takes a 32-bit string, R, and a 48-bit subkey, K. It performs the following operations:
1) Expands R to 48 bits by using an expansion function, E;
2) The output from 1) is XORed with K;
3) The output from 2) passes through 8 S-boxes to get a 32-bit result;
4) The output from 3) is finally permuted using a 32-bit permutation function, P.
1
Write a program that allows the user to input R and K in hexadecimal format. Then, the program prints out all outputs of the 4 steps above. For example:
Enter a 32-bit binary string: 3CFF03D8 Enter a 48-bit subkey: A01252102307
After E: 000111111001011111111110100000000111111011110000
After XOR: 101111111000010110101100100100000101110111110111
After S-Boxes: 01111001011101110001010011110000
After P: 1010011001011001110101100000111
The inputs are highlighted in blue.
(Note: 3CFF03D8 = 111100111111110000001111011000 and
A01252102307 = 101000000001001001010010000100000010001100000111) Here are the details of the functions:
The Expansion Function E
A 32-bit string is expanded based on the following fixed table:
The first bit of the output (upper left-hand corner of the table) is the 32nd bit of the input (B32). The second bit of the output is the 1st bit of the input (B1) and so on. Note that the table is read from left to right and top to bottom. Also note that some bits from the input are duplicated at the output.
2
The Eight S-boxes
Each S-box replaces a 6-bit input with a 4-bit output. The output from 2) is divided into eight 6-bit strings. Each of them is passed to 8 fixed S-boxes, S1, S2, S3, S4, S5, S6, S7, and S8 respectively. Given a 6-bit input, the 4-bit output is found by selecting the row using the outer two bits, and the column using the inner four bits. For example, below show the table of S1:
If the input is 101111, the outer two bits are 11 (3 in base 10) and the inner four bits are 0111 (7 in base 10). So, row 3 and column 7 of S1 is chosen. It is 7 and so the 4 bits are 0111. Please refer to the following link for the 8 tables:
https://commons.wikimedia.org/wiki/File:DES_S-box.jpg
The Permutation Function P
A 32-bit string is permuted based on the following fixed table:
The idea is the same of the expansion function E, but no bits are to be duplicated.
You program should implement at least THREE subroutines for the above functions. You may
also implement other subroutines, based on your design of the program.
You may assume the users input is always correct. No input validation is needed.
3
What to Submit
1) Your program code. Store the code in a file and name it as, p2_XXXXXXXX.s, where p2 means Programming Assignment 2 and XXXXXXXX is your 8-dight student number (the last letter is not needed). In addition, .s is the file extension.
2) Upload the file to Blackboard. No other form of submission will be accepted. Assessment Criteria
Correctness (Total 70 marks)
1) Program can be successfully loaded (10 marks)
2) Correct outputs for the 4 steps (60 marks)
Modularity, Readability and Neatness (Total 30 marks)
1) Modularity by using sub-routines (10 marks)
2) Description of logic using comments (10 marks)
3) Code formatting and style (10 marks)
Due Date
1) Nov 12, 2019 at 11am.
2) Late submission penalty will apply at 15% per day
In other words, after six days, the system will be closed.
3) In order to avoid rush and/or system crash and/or network overloaded, try to submit
your assignment as early as possible. Try not to submit it at the last minute.
4
Reviews
There are no reviews yet.