SECURED PERFORMANCE OF A CRYPTOGRAPHIC PROCESS

Information

  • Patent Application
  • 20230082339
  • Publication Number
    20230082339
  • Date Filed
    August 25, 2022
    2 years ago
  • Date Published
    March 16, 2023
    a year ago
  • Inventors
    • LIN; Tingting
  • Original Assignees
Abstract
A method of performing a cryptographic process in a secured manner, wherein the cryptographic process generates output data based on input data, the generating of the output data involving generating a value y based on an amount of data x, the value y representing a combination, according to a linear transformation L, of respective outputs from a plurality of S-boxes Sn (n=0, . . . , N−1) for integer N>1, wherein each S-box Sn (n=0, . . . , N−1) implements a respective function Hn that is either (a) the composition of a respective first function Fn and a respective linear or affine second function Gn so that Hn=Gn∘Fn, or (b) the composition of a respective first function Fn, a respective linear or affine second function Gn and a respective third function Wn so that Hn=Gn∘Fn∘Wn, wherein the method comprises: performing a first processing stage and a second processing stage to generate the value y based on the amount of data x, wherein: the first processing stage uses a plurality of first lookup tables to generate respective outputs, each output being based on at least part of the amount of data x, wherein, for each S-box Sn (n=0, . . . , N−1), the respective first function Fn is implemented by a corresponding first lookup table; and the second processing stage combines outputs from a plurality of second lookup tables to generate the value y, wherein the input to each second lookup table is formed from the output of a plurality of the first lookup tables, and wherein the set of second lookup tables is based on the second functions Gn (n=0, . . . , N−1) and the linear transformation L.
Description
FIELD OF THE INVENTION

The present invention relates to methods and systems for performing a cryptographic process in a secured manner and for generating a secured implementation of a cryptographic process.


BACKGROUND OF THE INVENTION

“White-box” cryptography is a known topic in cryptography. In white-box attacks, a cryptographic scheme is assumed to execute on an untrusted platform and a white-box adversary is assumed to have full control over the internal details of the execution. A white-box environment is, therefore, an execution environment for an item of software in which an attacker of the item of software is assumed to have full access to, and visibility of, the data being operated on (including intermediate values), memory contents and execution/process flow of the item of software. Moreover, in the white-box environment, the attacker is assumed to be able to modify the data being operated on, the memory contents and the execution/process flow of the item of software, for example by using a debugger—in this way, the attacker can experiment on, and try to manipulate the operation of, the item of software, with the aim of circumventing initially intended functionality and/or identifying secret information and/or for other purposes. Indeed, one may even assume that the attacker is aware of the underlying algorithm being performed by the item of software. However, the item of software may need to use secret information (e.g. one or more cryptographic keys), where this information needs to remain hidden from the attacker.


Under white-box attacks, many traditional cryptographic schemes cannot provide protection for private information. White-box cryptography aims at providing robustness of the implementations of cryptographic systems and constructing cryptographic systems that can succeed in their functionality (such as encryption, decryption and authentication) under white-box attacks.


White-box attacks are becoming more diversified and powerful. This enables the adversary to conduct many attacks (both static and dynamic). For example, grey-box attacks such as DPA (Differential Power Analysis) have been repurposed under the name DCA (Differential Computation Analysis) and are directly usable against white-box implementations. The main reason that DCA is successful is due to the nonnegligible correlation between expected values (from the standard cipher specification) and corresponding masked intermediate values (from the white-box implementation). Such correlation is often caused by linear imbalances in encodings used in some white-box implementation.


In many cryptographic processes (such as encryption and decryption algorithms), S-boxes (or substitution boxes) are used as a nonlinear component that is often critical for confusion. S-boxes are well-known—see, for example, https://en.wikipedia.org/wiki/S-box, the entire disclosure of which is incorporated herein by reference. In most white-box implementations, a cryptographic key will be hidden in one or more S-boxes. Therefore, the issue of how to protect the S-boxes is something that needs to be considered in order to have a secured implementation of the cryptographic process. Some protections are proven to be weak under white-box attacks, especially DCA attacks—this includes use of affine transformation, networked encoding, mask injection, etc. Common to these protections is that the statistic distribution of inputs affects the statistic distribution of outputs and there is nonnegligible correlation between the expected values and the masked intermediate values.


SUMMARY OF THE INVENTION

Embodiments of the invention aim to address such problems, using an improved/secured implementation of S-boxes.


According to a first aspect of the invention, there is provided a method of performing a cryptographic process in a secured manner, wherein the cryptographic process generates output data based on input data, the generating of the output data involving generating a value y based on an amount of data x, the value y representing a combination, according to a linear transformation L, of respective outputs from a plurality of S-boxes Sn (n=0, . . . , N−1) for integer N>1, wherein each S-box Sn (n=0, . . . , N−1) implements a respective function Hn that is either (a) the composition of a respective first function Fn and a respective linear or affine second function Gn so that Hn=Gn∘Fn, or (b) the composition of a respective first function Fn, a respective linear or affine second function Gn and a respective third function Wn so that Hn=Gn∘Fn∘Wn, wherein the method comprises: performing a first processing stage and a second processing stage to generate the value y based on the amount of data x, wherein: the first processing stage uses a plurality of first lookup tables to generate respective outputs, each output being based on at least part of the amount of data x, wherein, for each S-box Sn (n=0, . . . , N−1), the respective first function Fn is implemented by a corresponding first lookup table; and the second processing stage combines outputs from a plurality of second lookup tables to generate the value y, wherein the input to each second lookup table is formed from the output of a plurality of the first lookup tables, and wherein the set of second lookup tables is based on the second functions Gn (n=0, . . . , N−1) and the linear transformation L.


According to a second aspect of the invention, there is provided a method of generating a secured implementation of a cryptographic process, wherein the cryptographic process generates output data based on input data, the generating of the output data involving generating a value y based on an amount of data x, the value y representing a combination, according to a linear transformation L, of respective outputs from a plurality of S-boxes Sn (n=0, . . . , N−1) for integer N>1, wherein each S-box Sn (n=0, . . . , N−1) implements a respective function Hn that is either (a) the composition of a respective first function Fn and a respective linear or affine second function Gn so that Hn=Gn∘Fn, or (b) the composition of a respective first function Fn, a respective linear or affine second function Gn and a respective third function Wn so that Hn=Gn∘Fn∘Wn, wherein the method comprises: implementing a first processing stage and a second processing stage that, together, are arranged to generate the value y based on the amount of data x, wherein: implementing the first processing stage comprises generating a plurality of first lookup tables that provide respective outputs, each output being based on at least part of the amount of data x, wherein, for each S-box Sn (n=0, . . . , N−1), the respective first function Fn is implemented by a corresponding first lookup table; and implementing the second processing stage comprises generating a plurality of second lookup tables, the second processing stage arranged to combine outputs from the plurality of second lookup tables to generate the value y, wherein the input to each second lookup table is formed from the output of a plurality of the first lookup tables, and wherein the set of second lookup tables is based on the second functions Gn (n=0, . . . , N−1) and the linear transformation L.


In some embodiments of the first and second aspects, the outputs of the first lookup tables have a larger bit width than the inputs to the first lookup tables.


In some embodiments of the first and second aspects, the first lookup tables implement a corresponding obfuscation transformation that is undone by the plurality of second lookup tables.


In some embodiments of the first and second aspects, the output of each first lookup table being based on at least part of the amount of data x comprises the output of each first lookup table being based on a corresponding portion of bits of the amount of data x.


In some embodiments of the first and second aspects, the output of each first lookup table comprises the sum of a respective plurality of components, and wherein the input to each second lookup table is formed from one or more respective components of each of said plurality of the first lookup tables.


According to a third aspect of the invention, there is provided a system arranged to perform a cryptographic process in a secured manner, wherein the cryptographic process generates output data based on input data, the generating of the output data involving generating a value y based on an amount of data x, the value y representing a combination, according to a linear transformation L, of respective outputs from a plurality of S-boxes Sn (n=0, . . . , N−1) for integer N>1, wherein each S-box Sn (n=0, . . . , N−1) implements a respective function Hn that is either (a) the composition of a respective first function Fn and a respective linear or affine second function Gn so that Hn=Gn∘Fn, or (b) the composition of a respective first function Fn, a respective linear or affine second function Gn and a respective third function Wn so that Hn=Gn∘Fn∘Wn, wherein the system comprises one or more processors configure to: perform a first processing stage and a second processing stage to generate the value y based on the amount of data x, wherein: the first processing stage uses a plurality of first lookup tables to generate respective outputs, each output being based on at least part of the amount of data x, wherein, for each S-box Sn (n=0, . . . , N−1), the respective first function Fn is implemented by a corresponding first lookup table; and the second processing stage combines outputs from a plurality of second lookup tables to generate the value y, wherein the input to each second lookup table is formed from the output of a plurality of the first lookup tables, and wherein the set of second lookup tables is based on the second functions Gn (n=0, . . . , N−1) and the linear transformation L.


According to a fourth aspect of the invention, there is provided a system arranged to generate a secured implementation of a cryptographic process, wherein the cryptographic process generates output data based on input data, the generating of the output data involving generating a value y based on an amount of data x, the value y representing a combination, according to a linear transformation L, of respective outputs from a plurality of S-boxes Sn (n=0, . . . , N−1) for integer N>1, wherein each S-box Sn (n=0, . . . , N−1) implements a respective function Hn that is either (a) the composition of a respective first function Fn and a respective linear or affine second function Gn so that Hn=Gn∘Fn, or (b) the composition of a respective first function Fn, a respective linear or affine second function Gn and a respective third function Wn so that Hn=Gn∘Fn∘Wn, wherein the system comprises one or more processors arranged to: implement a first processing stage and a second processing stage that, together, are arranged to generate the value y based on the amount of data x, wherein: implementing the first processing stage comprises generating a plurality of first lookup tables that provide respective outputs, each output being based on at least part of the amount of data x, wherein, for each S-box Sn (n=0, . . . , N−1), the respective first function Fn is implemented by a corresponding first lookup table; and implementing the second processing stage comprises generating a plurality of second lookup tables, the second processing stage arranged to combine outputs from the plurality of second lookup tables to generate the value y, wherein the input to each second lookup table is formed from the output of a plurality of the first lookup tables, and wherein the set of second lookup tables is based on the second functions Gn (n=0, . . . , N−1) and the linear transformation L.


In some embodiments of the third and fourth aspect, the outputs of the first lookup tables have a larger bit width than the inputs to the first lookup tables.


In some embodiments of the third and fourth aspect, the first lookup tables implement a corresponding obfuscation transformation that is undone by the plurality of second lookup tables.


In some embodiments of the third and fourth aspect, the output of each first lookup table being based on at least part of the amount of data x comprises the output of each first lookup table being based on a corresponding portion of bits of the amount of data x.


In some embodiments of the third and fourth aspect, the output of each first lookup table comprises the sum of a respective plurality of components, and wherein the input to each second lookup table is formed from one or more respective components of each of said plurality of the first lookup tables.


According to a fifth aspect of the invention, there is provided a computer program which, when executed by one or more processors, causes the one or more processors to carry out the method of the first or second aspect (or any embodiment thereof). The computer program may be stored on a computer readable medium.





BRIEF DESCRIPTION OF THE DRAWINGS

Embodiments of the invention will now be described, by way of example only, with reference to the accompanying drawings, in which:



FIG. 1 schematically illustrates an example of a computer system;



FIGS. 2a and 2b schematically illustrate an overview of the rth round for SM4 encryption;



FIGS. 3a and 3b schematically illustrate an overview of the rth round for SM4 encryption;



FIGS. 4a and 4b schematically illustrate a general scenario for a cryptographic process;



FIG. 5 schematically illustrates an implementation of the cryptographic process of FIGS. 4a and 4b according to embodiments of the invention;



FIG. 6 schematically illustrates the implementation shown in FIG. 5, using SM4 as an example of the cryptographic process;



FIG. 7 is a flowchart illustrating a method, according to some embodiments of the invention, for performing a cryptographic process; and



FIG. 8 is a flowchart illustrating a method, according to some embodiments of the invention, for generating a secured implementation of a cryptographic process.





DETAILED DESCRIPTION OF EMBODIMENTS OF THE INVENTION

In the description that follows and in the figures, certain embodiments of the invention are described. However, it will be appreciated that the invention is not limited to the embodiments that are described and that some embodiments may not include all of the features that are described below. It will be evident, however, that various modifications and changes may be made herein without departing from the broader spirit and scope of the invention as set forth in the appended claims.


1—System Overview


FIG. 1 schematically illustrates an example of a computer system 100. The system 100 comprises a computer 102. The computer 102 comprises: a storage medium 104, a memory 106, a processor 108, an interface 110, a user output interface 112, a user input interface 114 and a network interface 116, which may be linked together over one or more communication buses 118.


The storage medium 104 may be any form of non-volatile data storage device such as one or more of a hard disk drive, a magnetic disc, a solid-state-storage device, an optical disc, a ROM, etc. The storage medium 104 may store an operating system for the processor 108 to execute in order for the computer 102 to function. The storage medium 104 may also store one or more computer programs (or software or instructions or code).


The memory 106 may be any random access memory (storage unit or volatile storage medium) suitable for storing data and/or computer programs (or software or instructions or code).


The processor 108 may be any data processing unit suitable for executing one or more computer programs (such as those stored on the storage medium 104 and/or in the memory 106), some of which may be computer programs according to embodiments of the invention or computer programs that, when executed by the processor 108, cause the processor 108 to carry out a method according to an embodiment of the invention and configure the system 100 to be a system according to an embodiment of the invention. The processor 108 may comprise a single data processing unit or multiple data processing units operating in parallel, separately or in cooperation with each other. The processor 108, in carrying out data processing operations for embodiments of the invention, may store data to and/or read data from the storage medium 104 and/or the memory 106.


The interface 110 may be any unit for providing an interface to a device 122 external to, or removable from, the computer 102. The device 122 may be a data storage device, for example, one or more of an optical disc, a magnetic disc, a solid-state-storage device, etc. The device 122 may have processing capabilities—for example, the device may be a smart card. The interface 110 may therefore access data from, or provide data to, or interface with, the device 122 in accordance with one or more commands that it receives from the processor 108.


The user input interface 114 is arranged to receive input from a user, or operator, of the system 100. The user may provide this input via one or more input devices of the system 100, such as a mouse (or other pointing device) 126 and/or a keyboard 124, that are connected to, or in communication with, the user input interface 114. However, it will be appreciated that the user may provide input to the computer 102 via one or more additional or alternative input devices (such as a touch screen). The computer 102 may store the input received from the input devices via the user input interface 114 in the memory 106 for the processor 108 to subsequently access and process, or may pass it straight to the processor 108, so that the processor 108 can respond to the user input accordingly.


The user output interface 112 is arranged to provide a graphical/visual and/or audio output to a user, or operator, of the system 100. As such, the processor 108 may be arranged to instruct the user output interface 112 to form an image/video signal representing a desired graphical output, and to provide this signal to a monitor (or screen or display unit) 120 of the system 100 that is connected to the user output interface 112. Additionally or alternatively, the processor 108 may be arranged to instruct the user output interface 112 to form an audio signal representing a desired audio output, and to provide this signal to one or more speakers 121 of the system 100 that is connected to the user output interface 112.


Finally, the network interface 116 provides functionality for the computer 102 to download data from and/or upload data to one or more data communication networks.


It will be appreciated that the architecture of the system 100 illustrated in FIG. 1 and described above is merely exemplary and that other computer systems 100 with different architectures (for example with fewer components than shown in FIG. 1 or with additional and/or alternative components than shown in FIG. 1) may be used in embodiments of the invention. As examples, the computer system 100 could comprise one or more of: a personal computer; a server computer; a mobile telephone; a tablet; a laptop; a television set; a set top box; a games console; other mobile devices or consumer electronics devices; etc. Additionally, it is possible that some components of the computer system 100 are not located in the computer 102 and are, instead, part of a computer network connected to the computer 102 via the network interface 116. Additionally or alternatively, the computer system 100 may comprise multiple computers 102, e.g. in a network of computers such as a cloud system of computing resources.


2—Secured Implementation of Cryptographic Processes and S-Boxes

The SM4 encryption and decryption algorithms are well-known—details of SM4 can be found at http://www.gmbz.org.cn/upload/2018-04-04/1522788048733065051.pdf, the entire disclosure of which is incorporated herein by reference.


SM4 encryption operates on a 128-bit input dIn and produces a corresponding 128-bit encrypted output dOut using a 128-bit encryption key. SM4 encryption involves performing a round 32 times—the input to the first round (round 0) is dIn, and the input to the (r+1)th round is the output of the preceding rth round (for r=0, 1, . . . , 30). The rth round (for r=0, 1, . . . , 31) makes use of a corresponding 32-bit round key kr that is derived from the 128-bit encryption key using a key expansion algorithm.



FIG. 2a schematically illustrates an overview of the rth round for SM4 encryption (for r=0, 1, . . . , 31). In summary:

    • The 128-bit input to the rth round comprises, or is treated as a concatenation of, four 32-bit quantities (or values): vr, vr+1, vr+2, vr+3.
    • The 32-bit round key kr and the 32-bit quantities vr+1, vr+2, vr+3 are XOR-ed together.
    • The result of this XOR is a 32-bit quantity that comprises, or is treated as a concatenation of, four 8-bit quantities (or values). Each of these four 8-bit quantities is used as an input to an S-box to obtain a corresponding output 8-bit quantity. In FIG. 2a, the S-box is shown as being implemented four times in parallel, as respective S-boxes (S0, S1, S2, S3) so that the four 8-bit quantities can be provided as inputs to their own respective S-box.
    • The four 8-bit quantities (or values) that are output by the S-boxes are combined by a linear transformation LSM4 to generate a 32-bit quantity (or value).
    • The 32-bit quantity generated by the linear transformation LSM4 is XOR-ed with vr to produce a 32-bit quantity vr+4.
    • The output of the round is then the 128-bit value that comprises, or is a concatenation of, the four 32-bit quantities vr+1, vr+2, vr+3, vr+4.


The output of the last round is, therefore, the four 32-bit quantities v32, v33, v34, v35. The 128-bit encrypted output dOut is formed by reversing the order of these four 32-bit quantities, i.e. the 128-bit quantity represented by the concatenation of v35, v34, v33, v32.


SM4 decryption may be implemented similarly, as is well-known.


The S-boxes S0, S1, S2, S3 for SM4 encryption each implement the lookup table set out in Table 1 below. In particular, for an 8-bit input with hexadecimal representation αβ, the corresponding 8-bit value that is output/provided by the S-box is as per Table 1 below.











TABLE 1









β


























0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F



























α
0
D6
90
E9
FE
CC
E1
3D
B7
16
B6
14
C2
28
FB
2C
5



1
2B
67
9A
76
2A
BE
4
C3
AA
44
13
26
49
86
6
99



2
9C
42
50
F4
91
EF
98
7A
33
54
0B
43
ED
CF
AC
62



3
E4
B3
1C
A9
C9
8
E8
95
80
DF
94
FA
75
8F
3F
A6



4
47
7
A7
FC
F3
73
17
BA
83
59
3C
19
E6
85
4F
A8



5
68
6B
81
B2
71
64
DA
8B
F8
EB
0F
4B
70
56
9D
35



6
1E
24
0E
5E
63
58
D1
A2
25
22
7C
3B
1
21
78
87



7
D4
0
46
57
9F
D3
27
52
4C
36
2
E7
A0
C4
C8
9E



8
EA
BF
8A
D2
40
C7
38
B5
A3
F7
F2
CE
F9
61
15
A1



9
E0
AE
5D
A4
9B
34
1A
55
AD
93
32
30
F5
8C
B1
E3



A
1D
F6
E2
2E
82
66
CA
60
C0
29
23
AB
0D
53
4E
6F



B
D5
DB
37
45
DE
FD
8E
2F
3
FF
6A
72
6D
6C
5B
51



C
8D
1B
AF
92
BB
DD
BC
7F
11
D9
5C
41
1F
10
5A
D8



D
0A
C1
31
88
A5
CD
7B
BD
2D
74
D0
12
B8
E5
B4
B0



E
89
69
97
4A
0C
96
77
7E
65
B9
F1
9
C5
6E
C6
84



F
18
F0
7D
EC
3A
DC
4D
20
79
EE
5F
3E
D7
CB
39
48









The S-box of Table 1 implements the S-box function H(x)=(A2((A1(x⊕C1))−1))⊕C2, where x, C1, C2custom-character28 (i.e. are represented by respective 8×1 vectors of bits), and A1, A2 are 8×8 matrices over custom-character2. It will be appreciated, of course, that there are other equivalent ways of mathematically representing the S-box function H(x).


If the 32-bit round key kr is viewed as a concatenation of four 8-bit subkeys kr,0, kr,1, kr,2, kr,3, then each of the subkeys kr,n (n=0, 1, 2, 3) may be implemented as part of the corresponding S-box Sn. This results in four bespoke S-boxes for the rth round, namely Sr,n (n=0, 1, 2, 3) that correspond, respectively, to the 8-bit subkeys kr,n. In particular, for any 8-bit input x, the S-box Sr,n generates an 8-bit output y that equals the output of the standard S-box for SM4 encryption when provided with the 8-bit input x⊕kr,n. Thus, the S-box Sr,n implements the S-box function Hr,n(x)=(A2((A1(x⊕kr,n⊕C1))−1))⊕C2. FIG. 2b schematically illustrates an overview of the rth round for SM4 encryption (for r=0, 1, . . . , 31) when the round key kr has been combined with the S-boxes S0, S1, S2, S3, i.e. when the bespoke S-boxes Sr,n (n=0, 1, 2, 3) are used instead of the S-boxes S0, S1, S2, S3.


The AES encryption and decryption algorithms are well-known—details of AES are given in Federal Information Processing Standards Publication 197 (found at http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf), the entire disclosure of which is incorporated herein by reference.


AES encryption operates on a 128-bit input dIn and produces a corresponding 128-bit encrypted output dOut. There are three variations of AES, known as AES-128, AES-192 and AES-256: for AES-n, the size of the encryption key is n bits. AES encryption involves performing a round a number of times, R—for AES-128, R=10; for AES-192, R=12; for AES-256, R=14. A key expansion algorithm is used to generate R+1 128-bit subkeys kr (r=0, 1, . . . , R). The rth round makes use of kr (r=1, 2, . . . , R). The input to AES encryption is dIn, which gets XOR-ed with k0, following which the sequence of R rounds (rounds 1, 2, . . . , R) is performed.



FIG. 3a schematically illustrates an overview of the rth round for AES encryption (for r=1, 2, . . . , R). In summary:

    • The 128-bit input to the rth round comprises, or is treated as a concatenation of, sixteen 8-bit quantities: vr,0, vr,1, . . . , vr,15.
    • Each of these sixteen 8-bit quantities vr,0, vr,1, . . . , vr,15 is used as an input to an S-box to obtain a corresponding output 8-bit quantity. In FIG. 3a, the S-box is shown as being implemented sixteen times in parallel, as respective S-boxes (S0, S1, . . . , S15) so that the sixteen 8-bit quantities vr,0, vr,1, . . . , vr,15 can be provided as inputs to their own respective S-box.
    • The sixteen 8-bit quantities that are output by the S-boxes are combined by a linear transformation LAES to generate a 128-bit value. For rounds 1, 2, . . . , R−1, this linear transformation LAES comprises a so-called ShiftRows function followed by so-called MixColumns operation; for the Rth round, this linear transformation LAES comprises just the ShiftRows function.
    • The 128-bit value generated by the linear transformation LAES is XOR-ed with kr to produce a 128-bit output value for the round. The 128-bit encrypted output dOut is the 128-bit value output from the Rth round.


AES decryption may be implemented similarly, as is well-known.


The S-boxes S0, S1, . . . S15 for AES encryption each implement the lookup table set out in Table 2 below. In particular, for an 8-bit input with hexadecimal representation αβ, the corresponding 8-bit value that is output/provided by the S-box is as per Table 2 below.










TABLE 2








β
























0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F



























α
0
63
7c
77
7b
f2
6b
6f
c5
30
1
67
2b
fe
d7
ab
76



1
ca
82
c9
7d
fa
59
47
f0
ad
d4
a2
af
9c
a4
72
C0



2
b7
fd
93
26
36
3f
f7
cc
34
a5
e5
f1
71
d8
31
15



3
4
c7
23
c3
18
96
5
9a
7
12
80
e2
eb
27
b2
75



4
9
83
2c
1a
1b
6e
5a
a0
52
3b
d6
b3
29
e3
2f
84



5
53
d1
0
ed
20
fc
b1
5b
6a
cb
be
39
4a
4c
58
cf



6
d0
ef
aa
fb
43
4d
33
85
45
f9
2
7f
50
3c
9f
a8



7
51
a3
40
8f
92
9d
38
f5
be
b6
da
21
10
ff
f3
d2



8
cd
0c
13
ec
5f
97
44
17
c4
a7
7e
3d
64
5d
19
73



9
60
81
4f
de
22
2a
90
88
46
ee
b8
14
de
5e
0b
db



A
e0
32
3a
0a
49
6
24
5c
c2
d3
ac
62
91
95
e4
79



B
e7
c8
37
6d
8d
d5
4e
a9
6c
56
f4
ea
65
7a
ae
8



C
ba
78
25
2e
1c
a6
b4
c6
e8
dd
74
1f
4b
bd
8b
8a



D
70
3e
b5
66
48
3
f6
0e
61
35
57
b9
86
c1
1d
9e



E
e1
f8
98
11
69
d9
8e
94
9b
1e
87
e9
ce
55
28
df



F
8c
a1
89
0d
bf
e6
42
68
41
99
2d
0f
b0
54
bb
16









The S-box of Table 2 implements the S-box function H(x)=(A1(x−1))⊕C1, where x, C1custom-character28 (i.e. are represented by respective 8×1 vectors of bits), and A1 is an 8×8 matrix over custom-character2. It will be appreciated, of course, that there are other equivalent ways of mathematically representing the S-box function H(x).


If the 128-bit subkey kr−1 is viewed as a concatenation of sixteen 8-bit subkeys kr−1,0, kr−1,1, . . . , kr−1,15, (r=1, 2, . . . , R), then each of the subkeys kr−1,n (n=0, 1, . . . , 15) may be implemented as part of the corresponding S-box S, in the rth round. In other words, the initial XOR of the input dIn with k0 may be implemented as part of the S-boxes for round 1. Likewise, the XOR at the end of the rth round (r=1, 2, . . . , R−1) may be implemented as part of the S-boxes for the following round, i.e. the (r+1)th round. This results in sixteen bespoke S-boxes for the rth round, namely Sr,n (n=0, 1, . . . , 15) that correspond, respectively, to the 8-bit subkeys kr−1,n. In particular, for any 8-bit input x, the S-box Sr,n generates an 8-bit output y that equals the output of the standard S-box for AES encryption when provided with the 8-bit input x⊕kr−1,n. Thus, the S-box Sr,n implements the S-box function Hr,n(x)=(A1((x⊕kr−1,n)−1))⊕C1. FIG. 3b schematically illustrates an overview of the rth round for AES encryption (for r=1, 2, . . . , R) when the subkey kr−1 has been combined with the S-boxes S0, S1, . . . , S15, i.e. when the bespoke S-boxes Sr,n (n=0, 1, . . . , 15) are used instead of the S-boxes S0, S1, . . . , S15 (note that the XOR at the end of the round is only present for the final round, hence it is shown using dotted lines).


As can be seen from the above, SM4 encryption, SM4 decryption, AES encryption and AES decryption may be viewed as a cryptographic process that comprises generating output data dOut based on input data dIn. The generation of the output data involves generating an amount of data y based on an amount of data x, the amount of data y representing a combination, according to a linear transformation L, of N S-box outputs for some integer N>1. In some implementations of such a cryptographic process, the S-box may be implemented once and used N times to provide the N S-box outputs; in other implementations of such a cryptographic process, the S-box may be implemented separately more than once (e.g. N times), with the N S-box outputs being provided from the plurality of implementations of the S-boxes—this is particularly true when the S-boxes are different for each S-box output, e.g. when a key (or a part thereof) has been combined with the S-box, as discussed above. Regardless of the actual implementation, in the following this may be regarded as equivalent to using a plurality N of S-boxes Sn (n=0, 1, . . . , N−1) for integer N>1, wherein each S-box Sn (n=0, 1, . . . , N−1) implements a respective function Hn (which may or may not be the same of the other functions Hj for j≠n). As illustrated above, the generation of an amount of data y based on an amount of data x occurs in each round of SM4 encryption, SM4 decryption, AES encryption and AES decryption, but it will be appreciated that this need not be the case for other cryptographic processes. It will be appreciated that embodiments of the invention are not limited to SM4 encryption/decryption or AES encryption/decryption as the cryptographic process, but that other algorithms could be used instead (such as Serpent encryption/decryption). Based on the above, it will be appreciated that embodiments of the invention are particularly suited to cryptographic processes that are, or that involve use of, a substitution-permutation network (such networks being well-known, and more details of which can be found at https://en.wikipedia.org/wiki/Substitution%E2%80%93permutation_network, the entire disclosure of which is incorporated herein by reference).


More generally, then, suppose there are N S-boxes Sn (n=0, 1, . . . , N−1), where N is an integer greater than 1. Each S-box Sn (n=0, 1, . . . , N−1) implements, or represents, an S-box function Hn, i.e. for each valid input x, for the S-box Sn, the corresponding output from the S-box Sn is Hn(xn). Thus, the amount of data x may comprise (or provide or represent) the inputs xn for the S-boxes Sn (n=0, 1, . . . , N−1), and the linear transformation L may operates on the outputs Hn(xn) from the S-boxes Sn (n=0, 1, . . . , N−1) to generate the amount of data y. For example (e.g. as in the SM4 encryption and decryption and AES encryption and decryption discussed above), the inputs xn (n=0, 1, . . . , N−1) may be formed from corresponding bits (e.g. blocks of consecutive bits) of the amount of data x.


Now, for each S-box Sn (n=0, 1, . . . , N−1), the corresponding S-box function Hn may be represented as a composition of a corresponding first function Fn and a corresponding second function Gn, so that Hn=Gn∘Fn. In the following discussion and embodiments, the corresponding second function Gn is an affine function/transformation or possibly a linear function/transformation. Indeed, the corresponding S-box function Hn may be represented as a composition of more than two functions, which may be represented as a composition of a corresponding first function Fn, a corresponding second function Gn and a corresponding third function Wn so that Hn=Gn∘Fn∘Wn. If, on the face of it, the corresponding S-box function Hn does not appear to be representable as a composition of two or more functions, then note that Hn=Gn∘(Gn−1∘Hn) for any affine (or possibly linear) function Gn having the same codomain as Hn's codomain—thus, the corresponding S-box function Hn may be represented as a composition of a corresponding first function, namely (Gn−1∘Hn), and a corresponding second function Gn.


Thus, each S-box Sn (n=0, 1, . . . , N−1) implements a respective function Hn that is either (a) the composition of a respective first function Fn and a respective second function Gn so that Hn=Gn∘Fn, or (b) the composition of a respective first function Fn, a respective second function Gn and a respective third function Wn so that Hn=Gn∘Fn∘Wn. It will be appreciated that, for any S-box function Hn, there may be multiple ways of writing Hn as a composition of two or more functions.


For each S-box Sn (n=0, 1, . . . , N−1), the corresponding S-box function Hn may be an algebraic function, but this is not essential. Likewise, the corresponding first function Fn (and, where used, the corresponding third function Wn) may be algebraic functions, but this is not essential. As mentioned, the corresponding second function Gn is an affine function/transformation (or possibly a linear function/transformation).



FIGS. 4a and 4b schematically illustrate the above-discussed general scenario. As shown in FIG. 4a, the cryptographic process generates output data dOut based on input data dIn. At some stage in the cryptographic process, the cryptographic process involves generating an amount of data (or value) y based on an amount of data (or value) x. There may be some processing P of the input data dIn to arrive at the amount of data x; however, such processing P may be optional, so that x=dIn. Likewise, there may be some processing Q of the amount of data y (and note that the processing Q may additionally be based on other data generated by the processing P) to arrive at the output data dOut; however, such processing Q may be optional, so that dOut=y. The amount of data y represents a combination, according to a linear transformation L, of respective outputs from a plurality of S-boxes Sn (n=0, 1, . . . , N−1) where N>1. These outputs from the S-boxes Sn (n=0, 1, . . . , N−1) correspond to respective inputs (or amounts of data or values) an for the S-boxes Sn, where an is based on the amount of data x (e.g. is formed as, or comprises, one or more bits, or components of, the amount of data x).



FIG. 4b schematically illustrates the cryptographic process of FIG. 4a, but in which each of the S-boxes Sn (n=0, 1, . . . , N−1) implements the corresponding S-box function Hn which can be written as either:

    • (a) a composition of a corresponding first function Fn and a corresponding second function Gn, so that Hn=Gn∘Fn—in this case, the input to the first function Fn (n=0, 1, . . . , N−1) is the value (or amount of data) xn, where xn=an; or
    • (b) a composition of a corresponding first function Fn, a corresponding second function Gn and a corresponding third function Wn, so that Hn=Gn∘Fn∘Wn—in this case, the input to the third function Wn (n=0, 1, . . . , N−1) is the value (or amount of data) an and the input to the first function Fn (n=0, 1, . . . , N−1) is the value (or amount of data) xn=Wn(an).


As discussed, the third functions Wn (n=0, 1, . . . , N−1) are optional, hence they are shown in dotted lines in FIG. 4b. Additionally, it will be appreciated that in some embodiments, some, but not all, of the S-boxes Sn (n=0, 1, . . . , N−1) implement the corresponding S-box function Hn written as a composition of a corresponding first function Fn, a corresponding second function Gn and a corresponding third function Wn so that Hn=Gn∘Fn∘Wn, and with the remaining S-boxes implementing the corresponding S-box function Hn written as a composition of a corresponding first function Fn and a corresponding second function Gn, so that Hn=Gn∘Fn. Regardless, in the following, the input to the first function Fn is the value xn (where xn=an or xn=Wn(an) as appropriate) for (n=0, 1, . . . , N−1).


In FIG. 4b, a first processing stage is illustrated, which involves determining Fn(xn) for each n=0, 1, . . . , N−1. Additionally, a second processing stage is illustrated, which involves applying the second functions Gn to respective outputs from the first processing stage to determine Gn(Fn(xn)) (n=0, 1, . . . , N−1) and then combining these quantities using the linear transformation L, to thereby generate y.


Now, Fn(xn) (n=0, 1, . . . , N−1) may be written, or represented as, a plurality of components (or parts), i.e. Fn(xn)=Σd=0Dn−1en,d for components en,d (d=0, 1, . . . , Dn−1), where Dn is an integer with Dn>1. For example, Fn(xn) may have a Bn-bit representation, i.e. it may be written as a vector of bits in custom-character2Bn—then each en,d may also be a vector in custom-character2Bn. For example, Dn could be equal to Bn, with en,d being the vector that has 0 in all elements except for the dth element, which is, instead, equal to the dth bit of Fn(xn)—thus, Fn(xn)=Σd=0Dn−1en,d. Similarly, Dn could be equal to 2, with en,0 being a vector for which a first subset of elements are 0 and for which the remaining elements equal the corresponding bit-value of Fn(xn), and with en,1 being a vector for which the first subset of elements equal the corresponding bit-value of Fn(xn) and the remaining elements are 0. Similarly, Dn could be equal to 2, with en,0 being a random element of custom-character2Bn and with en,1=en,0+Fn(xn) (noting that the addition operator here is equivalent to a bitwise XOR). It will be appreciated that these are merely examples, and that other ways of writing, or representing, Fn(xn) as a plurality of components (or parts) could be used instead. In some embodiments, Dn1 is different from Dn2 for some or all instances in which n1≠n2. Alternatively, in some embodiments, Dn is the same for all n=0, 1, . . . , N−1.


As a linear transformation, L may be represented as a matrix







L
=

[




l

0
,
0








l

0
,

N
-
1



















l


N
-
1

,
0








l


N
-
1

,

N
-
1






]


,




so that the first processing stage and the second processing stage together implement






y
=



[




l

0
,
0








l

0
,

N
-
1



















l


N
-
1

,
0








l


N
-
1

,

N
-
1






]

[





G
0

(


F
0

(

x
0

)

)












G

N
-
1


(


F

N
-
1


(

x

N
-
1


)

)




]

.





It will be appreciated that, in some embodiments, Gn(Fn(xn)) (n=0, 1, . . . , N−1) may be represented as Bn×1 a vector (e.g. a vector from custom-character2Bn), in which case each of lq,n (n, q=0, 1, . . . , N−1) is a Bn×Bn matrix. In alternative embodiments, Gn(Fn(xn)) (n=0, 1, . . . , N−1) may be represented as an element of a field custom-character, in which case each of lq,n (n, q=0, 1, . . . , N−1) may be an element of the field custom-character.


Now:









y
=



[




l

0
,
0








l

0
,

N
-
1



















l


N
-
1

,
0








l


N
-
1

,

N
-
1






]

[





G
0

(


F
0

(

x
0

)

)












G

N
-
1


(


F

N
-
1


(

x

N
-
1


)

)




]







=


[






l

0
,
0





G
0

(


F
0

(

x
0

)

)


+


l

0
,
1





G
1

(


F
1

(

x
1

)

)


+

+


l

0
,

N
-
1






G

N
-
1


(


F

N
-
1


(

x

N
-
1


)

)















l


N
-
1

,
0





G
0

(


F
0

(

x
0

)

)


+


l


N
-
1

,
1





G
1

(


F
1

(

x
1

)

)


+

+


l


N
-
1

,

N
-
1






G

N
-
1


(


F

N
-
1


(

x

N
-
1


)

)






]







=


[






l

0
,
0





G
0

(




d
=
0



D
0

-
1




e

0
,
d



)


+


l

0
,
1





G
1

(




d
=
0



D
1

-
1




e

1
,
d



)


+

+


l

0
,

N
-
1






G

N
-
1


(




d
=
0



D

N
-
1


-
1




e


N
-
1

,
d



)















l


N
-
1

,
0





G
0

(




d
=
0



D
0

-
1




e

0
,
d



)


+


l


N
-
1

,
1





G
1

(




d
=
0



D
1

-
1




e

1
,
d



)


+

+


l


N
-
1

,

N
-
1






G

N
-
1


(




d
=
0



D

N
-
1


-
1




e


N
-
1

,
d



)






]







=



[





l

0
,
0




G
0



e

0
,
0














l


N
-
1

,
0




G
0



e

0
,
0






]

+

[





l

0
,
0




G
0



e

0
,
1














l


N
-
1

,
0




G
0



e

0
,
1






]

+

+

[





l

0
,
0




G
0



e

0
,


D
0

-
1















l


N
-
1

,
0




G
0



e

0
,


D
0

-
1







]

+

[





l

0
,
1




G
1



e

1
,
0














l


N
-
1

,
1




G
1



e

1
,
0






]

+

+


[





l

0
,
1




G
1



e

1
,


D
1

-
1















l


N
-
1

,
1




G
1



e

1
,


D
1

-
1







]

+

+


[





l

0
,

N
-
1





G

N
-
1




e


N
-
1

,
0














l


N
-
1

,

N
-
1





G

N
-
1




e


N
-
1

,
0






]




+

[





l

0
,

N
-
1





G

N
-
1




e


N
-
1

,


D

N
-
1


-
1















l


N
-
1

,

N
-
1





G

N
-
1




e


N
-
1

,


D

N
-
1


-
1







]

+

c
_









Here, c is a constant vector. In particular, if Gn is linear or if Gn is affine and Dn is even, then Gnd=0Dn−1en,d)=Σd=0Dn−1Gnen,d and Gn will make no contribution to c—thus, if this holds for all Gn (n=0, 1, . . . , N−1), then c=0 and c can be ignored. Alternatively, if Gn is affine (so that Gn(x)=θx⊕ωn) and Dn is odd, then Gnd=0Dn−1en,d)=Σd=0Dn−1Gnen,dn, and so Gn will make a contribution of






[





l

0
,
n




ω
n













l


N
-
1

,
n




ω
n





]




to c—thus, c would be the sum of such contributions.


Thus, each component en,d (n=0, 1, . . . , N−1; d=0, 1, . . . , Dn−1) contributes the vector






[





l

0
,
n




G
n



e

n
,
d














l


N
-
1

,
n




G
n



e

n
,
d






]




to the computation of the amount of data y, with y being the sum of these vector contributions (and potentially with the addition of c if c≠0).


The set of components E={en,d: n=0, 1, . . . , N−1; d=0, 1, . . . , Dn−1} may be partitioned into a plurality of disjoint partitions, each having a respective plurality of the components en,d. Let there be M such partitions (for integer M>1), namely Em (m=0, 1, . . . , M−1), where Um=0M−1Em=E and Em1∩Em2=Ø if m1≠m2. In some embodiments, the partitions have the same number of components; in other embodiments, some or all of the partitions may have different numbers of components from each other. Each partition Em contributions the vector










e

n
,
d




E
m




[





l

0
,
n




G
n



e

n
,
d














l


N
-
1

,
n




G
n



e

n
,
d






]





to the computation of the amount of data y.


Based on the above, FIG. 5 schematically illustrates an implementation of the cryptographic process of FIGS. 4a and 4b according to embodiments of the invention. In particular, as shall be discussed in more detail below, the first functions Fn (n=0, 1, . . . , N−1) are implemented by respective lookup tables Φn (n=0, 1, . . . , N−1) (referred to herein as first lookup tables or Type 1 lookup tables) and the second functions Gn (n=0, 1, . . . , N−1) together with the linear transformation L are together implemented by a plurality (or network) of lookup tables Ωm (m=0, 1, . . . , M−1) (referred to herein as second lookup tables or Type 2 lookup tables) with the outputs of the lookup tables Ωm (m=0, 1, . . . , M−1) combined or summed. In essence, each second lookup tables Ωm (m=0, 1, . . . , M−1) corresponds to the partition Em—the input to that second lookup table Ωm comprises, or is based on, the components en,d in the partition Em (or at least a representation thereof), and the corresponding output from the second lookup table Ωm is the vector










e

n
,
d




E
m




[





l

0
,
n




G
n



e

n
,
d














l


N
-
1

,
n




G
n



e

n
,
d






]





(or a representation thereof), i.e. the contribution that the partition Em makes to the computation of y. The outputs from the plurality of second lookup tables Ωm (m=0, 1, . . . , M−1) may then be combined (i.e. summed/added) to generate y (and potentially with the addition of c if c≠0).


Thus, as can be seen from FIG. 5, performing the cryptographic process comprises performing a first processing stage and a second processing stage to generate the amount of data y based on the amount of data x, wherein:

    • (a) The first processing stage uses a plurality of first lookup tables Φn (n=0, 1, . . . , N−1) to generate respective outputs, each output being based on a part an of the amount of data x (insofar as Φn may provide an output corresponding to an input of an if the third function Wn is not used, or may provide an output corresponding to an input of Wn(an) if the third function Wn is used). For each S-box Sn (n=0, 1, . . . , N−1), the respective first function Fn is implemented by a corresponding first lookup table Φn of the first processing stage. Thus, given an input xn, the lookup table Φn provides Fn(xn) (or a representation or encoding thereof) as an output. As can be seen from the above, the output of each first lookup table may be based on a corresponding portion of bits of the amount of data x.
    • (b) The second stage combines the outputs from a plurality of second lookup tables Ωm (m=0, 1, . . . , M−1) to generate the amount of data y. The input to each second lookup table Ωm (m=0, . . . , M−1) is formed from the outputs of a plurality of the first lookup tables Φn (n=0, 1, . . . , N−1). In particular, the input to the second lookup table Ωm (m=0, . . . , M−1) comprises, or represents, at least a component (or part) of each of a respective plurality of the first lookup tables Φn (n=0, 1, . . . , N−1). The set of second lookup tables is based on (or implements) the second functions Gn (n=0, 1, . . . , N−1) and the linear transformation L.


In some embodiments, the second stage may be arranged to generate a masked version of the amount of data y. For example, the second stage may be arranged to generate the amount of data y+r for some predetermined secret vector/value r≠0. It will be appreciated that the addition of r may be the result of just one of the second lookup tables Ωm (m=0, 1, . . . , M−1), or may the result of a plurality (perhaps all) of the second lookup tables Ωm (m=0, 1, . . . , M−1). The masking may then be undone at a later processing stage as appropriate. Indeed, in some embodiments in which c≠0, the second processing stage may be arranged to combine the output of the plurality of second lookup tables Ωm (m=0, 1, . . . , M−1) but without the addition of c, thereby generating the masked version of y, namely y−c (i.e. y+c).


In FIG. 5, a certain configuration of the links of outputs of first lookup tables Φn (n=0, 1, . . . , N−1) with inputs to second lookup tables Ωm (m=0, 1, . . . , M−1) (i.e. a certain entanglement) is shown, but it will be appreciated that this is merely one example. Such entanglements between the first lookup tables Φn (n=0, 1, . . . , N−1) and the second lookup tables Ωm (m=0, 1, . . . , M−1) helps improve resistance against correlation attacks, such as DCA attacks. The attacker is no longer able to focus on a single S-box—instead, the result of the linear transformation L base on the outputs of the plurality of S-boxes gets generated without an attacker being able to isolate the output of a single S-box. Indeed, the input to a single S-box affects the outputs of multiple second lookup tables Ωm (m=0, 1, . . . , M−1), which helps obfuscate any correlation between inputs and outputs. In other words, each bit of input affects more output bits than an conventional implementation, thereby making it harder for the attacker to analyse/attack.


A specific example of this is set out below, and is illustrated schematically in FIG. 6, based on the SM4 encryption discussed above with respect to FIG. 2b. In this example, N=4 and, for the rth round, the four S-boxes Sr,n (n=0, 1, 2, 3) implement the corresponding S-box function






H
r,n(x)=(A2((A1(x⊕kr,n⊕C1))−1))⊕C2


In this case, one may write Hr,n=Gr,n∘Fr,n, where Fr,n(x)=(A1(x⊕kr,n⊕C1))−1 and Gr,n(x)=A2x⊕C2.


The 128-bit input to the rth round comprises, or is treated as a concatenation of, four 32-bit quantities (or values): vr, vr+1, vr+2, vr+3. For the first processing stage shown in FIG. 5, the amount of data x is the XOR of vr+1, vr+2 and vr+3 shown in FIG. 2b. Then, xr,n (n=0, 1, 2, 3) is the 8-bit value formed from the block of bits 8n to 8n+7 of x. Thus, for the rth round there will be four respective Type 1 lookup tables Φr,n (n=0, 1, 2, 3), with lookup tables Φr,n using xr,n as an input and providing Fr,n(xr,n) (or a representation thereof) as an output.


The outputs Fr,n(xr,n) from the lookup tables Φr,n (n=0, 1, 2, 3) for the rth round are 8-bit values, each of which may be viewed as having three respective components, namely: er,n,0 is the 8-bit value whose 3 most significant bits match those of Fr,n(xr,n) and whose other bits are 0; er,n,1 is the 8-bit value whose 2 middle bits match those of Fr,n(xr,n) and whose other bits are 0; and er,n,2 is the 8-bit value whose 3 least significant bits match those of Fr,n(xr,n) and whose other bits are 0. Thus Fr,n(xr,n)=er,n,0+er,n,1+er,n,2. Of course, the way in which components are chosen/selected may change from one Type 1 table to another Type 1 table. Likewise, the way in which components are chosen/selected may change from one round to another round.


The set of components Er={er,n,j: n=0, . . . , 3; j=0, 1, 2} could be partitioned in a variety of ways, but suppose that five partitions are used so that M=5, e.g. Er,0={er,0,0, er,1,2}, Er,1={er,0,1, er,1,0, er,3,2}, Er,2={er,0,2, er,2,1}, Er,3={er,2,0, er,3,1} and Er,4={er,1,1, er,2,2, er,3,0}. Of course, the way in which components are partitioned may change from one round to another round.


Then, for the rth round there will be five respective Type 2 lookup tables Ωr,m (m=0, . . . , M−1), where:

    • (a) The input to Ωr,0 corresponds to, or is based on, er,0,0 and er,1,2 and, therefore, could be a 6-bit value formed from the 3 most significant bits of the output of Φr,0 and the 3 least significant bits of the output of Φr,1; the output of Ωr,0 would then be







[





l

0
,
0




G

r
,
0




e

r
,
0
,
0









l

1
,
0




G

r
,
0




e

r
,
0
,
0









l

2
,
0




G

r
,
0




e

r
,
0
,
0









l

3
,
0




G

r
,
0




e

r
,
0
,
0






]

+


[





l

0
,
1




G

r
,
1




e

r
,
1
,
2









l

1
,
1




G

r
,
1




e

r
,
1
,
2









l

2
,
1




G

r
,
1




e

r
,
1
,
2









l

3
,
1




G

r
,
1




e

r
,
1
,
2






]

.







    • (b) The input to Ωr,1 corresponds to, or is based on, er,0,1, er,1,0 and er,3,2 and, therefore, could be an 8-bit value formed from the 2 middle bits of the output of Φr,0, the 3 most significant bits of the output of Φr,1 and the 3 least significant bits of the output of Φr,3; the output of Ωr,1 would then be










[





l

0
,
0




G

r
,
0




e

r
,
0
,
0









l

1
,
0




G

r
,
0




e

r
,
0
,
0









l

2
,
0




G

r
,
0




e

r
,
0
,
0









l

3
,
0




G

r
,
0




e

r
,
0
,
0






]

+

[





l

0
,
1




G

r
,
1




e

r
,
1
,
2









l

1
,
1




G

r
,
1




e

r
,
1
,
2









l

2
,
1




G

r
,
1




e

r
,
1
,
2









l

3
,
1




G

r
,
1




e

r
,
1
,
2






]

+


[





l

0
,
3




G

r
,
3




e

r
,
3
,
2









l

1
,
3




G

r
,
3




e

r
,
3
,
2









l

2
,
3




G

r
,
3




e

r
,
3
,
2









l

3
,
3




G

r
,
3




e

r
,
3
,
2






]

.







    • (c) The input to Ωr,2 corresponds to, or is based on, er,0,2 and er,2,1 and, therefore, could be a 5-bit value formed from the 3 least significant bits of the output of Φr,0 and the 2 middle bits of the output of Φr,1; the output of Ωr,2 would then be










[





l

0
,
0




G

r
,
0




e

r
,
0
,
2









l

1
,
0




G

r
,
0




e

r
,
0
,
2









l

2
,
0




G

r
,
0




e

r
,
0
,
2









l

3
,
0




G

r
,
0




e

r
,
0
,
2






]

+


[





l

0
,
2




G

r
,
2




e

r
,
2
,
1









l

1
,
2




G

r
,
2




e

r
,
2
,
1









l

2
,
2




G

r
,
2




e

r
,
2
,
1









l

3
,
2




G

r
,
2




e

r
,
2
,
1






]

.







    • (d) The input to Ωr,3 corresponds to, or is based on, er,2,0 and er,3,1 and, therefore, could be a 5-bit value formed from the 3 most significant bits of the output of Φr,2 and the 2 middle bits of the output of Φr,3; the output of Ωr,3 would then be










[





l

0
,
2




G

r
,
2




e

r
,
2
,
0









l

1
,
2




G

r
,
2




e

r
,
2
,
0









l

2
,
2




G

r
,
2




e

r
,
2
,
0









l

3
,
2




G

r
,
2




e

r
,
2
,
0






]

+


[





l

0
,
3




G

r
,
3




e

r
,
3
,
1









l

1
,
3




G

r
,
3




e

r
,
3
,
1









l

2
,
3




G

r
,
3




e

r
,
3
,
1









l

3
,
3




G

r
,
3




e

r
,
3
,
1






]

.







    • (e) The input to Ω4 corresponds to, or is based on, er,1,1, er,2,2 and er,3,0 and, therefore, could be an 8-bit value formed from the 2 middle bits of the output of Φr,1, the 3 least significant bits of the output of Φr,2 and the 3 most significant bits of the output of Φr,3; the output of Ωr,4 would then be










[





l

0
,
1




G

r
,
1




e

r
,
1
,
1









l

1
,
1




G

r
,
1




e

r
,
1
,
1









l

2
,
1




G

r
,
1




e

r
,
1
,
1









l

3
,
1




G

r
,
1




e

r
,
1
,
1






]

+

[





l

0
,
2




G

r
,
2




e

r
,
2
,
2









l

1
,
2




G

r
,
2




e

r
,
2
,
2









l

2
,
2




G

r
,
2




e

r
,
2
,
2









l

3
,
2




G

r
,
2




e

r
,
2
,
2






]

+


[





l

0
,
3




G

r
,
3




e

r
,
3
,
0









l

1
,
3




G

r
,
3




e

r
,
3
,
0









l

2
,
3




G

r
,
3




e

r
,
3
,
0









l

3
,
3




G

r
,
3




e

r
,
3
,
0






]

.





As mentioned, each S-box Sn (n=0, 1, . . . , N−1) implements a respective function Hn that can be written as either (a) the composition of a respective first function Fn and a respective second function Gn so that Hn=Gn∘Fn, or (b) the composition of a respective first function Fn, a respective second function Gn and a respective third function Wn so that Hn=Gn∘Fn∘Wn. There may be multiple ways of writing Hn as a composition of two or more functions. For example, as discussed above for the SM4 encryption example of FIG. 2b, N=4 and, for the rth round, the four S-boxes Sr,n (n=0, 1, 2, 3) implement the corresponding S-box function Hr,n(x)=(A2((A1(x⊕kr,n⊕C1))−1))⊕C2, so that one may write Hr,n=Gr,n∘Fr,n, where Fr,n(x)=(A1(x⊕kr,n⊕C1))−1 and Gr,n(x)=A2x⊕C2. Likewise, for the AES encryption example of FIG. 3b, N=16 and, for the rth round, the sixteen S-boxes Sr,n (n=0, 1, 2, 15) implement the corresponding S-box function Hr,n(x)=A1((x⊕kr−1,n)−1))⊕C1, so that one may write Hr,n=Gr,n∘Fr,n, where Fr,n(x)=(x⊕kr−1,n)−1 and Gr,n(x)=A2x⊕C2. Such formulations for the respective first and second functions Fn and Gn are naturally derived from the S-box function Hn. However, given any representation of the S-box function as either (a) the composition of a respective first function {circumflex over (F)}n and a respective second function Ĝn so that Hnn∘{circumflex over (F)}n, or (b) the composition of a respective first function {circumflex over (F)}n, a respective second function Ĝn and a respective third function Wn so that Hnn∘{circumflex over (F)}n∘Ŵn, it is possible to define a respective first function Fn and a respective second function Gn so that Hn=Gn∘Fn, or Hn=Gn∘Fn∘Wn as appropriate, where (i) Gn=(Ĝn∘Tn−1∘Jn−1) and Fn=(Jn∘Tn∘{circumflex over (F)}n) or (ii) Gn=(Ĝn∘Jn−1∘Tn−1) and Fn=(Tn∘Jn∘{circumflex over (F)}n) or (iii) Gn=(Ĝn∘Jn−1) and Fn=(Jn∘{circumflex over (F)}n) or (iv) Gn=(Ĝn∘Tn−1) and Fn=(Tn∘{circumflex over (F)}n) for invertible functions Tn and Jn, as discussed below. In particular, in some embodiments of the invention, the functions Tn (n=0, 1, . . . , N−1) are Bn-bit to Bn-bit invertible linear transformations and the functions Jn (n=0, 1, . . . , N−1) are one-to-one bit-expansion-functions, in that they map a Bn,1-bit value to a uniquely corresponding Bn,2-bit value, where Bn,2>Bn,1. For notation purposes, Jn−1 is the function whose domain is the codomain of Jn, so that Jn−1(α)=β if β is a Bn,1-bit value with Jn(β)=α. The use of the invertible linear transformations Tn (n=0, 1, . . . , N−1) helps obfuscate the Type 1 and Type 2 tables, whilst the use of the bit-expansion-functions Jn (n=0, 1, . . . , N−1) makes it harder for an attacker since there is a larger apparent dynamic range of values for the attacker to analyse.


The invertible linear transformations Tn (n=0, 1, . . . , N−1) could be any linear transformations and could, for example, be randomly generated. In some embodiments, Tn1 is different from Tn2 for some n1≠n2; in other embodiments, Tn is the same for all n=0, 1, . . . , N−1. In embodiments that make use of the invertible linear transformations Tn (n=0, 1, . . . , N−1), the first lookup tables Φn (n=0, 1, . . . , N−1) implement a corresponding obfuscation transformation that is undone by the plurality of second lookup tables Ωm (m=0, 1, . . . , M−1).


An example of bit-expansion-function Jn (n=0, 1, . . . , N−1) is as follows. Suppose Bn,1=8 and Bn,2=12. If the input to the bit-expansion function Jn is z (as an 8-bit vector or element of custom-character28), then let γ0 and γ1 be 4-bit values made from different bits of z, so that z can be reformed from γ0 and γ1 (e.g. γ0 is the value made from the 4 most significant bits of z and γ1 is the value made from the 4 least significant bits of z). Jn may generate two 4-bit random numbers α1 and β1, and define two 4-bit numbers α0 and β0 as α00⊕α1 and β01⊕β1. Then Jn(z)=(δ0, δ1, δ2), i.e. a triple of three 4-bit numbers, where δ00⊕β0, δ11⊕β1 and δ21⊕β0. Here we note that γ00⊕δ2 and γ11⊕δ2, so that γ0 and γ1 (and hence z) may be recovered from (δ0, δ1, δ2), thereby defining the inverse mapping Jn−1 over the codomain of Jn. Thus, one could represent Jn(z) with three 12-bit vectors or components, namely








e
0

=

[




δ
0





0




0



]


,


e
1

=



[



0





δ
1





0



]



and



e
2


=

[



0




0





δ
2




]







(with 0, δ0, δ1, δ2 viewed here as 4-bit vectors), so that Jn(z) (as an 12-bit vector or element of custom-character212) is Jn(z)=e0+e1+e2. It will be appreciated, of course, that other bit-expansion functions could be used instead. Regardless, in embodiments that make use of bit-expansion-functions Jn (n=0, 1, . . . , N−1), the outputs of the first lookup tables Φn (n=0, 1, . . . , N−1) have a larger bit width than the inputs to the first lookup tables Φn (n=0, 1, . . . , N−1).



FIG. 7 is a flowchart illustrating a method 700, according to some embodiments of the invention, for performing a cryptographic process that generates output data dOut based on input data dIn. As set out above, generating the output data dOut involves generating a value y based on an amount of data x. The value y represents a combination, according to a linear transformation L, of respective outputs from a plurality of S-boxes Sn (n=0, . . . , N−1) for integer N>1. Each S-box Sn (n=0, . . . , N−1) implements a respective function Hn that is either (a) the composition of a respective first function Fn and a respective linear or affine second function Gn so that Hn=Gn∘Fn, or (b) the composition of a respective first function Fn, a respective linear or affine second function Gn and a respective third function Wn so that Hn=Gn∘Fn∘Wn.


At a step 702, the method 700 comprises performing a first processing stage. The first processing stage uses a plurality of first lookup tables Φn (n=0, 1, . . . , N−1) to generate respective outputs, each output being based on at least part of the amount of data x. For each S-box Sn (n=0, . . . , N−1), the respective first function Fn is implemented by a corresponding first lookup table Φn.


At a step 704, the method 700 comprises performing a second processing stage. The second processing stage combines outputs from a plurality of second lookup tables Ωm (m=0, 1, . . . , M−1) to generate the value y (and potentially with the addition of c if c≠0). The input to each second lookup table Ωm (m=0, 1, . . . , M−1) is formed from the output of a plurality of the first lookup tables (namely the components en,d∈Em). The set of second lookup tables is based on the second functions Gn (n=0, . . . , N−1) and the linear transformation L.


The first processing stage and the second processing stage generate the value y based on the amount of data x.



FIG. 8 is a flowchart illustrating a method 800, according to some embodiments of the invention, for generating a secured implementation of a cryptographic process. The cryptographic process itself generates output data dOut based on input data dIn. As set out above, generating the output data dOut involves generating a value y based on an amount of data x. The value y represents a combination, according to a linear transformation L, of respective outputs from a plurality of S-boxes Sn (n=0, . . . , N−1) for integer N>1. Each S-box Sn (n=0, . . . , N−1) implements a respective function Hn that is either (a) the composition of a respective first function Fn and a respective linear or affine second function Gn so that Hn=Gn∘Fn, or (b) the composition of a respective first function Fn, a respective linear or affine second function Gn and a respective third function Wn so that Hn=Gn∘Fn∘Wn.


At a step 802, the method 800 comprises implementing a first processing stage. This involves generating a plurality of first lookup tables Φn (n=0, 1, . . . , N−1) that provide respective outputs, each output being based on at least part of the amount of data x. For each S-box Sn (n=0, . . . , N−1), the respective first function Fn is implemented by a corresponding first lookup table Φn.


At a step 804, the method 800 comprises performing a second processing stage. This involves generating a plurality of second lookup tables Ωm (m=0, 1, . . . , M−1). The second processing stage is arranged or configured to combine outputs from the plurality of second lookup tables Ωm (m=0, 1, . . . , M−1) to generate the value y. The input to each second lookup table Ωm (m=0, 1, . . . , M−1) is formed from the output of a plurality of the first lookup tables (namely the components en,d∈Em). The set of second lookup tables is based on the second functions Gn (n=0, . . . , N−1) and the linear transformation L.


The first processing stage and the second processing stage, together, are arranged to generate the value y based on the amount of data x.


4—Modifications

It will be appreciated that the methods described have been shown as individual steps carried out in a specific order. However, the skilled person will appreciate that these steps may be combined or carried out in a different order whilst still achieving the desired result.


It will be appreciated that embodiments of the invention may be implemented using a variety of different information processing systems. In particular, although the figures and the discussion thereof provide an exemplary computing system and methods, these are presented merely to provide a useful reference in discussing various aspects of the invention. Embodiments of the invention may be carried out on any suitable data processing device, such as a personal computer, laptop, personal digital assistant, mobile telephone, set top box, television, server computer, etc. Of course, the description of the systems and methods has been simplified for purposes of discussion, and they are just one of many different types of system and method that may be used for embodiments of the invention. It will be appreciated that the boundaries between logic blocks are merely illustrative and that alternative embodiments may merge logic blocks or elements, or may impose an alternate decomposition of functionality upon various logic blocks or elements.


It will be appreciated that the above-mentioned functionality may be implemented as one or more corresponding modules as hardware and/or software. For example, the above-mentioned functionality may be implemented as one or more software components for execution by a processor of the system. Alternatively, the above-mentioned functionality may be implemented as hardware, such as on one or more field-programmable-gate-arrays (FPGAs), and/or one or more application-specific-integrated-circuits (ASICs), and/or one or more digital-signal-processors (DSPs), and/or one or more graphical processing units (GPUs), and/or other hardware arrangements. Method steps implemented in flowcharts contained herein, or as described above, may each be implemented by corresponding respective modules; multiple method steps implemented in flowcharts contained herein, or as described above, may be implemented together by a single module.


It will be appreciated that, insofar as embodiments of the invention are implemented by a computer program, then one or more storage media and/or one or more transmission media storing or carrying the computer program form aspects of the invention. The computer program may have one or more program instructions, or program code, which, when executed by one or more processors (or one or more computers), carries out an embodiment of the invention. The term “program” as used herein, may be a sequence of instructions designed for execution on a computer system, and may include a subroutine, a function, a procedure, a module, an object method, an object implementation, an executable application, an applet, a servlet, source code, object code, byte code, a shared library, a dynamic linked library, and/or other sequences of instructions designed for execution on a computer system. The storage medium may be a magnetic disc (such as a hard drive or a floppy disc), an optical disc (such as a CD-ROM, a DVD-ROM or a BluRay disc), or a memory (such as a ROM, a RAM, EEPROM, EPROM, Flash memory or a portable/removable memory device), etc. The transmission medium may be a communications signal, a data broadcast, a communications link between two or more computers, etc.

Claims
  • 1. A method of performing a cryptographic process in a secured manner, wherein the cryptographic process generates output data based on input data, the generating of the output data involving generating a value y based on an amount of data x, the value y representing a combination, according to a linear transformation L, of respective outputs from a plurality of S-boxes Sn (n=0, . . . , N−1) for integer N>1, wherein each S-box Sn (n=0, . . . , N−1) implements a respective function Hn that is either (a) the composition of a respective first function Fn and a respective linear or affine second function Gn so that Hn=Gn∘Fn, or (b) the composition of a respective first function Fn, a respective linear or affine second function Gn and a respective third function Wn so that Hn=Gn∘Fn∘Wn, wherein the method comprises: performing a first processing stage and a second processing stage to generate the value y based on the amount of data x, wherein:the first processing stage uses a plurality of first lookup tables to generate respective outputs, each output being based on at least part of the amount of data x, wherein, for each S-box Sn (n=0, . . . , N−1), the respective first function Fn is implemented by a corresponding first lookup table; andthe second processing stage combines outputs from a plurality of second lookup tables to generate the value y, wherein the input to each second lookup table is formed from the output of a plurality of the first lookup tables, and wherein the set of second lookup tables is based on the second functions Gn (n=0, . . . , N−1) and the linear transformation L.
  • 2. A method of generating a secured implementation of a cryptographic process, wherein the cryptographic process generates output data based on input data, the generating of the output data involving generating a value y based on an amount of data x, the value y representing a combination, according to a linear transformation L, of respective outputs from a plurality of S-boxes Sn (n=0, . . . , N−1) for integer N>1, wherein each S-box Sn (n=0, . . . , N−1) implements a respective function Hn that is either (a) the composition of a respective first function Fn and a respective linear or affine second function Gn so that Hn=Gn∘Fn, or (b) the composition of a respective first function Fn, a respective linear or affine second function Gn and a respective third function Wn so that Hn=Gn∘Fn∘Wn, wherein the method comprises: implementing a first processing stage and a second processing stage that, together, are arranged to generate the value y based on the amount of data x, wherein:implementing the first processing stage comprises generating a plurality of first lookup tables that provide respective outputs, each output being based on at least part of the amount of data x, wherein, for each S-box Sn (n=0, . . . , N−1), the respective first function Fn is implemented by a corresponding first lookup table; andimplementing the second processing stage comprises generating a plurality of second lookup tables, the second processing stage arranged to combine outputs from the plurality of second lookup tables to generate the value y, wherein the input to each second lookup table is formed from the output of a plurality of the first lookup tables, and wherein the set of second lookup tables is based on the second functions Gn (n=0, . . . , N−1) and the linear transformation L.
  • 3. The method of claim 1, wherein the outputs of the first lookup tables have a larger bit width than the inputs to the first lookup tables.
  • 4. The method of claim 1, wherein the first lookup tables implement a corresponding obfuscation transformation that is undone by the plurality of second lookup tables.
  • 5. The method of claim 1, wherein the output of each first lookup table being based on at least part of the amount of data x comprises the output of each first lookup table being based on a corresponding portion of bits of the amount of data x.
  • 6. The method of claim 1, wherein the output of each first lookup table comprises the sum of a respective plurality of components, and wherein the input to each second lookup table is formed from one or more respective components of each of said plurality of the first lookup tables.
  • 7. A system arranged to perform a cryptographic process in a secured manner, wherein the cryptographic process generates output data based on input data, the generating of the output data involving generating a value y based on an amount of data x, the value y representing a combination, according to a linear transformation L, of respective outputs from a plurality of S-boxes Sn (n=0, . . . , N−1) for integer N>1, wherein each S-box Sn (n=0, . . . , N−1) implements a respective function Hn that is either (a) the composition of a respective first function Fn and a respective linear or affine second function Gn so that Hn=Gn∘Fn, or (b) the composition of a respective first function Fn, a respective linear or affine second function Gn and a respective third function Wn so that Hn=Gn∘Fn∘Wn, wherein the system comprises one or more processors configure to: perform a first processing stage and a second processing stage to generate the value y based on the amount of data x, wherein:the first processing stage uses a plurality of first lookup tables to generate respective outputs, each output being based on at least part of the amount of data x, wherein, for each S-box Sn (n=0, . . . , N−1), the respective first function Fn is implemented by a corresponding first lookup table; andthe second processing stage combines outputs from a plurality of second lookup tables to generate the value y, wherein the input to each second lookup table is formed from the output of a plurality of the first lookup tables, and wherein the set of second lookup tables is based on the second functions Gn (n=0, . . . , N−1) and the linear transformation L.
  • 8. A system arranged to generate a secured implementation of a cryptographic process, wherein the cryptographic process generates output data based on input data, the generating of the output data involving generating a value y based on an amount of data x, the value y representing a combination, according to a linear transformation L, of respective outputs from a plurality of S-boxes Sn (n=0, . . . , N−1) for integer N>1, wherein each S-box Sn (n=0, . . . , N−1) implements a respective function Hn that is either (a) the composition of a respective first function Fn and a respective linear or affine second function Gn so that Hn=Gn∘Fn, or (b) the composition of a respective first function Fn, a respective linear or affine second function Gn and a respective third function Wn so that Hn=Gn∘Fn∘Wn, wherein the system comprises one or more processors arranged to: implement a first processing stage and a second processing stage that, together, are arranged to generate the value y based on the amount of data x, wherein:implementing the first processing stage comprises generating a plurality of first lookup tables that provide respective outputs, each output being based on at least part of the amount of data x, wherein, for each S-box Sn (n=0, . . . , N−1), the respective first function Fn is implemented by a corresponding first lookup table; andimplementing the second processing stage comprises generating a plurality of second lookup tables, the second processing stage arranged to combine outputs from the plurality of second lookup tables to generate the value y, wherein the input to each second lookup table is formed from the output of a plurality of the first lookup tables, and wherein the set of second lookup tables is based on the second functions Gn (n=0, . . . , N−1) and the linear transformation L.
  • 9. The system of claim 7, wherein the outputs of the first lookup tables have a larger bit width than the inputs to the first lookup tables.
  • 10. The system of claim 7, wherein the first lookup tables implement a corresponding obfuscation transformation that is undone by the plurality of second lookup tables.
  • 11. The system of claim 7, wherein the output of each first lookup table being based on at least part of the amount of data x comprises the output of each first lookup table being based on a corresponding portion of bits of the amount of data x.
  • 12. The system of claim 7, wherein the output of each first lookup table comprises the sum of a respective plurality of components, and wherein the input to each second lookup table is formed from one or more respective components of each of said plurality of the first lookup tables.
  • 13. (canceled)
  • 14. (canceled)
  • 15. The method of claim 2, wherein the outputs of the first lookup tables have a larger bit width than the inputs to the first lookup tables.
  • 16. The method of claim 2, wherein the first lookup tables implement a corresponding obfuscation transformation that is undone by the plurality of second lookup tables.
  • 17. The method of claim 2 wherein the output of each first lookup table being based on at least part of the amount of data x comprises the output of each first lookup table being based on a corresponding portion of bits of the amount of data x.
  • 18. The method of claim 2, wherein the output of each first lookup table comprises the sum of a respective plurality of components, and wherein the input to each second lookup table is formed from one or more respective components of each of said plurality of the first lookup tables.
  • 19. The system of claim 8, wherein the outputs of the first lookup tables have a larger bit width than the inputs to the first lookup tables.
  • 20. The system of claim 8, wherein the first lookup tables implement a corresponding obfuscation transformation that is undone by the plurality of second lookup tables.
  • 21. The system of claim 8, wherein the output of each first lookup table being based on at least part of the amount of data x comprises the output of each first lookup table being based on a corresponding portion of bits of the amount of data x.
  • 22. The system of claim 8, wherein the output of each first lookup table comprises the sum of a respective plurality of components, and wherein the input to each second lookup table is formed from one or more respective components of each of said plurality of the first lookup tables.
Priority Claims (1)
Number Date Country Kind
21193193.6 Aug 2021 EP regional