Attacks On Smart Card
Attacks On Smart Card
Michael Tunstall
Outline
Smart Cards: What and Why Attacks on cards
! Physical ! Timing, spa, dpa, dfa
Chip Structure
[Blah Blah]
[@^#~r&]
Portability Ease of use Onboard key generation Cost
Outline
Smart Cards: What and Why Attacks on cards
! Physical ! Timing, spa, dpa, dfa
Classes of Attacks
Physical Side-channel Software Environment
Power Outage
Attack on VPP Using nail polish Card not debited
Chip Re-Wiring
Addition of a Track
Cutting of a Track
Countermeasures
Metal layers Bus scrambling Onboard sensors
Chip Structure
Classes of Attacks
Physical Side-channel Software Environment
Timing Attacks
You put $28 in one of the pots and $10 in the other:
$10 $28
Question: Compute ! Blue * 10 + Red *7 ! Tell me if the result is odd or even.
$28 $10
Timing Attacks
Well, normally not : 28 7 + 10 * 10 = 296 and 10 * 7 + 28 * 10 = 350 is also even is an even number
However, just by monitoring the time it takes to give the answer one can tell where each amount is!
Decision
t +t
Process 1
Process 2
end
Power Attacks
Measure the circuit's processing time and current consumption to infer what is going on inside it.
input
output
Power Attacks
Seattle, 1999. US and French delegates negotiate under which conditions beef could be imported to France. The Sun sends a journalist to investigate:
Power Attacks
But there is a technical problem: negotiations take place in a hotel which windows are opaque.
Power Attacks
Idea: look at the hotels electricity meter!
Power Attacks
Disk is spinning slowly:
DEAL CONCLUDED
+
Power Attacks
But if the disk is spinning quickly:
THE SUN
A London homeless eaten by giant rat!
NEGOTIATORS BREAK !
Let k = b ts of d i ize Let s = m For i = k-2 down to 0 Le s = s*s mod n (SQ U A R E) t I (bti o d i 1 then f i f )s Le s = s*m mod n ( ULTIPLY) t M End i f End fo r
Attacks on Smart Cards - Copyright Gemplus Ltd 2003
s = m9 = m1001b s=m
1 1 1 1
1 1 1 1 1 1 1 1 0000 0000
0F
F0
FF
0000 0000
00
00
00
Key value : 2E C6 91 5B F9 4A
Randomising RSA
RSA signature:
Summary on SPA
SPA uses implementation related patterns SPA strategy ! algorithm knowledge ! reverse engineering phase (signature location) ! representation tuning (height of view, zoom, visualisation) ! playing with implementation assumptions... SPA is always specific due to ! the algorithm implementation ! the applicative constraints ! the chips technology (electrical properties) ! possible counter-measures...
DPA
Based on SPA Adding the power of statistics to separate signal from noise
DPA Hypothesis
Play the algorithm N times (100 < N < 100000) Input data (messages Mi)
Algorithm
Acquisition procedure
After data collection, what is available ? ! N plain and/or cipher random texts
00 01 02 B688EE57BB63E03E 185D04D77509F36F C031A0392DC881E6
Mi
Mi = f [Mi]
Now select a single bit among M bits (in M buffer) One can predict the true story of its variations
i 0 1 2 Message B688EE57BB63E03E 185D04D77509F36F C031A0392DC881E6 bit 1 0 1 .
DPA Operator
Partition the data and related curves into two packs, according to the selection bit value...
Mi
Sum the signed consumption curves and normalise <=> Difference of averages (N0 + N1 = N) W1 W0 DPA = N1 N0
DPA curve
0 Selection bit
N
W
0
Average
Max
Min
Min
0 1 2 ...
= E [HW1] - E [HW0 ] = 1
Contrast (peak height) proportional to N1/2 (evaluation criterion) If prediction was wrong : selection bit would be random
E [HW0] = E [HW1] = 4 =>
Attacks on Smart Cards - Copyright Gemplus Ltd 2003
=0
Computation is before
Exclusive OR
Try different keys a valid them with DPA Isnt it like cryptographic exhaustive search ? Not exactly because the research space is drastically reduced !
Ki x
W01
DPA Average
Guess 1
Min
2n-1
1
Attacks on Smart Cards - Copyright Gemplus Ltd 2003
Average 1
D=0
2 C031A0392DC881E6
1 D=0
Average 0
Real Predicted
Attacks on Smart Cards - Copyright Gemplus Ltd 2003
DPA peak
Average 1 - Average 0
Average 1
D=0
2 C031A0392DC881E6
1 D=0
Average 0
Real Predicted
Attacks on Smart Cards - Copyright Gemplus Ltd 2003
Average 1 - Average 0
No DPA peak
2 7
5 8
2n-1
Hypothesis Testing
Typical difficulties
! low contrast between the guesses ! wrong guesses leading to higher peaks (false alarm) ! physical : lack of correlation between data & signals ! cryptographic : algorithmic noise (implementation model) ! try other selection bits (but they not necessarily agree !) ! complementary exhaustive search on gleaned information
Right guess
! 8 x 64 = 512 guesses ! only 48 bits on 1st round ! 2nd round attack for the whole key ! possibility of last round DPA
several possible targets 8 Sboxes: 6 input bits, 4 output bits key schedule (subkeys)
EPerm
6 bits x 8
SubKEY1 Ki (6 bits) x 8
6 bits x 8
S-Box
4 bits x 8 (
a)
PPerm
4 bits x 8 4 bits x 8
4 bits x 8 (
g)
L1 (32 bits)
R1 (32 bits)
DPA Countermeasures
subKi x
W01
DPA Average
Anti-DPA counter-measures
Applicative counter-measures : make message free randomization impossible ! Decorrelate power curves from data
! Fix some message bytes ! Constrain the variable bytes (ex : transaction counter) ! by hardware : current scramblers (additive noise) ! by software : data whitening
! software random delays ! software random orders (ex : SBoxes in random order) ! hardware wait states (dummy cycles randomly added by the CPU) ! hardware unstable internal clock (phase shift)
DPA is powerful, generic (to many algorithms) and robust (to model errors) but there are counter-measures !
Attacks on Smart Cards - Copyright Gemplus Ltd 2003
Anti-DPA counter-measures
Internal clock effects (phase shift)
Synchronized Desynchronized
1 GS/s
Attacks on Smart Cards - Copyright Gemplus Ltd 2003
DPA Summary
Very effective Target independent Can be automated Does not require expensive hardware Effective countermeasures exist Still need to get a hold of the card
Probe design
Hamming distance model for information leakage
Correlated to the number of flipping bits (CMOS, VLSI) Electrical transitions disturb EM near field (and its flow )
Captation by inductive probe
d dt (Diameter = 150 to 500 m) Difficult to calibrate (Bandwidth > 100 MHz, low voltage, parasitic effects) Good acquisition chain required, but no Faraday cage (Sampling at 1GHz)
Handmade solenoid V =
3 mm
Electromagnetic Signals
Raw signals (TIA : transfer into accumulator instruction) Power is less noisy But EM signatures are sharper ! Power
EM
Attacks on Smart Cards -Copyright Gemplus Ltd 2003
Spatial positioning
Horizontal cartography (XY plane) to pinpoint instruction related areas better if automated
ROM
Probe
EEPROM EEPROM ROM 5.5 mm
RAM
CPU
CRYPTO 4.5 mm
Spatial positioning
EM signals versus XY probe position
Differential traces between (00h 00h) and (FFh 00h) picked up at different locations
EM
DPA
DEMA
Attacks on Smart Cards -Copyright Gemplus Ltd 2003
Electomagnetic Signals
Advantage of EMA versus PA Local information more data correlated EMA bypasses current smoothers EMA goes through HW countermeasures: shields, randomized logic Drawbacks Experimentally more complicated Geometrical scanning can be tedious Low level and noisy signals (decapsulation required)
Countermeasures
Software (crypto routines) : coding techniques same as anti DPA/SPA (data whitening) Hardware (chip designers) : confine the radiation (metal layer) blur the radiation (e-g by an active emitting grid) reduce the radiation (technology trends to shrinking) cancel the radiation (dual logic)
Fault Attacks
Weights of coins: ! a dollar ! a cent 5 grams 3 grams
How much money a 15 gram vault contains? Trivially, one of the following: ! either 5 3 = 3 dollars ! or 5 3 = 5 cents But how to make the difference?
Fault Attacks
Assume that the owner of the vault has the habitude of counting each evening the amount in the vault. Have him drink some Vodka so that he mistakes a cent for a dollar or the other way around. Put the vault on the balance again: ! either 5 2 + 3 = 13 grams ! or 4 3 + 5 = 17 grams You can now tell exactly what was the amount in the vault.
The two elements that replace d will be half the size (in bits) compared to d.
These two exponentiations will be computed four times faster than the usual md (mod n). Which can be used to generate a signature:
If a fault occurs
If a fault occurs during the calculation of Sq then:
Countermeasures
Software
! Execution redundancy
Countermeasures
Hardware
Decision
Fault Detected
Reset
Bloc 1
Data
Result1
Raction
Comparison
Result
Bloc 2
Result 2
Outline
Smart Cards: What and Why Attacks on cards
! Physical ! Timing, spa, dpa, dfa
VerifyPIN ****
Summary
Bugs ! Insecure Handling of data ! Buffer Overflows Conceptions errors ! Plain text or bad protocols ! Reverse Engineering of programs Attack on the TCB ! Trojan Horses ! Viruses
Conclusion
Smart cards are like any security devices: they have limitations A system should be designed with these limitations in mind A system should be upgradeable to deal with the (inevitable?) security breach or the aging of the technology The race goes on
Scenario #01
Symptom : Merchants complain that their funddeposits are never credited to their accounts. Deposits are sealed in specific envelops at the end of each day and deposited by the merchants in the front-door mailboxes of their banks. Physical access to mailboxes is smart-card protected. Police investigation : card access control OK, mailbox OK.
Scenario #02
Symptom : Users insert their cards to ATMs, enter their PINs but get no money. The ATM swallows the card and displays the message "INVALID CARD CONTACT YOUR BANK", money was however withdrawn with the card later.
Scenario #03
Symptom : Same as scenario 2, using a smart-card with an EEPROM counter limited to 3. The card is always returned to the user but if its EEPROM counter contains 3 the card can not be used anymore. An audit of the ATM's log file showed that although the thief presented three false PIN codes, he could somehow try again and again. The correct PIN was found by exhaustive search after approximately 5000 attempts.
Scenario #04
Symptom : The ATM's log file and cash stock do not match; money is missing. An audit of the ATM's log file showed that the same user withdrew money several times. He always forgot his banknotes that were swallowed back by the ATM after a short time-out (a security feature).
Scenario #05
Symptom : Although PIN-protected, stolen smart credit cards were successfully used to withdraw money. An audit of the ATM's log file shows that the correct PIN was used in the withdrawal operation.
Scenario #06
Symptom : Users complain that the ATM has swallowed their card but when employees look into the ATM there is no card.