Skip to content

ashtonmendes/DES

Repository files navigation

<title>Homework #5 - CSCI 531, Spring 2015</title> <style type="text/css"></style>

The purpose of this assignment is to get familiar with DES by implementing DES from scratch with the flexibility of changing some of the internal tables.

  Compiling
    make hw5
an executable named hw5 is created.   Commandline Syntax & Program Output The commandline syntax for hw5 is as follows:
    hw5 tablecheck -t=tablefile
    hw5 encrypt -k=key -t=tablefile [file]
    hw5 decrypt -k=key -t=tablefile [file]
    hw5 encrypt3 -k=key3 -t=tablefile [file]
    hw5 decrypt3 -k=key3 -t=tablefile [file]

Square bracketed items are optional. Follows the UNIX convention that commandline options can come in any order. (Note: a commandline option is a commandline argument that begins with a - character in a commandline syntax specification.) If an input file is not specified, the program reads from stdin. Output of the program goes to stdout and error messages go to stderr.

The meaning of the commands are:

tablecheck   :   Check the integrity of tablefile. Please see tablefile format to see the requirements.
 
encrypt   :   Encrypts the input using DES driven by tablefile in the ECB mode using key as the encryption key (8-byte long and in hexstring format). If the filesize of the input is not a multiple of 8 bytes, pads it with zeroes. (Please treat file as a binary file.)
 
decrypt   :   Decrypts the input using DES driven by tablefile in the ECB mode using key as the encryption key (8-byte long and in hexstring format). If the filesize of the input is not a multiple of 8 bytes, pads it with zeroes. (Please treat file as a binary file.)
 
encrypt3   :   Encrypts the input using EDE triple DES driven by tablefile in the ECB mode using key3 as the encryption key (24-byte long and in hexstring format). If the filesize of the input is not a multiple of 8 bytes, pads it with zeroes. (Please treat file as a binary file.)
 
decrypt3   :   [BC: updated 3/24/2015] Decrypts the input (assuming it was created using the "encrypt3" command) driven by tablefile in the ECB mode using key3 as the encryption key (24-byte long and in hexstring format). If the filesize of the input is not a multiple of 8 bytes, pads it with zeroes. (Please treat file as a binary file.)

The output for various commands are as follows.

 
tablecheck   :   The command produces no output in stdout. All error output goes to stderr.
 
encrypt   :   The output of this command is a binary file where each 8-byte block is a direct DES encryption of the corresponding input 8-byte block.

To stderr, the values of the subkeys, the Li and Ri values are output as follows:

    (C0,D0)=...
    (C1,D1)=...
    k1=...
    (C2,D2)=...
    k2=...
    ...
    (C16,D16)=...
    k16=...
    (L0,R0)=...
    (L1,R1)=...
    ...
    (L16,R16)=...
The values of the C's, D's, L's, R's, and subkeys are printed in hexstring format. The L's and R's values during encryption of the first 8-byte block are output.
 
decrypt   :   The output of this command is a binary file where each 8-byte block is a direct DES decryption of the corresponding input 8-byte block. If the original (binary) plaintext filesize is not a multiple of 8 bytes, the output of the decrypt command will not be the same as the plaintext file.

To stderr, the values of the subkeys, the Li and Ri values are output as follows:

    (C0,D0)=...
    (C1,D1)=...
    k1=...
    (C2,D2)=...
    k2=...
    ...
    (C16,D16)=...
    k16=...
    (L0,R0)=...
    (L1,R1)=...
    ...
    (L16,R16)=...
The values of the C's, D's, L's, R's, and subkeys are printed in hexstring format. The L's and R's values during decryption of the first 8-byte block are output.
 
encrypt3   :   The output of this command is a binary file where each 8-byte block is a direct 3DES encryption of the corresponding input 8-byte block.
 
decrypt3   :   The output of this command is a binary file where each 8-byte block is a direct 3DES decryption of the corresponding input 8-byte block. If the original (binary) plaintext filesize is not a multiple of 8 bytes, the output of the decrypt command will not be the same as the plaintext file.

A tablefile is an ASCII file containing exactly 14 lines. Each line has the format of key=value where key can be one of the following (must be in uppercase): IP, E, P, S#, V, PC1, and PC2, where # is a number between 1 and 8, inclusive. To the right of the equal sign, value contains a list of integer values that are separated by commas. There should contain no white spaces (such as space or tab characters). Each line corresponds to a DES internal table with the same name. The following are requirements for each of the tables (and corresponding input lines).

IP   :   This table contains a random permutation of the values from 1 through 64, inclusive. (You need to compute the inverse transform in your code.)
 
E   :   This table contains 48 values. The allowed values are between 1 through 32, inclusive. All 32 numbers must appear in this table at least once and at most twice.
 
P   :   This table contains a random permutation of the values from 1 through 32, inclusive.
 
S#   :   This table contains 64 values, in a group of 16. Each group is a random permutation of the values from 0 through 15, inclusive.
 
V   :   This table contains 16 values. Each value can be either 1 or 2. There should be 4 ones and 12 twos.
 
PC1   :   This table contains 56 values. These values are a random permutation of the numbers from 1 through 64, inclusive, with the values which are multiples of 8 removed.
 
PC2   :   This table contains 48 values. These values are a random permutation of the numbers from 1 through 56, inclusive, with 8 randomly chosen numbers removed.

About

Implementation of the DES encryption standard in C

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors