| ๐ Section | ๐ Description |
|---|---|
| ๐ Overview | Understanding AES-128 Implementation |
| โจ Features | What's Included in This Repo |
| ๐ Algorithm Flow | Visual Encryption/Decryption Process |
| ๐ File Structure | Project Organization |
| ๐ Getting Started | Quick Setup Guide |
| ๐ก Usage | Code Examples & Implementation |
| ๐ Simulation Results | Waveform Analysis |
| ๐งช Testing | Test Bench Information |
| ๐ Technical Documentation | Deep Dive into AES |
| ๐ค Contributing | Join the Development |
| ๐ License | Legal Information |
This repository contains a complete implementation of the Advanced Encryption Standard (AES) with 128-bit key length in Verilog HDL. AES-128 is a symmetric block cipher that encrypts data in 128-bit blocks using a 128-bit key through 10 rounds of cryptographic operations.
Key Specifications:
- ๐ข Block Size: 128 bits (16 bytes)
- ๐ Key Size: 128 bits (16 bytes)
- ๐ Rounds: 10 rounds
- โ๏ธ Algorithm Type: Symmetric Block Cipher
- ๐ ๏ธ Implementation: Verilog HDL
- โ Complete AES-128 Encryption: Full encryption pipeline with all 10 rounds
- โ Complete AES-128 Decryption: Full decryption pipeline with inverse operations
- โ Modular Design: Separate modules for each AES operation
- โ Key Expansion: Dedicated key schedule implementation
- โ Core AES Operations: SubBytes, ShiftRows, MixColumns, AddRoundKey
- โ Inverse Operations: All inverse transformations for decryption
- โ Comprehensive Test Benches: Separate test benches for encryption and decryption
- โ Waveform Analysis: Visual simulation results
- โ NIST Compliant: Follows official AES specification
- โ Well Documented: Clear code structure and comments
flowchart LR
A["๐ค 128-bit<br/>Plaintext"] --> B["๐ Key<br/>Expansion"]
B --> C["โก Initial Round<br/>AddRoundKey"]
C --> D["๐ Rounds 1-9"]
D --> E["๐ SubBytes"]
E --> F["โฉ๏ธ ShiftRows"]
F --> G["๐งฎ MixColumns"]
G --> H["๐ AddRoundKey"]
H --> I{"๐ More<br/>Rounds?"}
I -->|"โ
Yes"| D
I -->|"โ No"| J["๐ Final Round 10"]
J --> K["๐ SubBytes"]
K --> L["โฉ๏ธ ShiftRows"]
L --> M["๐ AddRoundKey"]
M --> N["๐ 128-bit<br/>Ciphertext"]
style A fill:#e1f5fe,stroke:#01579b,stroke-width:3px
style N fill:#f3e5f5,stroke:#4a148c,stroke-width:3px
style B fill:#fff3e0,stroke:#e65100,stroke-width:2px
style D fill:#e8f5e8,stroke:#2e7d32,stroke-width:2px
style J fill:#fff8e1,stroke:#f57f17,stroke-width:2px
style I fill:#fce4ec,stroke:#c2185b,stroke-width:2px
flowchart LR
A["๐ 128-bit<br/>Ciphertext"] --> B["๐ Key<br/>Expansion"]
B --> C["โก Initial Round<br/>AddRoundKey"]
C --> D["๐ Rounds 9-1"]
D --> E["โช๏ธ InvShiftRows"]
E --> F["๐ InvSubBytes"]
F --> G["๐ AddRoundKey"]
G --> H["๐งฎ InvMixColumns"]
H --> I{"๐ More<br/>Rounds?"}
I -->|"โ
Yes"| D
I -->|"โ No"| J["๐ Final Round 0"]
J --> K["โช๏ธ InvShiftRows"]
K --> L["๐ InvSubBytes"]
L --> M["๐ AddRoundKey"]
M --> N["๐ค 128-bit<br/>Plaintext"]
style A fill:#f3e5f5,stroke:#4a148c,stroke-width:3px
style N fill:#e1f5fe,stroke:#01579b,stroke-width:3px
style B fill:#fff3e0,stroke:#e65100,stroke-width:2px
style D fill:#ffebee,stroke:#c62828,stroke-width:2px
style J fill:#fff8e1,stroke:#f57f17,stroke-width:2px
style I fill:#fce4ec,stroke:#c2185b,stroke-width:2px
AES128-EncryptionDecryption-Verilog/
โโโ ๐ AES128_Encryption/ # ๐ Encryption Implementation
โ โโโ ๐ง AES128_encryption.v # Main encryption module
โ โโโ ๐ง AES128_encryption_tb.v # Encryption test bench
โ โโโ ๐ง add_round_key.v # AddRoundKey operation
โ โโโ ๐ง aes_sbox.v # AES S-Box implementation
โ โโโ ๐ง encrypt_round.v # Single encryption round
โ โโโ ๐ง key_expansion.v # Key schedule generation
โ โโโ ๐ง mix_columns.v # MixColumns transformation
โ โโโ ๐ง shift_rows.v # ShiftRows transformation
โ โโโ ๐ง sub_bytes.v # SubBytes transformation
โ โโโ ๐ง sub_words.v # SubWord operation for key expansion
โ โโโ ๐ AES_encryption_waveform.png # Encryption simulation results
โโโ ๐ AES128_Decryption/ # ๐ Decryption Implementation
โ โโโ ๐ง AES128_decryption.v # Main decryption module
โ โโโ ๐ง AES128_decryption_tb.v # Decryption test bench
โ โโโ ๐ง add_round_key.v # AddRoundKey operation
โ โโโ ๐ง decrypt_round.v # Single decryption round
โ โโโ ๐ง inverse_MixColumns.v # Inverse MixColumns transformation
โ โโโ ๐ง inverse_ShiftRows.v # Inverse ShiftRows transformation
โ โโโ ๐ง inverse_SubBytes.v # Inverse SubBytes transformation
โ โโโ ๐ง inverse_sbox.v # Inverse S-Box implementation
โ โโโ ๐ง key_expansion.v # Key schedule generation
โ โโโ ๐ AES_decryption_waveform.png # Decryption simulation results
โโโ ๐ nist.fips.197.pdf # Official AES specification
โโโ ๐ README.md # This comprehensive guide
โโโ ๐ LICENSE # MIT License
- ๐ง Verilog HDL Simulator: ModelSim, Vivado, Quartus, or similar
- ๐ง Knowledge: Basic understanding of cryptography and digital design
- ๐ป Hardware: Computer capable of running HDL simulation tools
-
๐ฅ Clone the Repository
git clone https://github.com/Ardhish2210/AES128-EncryptionDecryption-Verilog.git cd AES128-EncryptionDecryption-Verilog -
๐ For Encryption Testing
cd AES128_Encryption # Compile all .v files in your simulator # Run AES128_encryption_tb.v testbench
-
๐ For Decryption Testing
cd AES128_Decryption # Compile all .v files in your simulator # Run AES128_decryption_tb.v testbench
-
๐ View Results
- Check waveform outputs
- Verify against expected test vectors
- Analyze timing and performance
module encryption_example;
// Test vectors
reg [127:0] plaintext = 128'h3243f6a8885a308d313198a2e0370734;
reg [127:0] key = 128'h2b7e151628aed2a6abf7158809cf4f3c;
wire [127:0] ciphertext;
// Instantiate encryption module
AES128_encryption encrypt_inst (
.plaintext(plaintext),
.key(key),
.ciphertext(ciphertext)
);
// Display results
initial begin
#100; // Wait for computation
$display("Plaintext: %h", plaintext);
$display("Key: %h", key);
$display("Ciphertext: %h", ciphertext);
end
endmodulemodule decryption_example;
// Use ciphertext from encryption
reg [127:0] ciphertext = 128'h3925841d02dc09fbdc118597196a0b32;
reg [127:0] key = 128'h2b7e151628aed2a6abf7158809cf4f3c;
wire [127:0] recovered_plaintext;
// Instantiate decryption module
AES128_decryption decrypt_inst (
.ciphertext(ciphertext),
.key(key),
.plaintext(recovered_plaintext)
);
// Verify decryption
initial begin
#100; // Wait for computation
$display("Ciphertext: %h", ciphertext);
$display("Key: %h", key);
$display("Plaintext: %h", recovered_plaintext);
end
endmoduleKey Observations:
- โฑ๏ธ Latency: 10 clock cycles (one per round)
- ๐ Throughput: One 128-bit block per 10 cycles
- ๐ Round Progress: Clear visualization of each transformation
- โ Correctness: Output matches NIST test vectors
Key Observations:
- โฑ๏ธ Latency: 10 clock cycles (inverse rounds)
- ๐ Throughput: One 128-bit block per 10 cycles
- ๐ Inverse Operations: Clear visualization of reverse transformations
- โ Correctness: Recovered plaintext matches original
For comprehensive AES-128 algorithm details, refer to the included nist.fips.197.pdf specification document.
- Purpose: Non-linear byte substitution using S-Box
- Implementation: 256-byte lookup table (aes_sbox.v)
- Input: 128-bit state
- Output: 128-bit transformed state
- Purpose: Cyclically shift rows of state matrix
- Pattern: Row 0: no shift, Row 1: left 1, Row 2: left 2, Row 3: left 3
- Implementation: Bit manipulation and concatenation
- Purpose: Matrix multiplication in Galois Field GF(2โธ)
- Matrix: Fixed 4x4 matrix with polynomial coefficients
- Implementation: Optimized using XOR operations
- Purpose: XOR state with round key
- Implementation: Simple 128-bit XOR operation
- Usage: Applied in every round
- Input: 128-bit original key
- Output: 11 round keys (128 bits each)
- Process: Rotation, substitution, and XOR with round constants
- ๐ Encryption Cycles: 10 cycles
- ๐ Decryption Cycles: 10 cycles
- ๐ฏ Throughput: 12.8 Gbps @ 100MHz
- ๐ Resource Usage: Optimized for FPGA implementation
We welcome contributions to improve this AES-128 implementation! ๐
- ๐ด Fork the repository
- ๐ฟ Create a feature branch
git checkout -b feature/amazing-improvement
- ๐ป Make your changes
- ๐งช Test thoroughly
- ๐ Commit with clear messages
git commit -m "Add: Enhanced key expansion optimization" - ๐ Push to your branch
git push origin feature/amazing-improvement
- ๐ Create a Pull Request
- ๐ง Code Optimization: Performance improvements
- ๐งช Testing: Additional test cases and scenarios
- ๐ Documentation: Better explanations and examples
- ๐ Bug Fixes: Issue resolution and improvements
- โจ New Features: Additional AES modes or variants
- Follow existing code style and structure
- Add comprehensive comments for new code
- Include test cases for new features
- Update documentation as needed
- Ensure all tests pass before submitting
This project is licensed under the MIT License - see the LICENSE file for details.
๐จโ๐ป Author: @Ardhish2210
๐
Last Updated: July 2025
๐ Repository: AES128-EncryptionDecryption-Verilog
โญ If you found this project helpful, please consider giving it a star! โญ
๐ค Questions? Issues? Suggestions?
Feel free to open an issue or start a discussion!

