TwoFish ========= .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is Twofish?** * Twofish is a symmetric-key block cipher developed by Bruce Schneier and colleagues in 1998. * It operates on 128-bit blocks and supports key sizes of 128, 192, or 256 bits. * It was one of the five finalists in the AES competition, although it was not ultimately selected. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Why is Twofish useful?** * **Strong security** – Resistant to differential and linear cryptanalysis * **Flexible key sizes** – 128, 192, and 256-bit keys supported * **Efficient performance** – Performs well in software and hardware * **Unpatented and free** – Openly available without licensing restrictions * **AES finalist** – Demonstrated strong design principles .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **How it works** * **Key expansion** – The key is expanded into 40 subkeys and S-boxes * **Input whitening** – Plaintext is XORed with the first 4 subkeys * **16 encryption rounds** – * Each round uses a Feistel structure * Key-dependent S-boxes, MDS matrix, rotations, and XORs * **Output whitening** – Final block is XORed with the last 4 subkeys * **Final output** – 128-bit ciphertext block is produced .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Where is Twofish used?** * **File and disk encryption** – Tools like TrueCrypt and VeraCrypt * **Embedded systems** – Efficient for constrained environments * **Secure communications** – Used in VPNs, messaging apps * **Open-source projects** – Included in cryptographic libraries * **Legacy systems** – Still in use where AES is unavailable or unnecessary .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Which OSI layer does this protocol belong to?** * **Presentation Layer (Layer 6)** * Handles encryption and decryption before data reaches the application * Twofish transforms plaintext into ciphertext and vice versa—core presentation layer tasks .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Topics in this section, * :ref:`Learnings in this section ` * :ref:`Terminology ` * :ref:`Version Info ` * :ref:`TwoFish Version&RFC Details ` * :ref:`TwoFish Basic Setup on Ubuntu using IPv4 ` * :ref:`TwoFish Basic Setup on Ubuntu using IPv6 ` * :ref:`TwoFish Protocol Packet Details ` * :ref:`TwoFish Usecases ` * :ref:`TwoFish Basic Features ` * :ref:`TwoFish Feature : Block Cipher ` * :ref:`TwoFish Feature : Variable Key Length ` * :ref:`TwoFish Feature : Feistel Network ` * :ref:`TwoFish Feature : Key-Dependent S-boxes ` * :ref:`TwoFish Feature : MDS Matrix ` * :ref:`TwoFish Feature : Whitening steps ` * :ref:`TwoFish Feature : High Performance ` * :ref:`TwoFish Feature : Unpatented and Open ` * :ref:`TwoFish Feature : AES Finalist ` * :ref:`Reference links ` .. _TwoFish_step1: .. tab-set:: .. tab-item:: Learnings in this section * In this section, you are going to learn .. _TwoFish_step2: .. tab-set:: .. tab-item:: Terminology * Terminology .. _TwoFish_step3: .. tab-set:: .. tab-item:: Version Info * Version Info .. _TwoFish_step5: .. tab-set:: .. tab-item:: TwoFish Version&RFC Details .. csv-table:: :file: ./TwoFish/TwoFish_rfcdetails.csv :widths: 10,10,10,30 :header-rows: 1 .. _TwoFish_step19: .. tab-set:: .. tab-item:: TwoFish Basic Setup on Ubuntu using IPv4 * setup .. _TwoFish_step20: .. tab-set:: .. tab-item:: TwoFish Basic Setup on Ubuntu using IPv6 * setup .. _TwoFish_step6: .. tab-set:: .. tab-item:: TwoFish Protocol Packet Details **Key Expansion Packet** .. csv-table:: :file: ./TwoFish/TwoFish_packetdetails1.csv :widths: 10,20,30,10 :header-rows: 1 **Input Whitening Packet** .. csv-table:: :file: ./TwoFish/TwoFish_packetdetails2.csv :widths: 10,20,30,10 :header-rows: 1 **Encryption Rounds Packet** .. csv-table:: :file: ./TwoFish/TwoFish_packetdetails3.csv :widths: 10,20,30,10 :header-rows: 1 **Output Whitening Packet** .. csv-table:: :file: ./TwoFish/TwoFish_packetdetails4.csv :widths: 10,20,30,10 :header-rows: 1 **Decryption Process Packet** .. csv-table:: :file: ./TwoFish/TwoFish_packetdetails5.csv :widths: 10,20,30,10 :header-rows: 1 .. _TwoFish_step7: .. tab-set:: .. tab-item:: TwoFish Usecases .. csv-table:: :file: ./TwoFish/TwoFish_usecases.csv :widths: 10,20,30 :header-rows: 1 .. _TwoFish_step8: .. tab-set:: .. tab-item:: TwoFish Basic Features .. csv-table:: :file: ./TwoFish/TwoFish_basicfeatures.csv :widths: 10,10,30 :header-rows: 1 .. _TwoFish_step9: .. tab-set:: .. tab-item:: TwoFish Feature : Block Cipher **Block Cipher - Testcases** .. csv-table:: :file: ./TwoFish/TwoFish_feature1_Block_Cipher.csv :widths: 10,10,30,20 :header-rows: 1 .. _TwoFish_step10: .. tab-set:: .. tab-item:: TwoFish Feature : Variable Key Length **Variable Key Length - Testcases** .. csv-table:: :file: ./TwoFish/TwoFish_feature2_Variable_key_length.csv :widths: 10,10,30,20 :header-rows: 1 .. _TwoFish_step11: .. tab-set:: .. tab-item:: TwoFish Feature : Feistel Network **Feistel Network - Testcases** .. csv-table:: :file: ./TwoFish/TwoFish_feature3_Feistel_Network.csv :widths: 10,10,30,20 :header-rows: 1 .. _TwoFish_step12: .. tab-set:: .. tab-item:: TwoFish Feature : Key-Dependent S-boxes **Key-Dependent S-boxes - Testcases** .. csv-table:: :file: ./TwoFish/TwoFish_feature4_Key_Dependent_S_boxes.csv :widths: 10,10,30,20 :header-rows: 1 .. _TwoFish_step13: .. tab-set:: .. tab-item:: TwoFish Feature : MDS Matrix **MDS Matrix - Testcases** .. csv-table:: :file: ./TwoFish/TwoFish_feature5_MDS_Matrix.csv :widths: 10,10,30,20 :header-rows: 1 .. _TwoFish_step14: .. tab-set:: .. tab-item:: TwoFish Feature : Whitening steps **Whitening steps - Testcases** .. csv-table:: :file: ./TwoFish/TwoFish_feature6_Whitening_steps.csv :widths: 10,10,30,20 :header-rows: 1 .. _TwoFish_step15: .. tab-set:: .. tab-item:: TwoFish Feature : High Performance **High Performance - Testcases** .. csv-table:: :file: ./TwoFish/TwoFish_feature7_High_Performance.csv :widths: 10,10,30,20 :header-rows: 1 .. _TwoFish_step16: .. tab-set:: .. tab-item:: TwoFish Feature : Unpatented and Open **Unpatented and Open - Testcases** .. csv-table:: :file: ./TwoFish/TwoFish_feature8_unpatented_and_open.csv :widths: 10,10,30,20 :header-rows: 1 .. _TwoFish_step17: .. tab-set:: .. tab-item:: TwoFish Feature : AES Finalist **AES Finalist - Testcases** .. csv-table:: :file: ./TwoFish/TwoFish_feature9_AES_Finalist.csv :widths: 10,10,30,20 :header-rows: 1 .. _TwoFish_step18: .. tab-set:: .. tab-item:: Reference links * Reference links