Lab 4 Introduction

In this lab, we implement RSA encryption on the BF561. Labs using the software generated in this lab could be coupled with communication software to build a complete encrypted communication device.

As a review of encryption, ou may wish to read the following Wikipedia articles

Following the RSA example in the Wikipedia article, assume the following values: p = 61, q = 53, r = 17, s = 2753, n = p X q = 3233. Transforming a character, x, into an encrypted character c may be done using equation (1). Similarly, transforming a character, x, into an decrypted character d may be done using equation (2).

encrypt(x) = xr mod n = c (1)

decrypt(x) = xs mod n = d (2)

To implement such equations in C, you may need to some of write the following:

  1. code to determine the number of bits required to represent a decimal number
  2. code to determine the ``bit state'' of the ith bit in a binary representation (i.e., 0 or 1)
  3. the Square-and-Multiply algorithm
  4. a binary exponentiaion algorithm or modular exponentiation algorithm

Encryption Mode

Use the fopen() function from stdio.h to read the file 0ws3410.txt For each line in the text file, encrypt each character using the keys above. For preliminary testing, print the encrypted character to the Visual DSP++ console using printf(). Then rewrite the code to use a #define macro as in Labs #2 and #3 to either print the encryped text to the console or to an RS232 communication device using UART_putc and/or UART_puts.

Decryption Mode

Use the UART getc and/or UART gets functions from UART Library.h to read in an ecrypted line of text. Write the code such that the program will always print it to the console (using printf() 9- but will only decrypt the line if a push button has been pressed. Also, if another button is pressed, the program will forgo decryption and will print the encrypted line - draw a FSM diagram representing this functionality.

For more information contact Michael Benjamin or David Kaeli
Last Modified: 08/22/17