Due Date: Th September 13, 2012.
This assignment demonstrates the use of the <\b>gcrypt library functions to implement a cryptographic protocol. In particular, you are to build public key pairs to encrypt and authenticate messages that can be decrypted and verified.
Follow these instructions:
Obtain the tarfile from here.
Unpack the tarfile in some appropriate directory on a UNIX system (there are many available at CSE -- see Notes below). You will need to get the gcrypt library (and its dependencies) if the machine does not have it installed already.
Your task is to implement two functions and fill in missing information for three other functions.
Functions to implement below.
VerifyMessagePK verifies a signature given a plainfile (specifically, decryption of encrypted plaintext), public key of sender, and signature file. The main task is to produce the same message as was signed in SignMessagePK (if the content is indeed the same). Then, specify the appropriate call to gcry_pk_verify to check signature.
AppendNonce must attach a nonce to a datafile to produce the plaintext to be encrypted. A nonce is "an arbtrary number used only once in a cryptographical communication." That is, you must choose a method of produce a quantity whose value is likely to be different with a high probability on each encryption.
The functions to modify are:
GenerateKeyPair uses gcrypt library functions to generate a key pair (public and corresponding private key). This function takes two inputs: the names of the files to store the public and private keys. Your task is to specify the s-expressions necessary to construct DSA and RSA keypairs and specify arguments for gcry_pk_genkey.
EncryptMessagePK uses the gcrypt library functions to encrypt a message (file with this message is supplied as input). Your task is to specify the arguments for gcry_pk_encrypt.
SignMessagePK uses the gcrypt library functions to produce a message signature. Your task is to specify the arguments for gcry_md_hash_buffer and gcry_pk_sign and the s-expression for the data to sign.
DecryptMessagePK uses the gcrypt library functions to decrypt messages. Your task is to specify the arguments for gcry_pk_decrypt.
You have some leeway about what format to use for the signature. I stored the S-expressions directly, but you can extract the data. My only requirement is that I can produce and verify (correctly) a valid signature of a SHA-1 hash of the plaintext.
I aim to test your code by running the following commands with my own input data (no more than 100 bytes). This emulates a sender generating an encrypted, signed message that is then decrypted and verified by a receiver. I will try the same message a few times using option 6 (AppendNonce) to verify unique plaintext each message.
./cse543-p1 1 rsa_private_decryption_key rsa_public_encryption_key 1
./cse543-p1 1 rsa_private_signing_key rsa_public_verifying_key 1
./cse543-p1 6 input-file nonce-file plaintext-file
./cse543-p1 2 plaintext-file rsa_public_encryption_key encrypted-file
./cse543-p1 3 plaintext-file rsa_private_signing_key signature-file
./cse543-p1 4 encrypted-file rsa_private_decryption_key decrypted-file
./cse543-p1 5 signature-file rsa_public_verifying_key decrypted-file
When you have completed the code, test it by encrypting some files and decrypting the contents. I will provide a drop box for submitting this project. The project is due on September 13 at 11:59pm. Please attach a tar file containing all the source, including your additions. You can build this tar file using the command make tar from the source directory.
You are to complete this on your own. Any sharing of code or help during the coding of this project is expressly forbidden. Do not discuss this project with anyone.
A Makefile has been created to help you build the applications. To build, simply type "make" in the target directories.
gcrypt library -- As part of this assignment, you will be required learn and use the GNU cryptography library. Details of this library are presented in the manual. Do not contact the professor (or anyone else) for information about this library -- learning how to use it is part of the exercise.
Specify the cryptographic operations implemented by this code using proper cryptograhic notation (slide 30 of applied cryptography lecture).
Why is the nonce necessary to the security of this protocol?
What is an important advantage of using separate keys for encrytion and signing?
What is an important disadvantage of using separate keys for encryption and signing?
In a real application of this protocol, does the same subject have access to both the RSA decryption and signing private keys? Explain.