Question
In C language: Implement function confidentiality_xor that gets a 32-bit encryption key (key) as argument, the encrypted data (data) along with its length (len) as
In C language:
Implement function confidentiality_xor that gets a 32-bit encryption key (key) as argument, the encrypted data (data) along with its length (len) as arguments. The length is indicated as the number of 32-bit blocks the data contains. The function should implement a simple encryption: each 32-bit data buffer will be encrypted using the XOR-bitwise operation using the encryption key. The function does not need to allocate memory, i.e., it operates on the data buffer directly. Note: the data should be handled as 32-bit unsigned integers (uint32_t data type in stdint.h header). More information in Wikipedia.
Implement also function confidentiality_xor_shift that, in addition to encrypting the data, will modify the encryption key after each 32-bit block. The function works otherwise similarly as the above one, but after each operation it shifts the bits in the key one step left. At each shift, the most significant (leftmost) bit it transferred to the other end, i.e. to represent the least significant (rightmost) bit. The modified key will be used on next encryption block, after which it is again modified, and so on.
Here are the definitions of the functions from the file:
/* * Encrypts / decrypts the void* buffer named * Encrypted data will be saved to the same -buffer. * Encryption is based on XOR operation using a 32-bit
/* * Encrypts / decrypts the void* buffer named * Encrypted data will be saved to the same -buffer. * Encryption is based on XOR operation using a 32-bit
void print_uint32_hex(void* data, int len) { for(int i = 0; i < len; i++) printf("0x%08x ", ((uint32_t*)data)[i]); printf(" "); }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started