Breaking Korea Tansit Card With Side- Channel Analysis .

Transcription

Breaking Korea Tansit Card with SideChannel Analysis Attack- Unauthorized recharging Tae Won Kim1,2, Tae Hyun Kim1, and Seokhie Hong212SNTWORKS, Gyeonggi-do, South KoreaCenter for Information Security Technologies,Korea University, Seoul, South KoreaRecent side-channel attacks have shown that thesecurity of smart devices are a matter of serious concern.In this paper, we target a real-world smartcardembedding cryptographic features. We completelyrestored the secret key in the device using the side-channelanalysis attack, although this employs somecountermeasures against side-channel attacks. Weprovide details on how to extract the secret key in anenvironment that gives the attacker only publicinformation of the target device. As a result of our attack,128-bit secret key for mutual authentication requiredwhen a legitimate user uses functions served by card suchas payment, refund, recharging et al. can be completelyrestored. Finally, with the restored key we are able to freerecharge balance on the card as much as attacker wantwithout spending any money.Keywords: smartcard, side channel analysis attack,Triple DES1I. IntroductionSide-channel analysis attacks are a serious threat to thesecurity of embedded devices, such as credit card, mobilephone SIMs. Moreover, due to the increase in Internet ofThings (IoT) market, countermeasures against side channelanalysis are widely studied.Core idea of Side-channel analysis attacks is to exploit keydependent signals, such as timing [1], power consumption [2],and electromagnetic radiation [3,4] that was evaluated duringthe execution cryptosystem in device, by measuring physicalquantities. Initially, P. Kocher et al. introduced the two types ofside-channel attack: simple power analysis attack (SPA),differential power analysis attack (DPA) [1,2]. Many relatedattacks [5-11] and countermeasures [12-17] have been studiedwidely until now.Power analysis attacks are one of the most powerful andefficient techniques among the these attacks. Especially,Correlation Power Analysis (CPA) attacks can retrieve secretinformation from the statistical tool such as correlationcoefficient by using power consumption traces [7].Electromagnetic Analysis (EMA) attacks are a powerful andpopular method as much as the DPA. These attacks can beapproached in the same manners as DPA. Note that the EMAdo not need to connect the ground for measurement of sidechannel signals as opposed to DPA. Thus, electromagneticanalysis attacks more widely have been used than poweranalysis attacks.

Beyond theoretical analysis and experiment with Deviceunder Test, practical investigation with respect to real-worlddevices was showed by academic research and relevant toindustry [18-23]. In [18], they presented how the KeeLoq,implemented in hardware and software, can be broken frompower analysis attack. As presented in [19-21], these papersoffer results of attack for new target (Xilinx Virtex FPGA,braking system in a car laptop PC respectively). It means thatside-channel analysis attacks can be applied to various targetusing cryptography system. Investigations, having a significantimpact on the real-world attack for the smartcard are shown in[22, 23]. Both results described how to recover the full-key ofcrypto algorithm equipped in target devices using poweranalysis attacks on commercial smartcard.In this paper, we specifically present breaking the Koreatransit card under black box attack environment using poweranalysis attacks. Although the target device employedcountermeasure that can be typically classified as hiding [8, 1315] against SCA attacks, we could retrieve the full key by usingconventional power analysis attacks. As a result of our attack,we could increase the balance in the transit card withoutrequired any money by recharging with restored secretinformation. This was demonstrated by simulation in practicewith capturing a video. We provide in detail how to set up foran attack environment and an attack for recovering the key anddesign an unauthorized recharging system in terms of our targetdevice.This paper is organized as follows: First, we describeinformation about our target device such as authenticationprotocol and cryptosystem etc. in Sect. II. Section III givesmethods and approaches for attacking in black boxenvironment including know-how from many trials and errors.Section IV shows practical results of power analysis attackbased on described in Sect. III. We present designing an illegalrecharging system and simulate practically it in Sect. V. Finally,Sect. VI concludes the paper.This not only can pay the toll fees when passing the all tollgates across the country but also can be used to pay in cafeteriaand convenience store on the freeway service area.This card is a contact IC smartcard communicating with acard reader by direct physical contact. According to data sheet,the contact IC card interface supports an International Standardunder ISO/IEC 7816. And it has been specified a KS X 6924Korean industrial standard approved by Korean Agency forTechnology and Standards (KATS) in 2014 for authenticationprotocol, command and cryptography algorithm.For data encryption, signature/verification and authentication,the target smartcard runs a hardware based symmetric-keycryptosystem which employs hiding countermeasure to thwartpower analysis attack in hardware level.2. Authentication protocolOur goal is to recharge balance of a pre-paid transit card inan unauthorized manner. Therefore, we need to examine theentire charging phase when balance stored in the card isincreased through authentication. We can profile usefulinformation for side-channel analysis attacks by analyzing theauthentication protocol for recharging process. It is animportant task to determine target points for side-channelanalysis attacks and indicate location of target operation in apower trace. The following figure is the authentication protocolfor recharging the balance.II. Target Device DetailsIn this section, we present specifications required to attack atarget device through side-channel analysis attacks. We noticethat described all information in this section are based on publicinformation. (see [24, 25] for more information).1. Transit CardOur target device is a pre-paid transit card for the freeway inKorea almost one out of three cars that passes freeway used thiscard. Over 800 million cards were issued and used, in July2016.2Figure 1. Authentication Protocol for Recharging theBalance.Entities in the above authentication are the smartcard andSecure Access Module (SAM).The first step towards recharging is that given rechargingcommand by user, the smartcard generates a session keythrough cryptosystem with random numbers obtained

internally and a card key stored in ROM. The session key isused as a one-time key generated randomly in every event. Tobe an authorized entity, the card generates Signature-1 with thesession key and the unique card information. After then, thisinformation that was used to generate Signature-1 is send to theSAM.Since the authentication mechanism in our target device isbased on symmetric key cryptography, to verify givenSignature-1, the identical key that was used to generate thesignature in the smartcard is needed. There is a unique card keyfor each card that was generated by cryptosystem using theSAM’s mater key and each card information. Thus, the SAMcan generate and share the card key using the received card.After that, the SAM generates signature and verifies its validitythrough comparing with the received signature.The subsequent authentication procedure is identical butreverse entities in signature and verification to mutuallyauthenticate each other as presented in Figure 1. After theauthentication protocol is completely finished, the balance canbe increased.64-bit keys (Kenc-Kdec-Kenc) respectively.As depicted in Figure 3, the crypto-function consists of twoT-DES operations with one identical 128-bit key and 128-bitinput plaintext. The input plaintext is divided into two 64-bitblocks (the most significant 64-bit and the least significant 64bit). The XOR of two 64-bit blocks is fed into one T-DES andthe least significant 64-bit block is used as the other input of TDES. The ciphertext is generated by simply concatenating twoT-DES output.Figure 3. Crypto-function.III. Approaches and Methods3. CryptosystemFigure 2 shows the cryptosystem used in the authenticationprotocol. It is enough to focus on the following cryptosystembecause it is the only method used in our target device.The cryptosystem essentially includes a crypto-function thatprocesses data blocks of 128-bit using a cipher key with lengthsof 128 bits. And it is operated in Cipher Block Chaining (CBC)mode with an initialization vector (IV) which fixed to aconstant value 0128. If necessary, the last block is padded with0x8000.00 to be multiple of 128-bit.In the authentication scheme, the most significant 32-bit ofthe last ciphertext block becomes the signature value.Figure 2. Cryptosystem.In the following, we focus on the crypto-function included inthe cryptosystem. Its core engine for data encryption is theTriple DES (T-DES) where processes three successive DESinstances in encryption-decryption-encryption order using two3In this section, we describe an attack scenario for our finalgoal - illegal recharging of balance. It starts by clarifying thesecret information which we need to recover through sidechannel analysis attacks. Also, we present a methodology forextracting this information. In our attack, we employ poweranalysis attacks as side-channel analysis attack.This includes setup for an experimental environment torecovering the secret information being able to generate a validsignature. We describe specific step by step procedure andknowhow obtained by many trials and errors.1. Attack ScenarioOur attack procedure can be divided into two parts. The firstpart is to recover secret information of the target card andsecond is to recharge the balance in the card.We have to note that which information is needed to disguiseas a valid user. Recall that the authentication protocol as statedin Sect.II-2. To recharge, the card verifies the validity ofSignature-2 generated by the SAM. Therefore, it suffices for anattacker to generate a signature that passes authentication in thecard. It means that the attacker needs the card key to generate avalid Signature-2. In other word, if an attacker recovers the cardkey stored in the ROM of the target card, the attacker candisguise as a valid user by sending a signature that passesverification.

2. Side-Channel Attack on Transit CardFrom now on, we focus on recovering the card key. The firstthing is to consider the possibility of exploiting power analysisattacks for the card key. Generally, in power analysis attacks, itrequires repetitive cryptographic computations with a fixedsecret key and varying plaintexts. Fortunately, this environmentcan be found in the authentication protocol. When the transitcard generates a session key, the cryptosystem operates withour targeted card key and a random number as an inputplaintext. Also as the attacker sends the recharging commandto the card, it carries out these operations. This facilitates for anattacker to obtain as many side-channel signals that he canmount side-channel analysis attacks.A. Measurement SetupTo recover information on the corresponding card key in thetarget device, we exploit power consumptions as physicalleakage.communication with a PC. Acquisition BoardTo measure power consumptions exploited in our attack, thetransit card has an output pin on the microcontroller. To make itpossible we fabricate an intermediary board that connect thetransit card to a reader. It is equipped with a 47-Ohm resistorinserted between the GND pin on the transit card and the groundline on a reader. Also, it supports an internal I/O channel forcommunicating. We will use the I/O as a trigger signal in order tosynchronize with an oscilloscope. Spectrum AnalyzerInevitably physical leakages such as power consumption,electromagnetic contain the noise. Thus, power consumptionsmeasured via an acquisition board sent to a pre-processing phasein order to increase Signal-to-Noise Ratio (SNR).The most popular method to reduce the amount of noise in thepower trace is filtering that aims at selecting the frequencies inwhich the success rate of the attack improves such as low-pass,high-pass, and band-pass filter [26-28].In view of this, a spectrum analyzer seems to be a good tool. Itprocesses power traces by using a band-pass filter centered at acarrier frequency. And then the signal is demodulated. Thisprocesses are performed in hardware level. Thus, a spectrumanalyzer comes at no additional cost for filtering phase and it leadsto important advantage from attack performance perspective. Digital OscilloscopeFigure 4. Measurement setup.The exhibit above depicts our setup for measuring powerconsumption signal of the transit card. These composed of fivehardware devices and a customized software controllingdevices. PCThis controls a card reader and an oscilloscope using acustomized software. PC sends commands to the card reader andreceives the corresponding responses from the card through thecard reader. Measured side-channel signals using theoscilloscope are stored in a hard disk by the PC. Card ReaderOur targeted transit card communicates with the PC through asmart card reader with ISO/IEC 7816-3 compliant electricalinterface to exchange commands and data. Card readers areequipped with a USB interface or an RS-232 serial port for4To sample the leakage measurements, we use a digitaloscilloscope which is LeCroy WaveRunner with maximumcapabilities 4GHz and 40GS/s and providing 8-bit samples. It isconnected to TCP/IP network to remotely control by the PC.B. Locate the point of T-DES Execution in MeasurementWe are in an attack environment without any information ofinternal implementations of the transit card such as operationof the system on which the cryptosystem is implemented,countermeasures against side-channel attacks and etc. So,guessing the location of cryptosystem where an attacker targetsshould be involved in the measurement phase before the keyrecovery phase.To do so, we first mounted a correlation based attack usingplaintexts and ciphertexts (here, signatures). Intuitively, itallows an attacker to detect parts relating to plaintexts andciphertexts in a power trace. This is based on the fact that whena crypto algorithm operates in the cryptosystem, plaintext, oneof the input parameters must be transferred to cryptosystemengine by data bus. When loading plaintext, power

consumption depends on the plaintext data. In this case,correlation coefficients are higher than that of cryptographicalgorithm in general due to the effect of countermeasures.Thus, by calculating correlation coefficient between inputplaintexts (or output ciphertexts) and power traces, we cancheck where the targeted cryptographic algorithm operates in atrace. It is important to locate the target operation since it canreduce the number of trials and errors.C. Key recoveryNote that we already mentioned that the target operation in theauthentication protocol for recharging is Sessionkey-1generation. Also, we described the mechanism for generatingSessionkey-1 in Sect. II-2. By using this information, we willpresent how to retrieve the card key through power analysisattacks in this subsection.The target operation involves two T-DES encryptions usingthe identical keys for generating Sessionkey-1. Hence ourultimate target is T-DES implemented with two 64-bit keys(defined Kenc, Kdec). A problem recovering keys of T-DESusing power analysis attacks boils down to attacking the firsttwo successive single-DES instances among three.For attacking the single-DES instance, we employ a divideand-conquer strategy which is generally used in most of thedifferential power analysis (DPA) attacks. In the divide phaseof the attack, an attacker targets the first round of the singleDES instance and recovers each 6-bit key portion of the 48-bitroundkey (usually called as sub-key). And then in the conquerphase, this information is gathered to reveal the 48-bit roundkey.In other word, it yields information about one roundkeyrecovered by combining the other recovered 6-bit keys in oneDPA attack. After this work, the attacker needs an additionalstep to obtain the remaining the information for the first DESkey i.e., Kenc. So, we apply the DPA on remaining all rounds ofthe DES.Next, we calculate all intermediate values of the full sixteenrounds of DES by guessing the remaining 8 bits of 56-bit Kencwith the restored 48-bit round key and then perform the DPAattack on every rounds.When guessing the remaining 8 bits of Kenc, we are able tofind 14 peaks at each round (Round 2-16). Even though itsuffices to recover the next roundkey for full key recovery, weperform the DPA attack on all remaining rounds for accuracydue to black-box attack environment.To recover the 64-bit full key of the single-DES, i.e., Kenc, itrequires two DPA attacks and total four DPA attacks to revealthe 128-bit card key, i.e. Kenc, Kdec. The following figurerepresents the flow of our attacks.5Figure 5. Block level description of key recoverymechanismIt should be noted that although we simply present here attackprocedure, in practice it might be too costly to perform preprocessing by applying alignment, signal compression, correcterrors for every DPA attack and so on.To identify validity of the recovered card key, an attackercompares a valid signature with the signature generated by theobtained card key and public card information.D. Alignment taskIn the black-box attack environment, the success of the attackgives us fruitful information for the secret key and the locationof the target operation at once. So, this work needs to precedevarying-stage processing, associated with each other asdepicted in the blow.Figure 6. Processing sequence for a key recovery attackAlignment in our attack has a lot of difficulties. One of themost difficult problems is finding a good reference pattern thatcan be commonly found in every power trace. This is due tohiding countermeasure such as random clock, random delay,adding intentional noise and so on in the hardware level.Hiding countermeasures disturb a successful alignment andreduce SNR. It would result in failure in recovering the secretkey. So, we use a local alignment strategy and the alignmentstep is repetitively performed for every the DPA attack by asimple trial and error using a local alignment.As the result of reduced SNR by hiding countermeasures,involving hardware DES engine and so on, we need theextremely large number of power traces to mount an effectiveDPA attack. It means that she needs a more elaborate alignment

process to increase SNR. Indeed, one or two sample points ofmisalignment lead to attack failure in our experiment.E. Correction of ErrorsIn our attack environment, the biggest problem in keyrecovery aspect is that we cannot determine whether the foundkey is correct in each attack session or not. We only canconfirm the validity of the restored key after all four DPAattacks are completely ended. Here, we note that every attackis dependent to each other. Thus, performing the next DPAattack without an error correction of the previous DPA attack,constitutes error propagation that raises failure of the remainingDPA attacks regardless of factors; the number of acquiredpower traces, SNR of the acquired traces etc. This errorpropagation increases the number of key candidatesexponentially. Thus, the attack might succeed but with lots ofcomputation that could not be finished in practical time.Therefore, correction of errors that may be yield by DPAattack is a very crucial part of the whole 128-bit key recoverymechanism.In the correlation power analysis attack (employed as DPAattack), the attacker classifies key candidates as the right key ifcorrelation coefficient value is higher than given noise level1.Therefore, an error correction needs to be set in the context ofeliminating incorrect keys having correlation higher than noiselevel.To correct the errors, we employ the BS-CPA (Built-inDetermined Sub-key Correlation Power Analysis) proposed byKomano et al. [29]. This is an enhanced CPA method toincrease the SNR in the hardware implementation where themultiple Sbox outputs are processed in parallel. The main ideaof BS-CPA is to decrease the switching noise in powerconsumption dependent on target secret information, by builtin the determined sub-key when recovering the next sub-key.This is indeed true for the reason that, when an attacker finds asub-key targeting a specific Sbox, where multiple Sbox outputsare processed in parallel, portions of power consumptionrelated to all other Sboxes are independently distributed, andthey constitute switching noise.In our attack, we utilize the idea described above and modifythe BS-CPA in accordance with our purpose for correction oferror. The modifying method for correction of error for onesub-key performs the following steps:- Enumerate candidates of 6-bit sub-key having correlationcoefficient value higher than given noise level by performingthe classical CPA on a Sbox.1A theoretical noise level is bounded by 4/sqr(n), where sqr() is thesquare root function and n is the number of traces.6- For each sub-key candidates, built-in and then perform theCPA on other Sboxes- Observe the seven peaks (corresponding the other sevenSbox) of CPA results for each sub-key candidate and checkwhether the rank maintains for each Sbox.- Count which sub-key candidates lead to maximum peak.- Regard candidates as more promising key by higher numberof counts- Eliminate key candidates if a count equals to zero.- In the same manner, recursively built-in other sub-key andreduce the candidates.- Utilize the reduced key candidates for the next DPA attack.The method devised for the error correction applying the BSCPA can expect more precise results since 12-bit CPA is moreenhanced than 6-bit CPA. Thus, for a correct key guess,although its peak value is not the highest in 6-bit CPA, the effectof error correction appears through 12-bit CPA by change inrank close to right key guess. Also, if correct key guess has thehighest peak value, its rank will remain unchanged.By using this effect, we expect to reduce the number ofenumerated key candidates and hence increase the efficiencyof DPA attack for recovering the full key in single-DESinstance, by prohibiting error propagation.IV. Attack in PracticeIn this section, we show the experimental results using theapproach and method based on Sect. III. To extract secretinformation from acquired power traces, we only used publicinformation obtained from statements in the publicdocumentation and card response values.Note that we did not specify all of its trials and errors but onlyones that lead successful result.1. Visual InspectionThe visual inspection phase starts with obtaining the targettrace from our target device; this is depicted in Figure 7.It represents power consumption corresponding toSignature-1 generation in the whole process of recharging. Itleads to the six T-DES operations, where the first two forSessionkey-1 generation, the remaining four for Signature-1generation, by analyzing the recharging protocol.

Figure 7. Full Trace.By comparing numerous power traces, we can deduce thathiding methods are equipped in our target device. Hidingtechniques in the hardware level such as random delay, randomcurrent, and random clock, hides key-related signals in theamplitude domain and disturbs the correct alignment in thetime domain. An evidence can be found in Figure 9. Whenacquiring power traces, we triggered with I/O signal at thesame point for every time, to obtain aligned power trace havingstarting point. However, we notice that the starting point wetargeted is different for each measurement (see Figure 9 (a)).Also, even though the measured traces are aligned with thesame starting point, we observed that the length of one DESinstance varies every execution (see Figure 9 (b), (c)).Thanks to that information, we can easily identify thelocation of the six T-DES operations in the power trace byfinding the six similar patterns as displayed on Figure 7. Also,it is well represented by feature typically known that powerconsumptions by cryptographic hardware engine with higherclock speed are higher than one by the smart card CPU.Figure 9. Countermeasure effects in the measurementsFigure 8. Zoom on the single T-DES.Figure 8 shows a zoomed view of the single T-DESoperation. To be precise, the whole interval referred to thesingle T-DES as in the above figure, is not leakage onlydepending on the single T-DES but leakage of T-DESoperation and some related operations.Since three single-DES instances are processed sequentially(Encryption-Decryption-Encryption), we can naturally predictthree distinct patterns and time for the single DES instance.This is reflected in deciding the location of the target operationin order to perform the key recovery attack with the CPA.As it turned out, a location that fulfilled these conditionsthrough the visual inspection could not be found in our targetoperation. This result gives an important thing to an attackerthat although visually inspecting a power trace is plausible, it isno more than pure speculation, not a significant information.Another important property is observing the effect ofimplemented countermeasures against power analysis attack.7These impose preprocessing methods on the attacker whichcan mitigate countermeasures such as converting the frequencydomain [30-32], applying various alignment methods in thetime domain [7, 12, 33-36]. Also, it requires to use the largenumber of power traces to improve the SNR. In our attack, toovercome the misalignment problem, we use correlationcoefficient based window method in the time domain, and itturned out to be the most efficient and effective method amongalignment methods which we used in our attack. We furtheraddress specifically in CPA on DES instance.2. Plaintext CPAIntuitively, the hardware DES engine must be preceded withdata loading by internal data transfer. To investigate whereplaintext is loaded in power traces, clarifies the location oftarget operation expected information by visual inspection.

Figure 10. Result of attack with plaintext information.Figure 10 shows an average trace of the single T-DES(plotted in blue) and correlations peak traces resulted from the1-bytewise CPA with plaintext using hamming weight powermodel. Note that we compressed all power traces to reduce thetime complexity. This indicates plaintext-related positions inthe power trace. Interestingly peaks are divided into two groupshaving similar composition. One is occurred at low voltage(approximately 1000-2000 time samples), that is estimated tobe the power consumption of the CPU. These significant peakswere observed in sequential order corresponding to each bytevalue transferred by internal data bus of the target device. Theother is occurred at high voltage (approximately 5000-5500time samples) that is estimated to be the power consumptionby the cryptographic engine. These peaks were ambiguous butwe could not exclude possibility of meaningful peaks sincethese peaks were higher than the noise level. After consideringall the factors, we reached to conclusion that possible intervalsfor target operation are approximately 2100-5000 or 55006300 of time samples.3. CPA on T-DESWe perform the CPA attack on every position inside thefounded intervals, where even little possibilities for the T-DESoperation exist. After tremendous trial and error, we can restorethe secret information and it means that we clearly found thelocation of the T-DES operation at the same time.Figure 11 shows a power trace captured during operating theT-DES. It was difficult to spot sixteen patterns for the DESround from single power trace (Figure 11(a)). Although theaveraged trace (Figure 11(b)) were carried out with aligned10,000 traces, each round in the single DES could not bedistinguished. Also, we could identify random effects such assignal amplitude, length of the DES operation, that lead tomisalignment and decreased the SNR by hiding. Interestingly,it was composed of four single-DES instances not three singleDES instances as depicted in Figure 11(b).8Figure 11. Zoom on the T-DES operation.It turned out that the last DES was decryption operation witha ciphertext yielded by the prior T-DES and Kenc, through theCPA attack on this spot. We deduce that it is assigned as a faultcountermeasure which can monitor fault injection during the TDES operation by comparing the intermediate value of the TDES with output value of the last DES decryption.A. Alignment for the Single-DESAlignment is the most time-consuming step of our attack. Itrequires for the reference trace to have a common pattern thatcould be observed in every power trace. Unfortunately, in ourattack, finding this pattern was very difficult. It was impossibleto perfectly arrange the power traces on time by an identicalcomputation in the single-DES operation.We found the best alignment technique suitable for our attackenvironment among existing methods which could overcomethe hiding countermeasure after many trial and errors. Adoptedstrategy is to repeat local alignments and eliminatemisalignment traces on several distinct patterns. Namely, traceshaving a similar pattern through Pearson correlation coefficientis only accepted, and we discarded as the dispensable ones ifnot. We repeatedly applied the above profiling process on theothers distinct patterns to obtain well-fitted traces satisfying ourpreference and taste.Figure 12 shows eight traces for the single-DES before andafter alignments. We aligned on whole DES operation notconsidering the partial operation such as rounds, Sbox and soon.

B. The Sin

128-bit secret key for mutual authentication required when a legitimate user uses functions served by card such as payment, refund, recharging et al. can be completely restored. Finally, with the restored key we are able to free recharge balance on the card as much as a