P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\titulka.jpg PV204 Security technologies LABS Introduction to smart cards •Petr Švenda svenda@fi.muni.cz •Faculty of Informatics, Masaryk University D:\Documents\Obrázky\services_icon_full_bw5.jpg P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg The masterplan for this lab •Secure channel and smartcard communication 1.Building Secure Channel protocol (together) –simple protocol ® design attack ® fix it ® iterate 2.Communicate with smart card (GPPro tool) –ATR, basic info, CPLC 3.Communicate with card programmatically –Java java.smartcardio.* or C/C++ PC/SC API –CPLC data –Obtain list of supported instructions from unknown card 3. | PV204: Introduction to smart cards P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg 1. Building Secure Channel protocol •Scenario: we like to transfer extrasupersensitive data between PC and smartcard •Simple protocol ® design attack ® fix it ® iterate •Participate in discussion –(Steps and solution will be published after the labs in IS) • | PV204: Introduction to smart cards P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg 2. Communicate with smart card (GPPro) •Contact PC/SC readers + cards •GlobalPlatformPro tool –https://github.com/martinpaljak/GlobalPlatformPro/releases –Basic smart card commands, sending APDUs –Management of GlobalPlatform cards (JavaCard) –Type gp --help for all functionality –We will use basic functionality now, rest next week – | PV204: Introduction to smart cards P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg gp --info •Obtain information about smart card –gp --info –Obtain ATR (Answer To Reset) –Parse using https://smartcard-atr.appspot.com/parse?ATR=xxx • •Who is probable manufacturer of card? •What is probable OS environment for this card? •Is it JavaCard? •What is card’s circuit serial number? •When was card produced? | PV204: Introduction to smart cards D:\Documents\Obrazky\question.png P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg gp --apdu APDU_in_hexa --debug •Send APDU command from command line •Try gp --info --debug –Can you spot APDU command to obtain CPLC info? •Send get CPLC APDU separately –gp --apdu 80CA9F7F --debug – •Can you relate card’s response data and gp --info? •What is response status word? • | PV204: Introduction to smart cards D:\Documents\Obrazky\question.png P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg 3. Communicate with card programmatically •SimpleAPDU project (IS, NetBeans) –Uses Java’s javax.smartcardio.* API –CardMngr.java – utility functions for card communication •Obtain list of available readers –List readers = TerminalFactory.getDefault().terminals().list(); •Connect to card –CardTerminal.isCardPresent(), CardTerminal.connect(“*”); •Obtain ATR: Card.getATR().getBytes() •Send APDU: –ResponseAPDU resp = CardChannel.transmit(apdu) – | PV204: Introduction to smart cards P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg 3. Communicate with card programmatically •Try to send get CPLC command –Pre-prepared in GetCPLCData() method –Necessary to set proper APDU •Parse response buffer • •Can you relate card’s response data and gp --info? •What is value of response status word? • • – | PV204: Introduction to smart cards D:\Documents\Obrazky\question.png P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Supported commands •Card responds to some APDU commands –Generic ones (e.g., get CPLC data) –Custom ones (what card’s owner wants) –Usually CLA/INS/P1 only (P2 sometimes) •How to get list of commands supported by a card? –Look into documentation / standard (e.g., SIM commands) –Try to probe card (limited number of possible commands) •Be careful – many failed attempts may block your card! | PV204: Introduction to smart cards P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Obtain list of supported commands •Write code that will try all combination if CLA/INS •Observe response codes •Make list of CLA/INS which returns interesting code •Analyse with curiosity! • | PV204: Introduction to smart cards