The present invention concerns a method of counter-measuring against side-channel attacks for block-ciphers, and in particular, but not exclusively, to a method of counter-measuring which uses a match-in-place function.
Many existing encryption algorithms in use today, such as the most widely used encryption algorithm ‘Advanced Encryption Standard (AES)’ are vulnerable to Differential Power Analysis (DPA). DPA is a side-channel attack that consists in first measuring a microprocessor's power consumption when executing a cryptographic algorithm and then performing statistical analysis in order to recover secret-keys used in the cryptographic algorithm for encryption. Once the secret-keys have been determined it is possible to decrypt encrypted information.
A microprocessor's electromagnetic emanations can also be measured and exploited to determine secret-keys used in a cryptographic algorithm for encryption.
A common technique to protect secret-key algorithms against DPA consists of masking every intermediate variable with a random mask. The masked data and the random mask are then processed separately and eventually recombined at the end of the algorithm. An attacker trying to analyze the power consumption of a microprocessor at a single point will obtain random values (random data values and random mask values); therefore, such masking will be secure against first-order DPA.
A masking counter-measure is characterized by the number of random masks used to protect a given sensitive variable; a masking with d random masks is called a d-th order masking. A d-th order masking can only be broken by a (d+1)th order side-channel analysis, i.e. an attack that requires the processing of d+1 variables simultaneously. The number of executions required to break a counter-measure grows exponentially with the order d. Therefore, the order d is a good security criterion. However, in practice the most efficient counter-measures are of order d=1 only
It has been shown that a second-order DPA attacks to decrypt masked data is possible. Therefore, better counter-measures are needed in order to obtain fully secure encryption of data.
Further developments in counter-measures have been made; one of the most recent counter-measures against side-channel attacks is a counter-measure with order d=2.
For any masking counter-measure the main difficulty is to protect the non-linear parts of the algorithm; for Advanced Encryption Standard (AES) the non-linear parts of the algorithm are essentially SBOX functions. The technique used consists of iterating over the entire SBOX function for every SBOX look-up, using a comparison algorithm that is implemented as a subroutine. The comparison algorithm being called for every SBOX input, it is possible to show that the counter-measure can resist any second-order side-channel attack.
However such masking counter-measures are grossly inefficient as it requires many operations during execution and also utilises much of the microprocessors memory during execution.
It is an aim of the present invention to obviate, or mitigate, at least some of the afore-mentioned disadvantages.
According to the invention, these aims are achieved by means of a method of counter-measuring against side channel attacks, the method comprising executing a block-cipher algorithm to mask intermediate variables, wherein the block-cipher algorithm comprises one or more non-linear functions, characterised in that at least one of the non-linear functions is implemented using a match-in-place function.
The method of the present invention makes use of a match-in-place function to improve the efficiency of the method. Using a match-in-place function reduces the number of operations which are required to provide an effective counter-measuring against side channel attacks. Furthermore, less memory is required to implement the method of the present invention compared to know methods.
The match-in-place function may be a bit-randomized match-in place function (MIPI (data; adr,b)).
The bit-randomized match-in place function may be defined as:
wherein adr is an address in a memory, data is a variable which can be stored at an address in a memory, and b is a value which is returned if the data variable is equal to actual data which is present at the address adr in memory; otherwise the complement of b is returned. b may be a bit value.
The following relationship may exist:
MIPI(data;adr;b)=MIP(data;adr)⊕b
wherein b is the complement of b.
The at least one of the non-linear function may comprise a compareb function, defined by:
wherein x is the first input variable of the compareb function and y is the second input variable of the compareb function, and b is a value which is returned if x is equal to y, such that the compareb function can be implemented by: writing the variable x to an address adr in memory; executing the bit-randomized match-in place function defined as:
The non-linear function may be comprised in a SubByte operation. The non-linear function may be comprised in a SubByte operation of an AES algorithm.
The block-cipher algorithm may further comprise one or more linear functions. At least one of the one or more linear functions may be masked by XORing variables of the function.
The block-cipher algorithm may be an Advanced Encryption Standard (AES) algorithm.
According to a further aspect of the present invention there is provided a computer readable medium comprising a computer program which is configured to implement a method according to any one of the afore mentioned methods.
According to a further aspect of the present invention there is provided a method of computing a second order masked Sbox function from a second order masked input, comprising the steps of:
(iii) Return Rb
wherein, b is a variable which represents a random bit which indexes a register, and a is a variable which represents an index which defines the number of times steps (a)-(c) should be carried out, r1, r2 is a pair of input masks, x is a masked value wherein x=x⊕r1⊕r2⊕εFn2, and s1, s2 are a pair of output masks, and adr is a free memory address, cmp is a bit variable which indexes a register and is an output of the function MIPI (r2; adr; b), Rcmp is a register address of a register of a micro-processor. Typically, at least two registers R0 and R1 in the micro-processor are used (i.e. cmp can be 0 or 1; a first register R0 is indexed/addressed if cmp=0, and a second register R1 is indexed/addressed if cmp=1). Rb is a register address of a register of a micro-processor. Typically at least two registers R0 and R1 in the micro-processor are used (i.e. b can be 0 or 1; register R0 is indexed/addressed if b=0, and register R1 is indexed/addressed if b=1). MIPI (r2; adr; b) is a bit-randomized match-in place function defined as:
According to a further aspect of the present invention there is provided a computer readable medium comprising a computer program which is configured to carry out the afore-mentioned method of computing a second order masked Sbox function.
The invention will be better understood with the aid of the description of an embodiment given by way of example and illustrated by the figures, in which:
The use of the method of the present invention in an AES encryption algorithm will be described in detail. However, it should be understood that the method of the present invention is not limited to use with an AES encryption algorithm; the method of the present invention could be used in any block-cipher algorithm.
The AES Encryption Algorithm operates on a 4×4 array of bytes si,j, termed the ‘state’. For encryption, each subpart of the AES Encryption Algorithm (except a last subpart) comprises the following four stages:
The pseudo-code for AES encryption with a 128-bit key is given in
For decryption, every round (except the last) comprises the following operations:
Finally, the round key-schedule (ki,j) is based on the following operations:
As discussed in the introduction, the principle of the masking counter-measure is to mask every intermediate variable with one or more random masks. In case of the masking counter-measure with order d=2, two masks are used, which gives a total of three shares. More precisely, any state variable p (represented as a byte in AES) is shared into three shares (p0; p1; p2) with:
p=p0⊕p1⊕p2
where the shares p1 and p2 are called the masks.
The three shares p0, p1 and p2 must be processed in such a way that the previous relation is preserved throughout the execution of the encryption algorithm. Note that similarly every byte k of the round key must be shared into three shares (k0; k1; k2) such that k=k0⊕k1⊕k2.
The linear parts of the block-cipher are easy to process. A function f is said to be linear when the following holds:
f(x⊕y)=f(x)⊕f(y) Equation (1)
Then for such linear function when given as input the three shares (p0; p1; p2) such that:
p=p0⊕p1⊕p2
it suffices to compute f(p0), f(p1) and f(p2) separately and forming Equation (1) one obtains:
f(p)=f(p0)⊕f(p1)⊕f(p2)
Therefore, the three output shares f(p0), f(p1) and f(p2) are a valid sharing of the output f(p). For AES encryption, the AddRoundKey, ShiftRows and MixColumns operation are linear functions and can therefore be processed in this manner. However, the SubBytes operation (such as the S-box function in the case of AES) is non-linear and must be processed differently.
To process non-linear operations such as the S-box function in the case of AES an algorithm can be defined as follows:
S:{0;1}n→{0;1}m
Note that for AES n=m=8. The algorithm preferably comprises a masked function compareb defined as follows:
where the x and y are the input variables of the compareb function.
Computation of a second-order masked S-box function from a second-order masked input may be carried out as follows:
Wherein r1⊕a; r2 are input variables of the compareb function, a=r1⊕r2 then cmp=compareb (r1⊕a, r2)=compareb (r2; r2)=b which gives Rb=(S(x⊕r1⊕r2) ⊕s1)⊕s2=S(x)⊕s1⊕s2 as required.
In this particular embodiment, care should be taken when implementing the compareb function. Namely the compareb (x; y) function preferably should not be implemented by computing x⊕y directly, since in the above algorithm this would amount to computing (r1⊕r2⊕a) which combined with x would give a second-order leakage.
The method implementing of the compareb function to prevent any first order side-channel leakage on x⊕y will now be described:
Recall that the function compareb is defined as:
The method of implementing requires a table T of 2n bits in RAM. The table T is pre-processed as follows:
At the end of this pre-processing step, the table T satisfies:
Then the compareb function is implemented as:
return T[(x⊕r3)⊕y]
In this case all intermediate variables in the computation are independent of x⊕y; this prevents any first-order side-channel leakage on x⊕y.
The above-mentioned implementation of the compareb is known in the art. Disadvantageously, the above-mentioned implementation of the compareb is inefficient; the compareb algorithm requires 2n bits of RAM; in practice however it may be more convenient to use 2n bytes of RAM since otherwise bit-access techniques must be used which might be cumbersome to implement securely. Pre-processing requires 2n+1 memory transfers; such pre-processing must be done before every call to the RDP2 algorithm. Every call to compareb then requires two XOR operations and one memory transfer. For AES with n=8, the compareb function therefore requires 256 bytes of RAM and 257 memory transfers during pre-processing. In total, the RDP2 algorithm then requires 6·2n XOR operations, 3·2n+1 memory transfers and the generation of n+1 random bits.
The method according to the present invention is based on a different implementation of the compareb function, and in particular an implementation which uses match-in-place function.
Any processor has the usual instructions data←read(adr) and write(data; adr) that read and write some data at some address adr in memory. In match-in-place technology the processor has an additional function MIP(data; adr) that works as follows:
In other words, data is matched at the memory location adr and the value at address adr never leaves the memory.
In the present invention there is provided additional function MIPI which is a bit-randomized version of the MIP function, defined as follows:
Preferably there exists the following relationship:
MIPI(data;adr;b)=MIP(data;adr)⊕b
Using the MIPI function, the compareb function can be simply implemented as follows, where adr is a free address in memory.
Using the MIPI function the computation of a second-order masked S-box function from a second-order masked input becomes as follows:
The implementation of the compareb function based on the MIPI function, satisfies the same property as the original compareb function implementation; namely all intermediate variables are independent of x⊕y.
Note that the randomized function MIPI(y; adr; b) is preferable. If the function MIP(y; adr) is used instead (by first computing MIP(y; adr) and then returning MIP(y; adr) ⊕b) then the implementation would be insecure, as the intermediate variable MIP(y; adr) is not independent from x⊕y.
Various modifications and variations to the described embodiments of the invention will be apparent to those skilled in the art without departing from the scope of the invention as defined in the appended claims. Although the invention has been described in connection with specific preferred embodiments, it should be understood that the invention as claimed should not be unduly limited to such specific embodiment.
Number | Date | Country | Kind |
---|---|---|---|
11290337 | Jul 2011 | EP | regional |
Number | Name | Date | Kind |
---|---|---|---|
20080019503 | Dupaquis et al. | Jan 2008 | A1 |
20110033043 | Gebotys | Feb 2011 | A1 |
20110044450 | Choi et al. | Feb 2011 | A1 |
Number | Date | Country | |
---|---|---|---|
20130028412 A1 | Jan 2013 | US |