Side Channel Analyses of CBC Mode Encryption
Total Page:16
File Type:pdf, Size:1020Kb
Side Channel Analyses of CBC Mode Encryption Arnold K. L. Yau Thesis submitted to the University of London for the degree of Doctor of Philosophy Information Security Group Department of Mathematics Royal Holloway, University of London 2009 Declaration These doctoral studies were conducted under the supervision of Professor Kenneth G. Paterson and Professor Chris J. Mitchell. The work presented in this thesis is the result of original research carried out by myself, in collaboration with others, whilst enrolled in the Department of Mathematics as a candidate for the degree of Doctor of Philosophy. This work has not been submitted for any other degree or award in any other university or educational establishment. Arnold K. L. Yau 2 Acknowledgements It was my great fortune to have met my supervisor Kenny Paterson during my undergrad- uate studies, who introduced to me the fascinating world of cryptography and security, and who subsequently encouraged me to pursue a doctorate in the subject. Over the course of my studies, his guidance, patience and encouragement have been invaluable and indeed indispensable. His uncompromising pursuit of conducting quality and thorough research has not only helped me to develop as a researcher, but has also taken the result of our research much further than I had anticipated. His depth and breath of knowledge in information security has been inspirational and influential for my career development. I wish to express my deepest gratitude to Kenny. I am also grateful to my academic advisor Chris Mitchell whose knowledge and expe- rience in international standards have given me a level of access to the standardisation process that would otherwise have been unavailable. Credits are also due to him for pro- viding the concept for an attack that has become a published paper and the basis of one of the thesis chapters. Special thanks to Nessim Kisserli for his help with the laboratory set-up. I wish him success in all his future endeavours. Thanks also to the UK's Engineering and Physical Sciences Research Council (EPSRC) and Hewlett-Packard Laboratories for their financial support, which smoothed the way to fulfilling my commitment to the requisite academic studies for a doctorate. Many thanks to the group of fellow researchers at Royal Holloway, with whom I have shared many a fond memory. In a variation to the Enigma Variations (and with apologies to Sir Edward Elgar), they are, in no particular order: F.Y.S., Y.P.W., &.G., Sergio, L.H.W., O.Z., H.S.L., Dao, P.J., S.A-R., T.Q., S.X., A.P., A.M., S.B., N.B., C.S.J., and J.F.D.I.. Finally, I must thank my parents who provided me with the ability, opportunity and freedom to pursue my interests. 3 Abstract A block cipher encrypts data one block at a time. For bulk data encryption, a block cipher is usually used in a mode of operation. Cipher Block Chaining (CBC) mode encryption is one of the most commonly used modes of operation. The security properties of CBC mode encryption have been studied extensively. One well-known attack against CBC mode encryption allows an attacker, with some restric- tions, to flip abitrary bits in the plaintext. In this thesis we present attacks using the bit flipping technique, in the presence of a side channel, to recover plaintext with varying degrees of efficiency. A side channel is a means by which confidential information about the plaintext is inadvertently leaked to an attacker, who then exploits the information to further his attacks. Error reporting is a common type of side channel in real cryptographic systems. We first examine the use of CBC mode encryption with some padding methods speci- fied by ISO standards, and analyse the security of those combinations in the presence of a padding oracle as a side channel. A padding oracle, first introduced in a paper by Vaude- nay, is a type of error oracle that reveals padding correctness information to an attacker. We show that, in a relaxed attack model in which initialisation vectors (IVs) are public, we can exploit a padding oracle to efficiently extract plaintext bits. We then show that in a stricter attack model (secret and random IVs), the padding schemes are still vulnerable to padding oracle attacks and therefore still weak. Putting theory into practice, we go on to investigate the applicability of error oracle attacks to IPsec, a suite of protocols commonly used to implement Virtual Private Net- works (VPNs) to secure the exchange of IP datagrams at the network layer. When IPsec is configured not to use integrity protection, a usage mode supported by IPsec standards, we show that a variety of efficient attacks are available for an attacker to recover plaintext datagrams, sometimes highly efficiently. By carefully manipulating encrypted IP data- grams, the attacker triggers the generation of Internet Control Message Protocol (ICMP) messages which he then intercepts. The ICMP messages, providing an error reporting side channel, contain plaintext information which can then be used to reconstruct plaintext datagrams in full. Finally, we present our view on the future of CBC mode encryption in the light of our attacks, and conclude with reflections on our experience of cryptography in theory and practice. 4 Contents 1 Introduction 14 1.1 Motivation and Contributions.......................... 14 1.2 Thesis Structure................................. 14 1.3 Publications.................................... 15 2 Preliminaries 16 2.1 Introduction.................................... 16 2.2 A High-Level Classification of Encryption Algorithms............ 16 2.2.1 Symmetric and Asymmetric Key Encryption Algorithms....... 16 2.2.2 Block Ciphers............................... 17 2.2.3 Stream Ciphers.............................. 17 2.2.4 Distinction between Block Ciphers and Stream Ciphers....... 18 2.3 Modes of Operation............................... 19 2.3.1 ECB Mode................................ 19 2.3.2 CBC Mode................................ 20 2.3.3 Other modes............................... 22 2.4 Integrity Protection and Authentication.................... 23 2.4.1 Hash Functions.............................. 24 2.4.2 Message Authentication Codes..................... 24 2.5 Attacks...................................... 25 2.6 Combined Modes of Operation......................... 26 2.7 Side channel Attacks............................... 27 2.7.1 Error Messages.............................. 28 2.7.2 Timing.................................. 31 2.7.3 Power Analysis.............................. 33 2.7.4 Electromagnetic Emanation Analysis.................. 34 2.7.5 Further Research............................. 36 2.8 Chapter Summary................................ 37 3 Padding Oracle Attacks on Proposed ISO/IEC 10116-1 38 3.1 Introduction.................................... 38 3.1.1 Padding Oracle Attacks......................... 38 3.1.2 ISO standards on Modes of Operation................. 39 3.1.3 Overview of Attacks........................... 39 5 CONTENTS 3.2 Attacking the Padding Methods of ISO/IEC 9797-1............. 40 3.2.1 The standard.............................. 40 3.2.2 Padding Method 1............................ 40 3.2.3 Padding Method 2............................ 41 3.2.4 Padding method 3............................ 41 3.3 Attacking the Padding Methods of ISO/IEC 10118-1............. 47 3.3.1 The standard............................... 47 3.3.2 Padding method 3............................ 47 3.4 Recommendations................................ 55 3.5 Chapter Summary................................ 56 4 Further Attacks on Proposed ISO/IEC 10116 57 4.1 Introduction.................................... 57 4.2 Overview..................................... 57 4.2.1 Attack Models.............................. 58 4.3 Analysis of Padding Method 3 of ISO/IEC 9797-1.............. 59 4.3.1 Review of Padding Method and Previous Attack........... 59 4.3.2 An Attack with Secret and Random IVs................ 60 4.3.3 Complexity and Impact......................... 62 4.3.4 Limitations................................ 63 4.3.5 Comparison................................ 63 4.4 Analysis of Padding Method 3 of ISO/IEC 10118-1.............. 64 4.4.1 Review of Padding Method and Previous Attacks........... 64 4.4.2 Attacking an Arbitrary Ciphertext Block............... 65 4.4.3 Attacking the Last Block(s)....................... 69 4.5 Dealing with Multiple IVs............................ 75 4.6 The Published ISO/IEC 10116:2006 Standard................. 77 4.6.1 Our Assessment of the Draft Standard................. 77 4.6.2 The Published Standard......................... 77 4.7 Chapter Summary................................ 78 4.8 Conclusions.................................... 78 5 Attacks in Theory and Practice: IPsec 80 5.1 Introduction.................................... 80 5.2 Internet Protocol................................. 80 5.2.1 IP Datagram Header........................... 81 5.2.2 ICMP................................... 83 5.3 IP Security.................................... 84 5.3.1 IPsec Architecture............................ 86 5.3.2 ESP.................................... 88 5.3.3 Evolution of ESP............................. 91 5.3.4 AH..................................... 93 6 CONTENTS 5.3.5 Internet Key Exchange Protocols: IKE and IKEv2.......... 94 5.3.6 Other IPsec Features........................... 96 5.3.7 Common Configurations......................... 98 5.3.8 IPsec Implementations.......................... 99 5.3.9 Critique and Attacks on IPsec....................