Reconfigurable Architectures for Cryptographic Systems
Total Page:16
File Type:pdf, Size:1020Kb
Imperial College London Department of Computing Reconfigurable Architectures for Cryptographic Systems Adrien Le Masle Submitted in partial fulfilment of the requirements for the degree of Doctor of Philosophy in Computing of Imperial College London and the Diploma of Imperial College London 12th January, 2013 Declaration I herewith certify that all material in this dissertation which is not my own work has been duly acknowledged. Adrien Le Masle 3 Abstract Field Programmable Gate Arrays (FPGAs) are suitable platforms for implementing cryp- tographic algorithms in hardware due to their flexibility, good performance and low power con- sumption. Computer security is becoming increasingly important and security requirements such as key sizes are quickly evolving. This creates the need for customisable hardware designs for cryptographic operations capable of covering a large design space. In this thesis we explore the four design dimensions relevant to cryptography { speed, area, power consumption and security of the crypto-system { by developing parametric designs for public-key generation and encryption as well as side-channel attack countermeasures. There are four contributions. First, we present new architectures for Montgomery multiplication and exponentiation based on variable pipelining and variable serial replication. Our implementations of these architectures are compared to the best implementations in the literature and the design space is explored in terms of speed and area trade-offs. Second, we generalise our Montgomery multiplier design ideas by developing a parametric model to allow rapid optimisation of a general class of algorithms containing loops with depen- dencies carried from one iteration to the next. By predicting the throughput and the area of the design, our model facilitates and speeds up design space exploration. Third, we develop new architectures for primality testing including the first hardware ar- chitecture for the NIST approved Lucas primality test. We explore the area, speed and power consumption trade-offs by comparing our Lucas architectures on CPU, FPGA and ASIC. Finally, we tackle the security issue by presenting two novel power attack countermea- sures based on on-chip power monitoring. Our constant power framework uses a closed-loop control system to keep the power consumption of any FPGA implementation constant. Our attack detection framework uses a network of ring-oscillators to detect the insertion of a shunt resistor-based power measurement circuit on a device's power rail. This countermeasure is lightweight and has a relatively low power overhead compared to existing masking and hiding countermeasures. Acknowledgements I would like to express my greatest gratitude to my supervisor Prof. Wayne Luk for pointing at the right direction and giving me invaluable guidance throughout my research at Imperial College London. I am grateful to my second supervisor Dr. Cristian Cadar for his insightful comments on my work. I would like to acknowledge Gary Chow for his help on designing the constant power frame- work presented in chapter6, in particular its proposed architecture for the power consumer. I am grateful to Professor Csaba Andras Moritz for giving me invaluable support and sug- gestions on my work, as well as all the people at BlueRISC: Sylvia Moritz, Kris Carver, Jeff Gummeson, Felipe Vilas-Boas and Alan Boulanger. I express my gratitude to my fellow colleagues in the Custom Computing Group of Imperial College London: Dr. Tobias Becker, Brahim Betkaoui, Thomas Chau, Kit Cheung, Gary Chow, Dr. Gabriel De Figueiredo Coutinho, Stewart Denholm, Dr. Andreas Fidjeland, Gordon Inggs, Maciej Kurek, Qiwei Jin, Nicholas Ng, Xinyu Niu, Dr. Timothy Todman, Dr. Anson Tse, and Dr. Brittle Tsoi for their friendly support. I would like to thank my family and my long-time friends Aur´elieVillaume, Emilie Dupetit- magneux, Yoann Gasque, and J´er^omeRaymond for their love and encouragement. Special thanks to all my UK friends for providing happiness and unforgettable memories to my PhD life, in particular: Nuri Purswani, Felipe Nascimento, Sofia Galligani, Sabine Wilke, Laith Sami, Magdalena Wiktoria Sliwinska, Ian Gladman, Cindy Bhagwandin, Florence Picoli, Tiffany Boutwood, Katy Evans, Joseph K. Ansah, Edward L. Albino Torres, and Kathleen Diane Gosling. The financial support of BlueRISC and UK EPSRC is gratefully acknowledged. 7 Contents Declaration 3 Abstract 5 Acknowledgements7 Contents 9 List of Figures 15 List of Tables 19 List of Algorithms 21 1 Introduction 23 1.1 Motivation....................................... 23 1.2 Contributions..................................... 25 1.3 Thesis organisation.................................. 28 1.4 Publications...................................... 29 2 Background 31 2.1 Field Programmable Gate Arrays (FPGAs)..................... 31 2.1.1 Device structure................................ 31 2.1.2 Tools...................................... 33 2.1.3 Applications.................................. 34 2.2 Symmetric-key cryptography............................. 36 9 2.2.1 Principles................................... 36 2.2.2 Cryptanalysis and brute-force attacks.................... 38 2.2.3 Data Encryption Standard (DES)...................... 40 2.2.4 Advanced Encryption Standard (AES)................... 43 2.3 Public-key cryptography............................... 48 2.3.1 Principles................................... 48 2.3.2 Requirements................................. 50 2.3.3 Key sizes................................... 51 2.3.4 RSA...................................... 51 2.4 Side-channel attacks................................. 54 2.4.1 FPGA power consumption.......................... 55 2.4.2 Power analysis................................ 57 2.4.3 Countermeasures............................... 59 2.5 Summary....................................... 60 3 Parametric Montgomery Multiplier Architecture 61 3.1 Motivation....................................... 61 3.2 Introduction to Montgomery Arithmetic...................... 62 3.2.1 Montgomery multiplication algorithm.................... 62 3.2.2 Hardware implementations of the Montgomery algorithm......... 66 3.2.3 Montgomery modular exponentiation.................... 69 3.3 Scalable Montgomery multiplier architecture.................... 70 3.4 Application to modular exponentiation....................... 74 3.4.1 Basic Montgomery exponentiator...................... 74 3.4.2 Adding interleaved exponentiation support................. 75 3.5 Design space exploration and comparison to existing architectures........ 78 3.6 Summary....................................... 86 4 Mapping Loop Structures onto Parametrised Hardware Pipelines 89 4.1 Motivation....................................... 89 10 4.2 Main idea....................................... 91 4.3 General bit by bit processing algorithm with loop-carried dependency...... 93 4.4 Mapping of the algorithm to the parametric hardware description........ 94 4.5 Modelling of the architecture............................. 98 4.5.1 Latency and throughput........................... 98 4.5.2 Frequency................................... 100 4.5.3 Area...................................... 101 4.5.4 Constraints.................................. 102 4.5.5 Throughput optimisation........................... 103 4.6 Optimising the design................................ 103 4.6.1 Determining the values of the parameters.................. 103 4.6.2 Design generation and optimisation process................ 105 4.7 Accuracy and design space exploration results................... 106 4.7.1 Accuracy of the model............................ 106 4.7.2 Design space exploration........................... 110 4.8 Summary....................................... 111 5 Novel Architectures for Probabilistic Primality Testing 113 5.1 Motivation....................................... 113 5.2 Probabilistic primality testing............................ 115 5.2.1 Fermat primality test............................. 115 5.2.2 Miller-Rabin primality test.......................... 116 5.2.3 Lucas primality test............................. 117 5.2.4 Combining tests................................ 121 5.3 Miller-Rabin primality test architecture....................... 122 5.4 Lucas primality test.................................. 123 5.4.1 Challenge 1: Jacobi symbol calculator................... 125 5.4.2 Challenge 2: Lucas sequence calculator................... 125 5.4.3 Challenge 3: scheduling........................... 128 5.4.4 Lucas prime tester.............................. 130 11 5.5 Speed/Area/Power trade-off of FPGA and ASIC implementations........ 131 5.5.1 FPGA implementation of our Miller-Rabin architecture.......... 131 5.5.2 FPGA and ASIC implementations of our Lucas architecture....... 132 5.6 Summary....................................... 136 6 Power Attacks Countermeasures Involving On-Chip Monitoring 139 6.1 Motivation....................................... 139 6.2 Power attack measurement settings......................... 141 6.3 On-chip power monitoring with ring oscillators................... 142 6.4 Constant power reconfigurable computing..................... 144 6.4.1 Principles................................... 144 6.4.2 On-chip power consumer........................... 147 6.4.3 Power controller................................ 147 6.4.4 Evaluation................................... 152 6.5 Detecting Power Attacks............................... 156 6.5.1 Principles..................................