ChaCha20 ============ .. 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 ChaCha20?** * ChaCha20 is a **symmetric stream cipher** designed by Daniel J. Bernstein. * It uses the same key for encryption and decryption and is a modern, secure alternative to older ciphers like RC4 and some AES modes. * Known for high speed, strong security, and resistance to timing attacks—ideal for mobile and embedded platforms. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Why is ChaCha20 useful?** * **High performance** – Faster than AES on many systems without AES hardware support * **Strong security** – 256-bit key, 96-bit nonce, and robust resistance to cryptographic attacks * **Simplicity** – Easy to implement with fewer chances of implementation errors * **Constant-time operation** – Prevents timing-based side-channel attacks * **Ideal for mobile/IoT** – Lightweight and efficient for resource-constrained environments .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **How it works** * **Key setup** – Uses a 256-bit key and a 96-bit nonce * **Keystream generation** – Produces a pseudorandom keystream * **Encryption** – Plaintext is XORed with the keystream → ciphertext * **Decryption** – Ciphertext is XORed with the same keystream → original plaintext * **Note** – No padding required; suitable for variable-length data .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Where is ChaCha20 used?** * **TLS/SSL (HTTPS)** – In the ChaCha20-Poly1305 AEAD cipher suite * **Mobile apps** – For messaging, file encryption, and VPNs on Android/iOS * **OpenSSH** – Secure remote access using ChaCha20 * **WireGuard VPN** – Lightweight VPN protocol using ChaCha20 * **Encrypted file storage** – Used in tools like VeraCrypt and `age` .. 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)** * Performs encryption/decryption and ensures confidentiality and integrity * Formats and protects data before it's delivered to applications .. 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:`ChaCha20 Version&RFC Details ` * :ref:`ChaCha20 Basic Setup on Ubuntu using IPv4 ` * :ref:`ChaCha20 Basic Setup on Ubuntu using IPv6 ` * :ref:`ChaCha20 Protocol Packet Details ` * :ref:`ChaCha20 Usecases ` * :ref:`ChaCha20 Basic Features ` * :ref:`ChaCha20 Feature : Symmetric Stream Cipher ` * :ref:`ChaCha20 Feature : 256-bit Key ` * :ref:`ChaCha20 Feature : 96-bit Nonce ` * :ref:`ChaCha20 Feature : 20 rounds of Mixing ` * :ref:`ChaCha20 Feature : No Padding Required ` * :ref:`ChaCha20 Feature : Constant-Time Execution ` * :ref:`ChaCha20 Feature : High Performance in Software ` * :ref:`ChaCha20 Feature : Design ` * :ref:`ChaCha20 Feature : AEAD Support (with poly1305) ` * :ref:`ChaCha20 Feature : Cross-Platform Compatibility ` * :ref:`Reference links ` .. _ChaCha20_step1: .. tab-set:: .. tab-item:: Learnings in this section * In this section, you are going to learn .. _ChaCha20_step2: .. tab-set:: .. tab-item:: Terminology * Terminology .. _ChaCha20_step3: .. tab-set:: .. tab-item:: Version Info * Version Info .. _ChaCha20_step5: .. tab-set:: .. tab-item:: ChaCha20 Version&RFC Details .. csv-table:: :file: ./ChaCha20/chacha20_rfc_details.csv :widths: 10,10,10,30 :header-rows: 1 .. _ChaCha20_step20: .. tab-set:: .. tab-item:: ChaCha20 Basic Setup on Ubuntu using IPv4 * Setup .. _ChaCha20_step21: .. tab-set:: .. tab-item:: ChaCha20 Basic Setup on Ubuntu using IPv6 * Setup .. _ChaCha20_step6: .. tab-set:: .. tab-item:: ChaCha20 Protocol Packet Details **ChaCha20 Encryption Packet** .. csv-table:: :file: ./ChaCha20/chacha20_packet1_details.csv :widths: 10,20,30,10 :header-rows: 1 **ChaCha20-Poly1305 AEAD Packet** .. csv-table:: :file: ./ChaCha20/chacha20_packet2_details.csv :widths: 10,20,30,10 :header-rows: 1 .. _ChaCha20_step7: .. tab-set:: .. tab-item:: ChaCha20 Usecases .. csv-table:: :file: ./ChaCha20/chacha20_usecases.csv :widths: 10,20,30 :header-rows: 1 .. _ChaCha20_step8: .. tab-set:: .. tab-item:: ChaCha20 Basic Features .. csv-table:: :file: ./ChaCha20/chacha20_features.csv :widths: 10,10,30 :header-rows: 1 .. _ChaCha20_step9: .. tab-set:: .. tab-item:: ChaCha20 Feature : Symmetric Stream Cipher **Symmetric Stream Cipher - Testcases** .. csv-table:: :file: ./ChaCha20/chacha20_feature1_test_cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _ChaCha20_step10: .. tab-set:: .. tab-item:: ChaCha20 Feature : 256-bit Key **256-bit Key - Testcases** .. csv-table:: :file: ./ChaCha20/chacha20_feature2_test_cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _ChaCha20_step11: .. tab-set:: .. tab-item:: ChaCha20 Feature : 96-bit Nonce **96-bit Nonce - Testcases** .. csv-table:: :file: ./ChaCha20/chacha20_feature3_test_cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _ChaCha20_step12: .. tab-set:: .. tab-item:: ChaCha20 Feature : 20 Rounds of Mixing **20 Rounds of Mixing - Testcases** .. csv-table:: :file: ./ChaCha20/chacha20_feature4_test_cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _ChaCha20_step13: .. tab-set:: .. tab-item:: ChaCha20 Feature : No Padding Required **No Padding Required - Testcases** .. csv-table:: :file: ./ChaCha20/chacha20_feature5_test_cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _ChaCha20_step14: .. tab-set:: .. tab-item:: ChaCha20 Feature : Constant-time Execution **Constant-time Execution - Testcases** .. csv-table:: :file: ./ChaCha20/chacha20_feature6_test_cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _ChaCha20_step15: .. tab-set:: .. tab-item:: ChaCha20 Feature : High Performance in Software **High Performance in Software - Testcases** .. csv-table:: :file: ./ChaCha20/chacha20_feature7_test_cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _ChaCha20_step16: .. tab-set:: .. tab-item:: ChaCha20 Feature : Design **Design - Testcases** .. csv-table:: :file: ./ChaCha20/chacha20_feature8_test_cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _ChaCha20_step17: .. tab-set:: .. tab-item:: ChaCha20 Feature : AEAD Support (with poly1305) **AEAD Support (with poly1305) - Testcases** .. csv-table:: :file: ./ChaCha20/chacha20_feature9_test_cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _ChaCha20_step18: .. tab-set:: .. tab-item:: ChaCha20 Feature : Cross-Platform Compatibility **Cross-Platform Compatibility - Testcases** .. csv-table:: :file: ./ChaCha20/chacha20_feature10_test_cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _ChaCha20_step19: .. tab-set:: .. tab-item:: Reference links * Reference links