Fix the functions in the file modes.c so that the outputis the desired output: plaintext: motherciph

Relax! Stop worrying about deadlines and let our professional writers help you. Hire an essay writer helper and receive a professional assignment before your deadline. We provide writing services for all types of academic assignments.


Order a Similar Paper Order a Different Paper

Fix the functions in the file modes.c so that the outputis the desired output: plaintext: motherciphertext: 0x2D2422090905plaintext: soldierciphertext: 0xF9CDAC548B5FEEplaintext: riskciphertext: 0x24FD940Fplaintext: endlessciphertext: 0xEDA9D7110425BAplaintext: hairciphertext: 0x3EDB6F38 #include

#include

#include

#include “hex.h”

#include /*The block cipher*/

char cipher(unsigned char block, char key)

{ //this is an affine cipher where “a” is fixed at 11 andb=key

return (key+11*block)%256;

} /*The inverse of the block cipher*/

char inv_cipher(unsigned char block, char key)

{ // 163 is the inverse of 11 mod 256

return (163*(block-key+256))%256;

} void ofb(char* pt, char key, char iv, int len)

{

/*fix me*/

} void ecb(char* pt, char key, char iv, int len)

{

/*fix me*/

} void ecb_dec(char* ct, char key, char iv, int len)

{

/*fix me*/

} void cfb(char* pt, char key, char iv, int len)

{

/*fix me*/

} void cfb_dec(char* ct, char key, char iv, int len)

{

/*fix me*/

} void cbc(char* pt, char key, char iv, int len)

{

/*fix me*/

} void cbc_dec(char* ct, char key, char iv, int len)

{

/*fix me*/

} void ctr(char* pt, char key, char iv, int len)

{

iv &= 0xF8; //use only left 5 bits

int i =0, ctr=0;

for(i=0; i

{

ctr &= 0x7; //use only right 3 bits

pt[i] ^= cipher((unsigned char) (iv | ctr), key);

ctr++;

}

} void print_ct(char* ct,int len)

{

printf(“ciphertext: 0x%sn”,bin2hex(ct,len));

} /*Desired output: plaintext: mother

ciphertext: 0x2D2422090905

plaintext: soldier

ciphertext: 0xF9CDAC548B5FEE

plaintext: risk

ciphertext: 0x24FD940F

plaintext: endless

ciphertext: 0xEDA9D7110425BA

plaintext: hair

ciphertext: 0x3EDB6F38 */ int main()

{

char key = 8;

char iv = 0xaa;

int len;

int a = 1;

char ct[1000] = {0};

char pt[12][100] = {“wife”, “mother”, “soldier”, “risk”, “endless”,”hair”, “vote”, “outside”, “plate”, “estate”, “slow”,”baby”};

char ct_ark[12][100] ={{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}}; len = strlen(pt[a]);

strncpy(ct,pt[a],len);

printf(“plaintext: %sn”,pt[a]);

ctr(ct,key,iv,len);

print_ct(ct,len);

strncpy(ct_ark[a],ct,len);

ctr(ct,key,iv,len);

assert((strncmp(ct,pt[a],len)==0)); a++;

len = strlen(pt[a]);

strncpy(ct,pt[a],len);

printf(“plaintext: %sn”,pt[a]);

ecb(ct,key,iv,len);

print_ct(ct,len);

strncpy(ct_ark[a],ct,len);

ecb_dec(ct,key,iv,len);

assert((strncmp(ct,pt[a],len)==0)); a++;

len = strlen(pt[a]);

strncpy(ct,pt[a],len);

printf(“plaintext: %sn”,pt[a]);

cfb(ct,key,iv,len);

print_ct(ct,len);

strncpy(ct_ark[a],ct,len);

cfb_dec(ct,key,iv,len);

assert((strncmp(ct,pt[a],len)==0)); a++;

len = strlen(pt[a]);

strncpy(ct,pt[a],len);

printf(“plaintext: %sn”,pt[a]);

cbc(ct,key,iv,len);

print_ct(ct,len);

strncpy(ct_ark[a],ct,len);

cbc_dec(ct,key,iv,len);

assert((strncmp(ct,pt[a],len)==0)); a++;

len = strlen(pt[a]);

strncpy(ct,pt[a],len);

printf(“plaintext: %sn”,pt[a]);

ofb(ct,key,iv,len);

print_ct(ct,len);

strncpy(ct_ark[a],ct,len);

ofb(ct,key,iv,len);

assert((strncmp(ct,pt[a],len)==0));

} . . .

Great students hand in great papers. Order our essay service if you want to meet all the deadlines on time and get top grades. Professional custom writing is the choice of goal-focused students. Word on the online streets is... we're simply the best!

Get a 15% discount on your order using the following coupon code SAVE15


Order a Similar Paper Order a Different Paper