/OneTimePad

A client-server architecture for one-time pad encryption and decryption.

Primary LanguageC

One-Time Pad

This collection of C programs implements a client-server architecture for encrypting and decrypting ASCII text using a one-time pad encryption scheme. For information on one-time pad encryption, please see the one-time pad Wikipedia entry.

The primary purpose of this project is to demonstrate interprocess communication on *nix systems as well as to create server programs that handle client requests using child processes.

Compilation

These programs are intended for use on Unix-based systems. To compile all programs, type compileall. This will run a Bash script that produces the following executables:

  • otp_enc - The one-time pad encryption client. This passes a plaintext message to an encryption server.
  • otp_enc_d - The one-time pad encryption server. This performs the encryption on behalf of the client.
  • otp_dec - The one-time pad decryption client. This passes a ciphertext message to a decryption server.
  • otp_dec_d - The one-time pad decryption server. This performs the decryption on behalf of the client.
  • keygen - Generates a key to be used in encryption and decryption.

If permission is denied for the Bash script, use chmod +x compileall to give the script executable permissions.

Usage

otp_enc

otp_enc <plaintext> <keytext> <port>

  • plaintext is a regular file containing text to be encrypted by otp_enc_d.
  • keytext is a regular file containing keytext generated by keygen. keytext must be at least as long as plaintext.
  • port is the port number of the otp_enc_d server.

otp_enc_d

otp_enc_d <port>

  • port is the listening port for otp_enc_d.

otp_dec

otp_dec <ciphertext> <keytext> <port>

  • ciphertext is a regular file containing text to be decrypted by otp_dec_d.
  • keytext is a regular file containing keytext generated by keygen. keytext must be at least as long as plaintext.
  • port is the port number of the otp_dec_d server.

otp_dec_d

otp_dec_d <port>

  • port is the listening port for otp_dec_d.

keygen

keygen <len>

  • len is the length of the key to be generated.

Usage

  1. Use keygen to generate keytext at least as long (in bytes) as the plaintext to be encrypted.
  2. Run otp_enc_d on an unreserved port not currently in use.
    • It may be helpful to run this and otp_dec_d as background processes with & as a suffix.
  3. Run otp_dec_d on an unreserved port not currently in use.
  4. Encrypt the plaintext using the generated keytext by running otp_enc, and redirecting stdout to a file of your choosing.
  5. Decrypt the plaintext by running otp_dec on the file created in the above step and the generated keytext.
  6. To exit the server programs, use kill -kill <process_id> to send SIGKILL signals to the process_id of each server.

Notes

  • By default, output from otp_enc and otp_dec are directed to stdout.
  • Capital letters and space are the only plaintext characters currently supported.

© Maxwell Goldberg 2017