CS320 Assignment 5

Date assigned: 4/14/04
Date Due: 4/26/04
Points: 40

Encrypting is a technique used to render the contents of messages and documents illegible to unintended readers. The basic notion of encrypting is to apply an invertible transformation to text, rendering it into encrypted form called a cryptogram for storage or transmission, and later to apply the inverse transformation to the cryptogram to recover the original text, called plaintext, for subsequent use.

Since encryption and decryption can involve large amounts of data it is important that we have a solution that executes as fast and as efficiently as possible. Therefore, we will choose to write the encryption and decryption routines in x86 assembly language.

Encryption Algorithm

Encryption methods have historically been divided into two categories: substitution ciphers and transposition ciphers. This encryption algorithm deals with a substitution cipher revolving around a code key which the user must know.

With a substitution cipher, each letter or group of letters is replaced by another letter, group of letters, or numbers to disguise it. Consider the following text to be encoded and a code key of: TRIGRAMS

codekey:    TRIGRAMSTRIGRAMSTRI
plaintext:  ENCODE THIS MESSAGE
If we take the ASCII values of the code key in each of the positions and add (unsigned) the plain text ASCII values in each corresponding position we would have the following:

codekey:     84  82  73  71  82  65...
plaintext: + 69  78  67  79  68  69...
ciphertext: 153 160 140 150 150 134
Notice that E encoded the first time is 153 and E encoded the second time is 134. This is important because we do not want the intruder to see patterns of characters to help them break the code. To get the message decoded, simply reverse the process as follows:

ciphertext:  153 160 140 150 150 134
codekey:   -  84  82  73  71  82  65
plaintext:    69  78  67  79  68  69
Application programs can use interrupt locations F1 to FF. I would like you to implement an encryption interrupt that can be used by calling the sofware interrupt F1. This interrupt routine will ask the user for the name of a file and the codekey. An encoded file with a .enc is to be saved. Interrupt F2 is to implement a decode interrupt that takes a .enc file and produces a .dec file.

Note1: Be careful. You are working in a troublesome environment!!

Note2: Do not use any IRVINE library routines in your solution. Only use built-in system interrupt calls.

Note3: There is a read and copy a text file example on pp. 483-484.