Question: This is on symmetric ciphers, block ciphers with different modes of operations, and stream ciphers built upon block ciphers. Given the DES source code https://tls.mbed.org/des-source-code

This is on symmetric ciphers, block ciphers with different modes of operations, and stream ciphers built upon block ciphers. Given the DES source code https://tls.mbed.org/des-source-code

Enhance and modify the code to a 4- round DES: DES4r for file operations. Then use your DES4r to encrypt / decrypt a given text file / cipher file in three modes: ECB, CBC, and OFB. With OFB mode, you actually turn the block cipher DES4r into a stream cipher.

The given file needs a padding scheme to make its length as a multiple of 64-bit (8-byte) for encryption. A simple padding method is to append a single 1 bit to the plaintext and then to append as many 0 bits as necessary to reah a multipe of the block length. Should the plaintext be an exact multiple of the block length, an extra block consisting only of padding bits is appended. Of course after decryption of a given ciphertext file, the padded bits should be removed before generating the plaintext.

The plaintext, in a text file plain.txt, contains the first paragraph of a New York Times article Hidden Kingdoms of the Ancient Maya Revealed in a 3-D Laser Map by Nicholas St. Fleur on Sept. 27, 2018. It has 526 characters (including spaces and punctuations). The plain.txt is as follows:

Using technology known as lidar, a team of archaeologists found evidence beneath the jungle canopy in Guatemala of how the Mesoamerican civilization altered its landscape. Hidden pyramids and massive fortresses in the jungle. Farms and canals scattered across swamplands. Highways traversing thickets of rain forest. These are among more than 61,000 ancient Mayan structures swallowed by overgrowth in the tropical lowlands of Guatemala that archaeologists have finally uncovered using a laser mapping technology called lidar.

DES4r key: 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEFDES4r key schedule is same as DES key schedule. IV: 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF For programming part, youll need to mimic mbedtls_des_crypt_ecb( ), mbedtls_des_crypt_cbc( ) to create following three functions with files as their input and output:

/** * \brief DES4r-ECB file encryption/decryption * \param ctx DES context * \param inFile input file name * \param outFile output file name * eturn 0 if successful */

int des4r_crypt_ecb( mbedtls_des_context *ctx, char* inFile, char* outFile );

/** * \brief. DES4r-CBC file encryption/decryption

* \param cts DES context

* \param mode MBEDTLS_DES_ENCRYPT or MBEDTLS_DES_DECRYPT

* \param iv initalization vector(updated after used)

* \param infile input file name

* \param outFile output file name

* eturn 0 if possible

*/

int des4r_crypt_cbc( mbedtls_des_context *ctx, int mode, unsigned char iv[8],

char* inFile, char* outFile );

/** * \brief DES4r-OFB file encryption/decryption * \ params are the same as des4r_crypt_cbc( ), see above

*/ int des4r_crypt_ofb( mbedtls_des_context *ctx, int mode, unsigned char iv[8],

char* inFile, char* outFile );

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!