What is DES?
The Data Encryption Standard, short DES, is a symmetric-key algorithm for en- and decryption of data. It was developed in the 1970’s and established as a standard for the United States by the National Bureau of Standards (NBS, now NIST). DES has been superseded by (AES).
DES is a block cypher, taking a fixed-length block of data (64 bits). The key used for processing consists of 64 bits, where only 56 are actually used for transformations and 8 bits are used for parity checks.
DES performs an initial permitation of the data, 16 rounds of transformation, and a final permitation, the inverse of the initial permutation. In the transformations the data block is initially splitted in two 32 bit blocks where the first block is transformated with the round key using a Feistel cipher and XOR-linked with the second block. The first block and the resulting block are used for the next round.
emLib DES uses a key of 64 bits to encrypt a block of 68 bits of data at a time. To optimize the performance of the algorithms the generation of the round keys can be done before the actual encryption or decryption and used more than one time. DES can also be used in cipher block chaining (CBC) mode to process more than 64 bits.
In CBC mode every chunk of 64 bits is XOR linked with the result of the previous encryption (the cipher text), before being encrypted. To decrypt one block, all previous blocks have to be known.
For the encryption of the first block an initialization vector which will be linked with the block, can be used to make sure the first block cannot be brute-force decrypted by comparing it to common first data blocks.
Using emLib DES
The emLib DES module has a simple yet powerful API. It can be easily integrated into an existing application. The code is completely written in ANSI-C.
All functionality can be verified with standard test patterns using the Validation API functions. The functions for generating the tables used for higher optimization levels are also included for full transparency. To simply encrypt or decrypt data the application would only need to call one function.
If more than one block needs to be processed with the same key, a context containing the round keys calculated from the key can be prepared and directly used by the encryption and decryption functions. For more than one call of these functions this method results in a slightly higher processing speed.
DES API Functions
The table below lists the available DES API functions.
|DES_CBC_Encrypt()||Encrypts data with DES using CBC.|
|DES_CBC_Decrypt()||Decrypts data with DES using CBC.|
|DES_Decrypt()||Decrypts 8 Bytes with DES.|
|DES_Encrypt()||Encrypts 8 Bytes with DES.|
|DES_Prepare()||Prepares the context for de-/encryption.|
|DES_Validate()||Test function for validation of DES.|
Detailed descriptions of all functions can be found in the emLib user manual.
DES en-/decryption of 16 Bytes using CBC
emLib includes some sample applications to show the modules functionality and provide an easy to use starting point for your application. The application’s source code is included within the module. The following applications are included in emLib DES:
|Application name||Target platform||Description|
|DESSpeedtest.exe||Windows||Console application testing the speed of emLib DES.|
|DESValidate.exe||Windows||Console application validating emLib DES with standard test patterns.|