Question: how to implement a triple DES code in CBC mode... fill in the code at the bottom where it asks #include des56.h #include #include #include
how to implement a triple DES code in CBC mode... fill in the code at the bottom where it asks
#include "des56.h" #include #include #include
//Use these constants to specify ENCRYPT or DECRYPT in the fencrypt function call. (The middle parameter) #define ENCRYPT 0 #define DECRYPT 1
/*This function takes the XOR of block A and block B and stores the result in block "result"*/ /*Note that it is possible that "result" is the same as "A" (or "B").*/ /*For example: XORblock(block1,IV,block1); Would XOR the first block with the IV and put the result in block1*/ void XORblock(char A[8],char B[8],char result[8]) { int i = 0; for(;i<8;i++) result[i] = A[i]^B[i]; }
/*This function takes a block as input and prints the corresponding hex to the terminal*/ void printhex(unsigned char block[8]) { int i=0; for(;i<8;i++) printf(" 0x%x ",block[i]); puts(""); }
void cbc_enc_three_blocks(char block1[8],char block2[8], char block3[8], char IV[8],keysched *ks)
{ // You write this code }
void cbc_dec_three_blocks(char block1[8],char block2[8], char block3[8], char IV[8],keysched *ks)
{ // You write this code }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
