The invention relates to a method and an apparatus for nonlinear IV setup in keystream generators.
More precisely, the invention describes efficient software implementation of a hardware-oriented stream-cipher
The invention concerns the contact-less technology MIFARE used within public transportation networks for ticketing and access management applications.
In the following description, some linear functions will be used. Linear function can be implemented using tables, and tables easily define corresponding linear functions. “Linear function” and “tables” will be used equally.
The main cryptographic building block of MIFARE is a stream cipher called CRYPTO-1. The general structure of CRYPTO-1 can be sketched as follows:
The most critical part of the CRYPTO-1 stream cipher with respect to software implementation performances is the IV-setup Function which is a nonlinear function. For the IV-setup phase, the successive nonlinear feedback bits used to update the shift register are computed, for each, as a nonlinear function of the previous state including the previous feedback bits.
Let STt0=(st0, . . . , st0+47) be the state of the cipher before performing the IV-setup function (we assume that the key-setup function has been already performed). The state STt0 will be updated by using a nonlinear Boolean function nlf and a 32-bit IV=(IV0, . . . , IV31) injected bit per bit into the state as follows:
FOR i=0 to 31 DO
st0+48+i=nlf(st0+i, . . . , st0+47+i, IVi)
STt0+i+1=(st0+i+1, . . . , st0+i+48).
After the injection of a 32-bit IV into STt0, the new state of the cipher is STt0+32=(st0+32, . . . , st0+79). Now, the cipher is ready to generate keystream, for example to complete the Mifare authentication protocol.
The function nlf “effectively” depends on only 28 variables (instead of 49). Without loss of generality, any n-variable Boolean function F can be represented using the Algebraic Normal Form by:
F(x1, . . . , xn)=G(x1, . . . , xn)xor L(x1, . . . , xn),
where L is a linear Boolean function and G(x1, . . . , xn) is a non-linear function. The function nlf falls into a particular class of Boolean functions, i.e. Boolean functions such that:
The function nlf is “bit-oriented”. A straightforward implementation of nlf makes use of a large number of bit selections (basically, it can be implemented using a right/left shifts and Byte-AND or Byte-OR). The bit values are next combined using bit-XOR and bit-AND.
One classical solution to turn a bit-oriented implementation into a byte-oriented implementation is to replace bit selections by look-up tables and bit-oriented operations by byte-oriented operations. However, this classical solution cannot be directly applied when the bit-value sj is computed using a non-linear function that non-linearly depends on sj−1 and/or sj−2 and/or . . . and/or sj−8.
The invention describes a method to update a state by injecting an IV using a non-linear feedback shift register that makes use of only look-up tables and basic operations on 8-bit words.
The size of the internal state of the cipher is N=8*n. A typical value for n is n=6 or n=32. At time t, the internal state of the cipher is represented by STt=(STt[0], . . . , STt[n−1]), or equivalently by STt=(st, . . . , st+8n−1).
We assume that a key setup function has been performed on the state of the cipher (e.g. the key has been loaded into the state) before starting the IV setup phase. We do not make any assumption on the key setup function.
IV setup phase:
Let STt0=(st0, . . . , st0+8n−1) be the initial state of the cipher for the IV setup phase, where t0>0 is a predetermined value. During this phase, the internal state of the cipher is updated using an Initialization Value (IV) of length 8*m bits, m>0 (a typical value for m is m=4, m=8, m=12 or m=16). We denote the IV bytes by: IV=(IV[0], . . . , IV[m−1]).
The final state of the IV setup phase is:
STt0+8m=(st0+8m, . . . , st0+8(m+n)−1)
Since the IV setup phase should not be “easy” to invert, i.e. knowing the final state of the IV setup phase, it should not be easy to recover the initial state of the IV setup phase, the function used to update the state during the IV Setup phase is generally chosen to be nonlinear.
Nonlinear Update of the State (NLF).
From the initial state STt0, the m successive states STt0+8, STt0+16, . . . , STt0+8m are computed by injecting byte per byte the IV into the state through a non-linear update function called 1-byteNLF.
At time T=t0, T+1=t0+8, . . . , T+m−1=t0+8*(m−1), the cipher state STT+i , 0≦i≦m−1, is updated using IV[i] by computing one byte-value which is STT+i+1[n−1]. Indeed, assuming that at time T+i, the state is:
STT+i=(STT+i[0], STT+i[1], . . . , STT+i[n−1])
Then, the state at time T+i+1 is:
STT+i+1=(STT+i[1], STT+i[2] . . . , STT+i[n−1], STT+i+1[n−1])=(STT+i+1[0], STT+i+1[1] . . . , STT+i+1[n−2], STT+i+1[n−1])
In other words, STT+i+1[j]=STT+i[j+1], for j=0, . . . , n−2, and only one-byte value (i.e. STT+i+1[n−1]) needs to be computed. We compute this byte value using a non-linear function called 1-byteNLF.
Function 1-byteNLF. This function makes use of:
1) n look-up tables of size (8 bits)*(8 bits) denoted by LF0, LF1, . . . , LFn−1 (possibly, there exists (i, j), 0≦i<j<n such that LFi=LFj, and/or there exists i, 0≦i<n, such that LFi=Ø.
2) 2n look-up tables of size (8 bits)*(4 bits) denoted by BFl0, BFr0, BFl1, BFr1, . . . , BFln−1, BFrn−1 (possibly, there exists (i, j), 0≦i<j<n such that BFxi=BFyj where x, yε{r, l}, and/or there exists i, 0≦i<n, such that BFxi=Ø where xε{r, l}). In particular implementations it is possible to use n tables of size (8 bits)*(8 bits). The previous tables sizes speak about useful tables sizes. It stills possible storing a (8 bits)*(4 bits) useful size table, inside a (8 bits)*(8 bits) real size table.
3) Two filtering functions:
4) One look-up table I0 of size (8 bits)*(8 bits)
The computation of STT+i+1[n−1]=(st+8(n+i−1), . . . , st+8(n+i)−1) includes the following steps:
1) Computation of intermediate 1-byte values:
(S[T+i], for some i, 0≦i≦n−1)represents a selection of 8 bits from two bytes of S.
Xi=BFli[S[T+i]], for some i, 0≦i≦n−1
Yi=BFli[S[T+i]], for some i, 0≦i≦n−1
2) Computation of two 1-byte values U and V:
U=Ga(Xil, . . . , Xik, Yil, . . . , Yik′), where 1≦k, k′≦8*n
V is computed using the function Gb, applied to 4 bytes. Each one of these bytes has been computed using one Xi value, and one Yi value. This can be also described as following:
V=Gb(Xil, . . . , Xik, Yil, . . . , Yik′), where 1≦k, k′≦8*n
3) Computation of a temporary value:
STT+i+1[n−1]=XORj=0, . . . , n−1 (LFi(STT+i[j]))
Advantageously, an additional step is used in order to update the temporary value STT+i+1[n−1] by adding, using the XOR operation, a linear function of one byte of the initialization value IV[i]. This can be also described as follows:
STT+i+1[n−1]=STT+i+1[n−1] XOR I0[IV[i]]
4) The current value of STT+i+1[n−1] is next updated bit per bit, as follows. For j=0 to 7, compute:
More precisely, the invention is a method to perform the “reader challenge setup step in the authentication phase”, according to the MIFARE authentication and encryption protocol, in the “tag device”, wherein, the size of the internal state of the cipher, called “ST” is 6 bytes, at time t, the internal state of the cipher is represented by STt=(STt[0], . . . , STt[5]), the reader challenge, called “RC” previously denoted by IV, of length 4 bytes, is denoted by: RC=(RC[0], . . . , RC[3]), a linear function “LF” performing the linear feedback function of the Mifare linear feedback shift register, and a non linear function, “NLF”, performing the Mifare two-layer filter generator, are used to update the value of the said ST using the said RC.
The said method comprises at least the following steps:
This method can comprise a preliminary step of arrangement of “ST” bits in byte to store, in one nibble the bits with a pair ranking, and in the other nibble the bits with an impair ranking.
The linear feedback function can be defined using 6 8-bit×8-bit pre-computed tables L0, . . . , L5 such that:
LF(ST8t+i[0], . . . , ST8t+i[5])=L5[ST8t+i[5]]⊕L4[ST8t+i[4]]⊕ . . . ⊕L0[ST8t+i[0]]
The “NLF” function can be defined by:
Ga(a, b, c, d)=(((âd) & (âb̂)(b & c)))̂0xFF̂d)
Gb(a, b, c, d)=((â(b & d)) & (ĉa)̂(a & d))
Other characteristics and advantages of the present invention will emerge more clearly from a reading of the following description of a number of preferred embodiments of the invention with reference to the corresponding accompanying drawings in which:
For each byte of the Reader Challenge (RC), the current invention computes the value of the new byte (24). It is first initialized with the byte-XOR operation between the linear feedback byte and the byte (28) which is a linear function of the byte of the reader challenge computed using a (1 byte)*(1 byte) table. Next, the invention computes two bytes values U and V using two functions G1 (21) and G2 (26). The value of the byte (24) is updated using 8 steps. For each of the 8 steps, a 4-variable Boolean function f2 is computed such that input bits are located on the rightmost byte of the current state (21) and/or the next state byte (28). For the first step, the taps are located on the current state as depicted by (23). For the last step, the taps of the 4-variable Boolean function are located on the new state byte as depicted by (24). The computation of f2 is done using either the table f2i or f2p.
The output bit of (23) is used to update UU and/or VV. Finally, UU and VV are used for final update of (24).
Number | Date | Country | Kind |
---|---|---|---|
11305482.9 | Apr 2011 | EP | regional |
Filing Document | Filing Date | Country | Kind | 371c Date |
---|---|---|---|---|
PCT/EP2012/056606 | 4/12/2012 | WO | 00 | 10/18/2013 |