Experiment 7: Encryption of plaintext using Twofish algorithm
Twofish Algorithm Encryption Process
Twofish is a symmetric key block cipher designed for fast and secure encryption. It was one of the five finalists in the Advanced Encryption Standard (AES) competition. This algorithm is known for its efficiency and strong security features. In this markdown, we will explore the process of encrypting plaintext using the Twofish algorithm.
Key Generation
The Twofish algorithm requires a symmetric key for encryption. The key generation process involves creating a set of subkeys from the original key using a key schedule. This schedule generates round subkeys, which are essential for the encryption process.
Block Division
Before encrypting the plaintext, it is divided into fixed-size blocks. Twofish operates on 128-bit blocks, so the plaintext is divided into blocks of 128 bits.
Whitening
The whitening process involves bitwise XOR (exclusive OR) of the plaintext block with a subkey. This is done to add an extra layer of security to the data before entering the main encryption rounds.
Feistel Network Structure
Twofish uses a Feistel network structure, which divides the block into two halves. The two halves go through multiple rounds of processing, and at each round, the function F is applied to one half and then mixed with the other half using modular addition.
F Function
The F function is a complex combination of operations involving substitution-permutation networks (S-boxes), key mixing, and bitwise operations. It takes one half of the block as input and produces a processed output.
Key Mixing
Key mixing involves XORing the output of the F function with a subkey. This step introduces the secret key into the encryption process, making it an integral part of the algorithm's security.
Mixing and Swapping
After applying the F function and key mixing for multiple rounds, the two halves of the block are mixed and swapped. This process ensures that both halves contribute to the final encrypted output.
Output Transformation
The final step involves the bitwise XOR of the two halves of the block, creating the encrypted ciphertext.