Hardware Implementation of the Salsa20 and Phelix Stream Ciphers
Total Page:16
File Type:pdf, Size:1020Kb
------ ------------------- Hardware Implementation of the Salsa20 and Phelix Stream Ciphers by @ Junjie Yan A THESIS SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE DEGREE OF MASTER OF ENGINEERING m Faculty of Engineering and Applied Science MEMORIAL UNIVERSITY OF NEWFOUNDLAND October 2007 St. John's Newfoundland Acknowledgements First of all I would like to thank my supervisor Dr. Howard Heys for his constant guidance and support. Without his supervision, this thesis would not exist. I would also like to thank Dr. Cheng Li. His courses, especially LSI Design (Engr. 8863) and Digital Systems (Engr. 5865) not only made me familiar with the hardware design flow but also the use of VHDL as design language and input for logic synthesis. They are critical tools for my research. I am very grateful to Canadian Microelectronic Corporation (CMC) as well as Mentor Graphics for their help in providing design tools and the access to state-of-the-art manufacturing technologies. I thank Namin Yu for the useful literature she provided. With the literature as guidance for chapter organization, grammars and format, I saved a lot of time in terms of thesis writing. Many thanks to Huiju Cheng for being a great lab partner, travel mate and my best friend at MUN. Our cooperation resulted in more ideas in my research, which was truly rewarding. I thank Peter Vandrish for his insightful comments and criticism and for careful reading of my papers before publishing. I very much appreciated the pleasant and fruitful time studying together with him. Furthermore, I would like to express my gratitude to Avalon Microelectronics Incorporation, who has provided me with a fabulous job as an FPGA designer, making it possible for me to continue my work and study on hardware implementation in a broader range of applications. Junjie Yan July 15, 2007 ii Abstract This thesis investigates the hardware implementation and statistical analysis of new stream ciphers, Phelix and Salsa20. Both are candidates for the eSTREAM project, a project highlighting the state of stream cipher design and analysis. From a physical technology perspective, hardware implementation methodology consists of Application Specific Integrated Circuit (ASIC) design and Field Programmable Gate Array (FPGA) design. When high performance is required, an ASIC is typically chosen as the implementation platform. However, FPGA platforms have become increasingly popular due to their flexibility and a diminishing performance tradeoff as compared with ASIC technology. Following this trend we have developed two versions of Salsa20, one for deployment on an ASIC, the other for an FPGA. The cipher Phelix is studied for application to ASIC environment. Implementing a cipher requires detailed knowledge of the cryptographic algorithm itself, particularly the underlying arithmetic. In the case of Phelix and Salsa20, both of which are composed of several simple operations: 32-bit addition, bitwise addition (exclusive or) and rotation, the most important operation is the 32-bit addition, for which we have investigated multiple structures for the adders and compared them in both speed and area. Different adder architectures are chosen for different designs, and the basic criteria is the concern of speed or area the overall implementation consumes. Two structures for Phelix have been implemented, one is a high speed design and the other one is aimed at compactness. The simulation results shows that it consumes about 12,000 two-input NAND gates in the compact design and achieves more than one Gbps throughput in the high speed design. The speed of the compact design is 260 Mbps and the area of the high speed design is 64,200 two-input NAND gates. Up to four different structures are investigated for Salsa20 as extra considerations are given to the utilization of FPGA. The proposed VLSI implementations achieve a data throughput up to 4.8 Gbps, and a compact FPGA design uses 194 slices and 4 memory blocks in a Xilinx device. The proposed designs in the thesis serve mainly as a quick evaluation of their hardware performance; hence, further architectural optimizations are certainly possible. Security analysis is an important concern in cipher designs. Thus, we have applied iii certain statistical tests, which are publicly available in the NIST (National Institute of Standards and Technology) test suite to test various sequences produced by using the Phelix and Salsa20 algorithms. Since the test suite has not considered the relationship between key, IV, internal state and the keystream, we also applied six novel tests to examine the ciphers. Two strategies are employed to interpret the test results: the examination of the proportion of sequences that pass a statistical test and the distribution of P-values to check for uniformity. NIST gives the definition of P-value: the probability that a perfect random number generator would have produced a sequence less random than the sequence that was tested. The experimental results show that both Salsa20 and Phelix have passed the tests in NIST, considering that P-value less than 0.01 indicate a possible weakness. An easily understood deviation is observed in the correlation test for the last internal state (the state after 9 double rounds) and the keystream in Salsa20. However, how this could be exploited in an attack is an open question. iv Table of Contents Acknowledgements .............................................................................. ............................................. ii Abstract ........................................................................................................................................... iii Table of Contents .............................................................................................................................. v List of Figures .................................................................................................................................. ix List of Tables ........... ....................................................................................... ................................. xi List of Abbreviations ....................................................................................................................... xii Chapter I An Introduction to Cryptography ....................................................................................... I 1.1 Brief History of cryptography ...................................................................................................... I 1.2 Information Security ............. ............................. .......................................................................... 2 1.3 Background on Functions ..................................................................................................... 3 1.3.1 One-way Function ............................. ............................................... ......................... 3 1.3.2 Permutation .............................................................................. ............................... .. 3 1.3.3 Substitution ............................................................ ....................... ............................ 4 1.3.4 Exclusive OR ................................................. .................. ....................................... .. 5 1.3.5 Modular Addition ...................................................................................................... 5 1.3.6 Modular Multiplication .............................................................................................. 6 1.4 Symmetric-key/Private-Key Cryptography ................................................................................... 6 1.4.1 Block Ciphers ............................................................................................................ 7 1.4.2 Stream Cipher .................................................................................................... .. ..... 8 1.5 Asymmetric-key/Public-key cryptography ................................................................................. II 1.6 Cryptanalysis ............................................................................................. ................... ........ ..... 12 1.7 Summary .. ............................................ .................................................................................. ... 14 Chapter 2 Cipher Implementation .......... .......................................................................................... 15 2. 1 Software Implementation ................................ ... ........................................................................ 15 2.2 Hardware Implementation .......................................................................................................... 16 2.2.1 Methodology ........................................................................................................... 17 v 2.2.1.1 Traditional Methodology Used for Non-feedback Cipher Modes .................... 16 2.2.1 .2 ASIC Design Flow & FPGA Design Flow ..................................................... 18 2.2.2 Main Concerns in Hardware Implementation ........................... ................................ 21 2.3 Software/Hardware Codesign .................................................................................................... 25 2.4 Summary .................................................................................................... ....................... .......