Skip to content

This Repository is a collection of different ethical hacking tools and malware's for penetration testing and research purpose written in python, ruby, rust, c++, go and c.

Create Advanced Encryption Standards.md

Abdul Wahab Junaide53d52fbdfbd
diff --git a/Cryptography/Cryptography Course/Course/Advanced Encryption Standards.md b/Cryptography/Cryptography Course/Course/Advanced Encryption Standards.md
new file mode 100644
index 0000000..0a7eb49
--- /dev/null
+++ b/Cryptography/Cryptography Course/Course/Advanced Encryption Standards.md
@@ -0,0 +1,156 @@
+### **Cryptography - Advanced Encryption Standard (AES)**
+
+The **Advanced Encryption Standard (AES)** is a symmetric key encryption algorithm that has become the most widely used standard for secure data encryption. Developed by cryptographers Joan Daemen and Vincent Rijmen, AES was selected by the U.S. National Institute of Standards and Technology (NIST) in 2001 to replace the aging **Data Encryption Standard (DES)**. Known for its strength, efficiency, and flexibility, AES is used worldwide to secure sensitive data in applications such as banking, telecommunications, and government.
+
+---
+
+### **Key Characteristics of AES**
+
+- **Type:** Symmetric key block cipher (uses the same key for encryption and decryption).
+- **Block Size:** 128 bits.
+- **Key Sizes:** 128, 192, or 256 bits, offering three different security levels.
+- **Rounds:** The number of encryption rounds depends on the key size:
+ - **AES-128:** 10 rounds
+ - **AES-192:** 12 rounds
+ - **AES-256:** 14 rounds
+
+AES is based on the **Rijndael algorithm**, which employs a series of transformations and a key schedule to provide robust encryption.
+
+---
+
+### **AES Encryption Process**
+
+The AES encryption process involves a series of transformations that alter the data block over multiple rounds. Each round consists of four main steps:
+
+1. **SubBytes:** Each byte in the block is substituted with a byte from a fixed 16x16 lookup table (S-box), adding non-linearity to the encryption process.
+
+2. **ShiftRows:** Each row of the block matrix is shifted to the left by a certain number of positions. This step ensures that each byte in the matrix influences multiple other bytes.
+
+3. **MixColumns:** Each column of the block matrix undergoes a linear transformation by multiplying it with a fixed polynomial. This step introduces inter-column mixing, further spreading the influence of each byte.
+
+4. **AddRoundKey:** Each byte in the block is XORed with a portion of the round key derived from the main AES key. This step combines the data with the key material, making it key-dependent.
+
+The encryption rounds are repeated according to the AES variant (128, 192, or 256), with a final round that skips the MixColumns step.
+
+---
+
+### **AES Decryption Process**
+
+AES decryption reverses the encryption process, applying inverse transformations in the opposite order. The four inverse steps are:
+
+1. **InvShiftRows:** Each row is shifted to the right by a specific number of positions.
+
+2. **InvSubBytes:** Each byte is replaced with a corresponding byte from an inverse S-box.
+
+3. **InvMixColumns:** Each column is transformed using an inverse polynomial.
+
+4. **AddRoundKey:** The round key is XORed with the data block, the same as in encryption.
+
+Like encryption, the decryption rounds are repeated according to the AES variant in use.
+
+---
+
+### **AES Key Schedule**
+
+The key schedule generates the required round keys from the main AES key. Using an initial key expansion process, each round key is derived from the previous one by substituting, shifting, and XORing bits with a round constant. This ensures that each round’s encryption key differs significantly, increasing the strength of the encryption.
+
+---
+
+### **Security of AES**
+
+AES is considered very secure and efficient due to several key features:
+
+- **Key Length:** AES offers three different key lengths (128, 192, and 256 bits), each providing progressively stronger encryption.
+- **Resistance to Known Attacks:** AES is resistant to both linear and differential cryptanalysis. Furthermore, the larger key sizes of AES-192 and AES-256 make brute-force attacks infeasible with current computational power.
+- **Efficient Implementation:** AES is highly efficient in both software and hardware, allowing fast encryption and decryption even on low-resource devices.
+
+The only known theoretical vulnerability for AES-256 is related to **biclique attacks**, but these attacks do not reduce AES's security to a practical level for real-world scenarios.
+
+---
+
+### **Modes of Operation**
+
+AES is used with various **modes of operation** to tailor its functionality for different applications. Common AES modes include:
+
+1. **Electronic Code Book (ECB):** Simplest mode; each block is encrypted independently. Not recommended for secure encryption due to patterns visible in ciphertexts of similar blocks.
+
+2. **Cipher Block Chaining (CBC):** Each plaintext block is XORed with the previous ciphertext block before being encrypted. Requires an initialization vector (IV) to ensure security for the first block.
+
+3. **Cipher Feedback (CFB):** Converts AES into a self-synchronizing stream cipher by XORing each plaintext segment with the previous ciphertext block.
+
+4. **Output Feedback (OFB):** Operates as a stream cipher by creating a keystream that is XORed with the plaintext. Less prone to error propagation compared to CBC.
+
+5. **Counter (CTR):** Converts AES into a stream cipher by generating a sequence of blocks based on a counter and XORing each plaintext block with the corresponding keystream block.
+
+Each mode provides different trade-offs in terms of security, error propagation, and performance, depending on the specific needs of the application.
+
+---
+
+### **Use Cases for AES**
+
+AES is widely implemented across multiple industries due to its versatility, efficiency, and high level of security. Common use cases include:
+
+- **Secure Communications:** AES secures data transmitted over networks, such as internet traffic, VPNs, and SSL/TLS protocols.
+- **Data Storage:** AES encrypts sensitive data stored in databases, file systems, and cloud storage services.
+- **Mobile and Embedded Devices:** AES is used in smartphones, IoT devices, and other embedded systems due to its low power requirements and speed.
+- **Payment and Financial Transactions:** AES is the standard for protecting financial transactions, credit card information, and ATM communications.
+
+---
+
+### **Python Implementation of AES**
+
+Here's a Python example of AES encryption and decryption using the **PyCryptodome** library, which supports AES with various modes of operation:
+
+```python
+from Crypto.Cipher import AES
+from Crypto.Random import get_random_bytes
+from Crypto.Util.Padding import pad, unpad
+
+# Generate a random AES key
+key = get_random_bytes(16) # 16 bytes for AES-128
+
+# Generate a random initialization vector (IV)
+iv = get_random_bytes(16) # 16 bytes for AES block size
+
+# Create AES cipher in CBC mode
+cipher = AES.new(key, AES.MODE_CBC, iv)
+
+# Example plaintext
+plaintext = b"Advanced Encryption Standard (AES) example."
+
+# Encrypt the plaintext
+ciphertext = cipher.encrypt(pad(plaintext, AES.block_size))
+
+print("Ciphertext:", ciphertext)
+
+# Decrypt the ciphertext
+decipher = AES.new(key, AES.MODE_CBC, iv)
+decrypted_plaintext = unpad(decipher.decrypt(ciphertext), AES.block_size)
+
+print("Decrypted:", decrypted_plaintext.decode())
+```
+
+**Explanation of the Code:**
+- **Key and IV Generation:** A random key and IV are generated. AES requires a 16-byte key for AES-128 and a 16-byte IV for CBC mode.
+- **Padding:** The plaintext is padded to match AES’s block size, as AES operates on fixed-size blocks.
+- **Encryption and Decryption:** AES encryption is performed in CBC mode. The same key and IV are used for decryption to obtain the original plaintext.
+
+---
+
+### **Benefits of AES**
+
+- **High Security:** AES is widely considered secure against all known practical attacks.
+- **Flexibility:** AES supports multiple key lengths and can operate in different modes.
+- **Efficiency:** AES offers fast encryption and decryption with minimal computational overhead.
+- **Compatibility:** AES is implemented in almost every modern security protocol and device.
+
+### **Limitations of AES**
+
+- **Key Management:** Securely managing, storing, and distributing keys remains a challenge in AES implementations.
+- **Single Key for Symmetric Encryption:** Being a symmetric algorithm, AES requires the same key for both encryption and decryption, which requires secure key exchange protocols like Diffie-Hellman or RSA.
+
+---
+
+### **Conclusion**
+
+AES is a versatile and robust encryption standard with extensive use across industries and applications. It has established itself as the de facto choice for secure, efficient, and reliable encryption in both public and private sectors. With the continued evolution of cryptography, AES remains a cornerstone of modern digital security, underpinning protocols such as SSL/TLS, IPsec, and many others.