Provable Security in Practice: Analysis of SSH and CBC Mode with Padding
Total Page:16
File Type:pdf, Size:1020Kb
Provable Security in Practice: Analysis of SSH and CBC mode with Padding Gaven James Watson Technical Report RHUL{MA{2011{2 21 February 2011 Department of Mathematics Royal Holloway, University of London Egham, Surrey TW20 0EX, England http://www.rhul.ac.uk/mathematics/techreports Provable Security in Practice: Analysis of SSH and CBC mode with Padding Gaven James Watson 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 2010 Declaration These doctoral studies were conducted under the supervision of Prof. Kenneth G. Paterson. 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 Mathe- matics 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. Gaven James Watson June, 2010 2 Acknowledgements When I first started my PhD, I did not know where it would take me or even how much it was possible for me to achieve. I have been incredibly lucky to have worked on some interesting problems which have given birth to significant results. This has all been possible due to the excellent supervision of Prof. Kenny Paterson. His advice, constructive criticism and the odd amusing analogy have helped me, not only to develop as a researcher but have taught me a great deal about writing and presenting my work. What I have learnt will be invaluable in my future career, what- ever that may be. I also extend my gratitude to my advisor Dr. Steven Galbraith, whom I met during my Masters at Royal Holloway and without whom I would not have met Kenny. I am grateful to the EPSRC and BT whose financial support has kept me well fed and watered throughout the course of my PhD. Whilst working on SSH I had the good fortune to work with Martin Albrecht. His speedy implementation of our attacks on SSH and the new insight he brought to our research can be summed up in one word: awesome! During my time at Royal Holloway I have been lucky to meet and become friends with a vast array of people. There have been many great times shared in the office, on the tennis court or at home in the “Houses of Crypto”. Thanks to everyone who has made my time at Royal Holloway so enjoyable. A special thanks goes to Liz Quaglia and Sriram Srinivasan. Liz for being like a third sister to me and giving me somewhere to stay when I was homeless. Sriram for sharing his philosophies on life and being an education to live with. Finally I would like to thank my family: My sisters for setting the standards I’ve had to live up to, my nephews and niece for always being able to put a smile on my face and my parents for their unwavering support and guidance. 3 Abstract This thesis illustrates and examines the gap that exists between theoretical and practical cryptography. Provable security is a useful tool which allows cryptogra- phers to perform formal security analyses within a strict mathematical framework. Unfortunately, the formal modelling of provable security sometimes fails to match how particular schemes or protocols are implemented in real life. We examine how certain types of attack are not covered by the current techniques and show how this can be remedied by expanding existing security models to capture a much wider array of attacks. We begin by studying padding oracle attacks, a powerful class of side-channel, plaintext-recovering attacks introduced by Vaudenay. These attacks have been shown to work in practice against CBC mode when it is implemented in certain ways. In particular, padding oracle attacks have been demonstrated for certain im- plementations of SSL/TLS and IPsec. We develop new security models and proofs of security for CBC mode (with padding). These models show how to select padding schemes and in what order to combine CBC mode encryption, padding and authen- tication to provably provide a strong notion of security incorporating padding oracle attacks. Next we study the secure network protocol SSH. The first formal security analysis of the SSH Binary Packet Protocol (BPP) was performed by Bellare, Kohno and Namprempre. We present new plaintext-recovery attacks against the SSH BPP which partially invalidate this work. By examining why a combination of flaws in the basic design of SSH leads implementations such as OpenSSH to be open to our attacks, we are able to determine what features are missing from Bellare et al.’s original provable security analysis for SSH. Using this knowledge we define new security models that accurately capture the capabilities of real-world attackers, as well as security-relevant features of the SSH specifications and the OpenSSH implementation of SSH. Our new models then give us the ability to prove that SSH using counter mode encryption is secure against a much wider array of attacks, including our plaintext-recovery attacks. We conclude with further discussion of why the gap between theory and practice exists and suggest other ways of narrowing the gap. 4 Contents 1 Introduction 9 1.1 Motivation ................................ 9 1.2 Contribution ............................... 11 1.3 Publications................................ 12 1.4 OrganisationofThesis .......................... 12 2 Theoretical Preliminaries 15 2.1 CryptographicPrimitives . 15 2.1.1 BlockCiphers........................... 16 2.1.2 Encryption Schemes and Modes of Operation . 17 2.1.3 Message Authentication Codes . 23 2.1.4 EncodingSchemes ........................ 24 2.1.5 Authenticated Encryption with Associated Data . 25 2.2 ProvableSecurity............................. 26 2.2.1 AShortHistory ......................... 26 2.2.2 Practice-OrientedProvableSecurity . 27 2.2.3 Functions and Permutations . 28 2.2.4 Security Models for Symmetric Encryption . 31 2.2.5 Results for Generic Compositions . 44 3 Practical Preliminaries 48 3.1 NetworkProtocols ............................ 48 3.1.1 SSL/TLS ............................. 49 3.1.2 SSH ................................ 50 3.1.3 IPsec................................ 53 3.2 Side-ChannelAnalysis . 54 3.3 A Short History of Padding Oracle Attacks . 55 4 Formal Security Models for Padding Oracle Attacks 60 4.1 Introduction................................ 60 4.2 PaddingSchemes............................. 61 4.3 SecurityModels.............................. 62 4.3.1 One-waySecurity......................... 63 4.3.2 Left-or-Right Indistinguishability . 64 4.3.3 Real-or-Random Indistinguishability . 66 4.3.4 Find-then-Guess Security . 68 4.4 RelationsBetweenModels . 70 4.5 Summary ................................. 77 5 CONTENTS 5 Formal Security Analysis of CBC Mode Against Padding Oracle Attacks 78 5.1 Introduction................................ 79 5.2 FurtherDefinitions ............................ 80 5.2.1 Some Padding Schemes . 80 5.2.2 ArbitraryLengthCBCMode . 82 5.3 Padding Methods for Chosen-Plaintext Security . 83 5.3.1 Padding Methods With Invalid Paddings . 83 5.3.2 Padding Methods With No Invalid Paddings . 87 5.4 Constructions Achieving Chosen-Ciphertext Security . ....... 88 5.4.1 Encrypt-&-Authenticate . 91 5.4.2 Encrypt-then-Authenticate . 91 5.4.3 Authenticate-then-Encrypt . 95 5.5 Conclusion ................................ 101 6 Attacking SSH 104 6.1 Introduction................................ 104 6.1.1 OverviewofourAttack . 105 6.1.2 PreviousAttacksonSSH . 108 6.2 TheSSHBinaryPacketProtocol . 109 6.2.1 The OpenSSH Implementation of the BPP . 111 6.3 AttackingOpenSSH ........................... 113 6.3.1 Recovering14PlaintextBits . 113 6.3.2 Recovering32PlaintextBits . 114 6.3.3 IteratingtheAttack . 115 6.4 ExperimentalValidation . 117 6.5 Countermeasures ............................. 120 6.5.1 BPPRedesign .......................... 122 6.6 Conclusion ................................ 123 7 Formal Security Analysis of SSH 124 7.1 Introduction................................ 125 7.2 Existing Formal Security Analysis of SSH . 126 7.2.1 SSH-NPC and SSH-$NPC . 127 7.2.2 Further Provably Secure Variants . 129 7.3 ImprovingtheAnalysis . 129 7.3.1 OnlineEncryption . 130 7.4 ModellingtheSSHBPPanditsSecurity. 131 7.5 FurtherDefinitions ............................ 133 7.5.1 BuildingBlocks. 134 7.5.2 Encode-then-Encrypt-&-MAC. 137 7.6 SecurityModels.............................. 141 7.6.1 Chosen-PlaintextSecurity . 141 7.6.2 Chosen-CiphertextSecurity . 144 7.6.3 IntegrityofCiphertexts . 148 7.6.4 Security of Message Authentication Schemes . 150 7.7 SecurityAnalysis ............................. 151 6 CONTENTS 7.8 Conclusion ................................ 168 8 Conclusion 170 8.1 TheGapBetweenTheoryandPractice . 170 8.2 ClosingtheGap ............................. 171 Bibliography 173 7 Notation We denote here some of the notation that we shall use throughout this thesis. l,L The blocksize in bits/bytes respectively. xky The concatenation of the bit strings x and y. xy Shorthand for xky. xi The concatenation of the bit string x with itself i times. x[i] The i-th block of the string x. x[i...j] The concatenation of blocks i up to j of the bit string x. {0, 1}n All bit strings of length n bits. {0, 1}∗ All bit strings. x ⊕ y The bit-wise exclusive-or (XOR) of x and y. |x| The size of x in bits. 8x8 The size of x in bytes. 8j hiij The j-byte representation of integer i, where 0 ≤ i< 2 . x ←r X Denotes x being chosen uniformly at random from the set X. Exp An experiment. Adv An advantage