Assignment 8: Secret Decoder Ring -- 04/15/2020

COSC 2200, Spring 2020

Marquette University, Department of Computer Science

Due: Friday, April 24th at 11:59pm CDT

Submit: Turn in your source file using the turnin command on a Systems Lab machine. Please name your file "main.c". Failure to follow this simple convention will cause TA-Bot to fail.
Remember, the turnin command (to submit your file) will look like this:

turnin -c cosc2200 main.c

Work may be completed in teams of two. The names of both partners must appear in a comment block at the top of your file for credit to be given. I strongly recommend that you take the time to meet with your partner in person and work together on these projects, rather than work separately and try to integrate at the last minute. Use the command hook "TA-BOT:MAILTO" in a comment in your source files to designate mail addresses for TA-Bot output.

This UNIX tutorial may be of some assistance.

Preparation

I have provided a reference implementation on Morbius under ~pmcgee6/cosc2200/bin/cipher-example.  Execute arm-console in this directory to run the reference implementation on a backend machine.

The Symmetric Key Block Cipher

Write a C program for the ARM Playground (still running on the Pi 3's) that enciphers input text by XORing the lower four bits of alphabetic characters with a variable length, hexadecimal key value.  By running the cipher program a second time with the same key, inputting the cipher text should reproduce the original message.

Notes:

This encryption scheme is technically a simple form of symmetric key block cipher.  It would be a much stronger encryption algorithm if the key value were chosen through a pseudorandom process, and if the key was as long as the message text, making it a one-time pad.  This is probably good enough to send messages by cereal box, however.  As a design note, this algorithm depends on an underlying character representation in ASCII, or at least the ASCII subset of UTF8/Unicode.  That means that this C code may not port over to a system that used a different character encoding scheme.

Example Run

In the examples below, I use text in blue to distinguish the output of the program from the input I typed. This is for purpose of clarity only; your program will not print text in different colors.

Cipher Generator
Enter Key Value:
01234
01234
Message:
TIG
QTK@O
BSMTJ
FNZ
JTOSAD MUAR
TIG HA[[
YDNOKW
DNE!
THE
QUICK
BROWN
FOX
JUMPED OVER
THE LAZY
YELLOW
DOG!

Note: Ctrl+D is the final input in the example.