Outsmarting Smart Cards
Total Page:16
File Type:pdf, Size:1020Kb
Outsmarting Smart Cards Gerhard de Koning Gans Copyright c Gerhard de Koning Gans, 2013 ISBN: 978-94-6191-675-4 IPA dissertation series: 2013-05 Typeset using LATEX The work in this thesis has been carried out under the auspices of the re- search school IPA (Institute for Programming research and Algorithmics) The graphical art of this work, except for the comic on page 25, is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ The remaining part of this work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Netherlands License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/nl/ Outsmarting Smart Cards PROEFSCHRIFT ter verkrijging van de graad van doctor aan de Radboud Universiteit Nijmegen op gezag van de rector magnificus prof. mr. S.C.J.J. Kortmann, volgens besluit van het college van decanen in het openbaar te verdedigen op donderdag 11 april 2013 om 15:30 uur precies door Gerrit Theodoor de Koning Gans geboren op 1 juni 1983 te Zwolle Promotor: Prof. dr. B.P.F. Jacobs Copromotor: Dr. F.D. Garcia Manuscriptcommissie: Prof. dr. G. Avoine Université Catholique de Louvain Prof. dr. ir. H.J. Bos Vrije Universiteit Amsterdam Dr. J.C. Hernandez-Castro University of Kent Dr. J.H. Hoepman Prof. dr. E.R. Verheul In memory of Johannes Pap Acknowledgements I would like to thank the many people that helped me directly or indirectly in the completion of my thesis. First of all, my gratitude goes to my direct supervisor Flavio Garcia for his guidance and pleasant assistance in my research. I would also like to thank my promotor Bart Jacobs. Bart has always been willing to share his clear view on a wide range of security related subjects. It encouraged me to develop my own critical view on new developments and applications in our information society, which helps me to this day. I thank Bart and Flavio for proofreading the early ver- sions of this thesis and providing me with constructive comments. Special thanks also go to the members of the reading committee, Gildas Avoine, Herbert Bos, Julio Cesar Hernandez-Castro, Jaap-Henk Hoepman and Eric Verheul, who helped im- proving this thesis a lot by their valuable and professional comments. Thanks to all the members of the “Mifare team” with whom I had the privilege to work on some exciting research. I am convinced that the dedicated and close collaboration between the team members has been one of the cornerstones of this success. We have defeated the Germans. I am grateful that the Digital Security group as a whole, with its dynamic compo- sition of members, was a nice environment for discussion and collaboration. Let me mention some people in particular. Ken Madlener, a good friend and colleague who means a lot to me. In our countless number of afternoon breaks we kept analyzing the (academic) world and motivated each other to keep on going. Another special friend and colleague I would like to thank here is Roel Verdult. Thank you for your close collaboration and friendship. Thanks go to my co-authors. Besides Flavio, Bart, Jaap-Henk, Eric and Roel it also has been a pleasure to work with Arjan Blom, Milosch Meriac, Ruben Muijrers, Erik Poll, Peter van Rossum, Joeri de Ruiter and Ronny Wichers Schreur. The past four years will remain in my thoughts as a period of new experiences, meeting inspirational people and a period in which I could develop myself in my profession. I would like to thank all the people who supported me in many ways over the years. It is impossible to name every person, but do know that I appreciated the support of many more people than mentioned here. I am really thankful for the opportunities that I have been given to increase my knowledge and skills. For the entire duration of my study I felt unconditionally supported by my family and close friends, without whom all of this would not have been possible. Gerhard de Koning Gans Arnhem, February 2013 Contents Acknowledgements vi 1 Introduction1 1.1 Smart cards and RFID............................3 1.2 Cryptography.................................5 1.2.1 Basic building blocks.........................6 1.3 Security protocols............................... 10 1.3.1 Security goals............................. 10 1.3.2 Formal verification and testing................... 11 1.4 Attack scenarios................................ 12 1.5 Outline and results.............................. 18 2 Tools for eavesdropping and analysis 23 2.1 Communication protocols.......................... 25 2.1.1 The physical layer.......................... 26 2.1.2 Encoding techniques......................... 27 2.1.3 Modulation techniques....................... 29 2.2 Proxmark III.................................. 31 2.2.1 Hardware board........................... 32 2.2.2 FPGA implementation........................ 34 2.2.3 Demodulation............................. 38 2.2.4 Other RFID research tools...................... 38 2.3 SmartLogic................................... 40 2.3.1 ISO/IEC 7816............................. 41 2.3.2 SmartLogic setup........................... 41 2.3.3 Hardware............................... 42 2.3.4 Software................................ 44 2.3.5 Other smart card tools........................ 45 2.4 Conclusion................................... 46 3 Case study: Smart cards in practice 49 3.1 An active man-in-the-middle attack on EMV............... 50 3.1.1 The EMV protocol.......................... 51 3.1.2 The attack............................... 52 3.1.3 Using the SmartLogic........................ 52 3.1.4 EMV attack implementation..................... 54 3.2 Security tokens for internet banking.................... 56 3.2.1 The e.dentifier2............................ 56 3.2.2 Attack on the USB-connected mode................ 57 3.3 Distance relaying............................... 59 3.4 Smart card emulation............................. 60 3.5 Concurrent SIM card sharing........................ 62 4 Dismantling Mifare Classic 65 4.1 Research context and related work..................... 66 4.2 Mifare Classic................................. 70 4.2.1 Communication layer........................ 71 4.2.2 Memory layout............................ 71 4.2.3 Commands.............................. 73 4.2.4 Anticollision and authentication.................. 73 4.3 Weak pseudo-random number generator................. 74 4.4 Recovering the command codes....................... 75 4.4.1 Keystream recovery......................... 77 4.4.2 Reading sector zero.......................... 80 4.4.3 Reading higher sectors........................ 81 4.4.4 Command codes........................... 81 4.5 Recovering the cryptographic system................... 83 4.5.1 Authentication protocol....................... 83 4.5.2 CRYPTO1 cipher........................... 85 4.6 Weaknesses and exploits........................... 89 4.6.1 LFSR state recovery......................... 89 4.6.2 LFSR rollback............................. 91 4.6.3 Odd inputs to the filter function.................. 92 4.7 Attacking Mifare Classic........................... 94 4.7.1 Attack one............................... 94 4.7.2 Attack two............................... 95 4.7.3 Multiple-sector authentication................... 95 4.7.4 Improved attacks........................... 96 4.8 Conclusion................................... 97 5 Dismantling iClass and iClass Elite 99 5.1 Research context and related work..................... 100 5.2 iClass...................................... 103 5.2.1 Functionality............................. 104 5.2.2 Authentication protocol....................... 106 5.3 iClass Standard................................ 106 5.3.1 Black box reverse engineering.................... 107 5.3.2 The function hash0 .......................... 114 5.3.3 Weaknesses in iClass Standard key diversification........ 115 5.3.4 Attacking iClass Standard key diversification........... 118 5.4 The iClass cipher............................... 119 5.4.1 Firmware reverse engineering................... 119 5.4.2 The cipher............................... 121 5.5 Weakness in iClass.............................. 123 5.5.1 Weak keys............................... 123 5.5.2 XOR key update weakness..................... 123 5.5.3 Privilege escalation.......................... 124 5.5.4 Lower card key entropy....................... 124 5.5.5 Key recovery attack on iClass Standard.............. 124 5.6 iClass Elite................................... 125 5.6.1 Key diversification on iClass Elite................. 126 5.6.2 Weaknesses in iClass Elite key diversification........... 128 5.6.3 Key recovery attack on iClass Elite................. 128 5.7 Conclusion................................... 130 6 A synchronizable forward-private low-cost RFID protocol 133 6.1 RFID next to barcodes............................ 135 6.2 Forward privacy................................ 136 6.3 The desynchronization problem....................... 137 6.3.1 Barcode analogy........................... 139 6.4 System model................................. 140 6.5 Security definitions.............................. 141 6.6 Protocol description.............................. 144 6.6.1 Second channel............................ 144 6.6.2 Tag and reader state......................... 145 6.6.3 Success, failure and synchronization run............. 146 6.6.4 Precomputation and state resolution...............