This project introduces students to mixed-language programming, specifically integrating C and assembly code, data encryption, and dynamic libraries.
Your task is to write a program that would encrypt and decrypt data files. The choice of which cipher to use is left up to you. At the least, you should do a simple XOR cipher. (XOR data with a key to encrypt, then XOR it again with the same key to decrypt.) Alternatively, you may want to implement a more secure algorithm, such as DES, Blowfish, or even RSA.
Your program should take four arguments: a switch specifying whether to encrypt or to decrypt the file (-e or -d, respectively), the cipher to use (see below), the source file name and the destination file name. It should then prompt user for a key, e.g. a secret password. After reading the data from the source file and encrypting it with a key, your program should write the encrypted data to the destination file.
For example:
$ ./crypt -e xor secrets.txt secrets.enc Enter the key: $ ./crypt -d xor secrets.enc secrets.txt Enter the key:
int encrypt(unsigned char *key, unsigned char *data, int size); int decrypt(unsigned char *key, unsigned char *data, int size);
That is, both functions should take a pointer to the secret key, a pointer to the data being encrypted or decrypted, and the size of the data in bytes. The return value should be the number of bytes processed, or a negative value on error. That is, upon success the return value will be equal to the size argument.
Please submit your source code, Makefile, object file, and executable to your submit directory for this class. (located under /home/submit/cs210.) In addition please submit a printout of your source code to the instructor.