458
edits
As of August 2020 the site you are on (wiki.newae.com) is deprecated, and content is now at rtfm.newae.com. |
Changes
Changed header levels
Correlation Power Analysis (CPA) is an attack that allows us to find a secret encryption key that is stored on a victim device. There are 4 steps to a CPA attack:
# Write down a model for the victim's power consumption. This model will look at one specific point in the encryption algorithm. (ie: after step 2 of the encryption process, the intermediate result is <math>x</math>, so the power consumption is <math>f(x)</math>.)
# Get the victim to encrypt several different plaintexts. Record a trace of the victim's power consumption during each of these encryptions.
# Attack small parts (subkeys) of the secret key:
## Consider every possible option for the subkey. For each guess and each trace, use the known plaintext and the guessed subkey to calculate the power consumption according to our model.
## Calculate the Pearson correlation coefficient between the modeled and actual power consumption. Do this for every data point in the traces.
## Decide which subkey guess correlates best to the measured traces.
# Put together the best subkey guesses to obtain the full secret key.
We can use the Hamming Distance model in our CPA attacks. If we can find a point in the encryption algorithm where the victim changes a variable from <blockquotecode><math>l(x) = HammingWeight(x)</mathcode>to <mathcode>w(p, i) = p \oplus iy</mathcode></blockquote>This implies , then we can estimate that the input plaintext power consumption is proportional to <mathcode>pHamming Distance(x, y)</mathcode> is being attacked a single byte at a time. Often, which means we are attacking our model can even be a single byte of the AES key at a time. While bit simpler: if we still need to enumerate all possibilities for this subkey, we now only have assume that the victim is replacing the value <mathcode>16 \times 2^8x = 0</mathcode> instead of , then our power model is<mathpre>2^{128} l(y) = HammingWeight(y)</mathpre> possibilities for AES-128.
These equations are referred to as the ''normalized cross-correlation''. There are typically used to pick out patterns in noisy signals. For example, in digital imaging, correlation can be used to find where an object is in a room. In our attack, we'll be looking for a our model (a pre-calculated pattern) in measured power traces (noisy signals). == Attacking with Correlation ==After taking our measurements, we'll have <blockquotemath>D</math>power traces <math>t</math>, and each of these traces will have <math>T</math> data points. Using subscript notation, <math>t_{\rho _{Xd,Yj}} = </math> will refer to point <math>j</math> in trace <math>d</math> (<math>1 \frac{{{le d \mathop{le D, 0 \rm cov}} \left( le j < T</math>). We'll also estimate the power consumption in each trace using our model. We'll say that there are <math>I</math> different subkeys that we want to try. Then, <math>h_{Xd,Yi} </math> will refer to our power estimate in trace <math>d</math>, assuming that the subkey is <math>i</math> (<math>1 \rightle d \le D, 0 \le i < I</math>)}}{{. With this data, we can see how well our model and measurements match for each guess <math>i</math> and time <math>j</math>. We'll do this by finding how <math>t</math> and <math>h</math> correlate over the <math>D</math> traces. One way of calculating this is: <math>r_{\sigma _X}{\sigma _Y}}i,j} = \frac{{E\sum\nolimits_{d = 1}^D {\left[ {\left( {X - {h_{d,i}} - \mu _Xoverline {{h_i}}} \right)\left( {Y - {t_{d,j}} - \mu _Yoverline {{t_j}}} \right)} \right]} }}{{\sqrt {E\left[ sum\nolimits_{d = 1}^D {{{\left( {X - {h_{d,i}} - \mu _Xoverline {{h_i}}} \right)}^2}} \right]} sum\sqrt nolimits_{E\left[ d = 1}^D {{{\left( {Y - {t_{d,j}} - \mu _Yoverline {{t_j}}} \right)}^2}} \right]} }}</math> There is an alternative form of the correlation equation that we can use for ''online'' calculations - it allows us to add one trace at a time without re-summing all of the past data. This form is: <math>r_{i,j} = \frac{D \sum_{d=1}^D h_{d,i}t_{d,j} - \sum_{d=1}^D h_{d,i} \sum_{d=1}^D t_{d,j}}{\sqrt{\Big(\big(\sum_{d=1}^D h_{d,i}\big)^2 - D\sum_{d=1}^D h_{d,i}^2\Big)\Big(\big(\sum_{d=1}^D t_{d,j}\big)^2 - D\sum_{d=1}^D t_{d,j}^2\Big)}}</blockquotemath> Note that these two sums are equivalent. == Picking a Subkey ==The problem last step is to use the values of finding a known signal in a noisy measurement exists in many other fields beyond side-channel analysis<math>r_{i,j}</math> to decide which subkey matches our traces most closely. These two equations There are referred two steps to as this:* For each subkey <math>i</math>, find the ''normalized crosshighest value of <math>|r_{i,j}|</math>. This will discard the time information -correlationwe want to know how good our guess was, but we don't care where our guess matched the trace. * Looking at the maximum values for each subkey, find the highest value of <math>|r_i|</math>. The location <math>i</math> of this maximum is our best guess: it correlated more closely with the traces than any other guess.Note that we're only working with absolute values here because we don't care about the sign of the relationship. All we need to know is that a linear correlation exists. == Example: AES-128 ==As an example, and frequently used consider AES-128 encryption. The pseudo-code for this algorithm is:<pre>// AES-128 Cipher// in digital imaging : 128 bits (plaintext)// out: 128 bits (ciphertext)// w: 44 words, 32 bits each (expanded key)state = in AddRoundKey(state, w[0, Nb-1]) for matching a known `template' round = 1 step 1 to an imageNr–1 SubBytes(state) // <-- Attack this point in round 1! ShiftRows(state) MixColumns(state) AddRoundKey(state, ew[round*Nb, (round+1)*Nb-1])end for SubBytes(state)ShiftRows(state)AddRoundKey(state, w[Nr*Nb, (Nr+1)*Nb-1]) out = state</pre>This might look pretty complex, but we only need to worry about one part of the algorithm.g. finding After the location of some specific item first <code>SubBytes()</code> step, the state is effectively<pre>// State after AddRoundKey() and SubBytes()state = sbox[in ^ key]</pre>where <code>sbox</code> is a lookup table used in AES. This is an effective point to attack. If we know that a photo byte of the plaintext is <math>p_d</math>, then our modeled power consumption will be <math>h_{d, i} = \text{Hamming Weight}(\text{sbox}[p_d \oplus i])</math> Then, we can proceed with the attack as described above. Since we are attacking one byte of the key at a roomtime, we will have to try <math>I = 2^8</math> values for each subkey.Then, there are 16 bytes in the key, so our attack will take <math>16 \times 2^8 = 2^{12}</math> time. This is an enormous improvement over trying every possible key, which would take <math>2^{128}</math> time. [[Category:Theory]] [[Category:TocTheory]]