Abstract
This paper presents a high-performance implementation of the SHA-3 (Keccak) hashing algorithm optimized for NVIDIA GPUs using CUDA. Cryptographic hashing is traditionally a sequential process, creating bottlenecks in high-volume applications. By transitioning to a "Batch mode" approach—processing thousands of independent messages simultaneously—we leverage the massively parallel architecture of the GPU. Our results demonstrate that for large datasets, the GPU implementation achieves a throughput speedup of over 1,700x compared to a traditional CPU-based approach, effectively transforming cryptographic bottlenecks into high-speed services.
1. Introduction
As cryptographic standards evolve, the industry has shifted from vulnerable functions like MD5 and SHA-1 to the more robust SHA-3 standard, based on the Keccak algorithm. While SHA-3 offers enhanced security, its computational intensity can hinder performance in systems requiring massive volumes of hash operations, such as authentication servers, digital signature verification, and network security monitoring. This study explores the use of General-Purpose Graphics Processing Units (GPGPUs) to accelerate these operations through massive parallelism.
2. The Parallelization Challenge
The primary hurdle in parallelizing Keccak is its "Sponge construction." This design requires each block of data to be processed into an internal state sequentially, making it inherently difficult to speed up the hashing of a single message. However, many real-world scenarios involve processing millions of small, independent messages (e.g., password hashing). This "Batch mode" requirement is ideal for the SIMT (Single Instruction, Multiple Threads) architecture of modern GPUs.
3. Methodology
3.1 Parallel Granularity
Our implementation adopts a "one thread per message" strategy. Rather than attempting to parallelize a single hash, we utilize thousands of CUDA threads to compute thousands of different hashes in parallel. This approach maximizes GPU occupancy and hides memory latency.
3.2 Keccak-p Permutations
The core of the implementation involves the five step mappings of the Keccak-p permutation: $\theta$ (Theta), $\rho$ (Rho), $\pi$ (Pi), $\chi$ (Chi), and $\zeta$ (Iota). These steps involve XORing, bit rotation, lane rearrangement, and non-linear bitwise mappings. The parameters for these permutations vary based on the state width $b$, as illustrated in the relationship between state width, lane size $w$, and the parameter $l$.
3.3 Memory and Performance Optimization
To minimize latency, we stored the Round Constant (RC) tables—which are accessed frequently during the $\zeta$ step—in the GPU’s Constant Memory. This specialized cache is significantly faster than global memory for read-only data shared across threads, preventing bank conflicts and ensuring high-speed access. Additionally, the implementation is optimized for 10-byte messages, common in short-string scenarios, by synchronizing them efficiently across the GPU grid.
4. Experimental Evaluation
4.1 Environment
The performance benchmarks were conducted using a mobile-class workstation. The specific hardware and software specifications used for these tests are detailed in the table below.
4.2 Performance Results
Benchmarks were performed using synthetic message batches of varying sizes to observe scaling.
- Small Workloads: For tasks around 1,202 bytes, the GPU provided a modest 6x speedup. At this scale, the overhead of kernel launching and data transfer between the CPU and GPU is a significant portion of the total execution time.
- Large Workloads: As the workload increased to approximately 1.2 MB, the GPU's throughput reached ~988.7 MB/s (988,705,980 bytes/sec), while the CPU managed only ~0.58 MB/s (577,762 bytes/sec).
At the highest tested volume, the GPU outperformed the CPU by a factor of 1,711x. This demonstrates that once the parallelism threshold is met, the GPU's ability to hide memory latency with massive thread counts allows it to pull ahead rapidly.
5. Conclusion and Future Work
This work demonstrates that GPU acceleration can significantly alleviate the computational burden of SHA-3 in batch processing scenarios. While the current implementation is optimized for many small messages, future research will focus on "Hash Tree Mode." This will involve using CUDA reduction operations to parallelize the hashing of single, massive files by combining hashes from different branches of a tree into a single root hash.
Summary updated