Efficient and Secure Implementations of Lightweight Symmetric Cryptographic Primitives
Total Page:16
File Type:pdf, Size:1020Kb
PhD-FSTC-2017-77 The Faculty of Sciences, Technology and Communication DISSERTATION Defence held on 29/11/2017 in Luxembourg to obtain the degree of DOCTEUR DE L’UNIVERSITÉ DU LUXEMBOURG EN INFORMATIQUE by Dumitru-Daniel DINU EFFICIENT AND SECURE IMPLEMENTATIONS OF LIGHTWEIGHT SYMMETRIC CRYPTOGRAPHIC PRIMITIVES Dissertation defence committee Dr Alex Biryukov, dissertation supervisor Professor, Université du Luxembourg Dr Benedikt Gierlichs Researcher, KU Leuven Dr Volker Müller, Chairman Associate Professor, Université du Luxembourg Dr Daniel Page Senior Lecturer, University of Bristol Dr Peter Y. A. Ryan, Vice Chairman Professor, Université du Luxembourg iii Abstract This thesis is devoted to efficient and secure implementations of lightweight symmetric cryptographic primitives for resource-constrained devices such as wireless sensors and actuators that are typically deployed in remote locations. In this setting, cryptographic algorithms must consume few computational resources and withstand a large variety of attacks, including side-channel attacks. The first part of this thesis is concerned with efficient software implementations of lightweight symmetric algorithms on 8, 16, and 32-bit microcontrollers. A first contribution of this part is the development of FELICS, an open-source benchmarking framework that facilitates the extraction of comparative performance figures from implementations of lightweight ciphers. Using FELICS, we conducted a fair evaluation of the implementation properties of 19 lightweight block ciphers in the context of two different usage scenarios, which are representatives for common security services in the Internet of Things (IoT). This study gives new insights into the link between the structure of a cryptographic algorithm and the performance it can achieve on embedded microcontrollers. Then, we present the Sparx family of lightweight ciphers and describe the impact of software efficiency in the process of shaping three instances of the family. Finally, we evaluate the cost of the main building blocks of symmetric algorithms to determine which are the most efficient ones. The contributions of this part are particularly valuable for designers of lightweight ciphers, software and security engineers, as well as standardization organizations. In the second part of this work, we focus on side-channel attacks that exploit the power consumption or the electromagnetic emanations of embedded devices executing unprotected implementations of lightweight algorithms. First, we evaluate different selection functions in the context of Correlation Power Analysis (CPA) to infer which operations are easy to attack. Second, we show that most implementations of the AES present in popular open-source cryptographic libraries are vulnerable to side-channel attacks such as CPA, even in a network protocol scenario where the attacker has limited control of the input. Moreover, we describe an optimal algorithm for recovery of the master key using CPA attacks. Third, we perform the first electromagnetic vulnerability analysis of Thread, a networking stack designed to facilitate secure communication between IoT devices. The third part of this thesis lies in the area of side-channel countermeasures against power and electromagnetic analysis attacks. We study efficient and secure expressions that compute simple bitwise functions on Boolean shares. To this end, we describe an algorithm for efficient search of expressions that have an optimal cost in number of elementary operations. Then, we introduce optimal expressions for first-order Boolean masking of bitwise AND and OR operations. Finally, we analyze the performance of three lightweight block ciphers protected using the optimal expressions. To my family. vii Acknowledgements This doctoral thesis would not exist without the support, help, and encouragement of many people. It is a pleasure for me to express my gratitude to all of them. I am deeply thankful to my supervisor, Alex Biryukov. He gave me the opportu- nity to pursue a Ph.D. in his research group and guided me with patience through my studies. I highly appreciate the freedom and flexibility that Alex offered to me in addition to his wise advice. I am very grateful to Johann Großschädl for his enthusiastic support, the in- teresting discussions we had, and the wonderful time I spent working with him on interesting research problems. Johann introduced me to the design of masking coun- termeasures and taught me how to write papers. I also thank him for proofreading this thesis and suggesting many corrections. I am also grateful to Ilya Kizhvatov, who was my mentor during an exciting internship at NXP Semiconductors. He provided me an industrial view on side- channel attacks and generously shared his expertise with me. I enjoyed very much our collaboration and the interaction with the highly experienced researchers and engineers from NXP Semiconductors. I warmly thank Yann Le Corre and André Stemper for the endless engineering discussions we had and their technical assistance. I also owe gratitude to Fabienne Schmitz, Isabelle Schroeder, and Natalie Kirf for their help with many administrative tasks. I am lucky to have had the opportunity to write papers together with out- standing researchers: Alex Biryukov, Johann Großschädl, Ilya Kizhvatov, Dmitry Khovratovich, Yann Le Corre, Léo Perrin, Aleksei Udovenko, and Vesselin Velichkov. I would like to thank Benedikt Gierlichs, Volker Müller, Daniel Page, and Peter Ryan for serving on my defence committee and providing valuable comments on my thesis. Many thanks to my current and former colleagues from the University of Lux- embourg for creating a good working environment: Patrick Derbez, Daniel Fehrer, Johann Großschädl, Dmitry Khovratovich, Yann Le Corre, Zhe Liu, Léo Perrin, Ivan Pustogarov, Sergei Tikhomirov, Aleksei Udovenko, Praveen Vadnala, Vesselin Velichkov, and Srinivas Venkatesh. I am thankful to all my friends from Luxembourg for the nice time and good mem- ories. I am grateful to my family for their unconditional support and encouragement through all these years. The work described in this thesis would not have been possible without the funding from the Fonds National de la Recherche (FNR) through the CORE project ACRYPT (ID C12-15-4009992). Contents 1 Introduction 1 1.1 From Classical to Modern Cryptography . 2 1.2 Modern Cryptography . 3 1.2.1 Security Services . 3 1.2.2 Kerckhoffs’ Principle . 4 1.2.3 Adversarial Models . 5 1.3 Cryptographic Toolkit . 6 1.3.1 Symmetric Cryptography . 6 1.3.1.1 Block Ciphers . 6 1.3.1.2 Stream Ciphers . 7 1.3.1.3 Hash Functions . 8 1.3.1.4 Message Authentication Codes . 8 1.3.1.5 Authenticated Ciphers . 8 1.3.2 Asymmetric Cryptography . 8 1.3.2.1 Public-Key Encryption . 9 1.3.2.2 Digital Signatures . 9 1.3.2.3 Public Key Infrastructure (PKI) . 9 1.3.3 Symmetric vs. Asymmetric Cryptography . 9 1.4 Implementations . 10 1.4.1 Hardware Implementations . 11 1.4.2 Software Implementations . 11 1.4.3 Hardware vs. Software Implementations . 12 1.4.4 Implementation Efficiency . 12 1.4.5 Metrics for Hardware Implementations . 12 1.4.6 Metrics for Software Implementations . 13 1.4.7 Optimization Strategies . 14 1.5 Implementation Attacks . 15 1.5.1 Short History . 15 1.5.2 Classification . 18 1.6 Side-Channel Attacks . 20 1.6.1 Power Analysis Attacks . 20 1.6.2 Electromagnetic Analysis Attacks . 21 1.6.3 Attack Toolkit . 21 1.6.3.1 Measurement Setup . 22 x Contents 1.6.3.2 Signal Processing . 24 1.6.3.3 Attack Algorithms . 25 1.6.3.4 Metrics . 28 1.6.3.5 Tools . 29 1.7 Countermeasures against Side-Channel Attacks . 30 1.7.1 Masking . 31 1.7.1.1 Boolean Masking . 32 1.7.1.2 Provable Security . 32 1.7.2 Leakage Detection Tests . 33 1.8 Internet of Things (IoT) . 33 1.8.1 Constraints . 34 1.8.2 Lightweight Cryptography . 34 1.8.3 Device Types . 35 1.8.3.1 Lower Bound for the Computational Power of IoT Devices . 35 1.8.3.2 Upper Bound for the Computational Power of IoT Devices . 36 1.8.3.3 Middle Range IoT Devices . 36 1.8.4 Threat Model . 36 1.9 Motivation . 37 1.10 Research Contributions . 37 1.10.1 Part I – Efficient Implementations . 38 1.10.2 Part II – Side-Channel Attacks . 39 1.10.3 Part III – Side-Channel Countermeasures . 40 I Efficient Implementations 41 2 Fair Evaluation of Lightweight Cryptographic Systems 43 2.1 Introduction . 44 2.1.1 Research Contribution . 45 2.2 Related Work . 45 2.2.1 BLOC Project . 45 2.2.2 eBACS Project . 46 2.2.3 XBX Project . 47 2.2.4 ATHENa Project . 48 2.2.5 ECRYPT II Project – Performance Evaluation on ATtiny45 . 48 2.3 Motivation . 49 2.4 Goals . 50 2.5 Benchmarking Framework . 51 2.5.1 Structure . 51 2.5.1.1 Core Module . 51 2.5.1.2 Block Ciphers Module . 53 2.5.1.3 Stream Ciphers Module . 54 2.5.1.4 Authenticated Ciphers Module . 55 Contents xi 2.5.1.5 Hash Functions Module . 56 2.5.2 Export Formats . 57 2.6 Target Devices . 57 2.6.1 8-bit AVR ATmega128 Microcontroller . 58 2.6.2 16-bit MSP430F1611 Microcontroller . 58 2.6.3 32-bit ARM Cortex-M3 Microcontroller . 59 2.7 Metrics . 59 2.7.1 Code Size . 59 2.7.2 RAM . 60 2.7.3 Execution Time . 61 2.8 Summary . 61 3 Fair Evaluation of Lightweight Block Ciphers 63 3.1 Introduction . 63 3.1.1 Our Contributions . 65 3.2 Benchmarking Framework . 66 3.2.1 Usage Scenarios . 67 3.2.1.1 Scenario 1: Communication Protocol . 67 3.2.1.2 Scenario 2: Challenge-Response Authentication . 68 3.3 Analyzed Ciphers . 68 3.4 Results . 74 3.4.1 Methodology . 75 3.4.2 Discussion of Results . 77 3.4.3 Comparison with other Benchmarking Results . 81 3.5 Summary .