fpga-aes256-video-encryption
An FPGA-based video encryption prototype using AES-256-CTR and WIZnet W5500 hardware UDP sockets to transmit encrypted camera data over Ethernet.
0
Project description
FPGA-Based Video Encryption with WIZnet W5500
Project Overview
Video encryption is essential for applications where sensitive visual data must be transmitted across a network. Implementing encryption and network communication on embedded hardware, however, can introduce significant processing overhead and system complexity.
The FPGA AES-256 Video Encryption project by Tejas Choudhary explores a hardware-based approach to this challenge.
Built around the Sipeed Tang Nano 20K FPGA, an OV7670 camera, and the WIZnet W5500 Ethernet controller, the project combines camera capture, hardware-accelerated AES-256 encryption, and UDP-based Ethernet communication.

The FPGA handles video acquisition and encryption, while the W5500 provides network connectivity through its hardware UDP socket.
Unlike software-based networking solutions, this architecture does not require a separate microcontroller or a software TCP/IP stack on the FPGA.
The project demonstrates how hardware encryption and WIZnet's Ethernet technology can be combined to develop a compact video transmission platform.
Key Features
1. Hardware-Accelerated AES-256 Encryption
The project implements AES-256 encryption directly in Verilog HDL.
Video data is processed using AES-256 in Counter (CTR) mode, which generates a keystream to encrypt incoming pixel data.
By implementing the encryption logic in FPGA hardware, the system avoids relying on a general-purpose processor for the cryptographic calculations.
2. Camera Interface and Video Processing
The OV7670 CMOS camera provides raw RGB565 video data through an 8-bit parallel DVP interface.
An asynchronous FIFO bridges the camera pixel clock domain and the FPGA's system clock domain.
The captured pixels are then assembled into 128-bit blocks for the encryption engine.
This processing pipeline connects video acquisition with hardware-based cryptographic operations.
3. Ethernet Communication Using WIZnet W5500
The WIZnet W5500 provides the network interface between the FPGA and the receiving PC.
A custom Verilog SPI master configures the W5500's network registers and uses Socket 0 in UDP mode.
Because UDP communication is handled by the W5500's hardware socket engine, the FPGA does not need to implement a complete software TCP/IP stack.
This is particularly useful for FPGA applications where logic resources and system integration complexity are important considerations.
4. Custom SPI Communication Controller
The project uses a dedicated Verilog module, w5500_spi_master.v, to communicate with the W5500.
The controller handles device initialization, network configuration, transmission buffer writes, and UDP send commands.
It is implemented independently of the official WIZnet ioLibrary.
5. Python-Based Receiver and Visualization
The repository also includes a Python application named command_center_rx.py.
It provides UDP packet reception, AES-256-CTR decryption, RGB565 image conversion, and OpenCV-based visualization.
A built-in software transmitter simulator can generate encrypted test video data, allowing the host-side processing pipeline to be tested without requiring the complete FPGA hardware setup.
Hardware Setup
The system consists of three main sections: video capture, FPGA processing, and Ethernet transmission.
Video Capture
An OV7670 camera is connected to the Tang Nano 20K FPGA using an 8-bit DVP interface.
The camera provides pixel data together with synchronization signals, including PCLK, VSYNC, and HREF.
FPGA Processing
The Tang Nano 20K handles the video processing pipeline:
- Camera configuration through SCCB
- RGB565 pixel acquisition
- Clock-domain crossing through asynchronous FIFO
- 128-bit pixel block packing
- AES-256-CTR encryption
- SPI communication with the W5500
Ethernet Interface
The W5500 is connected to the FPGA through SPI signals:
| Signal | Function |
|---|---|
| SCLK | SPI clock |
| MOSI | FPGA-to-W5500 data |
| MISO | W5500-to-FPGA data |
| CS | Chip select |
| RESET | Hardware reset |
The design uses the FPGA's 27 MHz system clock and generates an SPI clock of approximately 13.5 MHz.
The W5500 connects to the receiving computer through an Ethernet network.
Software Implementation
AES-256-CTR Encryption Engine
The encryption pipeline is implemented in Verilog using dedicated AES modules.
The aes256_core.v module provides the AES encryption operations, while aes256_ctr.v implements Counter mode.
The video processing logic prepares 128-bit data blocks and passes them to the encryption engine.
After encryption, the resulting ciphertext is forwarded to the W5500 transmission controller.
W5500 UDP Socket Configuration
A key part of the project is the direct configuration of the W5500's hardware UDP socket.
The following excerpt shows the Socket 0 initialization approach:
// Socket 0: UDP mode
5'd19: init_rom = {
16'h0000, 8'h0C, 8'h02
};
// Open Socket 0
5'd28: init_rom = {
16'h0001, 8'h0C, 8'h01
};The first operation configures Socket 0 for UDP communication. The second issues the socket OPEN command.
The FPGA communicates with the W5500 through SPI register operations, while the W5500 handles the UDP networking functions in hardware.
This demonstrates the W5500's TCP/IP offload capabilities without requiring a software networking stack on the FPGA.
Encrypted Data Transmission
The transmission controller collects encrypted 128-bit blocks and writes them to the W5500's transmission buffer.
Its current RTL organizes 64 encrypted blocks into a 1,024-byte UDP payload.
After writing the data, the controller updates the transmission buffer pointer and issues the W5500 SEND command.
The configured networking parameters include:
| Parameter | Configuration |
|---|---|
| FPGA IP Address | 192.168.1.50 |
| Destination PC IP | 192.168.1.10 |
| UDP Port | 5005 |
| W5500 Socket | Socket 0 |
| Network Protocol | UDP |
| Payload Size | 1,024 bytes |
Host-Side Software
The Python receiver uses socket programming, PyCryptodome, NumPy, and OpenCV.
Its implementation includes functions for receiving encrypted UDP packets, decrypting data using AES-256-CTR, converting RGB565 image data, and displaying video frames.
The repository also provides a simulation mode for testing encrypted video transmission using generated frames.
These features offer a software environment for developing and testing the intended communication pipeline.
Network Architecture
The proposed system follows a hardware-oriented processing architecture.
OV7670 Camera
|
8-bit DVP Video
|
v
Sipeed Tang Nano 20K
+---------------------+
| Camera Capture |
| | |
| Asynchronous FIFO |
| | |
| 128-bit Pixel |
| Packing |
| | |
| AES-256-CTR Engine |
+---------------------+
|
Encrypted Data
|
SPI Bus
|
v
WIZnet W5500
Hardware UDP Socket
|
Ethernet / UDP
|
v
Host PC
Python UDP Receiver
|
AES Decryption
|
OpenCV Video DisplayThe W5500 serves as the hardware networking interface for the encrypted data.
In this architecture, encryption and networking are handled by separate hardware components.
The FPGA performs the cryptographic processing, while the W5500 handles UDP communication.
This division of responsibilities reduces the need for a processor-based networking subsystem in the FPGA design.
Performance Results and Implementation Status
The public repository contains the main RTL modules for camera capture, AES-256 encryption, and W5500 UDP transmission, along with a Python receiver and testing utility.
The available source code identifies several design parameters:
- FPGA system clock: 27 MHz
- SPI clock: Approximately 13.5 MHz
- Encryption: AES-256-CTR
- AES block size: 128 bits
- UDP payload: 1,024 bytes
- Host UDP port: 5005
However, independently verified hardware measurements for encryption throughput, end-to-end frame rate, packet loss, and long-term operation are not provided.
These values should therefore be treated as implementation parameters rather than demonstrated performance benchmarks.
The current design also requires additional validation of the FPGA-to-PC packet format and synchronization between the encryption and decryption components.
Future Improvements
- The project provides a foundation for further development, including:
- Completing and validating end-to-end FPGA-to-PC video transmission.
- Improving UDP packet sequencing and frame reconstruction.
- Adding hardware socket status monitoring and transmission error handling.
- Implementing secure key provisioning and non-repeating AES-CTR counters.
- Adding message authentication to detect tampering.
- Measuring actual video frame rate, encryption throughput, and packet loss.
- Optimizing the FPGA and SPI data pipelines for continuous streaming.
- These improvements could help extend the prototype into a more robust embedded video networking platform.
