Security of Embedded Systems
Security of Embedded Systems
Systems
Ibrahima DIOP,
Cryptologist and Smartcards Security Specialist
@STMicroelectronics, Rousset (France)
[email protected]
Global Objective
7 Invasive Attacks
4
Context
Embedded Systems are Everywhere…
6
Smart Cards Key Players
Source: https://www.marketsandmarkets.com/Market-Reports/smart-card-285.html
Smart Cards Market
Source: https://www.marketsandmarkets.com/Market-Reports/smart-card-285.html
Smart Card Architecture
Smart Cards
Integrated Circuit Architecture
• Processor:
• 8, 16 or 32 bits
• CISC or RISC
• Harvard or Von Neumann
• In/Out IPs
• MPU/MMU: Memory Management Unit
• Security sensors
Standard Crypto Algorithms in Products
• Symmetric
• DES/TDES: NIST recommendation now TDES for 240 use of same key
• AES 128-192-256
• SM4,…
• Hash Functions
• SHA-1, SHA-256
• RIPEMD 160
• SHA-3: KECCAK
• HMAC Functions And also …
• SM3 • DRNG, example: AES-CTR
based i.e. NIST SP800-90
• Asymmetric
• Stream Ciphers
• CRT-RSA – RSA SFM (≥ 2048 bit)
• Lightweight crypto
• DSA / ECDSA (i.e. GF-P256)
• Post Quantum Cryptography
• DH / ECDH
• OBKG, Kgen
• SM2
Smart Card Manufacturing
Product Conception Phases
OS CRYPTO
Integrated Circuit
Tests Definition/Dev Development
Design/Dev
Production
Applications
Securing
Preparation Development
Manufacturing
Photomasks
wafer
Final Product
Personalization
personalization
Product Conception Phases
OS CRYPTO
Integrated Circuit
Tests Definition/Dev Development
Design/Dev
Production
Applications
Securing
Preparation Development
Manufacturing
Photomasks
wafer
Final Product
Personalization
personalization
Different Phases
From User to End-Of-Life cycles
Gestion du Parc
- Désactivation, - Remplacements
- Usure fonctionnelle Fin de vie - Vols, oppositions, pertes
- Casse
16
Classical Target of Hackers
• Payment
• Passports/Government IDs
• Trusted computing
• Brand protection: Printer cartridges, batteries
• IP protection: Source code, netlists, …
• Digital rights management (DRM)
• Transportation
• Car Immobilizers
• Hardware hacking
[1] http://events.ccc.de/congress/2007/Fahrplan/events/2378.en.html
Recent Example: A side Journey to Titan
• Meltdown
• Spectre
• ROCA
• Rowhammer
• TPM Fails
• ….
Physical Attacks Categories
Physical Attacks
Categorization
• Behavior of the attacker
• Active: Actively alter the functionality
• Passive: Only observes certain physical properties
• Degree of invasiveness
• Non-invasive: Device is not altered physically
• Semi-invasive: De-packaging, no electrical contact to internal signals
• Invasive: No limits
Basic Idea of Active Attack
37
Introduction
Cryptography
DES, RSA,
AES, ECC
…
Symmetric Cryptography
DES, RSA,
AES, ECC
…
Asymmetric Cryptography
Theoretical Security
Power Consumption
Power Consumption
Electro-Magnetic Radiation
Time
Acoustic Temperature
41
SCA Materials
• Acquisition Bench Setup
42
EM Bench
EM Probe
on IC
43
EM Bench
cont.
• cc
44
Power Consumption
48
What is this?
RSA exponentiation
49
These ones?
50
These ones?
51
Triple DES
52
From Visual Inspection to Side Channel
Attacks
Timing Attack and
Simple Power Analysis
54
Side-channel History
55
Types of SCA 56
• Categories and criteria not 100% clear, definitions vary, transitions are smooth
60
Simple Power Analysis
• Anything but simple (except in examples ;) )
Multiplications by 02 in GF(28):
Shift one bit to the left
If carry occurs, XOR the result with 1B
Simple Power Analysis
• Timing
Simple Power Analysis
HW = 0
69
Remember RSA
70
• CRT RSA: modular exponentiation M d mod n is replaced by two exponentiations of
half size.
• As the complexity of this operation is in O(𝓵3) (with 𝓵 the bit-length of n) a half size
exponentiation is 8 times faster.
• The CRT-RSA is then theoretically about 4 times faster than the non-CRT
Implementing •
exponentiation.
In practice, the efficiency gain will be closer to 3 than 4 due to the reduction and the
RSA (and recombination operations.
ECC) • Most of the chip manufacturers include an arithmetic long integer accelerator, also
said public key coprocessor, to compute modular multiplication operations more
efficiently.
• Depending on the manufacturer, the choice of the modular arithmetic can vary (i.e.,
Montgomery, Barrett, Quisquater).
𝒌 −𝟏
¿ ∏ (𝒎 )𝒅
𝒊
𝟐 𝒊
𝒊=𝟎
d fois
72
Classical Exponentiation
Square and Multiply
73
Modular Arithmetic Methods
• The implementation of long integer efficient modular squaring and multiplication operations is of crucial importance for product makers.
• Heavy constraints lie on these operations, especially in the context of embedded devices.
• Several methods can be found in the literature. For instance, some common ones are the following:
• Montgomery method
• Barrett method
• Quisquater method
• Brickell method
• Sedlak method
• Scholar method (Knuth)
• In practice the Montgomery and Barrett methods are the most efficient and most commonly used in most of the products.
• Barrett, P. (1986). Implementing the Rivest Shamir and Adleman public key encryption algorithm on a standard digital signal processor. In Advances in Cryptology - CRYPTO '86, Santa Barbara, California, USA, 1986, Proceedings, pages 311-323.
• Brickell, E. F. (1982). A fast modular multiplication algorithm with application to two key cryptography. In Advances in Cryptology: Proceedings of CRYPTO '82, Santa Barbara, California, USA, August 23-25, 1982, pages 51-60.
• Knuth, D. E. (1997). The Art of Computer Programming, Volume 2 (3rd Ed.): Seminumerical Algorithms. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA.
• Montgomery, P. L. (1985). Modular multiplication without trial division. Mathematics of computation, 44(170):519-521.
• Quisquater, J.-J. (1992). Encoding system according to the so-called RSA method, by means of a microcontroller and arrangement implementing this system. US Patent 5,166,978.
• Sedlak, H. (1987). The RSA cryptography processor. In Advances in Cryptology - EUROCRYPT '87, Workshop on the Theory and Application of Cryptographic Techniques, Amsterdam, The Netherlands, April 13-15, 1987, Proceedings_, pages 95-105.
74
Demo on SSCA on RSA challenge
WITHOUT WITH
CLUSTERING CLUSTERING
75
https://scikit-leaxrn.org/stable/modules/clustering.html
Differential Power Attacks (DPA)
Differential Side-Channel Analysis
…
C0 = EK(P0) CN-1 = EK(PN-1)
77
Side-Channel Analysis
Plaintext0 Ciphertext0
Plaintext1 Ciphertext1
Plaintext2 Ciphertext2
Plaintext3 Ciphertext3
PlaintextN-1 CiphertextN-1
78
Differential Side-Channel Analysis
79
Selection Function
Key Byte 0
P0 P1 … P14 P15
⊕
Selection function output K0
SuBbytes
n
plaintexts
P0 P1 … P14 P15
⊕ 256
00 K1 … K14 K15
0x1C
SuBbytes
n
plaintexts
1C P1 … P14 P15
⊕ 256
00 K1 … K14 K15
0x1C
SuBbytes
0x8A
n
plaintexts
8A P1 … P14 P15
⊕ 256
00 K1 … K14 K15
0x1C
SuBbytes
0x8A
n
plaintexts …
73 P1 … P14 P15
0x73
⊕ 256
01 K1 … K14 K15
0x1C 0xAB
SuBbytes
0x8A
n
plaintexts …
AB P1 … P14 P15
0x73
⊕ 256
01 K1 … K14 K15
0x1C 0xAB
SuBbytes
0x8A 0x12
n
plaintexts …
12 P1 … P14 P15
0x73
⊕ 256
01 K1 … K14 K15
0x1C 0xAB
SuBbytes
0x8A 0x12
n
plaintexts … …
F1 P1 … P14 P15
0x73 0xF1
P0 P1 … P14 P15
Plaintext n-1
256
256 × n
Key byte 15
n 256 × n
plaintexts
Key byte 0
16
256
n
plaintexts n traces
… … …
Simulated
Data from Guess Guess … Guess 255 Measurement
guesses 0 1 Data
89
Differential Side-Channel Analysis
DPA for Differential Power Analysis
256
0x1C
n
plaintexts
… … …
0x1C
0x8A
n
plaintexts
… … …
… …
0x1C
0x8A
n
plaintexts
… … …
… …
0x73
Guess Guess … Guess 255
0 1
Average traces
94
Side-Channel Analysis
• Wrong assumption
,
• Good assumption
,
95
Differential Side-Channel Analysis
Not always efficient technique
HOW CAN WE
IMPROVE?
96
Correlation Analysis
the first break event …
97
Correlation Power Analysis
Simulated
Measurement
Data from
Data
guesses
98
Correlation Power Analysis
• Most cases have shown Linear leakage model in Hamming weight is efficient
• Model:
W = a × HW(data) + b + noise
99
Correlation Power Analysis
100
Now use Correlation Analysis
256
n
plaintexts n traces
… … …
Simulated
Data from Guess Guess … Guess 255 Measurement
guesses 0 1 Data
101
Now use Correlation Analysis
256
n W Correlation
plaintexts
(W0 , C)
C
0
102
Now use Correlation Analysis
256
W Correlation
n
plaintexts 1
(W1 , C)
C
103
Now use Correlation Analysis
256
W
Correlation
n
plaintexts K (WK , C)
C
104
Now use Correlation Analysis
256
W255 Correlation
n
plaintexts
(W255 , C)
C
105
Correlation Attack Result
106
Correlation Power Analysis
• We can use information from all bits contrarily to DPA – no information loss
• All operand and values can be used with
• Mono-bit attacks
• Hamming weight attack
• Value itself to be correlated
• Distinguisher
• Statistical tool used to compare simulated set (from guess) and real traces set (from DUT)
• DPA, CPA, SNR, NICV, MIA, ANOVA …
• Discriminant:
• Function to apply to sort the distinguisher resulting scores
108
Time to practice ?
CPA demonstrations on DES and AES
110
Profiled Side Channel Attacks
Types of SCA 112
• Desynchronize
• Hardware de-synchronization: jitter, clock and frequency jitters, random delays
• Shuffling
• One amongst N techniques
• Protocol
• Paddings
• Session keys,
• Fresh re-keying
• Unknown input and/or output (partially): CTR mode, payment ATC
• De-correlate
• Hardware techniques to balance consumption (dual rail)
• Masking techniques
117
Desynchronization
P0 P1 … P14 P15
⊕ K0 K1 … K14 K15
SuBbytes
A0 A1 … A14 A15
Selection Function
Key Byte 0
P0 P1 … P14 P15
⊕
Selection function output K0
SuBbytes
n
plaintexts
P0 P1 … P14 P15
⊕ 256
00 K1 … K14 K15
0x1C
SuBbytes
n
plaintexts
1C P1 … P14 P15
⊕ 256
00 K1 … K14 K15
0x1C
SuBbytes
0x8A
n
plaintexts
8A P1 … P14 P15
⊕
1
0x1C
SuBbytes
0x8A
n
plaintexts …
73 P1 … P14 P15
0x73
P0 P1 … P14 P15
⊕ K0 K1 … K14 K15
SubBytes
A0 A1 … A14 A15
AES
P0 P1 … P14 P15
⊕ R R … R R
⊕ K0 K1 … K14 K15
A0 ⊕ A1⊕
…
A14⊕ A15⊕ • SubBytes is not linear, more complex operation
? ? ? ? • SubBytes(A ⊕ R ) ≠ SubBytes(A) ⊕ SubBytes(R)
P0 P1 … P14 P15
⊕ R R … R R
⊕ K0 K1 … K14 K15
SuBbytes*
A0 ⊕ A1⊕
…
A14⊕ A15⊕
• for value from 0 to 255
R R R R
SubByte_Masked [value ⊕R] = SubByte[value ] ⊕ R
ShiftRow
R ⊕ (D ⊕ R) = D
i1 : R i2 : D ⊕ R
Reminder on Second order attacks
• …
Second Order Attack Demonstration
139
Deep Learning Based Side Channel
Attack
Profiled SCA
Target
• AES (Advanced Encryption Standard) Algorithm
S-BOX ()
142
Profiled SCA
Example
• Template Attack
Training/Building
Phase
Attack/Matching
Phase
143
Profiled SCA 144
Example
• Example of Template Attack Result on 128 Bits AES
Key Recovery
Countermeasures against Side
Channel Attack
SCA
Coutermeasures
• Masking Data
S-BOX () S-BOX [( )]
random value
146
SCA
Coutermeasures
• Jittering
• Add death cycles in random manner
• Shuffling Desynchronization
• Operation are executed in random Order
• Dummies Operations insertion
Curves AES without countermeasure Curves of AES with Jittering + Shuffling + Dummy
147
SCA 148
Countermeasures
• Limit of Template Attack
Template SCA
S-BOX ()
S-BOX [() ( )]
Template SCA
DL SCA
Neural Network
150
Deep Learning SCA
• What model architecture to use ?
• We are going to use a Convolutional Network architecture
• Little or no invariance to shifting, scaling, and other forms of distortion
• Detect the features independently of their position.
151
Deep Learning SCA
• How do I find Suitable model ?
• DL-SCA suitable models are hard to find by hand so instead it is best to use
hyperparameters-tuning to find the right model automatically.
• Training thousand of model using Keras Tuner or HyperOpt/Hyperas and GPU
152
Deep Learning SCA
• Training Phase
Features Labels S-BOX ()
S = 43
S = 145
S = 228
S=5
153
Deep Learning SCA
• How do I recover the key?
• Leverage all model predictions on many traces to carry out probabilistic attacks
154
Deep Learning SCA 155
156
Deep Learning SCA
• DL-SCA vs Classical SCA
157
Back to Countermeasure
How to improve resistance
AES Key K
H
• Not a countermeasure “recommended”
Infective Computation
• Split the data D and key K to be protected into d+1 random shares to prevent the
product from dth high order side-channel attacks.
Attack Observe
Characteri
ze Collect
Align
168
Side Channel Attacks Methodology
Step 1: Tests Plan
• Evaluation mode
• Knowledge on the product is given for the evaluation
• Source code, IC design, cryptographic operations and IPs, etc.
information given
• Vulnerability Analysis
• Identify potential attack if information available
• Test Plan
• Define tests based on Vulnerability Analysis if it was performed.
169
Side Channel Attacks Methodology
Step 2: Measurement
• Measurement set-up
• Setup the measurement
• Select probe, location
• Sampling rate,
• EM (preferably often)
• Triggering
• Chosen input
• Depending on the leakage model of the device for the targeted operation, fixing a certain number of bytes to a
constant (i.e., 0) can make appear specific patterns in the trace to locate the interesting area in the trace or even
to recover secret.
• Signal Processing
• Apply signal processing techniques to observe potential loops, identify better the operations related to the
computations
• Investigate better signal processing that will be helpful for aligning the traces once collected 171
Side Channel Attacks Methodology
Step 4: Collect traces
• Define setup
• Sampling to use
• Define Area to collect in the computation for the chosen attack path
(first or last rounds for example)
• Setup for trace collection
172
Side Channel Attacks Methodology
Step 5: Align
• Alignment
• Identify which signal processing techniques to combine to align traces
• Run the alignment(s)
• Critical Path
• Alignment can determine the success or failure of the attacks
• Major part of the global effort
173
Example: observe then align
174
Side Channel Attacks Methodology
Step 5: Characterize
• What is the knowledge you can get to characterize?
• Input – Output
• Knowing the computation input and/or output (plaintext or ciphertext) can help
• Perform SCA tests on input to locate the beginning of the targeted operation in the trace(s)
• Perform SCA tests on output to locate the end of the targeted operation in the trace(s)
• Require a first traces collection to be done
177
Side Channel Attacks Methodology
Step 8: Analyse and Decide
178
Welsch t-test
179
Welsch t test
• T-test examines the leakage of the Device Under Test (DUT) independent of its
underlying architecture.
• Gives a level of confidence to conclude that the DUT has an exploitable leakage or not.
• However, it provides no information
• about the easiness/hardness of an attack which can exploit the leakage,
• nor about an appropriate intermediate value and the hypothetical model.
• Can easily and rapidly report that the DUT fails to provide the desired security level:
• e.g., due to a mistake in the design engineering
• or a flaw in the countermeasure.
• [GJJR] G. Goodwill, B. Jun, J. Jaffe, P. Rohatji - A testing methodology for side-channel resistance validation. https://csrc.nist.gov/csrc/media/events/non-invasive-attack-testing-workshop/documents/08_goodwill.pdf
• [SM15] Tobias Schneider and Amir Moradi. Leakage Assessment Methodology - a clear roadmap for side-channel evaluations. CHES-2015 - https://eprint.iacr.org/2015/207.pdf
• [BCDJKKLMRS] G. Becker, J. Cooper, E. DeMulder, G. Goodwill, J. Jaffe, G. Kenworthy, T. Kouzminov, A. Leiserson, M. Marson, P.Rohatgi and S. Saa. Test Vector Leakage Assessment (TVLA) methodology in
practice
180
t test
181
Example of t-test on AES
182
Example of
leakage analysis See demo notebook
with reverse on
AES
183
Attack and Remaining Key Entropy
184
Back to the past…
Past: 90’s (before Kocher)
187
(Designing) A Security Product
188
Reverse Engineering
• Use chemical products to remove (destroy) epoxy (resin) with nitric acid and acetone …
We observe now the chip that we can analyze using microscope(s)
• Reconnect the circuit on another ‘’package’’
• In order to use it again we reconnect the IO pins, clock pins, VCC pads, etc.
• We can then analyze the IC when running with several tools
189
Reverse Engineering
Reverse the IC Layout
• Using an optical microscope we can observe and take a picture of each metal layer
• We start at the higher (upper) layer
• We remove chemically this layer with fluoric acid or a plasma machine
• We iterate until we reach the lowest layer (metal 1)
190
Reverse Engineering
Reverse the Layout
191
Reverse Engineering
Read Memories Content
192
Read/Modify bits with Probing
193
Read/Modify bits with Probing
• We position one or more probes on a circuit area to ‘’read’’ or ‘’change/flip’’ a value (bits):
• For instance, the bit lines in a data bus, or code bus
• For instance, you can read a key value transferred on a bus to a memory or register
• You change the key bits ..
• Etc.
194
Modify the Circuit
Focused Ion Beam (FIB)
• FIB (Focused Ion Beam ) stations are most often used to analyze (and
“debug”) failures in circuits
• FIB can
• ‘’remove’’ metal, and modify connections
• He can add metal and then create new connections
197
IC Reverse Engineering
Countermeasures
• Glue Logic
• Makes the IP and block localization
difficult to the attacker
• Software Encryption
199
• Is recommended to be added at software level for (very) sensitive assets
Probing Countermeasures
• Be a Clever Designer
• place sensitive buses, registers (data or configuration) in area difficult to access to a probe
• Memories/Buses/Registers Encryption
200
Active Shield/Mesh (efficient)
Difficult
201
Section title
Section title
Section title
Find out more at www.st.com