Low-depth AES SBox architecture for area-constrained hardware
By designing a new SBox circuit architecture in the AES hardware implementation, removing the bottom matrix and adopting parallel computing, the problem of large depth of SBox subcomponents is solved, achieving faster encryption speed and smaller area, suitable for area-limited applications ASICs and FPGAs.
Patent Information
- Application Number
- CN202080029402.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2019-04-15
- Filing Date
- 2020-03-06
- Publication Date
- 2024-10-08
- Estimated Expiration
- 2040-03-06
AI Technical Summary
In existing AES hardware implementations, the depth of the SBox subcomponent is large, resulting in limited encryption speed. It is especially difficult to implement efficient AES encryption algorithms in area-limited ASICs and FPGAs.
By designing a new SBox circuit architecture, the traditional bottom matrix is removed, and the top linear matrix is used for parallel computing to reduce circuit depth. The circuit structure is optimized through multiplexers to achieve lower depth and area.
A shorter critical path is achieved, the frequency of AES encryption and decryption is increased, circuit depth is reduced by approximately 25%-30%, and smaller area and faster encryption algorithms are implemented in ASICs and FPGAs.
Smart Images

Figure CN113711533B_ABST
Abstract
Description
Technical Field
[0001] The embodiments presented herein relate to devices, methods therein, controllers, computer programs, and computer program products. Specifically, they relate to and are associated with the following technical fields / keywords: Advanced Encryption Standard AES, SBox, hardware implementation, critical path. Background Art
[0002] Technical Background / Prior Art
[0003] Advanced Encryption Standard (AES) is an encryption algorithm standardized by the National Institute of Standards and Technology (NIST) of the United States and is one of the most widely used encryption algorithms today. It is used to protect Web traffic in the TLS protocol and is also used in 3GPP LTE systems as one of the three air interface encryption methods.
[0004] Hardware implementations of AES are also common, especially in high-speed applications such as LTE networks, but also in datacom, the need for hardware-accelerated encryption algorithms is critical for high-load servers that terminate encrypted network traffic directly in the network interface card (NIC) and thereby reduce the load on the main CPU.
[0005] The AES encryption algorithm is described in detail in [1], but will be described very briefly here. AES is a block cipher that takes two input variables, plaintext (P) and a key (K), and produces a ciphertext (C) as output. The size of P and C determines the block size of the cipher, in the case of AES this is 128 bits, so both P and C are 128 bits in size. The key K can be 128, 192, or 256 bits in size. The input P is split into 16 bytes and arranged in a 4×4 byte matrix called the state matrix. The algorithm consists of a series of operations performed on the state matrix, scrambling the plaintext more and more into the final ciphertext output. These operations are grouped together in so-called rounds. Each round in AES performs the following operations: SubBytes, ShiftRows, MixColumns, and AddRoundKey. Depending on the size of K (128, 192, or 256 bits), the algorithm performs 10, 12, or 14 of these rounds. For hardware implementations, the state matrix between each round is usually stored in some kind of register (flip-flops or latches). This means that the maximum clock speed at which the circuit can be clocked is determined by how fast the signal can move from one register to the next. The speed of a signal is primarily determined by the number of gates the signal must pass through before being stored in the latches. The number of gates a signal passes through is often referred to as the depth of the signal, or path depth. The critical path of a circuit is the longest path (most gates to pass through) of any component signal in the circuit.
[0006] This disclosure will focus on the so-called SBox or substitution box of AES, which is the basic building block of the SubBytes operation. It is also the operation with the highest gate count and the highest round function depth. Therefore, minimizing the number of gates used to implement it and the depth of the circuit is an interesting and valuable research goal. Minimizing the number of gates reduces the area and power consumption of the circuit, and as mentioned above, minimizing the critical path increases the possible clock rate of the algorithm, making encryption / decryption faster.
[0007] Efficient hardware design of the AES SBox is a subject of intensive research. If absolute maximum speed is desired, a simple table lookup implementation is most likely to be used, which naturally results in a larger area. In many practical cases, the physical area of the cryptographic subsystem is limited and the designer cannot implement a table lookup for the SBoxes involved in an AES round, especially when implementing in an FPGA. For these cases, it is necessary to investigate how to implement the AES SBox using only logic gates, focusing on area and maximum clocking speed. The maximum clocking speed of a circuit is determined by the critical path or depth of the circuit and the worst-case time it takes to obtain a stable output signal from a change in the input signal.
[0008] Another aspect when implementing AES is the need for a reversal cipher. Many modes of operation of block ciphers use only the encryption function and therefore do not require a reversal cipher. If both a forward SBox and a reverse SBox are needed, it is often beneficial to combine the two circuits. This is because the primary operation of the AES SBox is field element inversion, which is naturally its own inverse, and it is expected that many gates of the two circuits can be shared.
[0009] Figure 1 is a block diagram of an SBox circuit 101 that is advantageously used in an AES circuit to map an 8-bit input 103 to an 8-bit output 105.
[0010] At the circuit level, SBox 101 defines 8 Boolean functions, each taking 8 bits as input. From a mathematical point of view, the forward AES SBox is defined as a combination of a nonlinear function I(g) and an affine function A(g) such that SBox(g) = A(I(g)). Nonlinear function I(g) = g -1 is the irreducible polynomial x 8 +x 4 +x 3 The multiplicative inverse of an element g in the finite field GF(2^8) defined by x + x + 1. The circuit to construct the inverse over GF(2^8) is very large, so it is desirable to minimize it.
[0011] Rijmen [2] described the first step towards a small area implementation. The idea is to use GF((24 ) 2 ) to perform basis transformation, GF(2 8 ) can be simplified to the subfield GF(2 4 ) is a much simpler reverse calculation.
[0012] In 2001, Satoh et al. published [3] which took this idea a step further and simplified the inverse calculation to the subfield GF(2 2 ). This approach is called the tower domain construction. In 2005, Canright published [4], building on the work of Satoh et al., studying the importance of subdomain representations and testing many different isomorphisms that lead to the minimum area design. This construction is probably the most commonly cited and used implementation of the area-constrained combinatorial AES SBox.
[0013] In a series of papers, Boyar, Peralta et al. proposed some very interesting ideas about subdomain inverters and new heuristics for minimizing logic circuit area [8, 9, 10, 11]. They used GF(2 4 ) is derived from an inverter with a depth of 4 and only 17 gates. The construction in
[10] is the starting point of the present invention.
[0014] After Boyar, several other papers focused on low-depth implementations, e.g. [5]. In 2018, two papers by Reyhani et al. [12, 6] introduced the most well-known implementations (so far) of both forward SBox and combined SBox.
[0015] Theoretically comparing the results
[0016] First, let's introduce the notation used in this article. Gate names are written with capital letters GATE (e.g., AND, OR). The notation mGATEn represents m gates of type GATE, each with n inputs (e.g., XOR4, 8XOR4, NAND3, 2AND2). When the number of inputs n is missing, the gate is assumed to have the minimum number of inputs, usually just 2 (3 for MUX).
[0017] 1. Standard Methods
[0018] The basic primitive elements considered in the standard approach are: {XOR, XNOR, AND, NAND, OR, NOR, MUX, NMUX, NOT}.
[0019] Negotiation of the NOT Gate. At certain locations in a circuit, it is necessary to use the inverted version of a signal. However, there are many ways to negotiate the need to use a NOT gate. Some of them are listed here.
[0020] Method 1. One way to negotiate a NOT gate is to change the previous gate that generated the signal to instead generate an inverted signal. For example, switch XOR to XNOR, switch AND to NAND, etc.
[0021] Method 2. In various technologies, there are gates that can generate both a positive signal and its inverted version. For example, the XOR gate in many implementations generates both signals at the same time, so the inverted value is available.
[0022] Method 3. Subsequent gates can be changed after the inverted signal so that given the inverted input, the subsequent scheme will produce the correct result.
[0023] In summary, it is considered that NOT gates can be ignored when evaluating the circuit using the standard method; they barely count as full gates in the standard method. However, for completeness, the number of NOT gates is included in the result table. However, some of these NOT gates can be further negotiated.
[0024] In the standard approach, the circuit area is calculated by counting the number of primitives without any size distinction between primitives. NOT gates are ignored. The depth is counted based on the number of primitives on the circuit path. Therefore, the total depth of the circuit is the delay of the critical path. NOT gates are ignored.
[0025] 2. Technical methods
[0026] Area. There are many ASIC technologies (90nm, 45nm, 14nm, etc.) from different vendors (Intel, Samsung, etc.) with different characteristics. To develop an ASIC, you need to have access to a "standard primitive library" for a specific technology, which typically includes much larger primitives than the standard elements listed above, allowing the design to have a wider choice of construction primitives.
[0027] However, even considering a standard primitive, such as XOR, this primitive has different areas and delays for different technologies. This makes it difficult to compare two circuits of the same logic developed by two teams when those teams choose to apply different technologies.
[0028] In order to fairly compare the circuit areas of various solutions in academia, the term "gate equivalent (GE)" is often used, where 1GE is the size of the smallest NAND gate. The circuit size (in terms of GE) is then calculated as Area(Circuit) / Area(NAND)→tGE. Knowing the estimated GE value for each standard or technology primitive enables the calculation of the estimated area size of the circuit in terms of GE. Although various technologies have slightly different GEs for standard primitives, these GE numbers are still quite close. For this disclosure, it has been decided to use the GE values given in the data sheet for Samsung's STD90 / MDL90 0.35μm 3.3V CMOS technology [7]. The primitives to be used have no speed x factor.
[0029] Depth. Different primitives (like XOR and NAND) differ not only in GE but also in the maximum delay of a gate.
[0030] Typically, the data sheet includes the delays (e.g., in ns) tPHL and tPLH for each gate and each input-output combination. The switching characteristics {tPHL, tPLH} are calculated as the difference between the time when the input switches 50% of the voltage threshold and the time when the output signal switches 50% of the voltage from high to low (tPHL) or from low to high (tPLH). It is recommended to normalize the delays of all gates used by the delay of the XOR gate. That is, the worst-case delay of the XOR gate is used as 1 unit in the measurement of the critical path. Then look at each standard primitive and select the maximum switching characteristics {tPHL, tPLH} for all input-output paths of the primitive. Then, they are divided by the maximum delay of the XOR gate to obtain the normalized delay unit for each gate used.
[0031] For multiplexers (MUX and NMUX), the propagation delay of the select bit is ignored because in most cases, the select bit is usually an input to the circuit. For example, in a combinatorial SBox, the select bit controls whether the forward SBox or the reverse SBox is calculated. The select is ready and does not switch when the circuit signal propagates, so it is a stable signal.
[0032] The method proposed above is similar to the idea of GE, but is used to calculate the depth of the circuit, normalized by the XOR delay. The reason for choosing XOR as the basic element of the delay count is that the circuit is most likely to have many XOR gates, so now the depth between the standard method and the technical method can be compared.
[0033] Previous Work
[0034] 1. Forward SBox
[0035] The most widely used design is that of Canright in 2005 [4]. Since 2005, there have been several attempts to improve the design of the forward SBox in terms of speed and area. The previous smallest known implementation was constructed by Boyar et al. in 2012
[10] , while Ueno et al. in 2015 [5] had the record for the shortest critical path. More recently, Reyhani et al. proposed a new construction that better balances the area-speed tradeoff
[12] . Previous results are summarized in Table 1.
[0036]
[0037] Table 1. Previous results on forward SBox.
[0038] 2. Combination SBox
[0039] The most widely used design is from Canright [4] published in 2005. The main disadvantage of this design is the relatively large critical path (large depth). After 2005, there have been many attempts to improve the design in terms of speed and area, but almost all of them focused only on implementing the forward SBox. This is relevant in certain operation modes where only the cryptographic part of the algorithm is used. In 2018, new results on the combined SBox were published by Reyhani et al. [6]. It improves both speed and depth. Previous results are summarized in Table 2.
[0040]
[0041] Table 2. Previous results on combined SBoxes.
[0042] Problems with existing solutions
[0043] The essence of the technique described herein is that it is able to do much better in terms of critical paths. Thus, implementations using the optimizations disclosed herein can be clocked at higher frequencies than previously implemented, thereby speeding up encryption and decryption, or implemented in an ASIC or FPGA using fewer primitives than, for example, table lookups. This will become increasingly important as communication speeds increase and Internet of Things (IoT) devices become smaller, and the need for area-optimized cryptographic algorithms in hardware increases. Summary of the invention
[0044] When implementing a cryptographic algorithm in hardware, the main parameter that determines the possible clock speed is the depth (or critical path) of the design. For the Advanced Encryption Standard (AES) [1], this path is dominated by the SBox subcomponent. Therefore, the goal is to find a Boolean expression for the SBox that gives the lowest possible depth. For area-constrained ASICs, it is also important to keep the area of the SBox small.
[0045] According to one aspect of the present invention, the above and other objectives are achieved by a technique (e.g., a method, an apparatus, a non-transitory computer-readable storage medium, a program device, such as when included in a cryptographic circuit) for implementing SBox functionality. In one aspect of some embodiments, an SBox circuit includes a first circuit portion, a second circuit portion, and a third circuit portion. The first circuit portion includes a digital circuit that generates a 4-bit first output signal (Y) based on an 8-bit input signal (U). The second circuit portion is configured to operate in parallel with the first circuit portion and generate a 32-bit second output signal (L) based on the 8-bit input signal (U), wherein the 32-bit second output signal (L) includes four 8-bit sub-results. The third circuit portion is configured to generate four preliminary 8-bit results (K) by scalar multiplying each of the four 8-bit sub-results by a corresponding one bit of the 4-bit first output signal (Y), and to generate an 8-bit output signal (R) by adding the four preliminary 8-bit results (K). In addition, the first circuit portion is configured to generate the 4-bit first output signal (Y) according to the input signal (U) by performing calculations including a first linear matrix operation, a Galois field GF multiplication, and a GF inversion; and the second circuit portion is configured to generate the second output signal (L) according to the input signal (U) by performing calculations including a second linear matrix operation.
[0046] In one aspect of some but not necessarily all embodiments consistent with the invention, the third circuit portion includes a digital circuit that performs a calculation according to the following formula:
[0047] R=Y0·M0·U⊕...⊕Y3·M3·U,
[0048] in:
[0049] Each M i is an 8×8 matrix representing the 8 linear equations on the 8-bit input U,
[0050] i=0..3,
[0051] L=M0·U||M1·U||M2·U||M3·U,
[0052] ⊕ represents the XOR operation, and
[0053] || indicates concatenation.
[0054] In another aspect of some, but not necessarily all, embodiments consistent with the invention, each of the first circuit portion, the second circuit portion, and the third circuit portion is configured from a digital circuit selected from any one or more of the following:
[0055] "Exclusive OR" XOR gate;
[0056] "XNOR" gate;
[0057] AND gate;
[0058] NAND gate;
[0059] OR gate;
[0060] NOR gate;
[0061] Multiplexer MUX;
[0062] NMUX gate;
[0063] NOT gate;
[0064] AND-OR inverter AOI; and
[0065] OR-AND inverter OAI.
[0066] In another aspect of some but not necessarily all embodiments consistent with the present invention, the first circuit portion and the second circuit portion are configured to generate the 4-bit first output signal (Y) and the 32-bit second output signal (L) according to a forward SBox operation.
[0067] In another aspect of some but not necessarily all embodiments consistent with the present invention, the first circuit portion (301, 503) and the second circuit portion (303, 505) are configured to generate the 4-bit first output signal (Y) and the 32-bit second output signal (L) according to an inverse SBox operation.
[0068] In another aspect of some but not necessarily all embodiments consistent with the invention, the first circuit portion and the second circuit portion are configured to generate the 4-bit first output signal (Y) and the 32-bit second output signal (L) according to a forward SBox operation; and the SBox circuit further includes a fourth circuit portion, a fifth circuit portion, and a selection circuit. The fourth circuit portion includes generating an alternative 4-bit output signal (Y) according to the 8-bit input signal (U) alt ) for a digital circuit for inverse SBox operation. The fifth circuit portion is configured to operate in parallel with the fourth circuit portion and generate an alternative 32-bit second output signal (L) based on the 8-bit input signal (U) alt ) for the inverse SBox operation, wherein the alternative 32-bit second output signal (L alt) includes four 8-bit sub-results. The selection circuit is controllable to connect the first circuit portion and the second circuit portion when the forward SBox operation is selected, and to connect the fourth circuit portion and the fifth circuit portion when the reverse SBox operation is selected.
[0069] As noted above, aspects of embodiments consistent with the present invention (such as those described above) may alternatively be embodied in other forms, such as but not limited to methods, non-transitory computer-readable storage media, and program devices (eg, computer program products). BRIEF DESCRIPTION OF THE DRAWINGS
[0070] The objects and advantages of the present invention will be understood from the following detailed description when read in conjunction with the accompanying drawings, in which:
[0071] Figure 1 is a block diagram of an SBox circuit that maps 8-bit input to 8-bit output;
[0072] Figure 2 This is a block diagram of the classic architecture of SBox;
[0073] Figure 3A and 3B are block diagrams respectively depicting a first alternative embodiment and a second alternative embodiment of an SBox according to the present invention;
[0074] Figure 4 It is a block diagram of the traditional SBox architecture;
[0075] Figure 5 is a block diagram of an SBox architecture consistent with the present invention;
[0076] Figure 6 depicts a set of graphs showing synthesis results of different embodiments of the Forward SBox;
[0077] Figure 7 depicts a set of graphs showing synthesis results of different embodiments of combining SBoxes;
[0078] Figure 8 is a flow chart of actions performed by embodiments consistent with the present invention in one aspect;
[0079] Fig. 9 A computer program, a computer-readable storage medium, and a computer program product are shown, all consistent with aspects of the present invention. DETAILED DESCRIPTION
[0080] The embodiments describing the method and the device are valid for all technologies having the features and possibilities discussed in the present disclosure.The embodiments described herein serve as non-limiting examples.
[0081] To facilitate a better understanding of the various aspects of the technology described herein, this "Detailed Description" is divided into three parts. The first part ("Part A") focuses on key aspects and provides a complete description of these aspects. The second part ("Part B") describes these aspects and also describes other aspects of the technology in addition to these aspects. The third part ("Part C") describes additional embodiments consistent with the technical aspects set forth in Parts A and B.
[0082] Part A
[0083] The classic SBox architecture is constructed using tower field extensions. To construct GF(2^8) using the tower field construction, we start with the base binary field GF(2) and construct the extension field following the teachings described in references [4,10]. Let us start with the irreducible polynomial f(x)=x^2+x+1 over GF(2). Let W be the root of f(x) such that f(W)=0. The normal base is constructed from the conjugate of W [W,W^2]. Now, every element k in GF(2^2) can be represented as k=k0W+k1W^2, where k0 and k1 are elements in GF(2); that is, 1 or 0.
[0084] Using the same technique, we can construct the field GF(2^4) from GF(2^2), and finally the target field GF(2^8) from GF(2^4). Table 3 summarizes the irreducible polynomials, roots, and normal bases used.
[0085]
[0086] Table 3. Definition of subfields used to construct GF(2^8).
[0087] Let A = a0Y + a1Y^16 be a common element in GF(2^8) with coefficients in GF(2^4). The inverse of A can be written as:
[0088] A -1 =(AA 16 ) -1 A 16
[0089] =((a0Y+a1Y 16 )(a1Y+a0Y 16 )) -1 (a1Y+a0Y 16 )
[0090] =((a 2 0+a 2 1) Y 17 +a0a1(Y 2+Y 32 )) -1 (a1Y+a0Y 16 )
[0091] =((a0+a1) 2 Y 17 +a0a1(Y+Y 16 ) 2 ) -1 (a1Y+a0Y 16 )
[0092] =((a0+a1) 2 WZ+a0a1) -1 (a1Y+a0Y 16 ).
[0093] The inversion of elements in GF(2^8) can be done in GF(2^4) as:
[0094] T1=(a0+a1) T2=(WZ)T1 2 T3=a0a1 T4=T2+T3
[0095] T5=T4 -1 T6=T5a1 T7=T5a0,
[0096] The result is A -1 =T6Y+T7Y 16 There are several operations used in these equations (addition, multiplication, scaling, and squaring), but only two of them are nonlinear in GF(2): multiplication and inversion. In addition, the standard multiplication operation also contains some linear operations. If all linear operations are separated from the nonlinear operations and combined with the AES SBox input (using the AES SBox irreducible polynomial x 8 +x 4 +x 3 +x+1 is represented in a polynomial basis) and the linear equations required for basis conversion are bundled together, and finally we get Figure 2 The classical architecture of an SBox 201 is shown (denoted here as "A"). The top linear layer 203 of the circuit performs the basis conversion and generates the linear part of the inverse. The bottom linear layer 205 performs the basis inverse conversion and affine transformation of the AES SBox.
[0097] Important Aspects of the Invention: "Architecture D"
[0098] The new architecture (herein referred to as "D" for depth) is one in which the bottom matrix of the earlier design is removed, thereby minimizing the depth of the circuit. The idea behind this is that the bottom matrix depends only on a set of multiplications of some linear combinations of the 4-bit signal Y and the 8-bit input U. The result R can be realized as follows:
[0099] R=Y0·M0·U⊕...⊕Y3·M3·U,
[0100] Among them, each M i is an 8×8 matrix representing eight linear equations on an 8-bit input U that will be compared with Y i 4×8 linear circuits can be computed as a 32-bit signal L, in parallel with the circuits for 4-bit Y. The result R is obtained by adding the four 8-bit sub-results. Therefore, in architecture D, in the inversion step (critical path: MULL and 8XOR4 blocks, see Figure 5 ) to obtain a depth of 3, instead of the depth of 5-6 in architecture A (see Figure 4 ).
[0101] The new architecture D requires a few more gates, as assembling the bottom circuit requires 56 gates: 32NAND2+8XOR4. The bonus is lower depth.
[0102] Figure 3A A block diagram depicting an exemplary embodiment of architecture D is shown. Figure 3B An alternative exemplary embodiment of architecture D is depicted. The difference between the two embodiments is that, by using further techniques described later herein, signal Q can be reduced from 22 bits to 18 bits. In all other respects, the two embodiments are identical, and for this reason and for efficiency, the description will focus on Figure 3B The embodiments shown, and it will be understood that the discussion applies equally to Figure 3A Embodiment of the invention.
[0103] like Figure 3B As shown, the Sbox circuit 300 is arranged to perform the SBox calculation steps when included in a cryptographic circuit. The exemplary SBox circuit (300) includes a first circuit portion 301, a second circuit portion 303, and a third circuit portion 305. The first circuit portion 301 includes a digital circuit that generates a 4-bit first output signal (Y) based on an 8-bit input signal (U).
[0104] The second circuit portion 303 is configured to operate in parallel with the first circuit portion 301 and to generate a 32-bit second output signal (L) from the 8-bit input signal (U), wherein the 32-bit second output signal (L) includes four 8-bit sub-results.
[0105] The third circuit portion 305 is configured to generate four preliminary 8-bit results (K) by scalar multiplying each of the four 8-bit sub-results (L) by a corresponding one bit of the 4-bit first output signal (Y), and to generate an 8-bit output signal (R) by adding the four preliminary 8-bit results (K).
[0106] Further according to an exemplary embodiment, the first circuit portion 301 is configured to generate a 4-bit first output signal (Y) according to the input signal (U) by providing the 8-bit input U to the first linear matrix circuit 307, which generates the output Q (in Figure 3A In the embodiment of Figure 3B The output Q is provided to the multiplication / summation circuit 309, which performs a Galois Field (GF) multiplication 309 to generate a 4-bit signal X, which is then provided to an inverse Galois Field circuit (311), which performs a GF inversion to generate a 4-bit signal Y.
[0107] Likewise, according to an exemplary embodiment, the second circuit portion 303 is configured to generate a second output signal L from the input signal U by performing a calculation including a second linear matrix operation.
[0108] In order to compare the traditional architecture A with the new architecture D, Figure 4 (Traditional Architecture A) and Figure 5 (New Architecture D) shows a more detailed description and implementation size of the different blocks.
[0109] First Look Figure 4 , it can be seen that the conventional SBox architecture 400 includes a top layer 401, which is alternately configured as a forward SBox (FTopA), an inverse SBox (ITopA), or a combination SBox (CTopA) that can select between forward calculation and inverse calculation. However, it is worth noting that the conventional SBox architecture 400 also includes a bottom layer 403, which is alternately configured for forward operation (FBotA), inverse operation (IBotA), or a combination (CBotA) that can select between forward operation and inverse operation.
[0110] The inventors have realized that by redistributing many functional aspects of the bottom layer into the upper layers, the bottom layer 403 of the conventional SBox architecture A 400 can be eliminated and the depth can be reduced. Figure 5 Architecture D500 shown.
[0111] Figure 5The depicted architecture D 500 has an organization equivalent to that shown in FIG3 . Notably, it includes a top layer 501 that is alternatively configured as a forward SBox (FTopD), an inverse SBox (ITopD), or a combined SBox (CTopD) that can select between forward and inverse computations. In the case of a combined SBox (CTopD), the selection between forward and inverse computations depends on the forward / inverse received.
[0112] A notable feature is the traditional bottom layer (see e.g. Figure 4 Some functional aspects of the bottom layer 403 in the new architecture 500 have been redistributed to the upper layers of the new architecture 500 so that it now has a first circuit portion 503 operating in parallel with a second circuit portion 505. The first circuit portion 503 generates a 4-bit first output signal (Y) based on an 8-bit input signal (U), and the second circuit portion 505 generates a 32-bit second output signal (L) based on the 8-bit input signal (U), wherein the 32-bit second output signal (L) includes four 8-bit sub-results.
[0113] The output Y from the first circuit portion 503 and the output L from the second circuit portion 505 are processed together by the third circuit portion 509, which is configured to generate four preliminary 8-bit results (K) by scalar multiplying each of the four 8-bit sub-results by a corresponding one bit of the 4-bit first output signal (Y), and to generate an 8-bit output signal (R) by adding the four preliminary 8-bit results (K).
[0114] Details of an exemplary gate configuration of the new SBox architecture 500 are presented below.
[0115] Prerequisites
[0116] In the listing given below, the specifications of the six circuits of the forward, reverse, and combined SBoxes in two architectures A (small) and D (fast) are described. The symbols used in the following listings are as follows and have the indicated meanings:
[0117] #comment – comment line
[0118] @filename – indicates that code from another file called “filename” should be included, and its listing is then also given in this section.
[0119] a^b – is the common XOR gate; other gates are explicitly represented and are taken from the set {XNOR, AND, NAND, OR, NOR, MUX, NMUX, NOT}
[0120] (a op b) – In cases where the order of execution (the order in which gates are connected) is important, specify that order with parentheses.
[0121] The input to all SBoxes is 8 signals {U0..U7} and the output is 8 signals {R0..R7}. The input bits and output bits are represented in Big Endian bit order. For the combined SBox, the input has additional signals ZF and ZI, ZF=1 if the forward SBox is executed, otherwise ZF=0 if the reverse SBox is executed; signal ZI is the complement signal of ZF. We have tested all the proposed circuits and verified their correctness.
[0122] These circuits are divided into subroutines corresponding to Figure 5 Functionality / layers shown. The discussion begins by describing the common shared components, and then for each solution, the components of the circuit (common or specific) are described.
[0123] Shared Components
[0124] MANIFEST: MULX / INV / S0 / S1 / 8XOR4: shared components.
[0125]
[0126]
[0127] MANIFEST:MULN / MULL: Shared components.
[0128]
[0129] Listing: Forward SBox with Minimum Latency (Fast)
[0130] Forward SBox (fast)
[0131]
[0132] Checklist: Forward SBox circuit with area / depth tradeoff (best)
[0133] Forward SBox (Best)
[0134]
[0135] The following bonus circuit is included to update the world record for the smallest SBox.
[0136] The new record is 108 gates with a depth of 24.
[0137] Checklist: Forward SBox Circuit with Minimum Gate Count (Bonus)
[0138]
[0139] Listing: Inverse SBox with Minimal Latency (Fast)
[0140] Reverse SBox (fast)
[0141]
[0142] Checklist: Inverse SBox Circuit with Area / Depth Tradeoff (Best)
[0143] Reverse SBox (Best)
[0144]
[0145] Note: The above 'NOT(U2)' in the file 'itop.a' can be removed by setting Q11 = U2 and negating some of the gates and variables involving Q11 exactly downwards. For example, variable Y01 should also be negated because: N0 = NAND(Y01,Q11), so all gates involving Y01 are negated, which causes other Q variables to be negated, and so on.
[0146] Checklist: Inverse SBox circuit with minimum gate count (bonus)
[0147] Reverse SBox (reward)
[0148]
[0149] Listing: Combinatorial SBox circuit with minimal delay (Fast / -S)
[0150] Combination SBox (fast)
[0151]
[0152]
[0153]
[0154] Checklist: Combinatorial SBox circuit with area / depth tradeoff (best)
[0155] Combination SBox (Best)
[0156]
[0157]
[0158] Checklist: Combinational SBox Circuit with Minimal Gate Count (Bonus)
[0159] Combination SBox (reward)
[0160]
[0161]
[0162] Advantages of the present invention
[0163] Having a design for a fast SBox is very important for certain classes of applications, such as AES hardware support in CPUs. In this case, the SBox design is likely to be very carefully placed and routed for the critical path. Having a very short critical path will significantly speed up the possible clocking frequency. Also, in FPGAs where it is more difficult (compared to ASICs) to achieve high clocking frequencies, it is important to have as few gates as possible in the critical path.
[0164] The table in the "Background Art" section has been expanded to now include results for the new architecture D described in this paper. Note how the critical path is significantly reduced compared to the traditional SBox circuit.
[0165] 1. Forward SBox
[0166]
[0167] Results for the new architecture D
[0168]
[0169]
[0170] 2. Combination SBox
[0171]
[0172] The results have been synthesized and compared with other recent academic work.
[0173] The technology process is GlobalFoundries 22nm CSC20L[Glo19], and the synthesis has been performed using Synopsys’ Design Compiler 2017 in topology mode and the compile_ultra command. In addition, the flag compile_timing_high_effort was turned on to force the compiler to generate the fastest possible circuit. In the figure below, the X-axis is the clock cycle (in ps) and the Y-axis is the resulting topology estimated area (in μm 2The number of available gates is not restricted in any way, so the compiler is free to use nonstandard gates, such as a 3-input AND-OR gate. To obtain the figures in the following subsections, the clock cycle started with a 1200ps clock cycle (~833MHz) and was then reduced by 20ps until the timing constraints could not be met. Note that the compiler's area estimates fluctuate widely, which is believed to be a result of the many different strategies the compiler must use to minimize the depth. One strategy may be successful for, say, a 700ps clock cycle, but another strategy (which results in significantly larger area) may be successful for 720ps. The compiler's strategy also involves an element of randomness.
[0174] The synthesis result of the forward SBox is as follows Figure 6 As shown, the synthesis result of the combined SBox is as follows Figure 7 For comparison, Figure 6 A diagram showing the synthesis results for the following architecture:
[0175] ·Ches18_fast 601
[0176] ·Ches18_small 603
[0177] • "Fast" circuit 605, as described herein.
[0178] • "Optimal" circuit 607, as described herein.
[0179] • "Reward" circuit 609, as described herein.
[0180] (The terms “Ches18_fast” and “Ches18_small” refer to the results in
[12] ).
[0181] exist Figure 6 middle:
[0182] - Curve 605 depicting the "fast" circuit described herein is shown to range from just under 650 ps to approximately 1075 ps.
[0183] - Curve 603 depicting "ches18_small" ranges from approximately 780 ps to approximately 1075.
[0184] - Curve 601 depicting "ches18_fast" ranges from about 800 up to about 1075.
[0185] For further comparison, Figure 7 A diagram showing the synthesis results for the following architecture:
[0186] ·canright 701.
[0187] ·reyhani 703.
[0188] • "Fast" circuit 705, as described herein.
[0189] • "fast-s" circuit 707, as described herein.
[0190] • "Optimal" circuit 709, as described herein.
[0191] • "Reward" circuit 711, as described herein.
[0192] (The term “Canright” refers to the results in [4], and the term “reyhani” refers to the results in [6]).
[0193] exist Figure 7 middle:
[0194] - Curve 707 depicting "fast-s" is shown closest to the X-axis, ranging from approximately 740 to 1200.
[0195] - Curve 705 depicting "Fast" is shown second closest to the X-axis, ranging from approximately 740 to 1200.
[0196] - The curve 703 depicting "reyhani" ranges from about 900 to 1200.
[0197] - The curve 701 depicting "canright" ranges from about 1000 to about 1200.
[0198] exist Figure 6 and Figure 7 In each of these, the closer the curve is to the axis, the better the area / speed trade-off.
[0199] Reference now Figure 8 Describe other aspects of the technology described herein, Figure 8 In one aspect, a flow chart of actions performed by embodiments consistent with the present invention. In another aspect, Figure 8 Also seen is a block diagram of an apparatus 800 for performing an SBox function, including various component parts (801, 803, 805, 807 and 809) for mapping inputs to outputs according to the SBox function.
[0200] The action begins with receiving an 8-bit input U (step 801). The 8-bit input is provided as input to two other actions that operate in parallel with each other. The first action is to generate a 4-bit first output signal (Y) from the 8-bit input signal (U) using a first linear matrix operation, Galois Field (GF) multiplication, and GF inversion (step 803).
[0201] In parallel, a calculation including a second linear matrix operation is performed (step 805) to generate a 32-bit second output signal (L) from the input signal (U), wherein the 32-bit second output signal (L) includes four 8-bit sub-results.
[0202] Next, four preliminary 8-bit results (K) are generated by scalar multiplying each of the four 8-bit sub-results of the 32-bit second output signal (L) by a corresponding one bit of the 4-bit first output signal (Y) (step 807).
[0203] Then, an 8-bit output signal (R) is generated by adding the four preliminary 8-bit results (K).
[0204] In other aspects of embodiments consistent with the present invention, such as Fig. 9 As shown, the improved SBox architecture described herein may also be embodied in a variety of other forms, including a computer program 901, which includes a set of program instructions configured to cause one or more processors to perform a series of actions, such as Figure 3A , 3B , 5, and 8 (e.g., when executed on a processing device, computer program 901 causes operations according to various embodiments described herein). In general, program modules may include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. Computer executable instructions, associated data structures, and program modules represent examples of program code for performing the method steps disclosed herein. A specific sequence of such executable instructions or associated data structures represents an example of corresponding actions for implementing the functions described in such steps or processes.
[0205] Some other embodiments take the form of a computer-readable storage medium 903 (or an equivalent set of media) including the above-mentioned computer program 901. The computer-readable medium 901 may include removable and non-removable storage devices, including but not limited to read-only memory (ROM), random access memory (RAM), compact disk (CD), digital versatile disk (DVD), and the like.
[0206] Still other embodiments may take the form of a computer program product 905 embodied in a computer-readable medium 903 including computer-executable instructions, such as program code, executed by computers in a networked environment.
[0207] Throughout this disclosure, the boxes in the various figures may refer to a combination of analog and digital circuits and / or one or more controller units, which are configured with software and / or firmware, such as stored in a storage unit (database), which, when executed by one or more controller units, are executed in the manner described above. These controller units, as well as one or more of any other combination of analog and digital circuits, may be included in a single application-specific integrated circuit (ASIC), or several controller units and various digital hardware may be distributed in several separate components, whether packaged separately or assembled into a system on a chip (SoC). One or more controller units may be any one or combination of a central processing unit (CPU), a graphics processing unit (GPU), a programmable logic array (PAL), or any other similar type of circuit or logic arrangement.
[0208] Advantages
[0209] This paper discloses a new architecture that is faster (with shorter key depth) than previously known results. In this new architecture, the bottom linear matrix present in the traditional solution (see e.g. Figure 2 ) has been removed and instead most of the computation is performed in the top linear matrix in parallel with the inversion circuit (see e.g. Figure 3A and 3B ). In this way, the depth of the circuit is reduced by about 25%-30%. The resulting SBox is the fastest known.
[0210] Abbreviations
[0211] AES: Advanced Encryption Standard
[0212] ASIC: Application-Specific Integrated Circuit
[0213] FPGA: Field Programmable Gate Array
[0214] References
[0215] [1] NIST: Advanced Encryption Standard (AES) Specification. Technical Report FIPS PUB 197, National Institute of Standards and Technology (NIST) (2001)
[0216] [2] Vincent Rijmen. Efficient implementation of the Rijndael S-box. Available from www.esat.kuleuven.ac.be.
[0217] [3] Akashi Satoh, Sumio Morioka, Kohji Takano, and Seiji Munetoh. A Compact Rijndael Hardware Architecture with S-box Optimization. In Cryptology-ASIACRYPT 2001, Colin Boyd, ed., 7th International Conference on Theory and Applications of Cryptography and Information Security, Gold Coast, Australia, December 9–13, 2001, Proceedings, Lecture Notes in Computer Science, volume 2248, pages 239–254. Springer, 2001.
[0218] [4] D. Canright. Extremely Compact S-Box for AES. In Josyula R. Rao and Berk Sunar, eds., Cryptographic Hardware and Embedded Systems - CHES 2005, pp. 441-455, Berlin, Heidelberg, 2005. Springer Berlin Heidelberg.
[0219] [5] Rei Ueno, Naofumi Homma, Yukihiro Sugawara, Yasuyuki Nogami, and Taka-fumi Aoki. Efficient GF(2) based on redundant GF arithmetic 8 ) Inverting Circuits and Their Application to AES Design. Tim Güneysu and Helena Handschuh, eds., Cryptographic Hardware and Embedded Systems - CHES 2005, 17th International Symposium, Saint-Malo, France, September 13-16, 2015, Proceedings, Lecture Notes in Computer Science, volume 9293, pages 63-80. Springer, 2015.
[0220] [6] Reyhani-Masoleh, A., Taha, M., and Ashmawy, D. (2018). New area record for AES combined S-box / inverse S-box. 2018 IEEE 25th Annual Symposium on Arithmetic in Computers (ARITH), pp. 145–152, 2018.
[0221] [7] Samsung Electronics Co., Ltd. STD90 / MDL900.35μm 3.3V CMOS Standard Primitive Library for Pure Logic / MDL Products Data Sheet, 2000.
[0222] [8] Joan Boyar and René Peralta. New combinatorial logic minimization techniques for cryptography. Paola Festa, ed., Experimental Algorithms, pp. 178–189, Berlin, Heidelberg, 2010. Springer BerlinHeidelberg. Available at: eprint.iacr.org.
[0223] [9] Joan Boyar and René Peralta. Novel combinatorial logic minimization techniques for cryptography. Lecture Notes in Computer Science, pp. 178–189. Springer, 2010.
[0224]
[10] Joan Boyar and René Peralta. Small Depth 16 Circuits for the AES S-Box. Dimitris Gritzalis, Steven Furnell, and Marianthi Theoharidou, eds., SEC, IFIP Advances in Information and Communication Technologies, volume 376, pages 287–298. Springer, 2012. URL: link.springer.com.
[0225]
[11] J. Boyar and R. Peralta. Patent application No. 61089998 filed with the U.S. Patent and Trademark Office. New Techniques for Combinatorial Circuit Optimization and New Circuits for the S-Box for AES, 2009.
[0226]
[12] Arash Reyhani-Masoleh, Mostafa Taha, and Doaa Ashmawy. Shattering the AES S-Box Implementation Record. IACR Transactions on Cryptographic Hardware and Embedded Systems, 2018(2): 298–336, May 2018.
[0227] The embodiments disclosed herein can be implemented by a combination of analog and digital circuits, one or more controller units, and computer program codes for performing the functions and actions of the embodiments described herein. The above program code can also be provided as a computer program product, such as in the form of a data carrier carrying the computer program code, which, when loaded into a mobile communication device, is used to perform the embodiments herein. One such carrier can be in the form of a CD ROM disk. However, other data carriers (such as memory sticks) are also feasible. The computer program code can also be provided as a pure program code on a server and downloaded to the mobile communication device during production and / or during software updates.
[0228] When the word “comprising” or “including” is used, it should be interpreted in a non-limiting sense, that is, meaning “consisting at least of…”
[0229] The inventive concept has mainly been described above with reference to a few embodiments. However, it is readily appreciated by a person skilled in the art that embodiments other than the ones disclosed above are equally possible within the scope of the inventive concept disclosed herein.
[0230] Those skilled in the art will appreciate that key aspects of the technology described herein include those described above with respect to Section A of the present disclosure. Figure 3A , 3B , 5, 8 and 9 ("Architecture D") and various combinations and sub-combinations of the technical features discussed and depicted in connection with the architectural improvements disclosed in Section 5 of Part B of this disclosure.
[0231] Those skilled in the art will appreciate that other key aspects of the technology described herein include various combinations and sub-combinations of the technical features discussed above with respect to the method for resolving linear systems using a multiplexer as discussed in Section 4 of Part B of the present disclosure below.
[0232] Part B of this Disclosure
[0233] Smallest, Best and Fastest AES SBox
[0234] 1 Introduction
[0235] Efficient hardware design of the AES SBox is a subject of intensive research. If one wants absolute maximum speed, one might use a simple table lookup implementation, which naturally results in a larger area. In many practical cases, the area of the cryptographic subsystem is limited, and the designer cannot implement a table lookup for the 16 SBoxes involved in an AES round, especially when implemented in an FPGA. For these cases, one needs to investigate how to implement the AES SBox using only logic gates, focusing on both area and maximum clocking speed. The maximum clocking speed of a circuit is determined by the following factors: the critical path or depth of the circuit; and the worst-case time it takes to obtain a stable output signal from a change in the input signal.
[0236] Another aspect when implementing AES is the need for a reversal cipher. Many modes of operation of block ciphers use only the encryption function and therefore do not require a reversal cipher. If both a forward SBox and a reverse SBox are needed, it is often beneficial to combine the two circuits. This is because the primary operation of the AES SBox is field element inversion, which is naturally its own inverse, and it is expected that many gates of the two circuits can be shared.
[0237] From a mathematical point of view, the forward AES SBox is defined as the combination of a nonlinear function I(g) and an affine function A(g) such that SBox(g) = A(I(g)). Nonlinear function I(g) = g -1 is the irreducible polynomial x 8 +x 4 +x 3 The multiplicative inverse of an element g in the finite field GF(2^8) defined by +x+1. We assume that the reader is familiar with the AES SBox and refer to [oST01] for a more comprehensive description.
[0238] A first step towards a small-area implementation was described by Rijmen [Rij00], using results from [IT88]. The idea is to use GF((2 4 ) 2 ) to perform basis transformation, GF(2 8 ) can be simplified to the subfield GF(2 4 ) is a much simpler inverse calculation. In 2001, Satoh et al. published [SMTM01] which took this idea a step further and simplified the inverse calculation to the subfield GF(2 2 ). In 2005, Canright published [Can05], building on the work of Satoh et al., studying the importance of subdomain representations, testing many different isomorphisms that lead to a minimal area design. This construction is probably the most commonly cited and used implementation of the area-constrained combinatorial AES SBox.
[0239] In a series of papers, Boyar, Peralta et al. proposed some very interesting ideas for subdomain inverters and new heuristics for minimizing logic circuit area [BP10a, BP10b, BP12, BFP18]. They 4 ) is derived from an inverter with a depth of 4 and a gate count of only 17. The construction in [BP12] is the starting point of the present disclosure.
[0240] After Boyar, several other papers focused on low-depth implementations [JKL10, NNT+10, UHS+15]. In 2018, two papers by Reyhani et al. [RMTA18a, RMTA18b] presented the most notable implementations (so far) of the forward SBox and the combinatorial SBox. As noted in [RMTA18a], researchers disagree on how to present and compare implementations of combinatorial circuits. One approach is to simply count the total number of standard gates in the design and find paths through the circuit containing the critical path to determine and compare speeds. The reality is much more complicated than this. In this paper, we show a simple metric using only the number of gates, as well as a "Gate Equivalent (GE)" number based on the typical area required for a gate compared to a "NAND" gate. So, for example, a "NAND" gate has GE=1, while an "XOR" gate has GE=2.33. The relative number of GEs depends on the specific ASIC process technology used, as well as the required drive strength from the gates. We used GE values obtained from Samsung’s STD90 / MDL90 0.35μm 3.3V CMOS technology [Sam00]. A full discussion of our choices for circuit comparison can be found in Appendix A. In addition, we propose to count the technological depth of the circuits normalized by the delay of the XOR gate, which makes it possible to compare the depth and speed of various academic works.
[0241] In the following disclosure, various new techniques for minimizing the circuit implementation of a linear matrix are presented and analyzed. In addition, a new method for including a multiplexer in the minimization is introduced, which is related to the combined SBox construction. In addition, a new architecture is provided in which the bottom linear matrix (present in the traditional circuit) is removed to obtain the smallest possible circuit depth. These new techniques result in an AES SBox that is smaller and faster than previously proposed AES SBoxes.
[0242] 2 Preliminary knowledge
[0243] When we now construct our own representation of the tower domain, we will follow the notation used in [Can05] and [BP12]. The irreducible polynomials, roots, and normal bases are shown in Table 1.
[0244] Table 1: The methods used to construct GF(2 8 )'s subdomain definition.
[0245]
[0246] Following [Can05] and [BP12], we can now derive the following for GF(2 8 ) in the common element A=a0Y+a1Y 16 The inverse expression is:
[0247] A -1 =(AA 16 ) -1 A 16
[0248] =((a0Y+a1Y 16 )(a1Y+a0Y 16 )) -1 (a1Y+a0Y 16 )
[0249] =((a 2 0+a 2 1) Y 17 +a0a1(Y 2 +Y 32 )) -1 (a1Y+a0Y 16 )
[0250] =((a0+a1) 2 Y 17 +a0a1(Y+Y 16 ) 2 ) -1 (a1Y+a0Y 16 )
[0251] =((a0+a1) 2 WZ+a0a1) -1 (a1Y+a0Y 16 ).
[0252] GF(2 8 ) can be inverted according to the following formula in GF(2 4 ) is completed:
[0253] T1=(a0+a1) T2=(WZ)T 2 1 T3=a0a1 T4=T2+T3
[0254] T5=T4 -1 T6=T5a1 T7=T5a0
[0255] The result is A -1 =T6Y+T7Y 16 In these equations, several operations are used (addition, multiplication, scaling, and squaring), but only two of them are nonlinear in GF(2); multiplication and inversion. In addition, the standard multiplication operation also contains some linear operations. If all linear operations are separated from nonlinear operations and combined with the AES SBox input (using the AES SBox irreducible polynomial x), the AES SBox irreducible polynomial x will be 8 +x4 +x 3 +x+1 is represented by a polynomial basis) and the linear equations required for the basis conversion are bundled together, and finally the linear equations required for the basis conversion are obtained according to Figure 2 The architecture of the SBox.
[0256] If you are dealing with an inverse SBox, you naturally want to apply the inverse affine transform to the top linear matrix instead of the bottom linear matrix.
[0257] This architecture will be our starting point, and we now provide a set of new or enhanced algorithms for minimizing both the area and depth of the two linear top and bottom matrices.
[0258] 3 Circuits for Systems of Two-Variable Linear Equations
[0259] In this section, we summarize known linear circuit minimization techniques and propose some improvements. We begin by explicitly stating our goal.
[0260] 3.1 Basic Problem Statement
[0261] Given a binary matrix M m×n and the maximum allowed depth maxD, find a circuit with depth D ≤ maxD, with the minimum number of XOR gates, so that it computes Y = M·X. In other words, given an n-bit input X = (x0...x n-1 ), the circuit should calculate m linear combinations Y = (y0...y m-1 ). Any circuit implementation that realizes a given system of linear equations is called a solution.
[0262] The above problem is NP-complete and we have seen various heuristics that help find suboptimal solutions in the literature. In all the previous work we have studied, it is assumed that all input signals arrive at the same time and all output signals are “ready” with a delay of at most maxD. In this paper, we extend the problem with AIR and AOR defined as follows.
[0263] Additional Input Requirements (AIR). This problem can be extended by placing an additional requirement on the input signal X, such that each input bit x i With its own delay d i (in terms of XOR gate delay) arrives. The resulting depth D ≤ maxD includes the input delay. For example, if an input x i With delay d i >maxD, then there is no solution. AIR is useful when deriving the bottom matrix, as described in Section 2, because after the nonlinear part, the signals entering the bottom matrix will have different delays.
[0264] Additional Output Requirements (AOR). This problem can be extended by adding additional requirements on the output signals. It can be required that each output signal y i At most e i AOR is used when deriving the top matrix because when we introduce multiplexers for the combinatorial SBoxes, the output signals of the top matrix will be required to have different delays.
[0265] 3.2 Cancellation-free heuristics
[0266] The no-elimination heuristic is an algorithm that produces a linear expression z = a ⊕ b, where a and b are both Boolean linear expressions in input variables, and a and b have no common terms. In other words, when a and b are added, no terms are eliminated.
[0267] Paar [Paa97] proposed a greedy method for solving the basic problem in 3.1. The solution starts with a matrix M and considers all column pairs (i, j) in M. The metric is then defined (on the column pairs) as the number of rows, where M r,i =M r,j =1, that is, the input variable x i and x j For the column pair with the highest metric, a new variable x is formed n =x i ⊕x j and add it to the matrix (the matrix is now of size m×(n+1)), and set position M r,i =M r,j =0, and M r,n+1 =1.
[0268] Alternatively, Canright [Can05] uses this technique, but instead of using a metric function, he performs an exhaustive algorithm on all possible column pairs. This is possible because in his case the target matrix is the base transformation matrix of size only 8×8. As we saw in Section 2, our base matrix will be much larger, so another approach is needed. We also need to consider AIR and AOR.
[0269] Solve for AIR. When executing the algorithm, the depth of the newly added XOR gates should be tracked. This is done by having a vector D = (d0...d n-1 ), where the vector has all the inputs and the newly added signal X i The current depth of then =x i ⊕x j When x n The delay is negligible n =max(d i ,d j )+1. Then, we also restrict the algorithm so that if d n >maxD, then adding x is not allowed n As a new input signal, AIR is automatically solved.
[0270] Solve AOR. Similarly, when adding a new input variable x n When , we need to check whether the solution is theoretically possible. We can use the function CircuitDepth (see Algorithm 2 in Appendix B.1 for details) to do this. If CircuitDepth returns a value greater than e i For larger delays, we know that no solution exists and that particular x should be avoided n .
[0271] Probabilistic Heuristics. Due to the size of the bottom matrix, we cannot perform a full exhaustive algorithm on the bottom matrix, so we need to limit the number of pairs to be retained and further evaluated. We have found that retaining the K best candidates (based on Paar's original metric) and then randomly choosing which candidate to pick for the next XOR gate is a good strategy. In our simulations, this probabilistic approach gives us smaller circuits than considering only the best metric candidates. Naturally, if K is chosen too large, the execution time will be too long, and conversely, if K is chosen too small, the chances of deriving a good circuit will be reduced. In practice, we have found K = 2...6 to be a reasonable number of candidates to retain and try.
[0272] 3.3 Eliminable Heuristics
[0273] The non-elimination method is suboptimal, as shown in Boyar and Peralta [BP10a], where they also introduced a new algorithm that can be eliminated. This algorithm was subsequently improved by Reyhani et al. in [RMTA18a]. The basic idea of this heuristic is briefly described below.
[0274] 3.3.1 Basic Eliminability Algorithm [BP10a]
[0275] Each row of M is an n-bit vector containing 0 and 1. This vector can be viewed as an n-bit integer value. The integer value is defined as the target point. Therefore, the matrix M can be viewed as a column vector of m target points. The input signal {x0,...,x n-1} can also be represented as an integer value x i =2 i, where i=0...n-1.
[0276] Let the basic set S = {s0,...,s n-1}={1,2,4,...,2 n} initially represents the input signal. The key function of this algorithm is the distance function δ i (S,y i ), this function returns the target point y calculated based on the known point set S i The minimum number of XOR gates required. The algorithm retains the vector Δ = [δ0, δ1, ..., δ n-1 ], which is initially set to one of the rows of the Hamming weight minus M, which is the number of XOR gates required without any sharing.
[0277] The algorithm then proceeds to combine two basis points s in the basis set S i and j , and XOR them together to generate the candidate point c = s i ⊕s j s is performed by an exhaustive search over all distinct pairs i and j The choice of, and then for each candidate point, calculate the distance vector ∑δ i The sum of , where i∈[0,n-1]. Note that the distance function δ is now calculated on the set S∪{c} i The pair that gives the minimum sum of distances is chosen, and S is updated to S = S ∪ {c}. If there is a tie, the algorithm chooses the pair that makes the Euclidean norm maximized pair. If there is still a tie after this step, the authors of [BP10a] studied different strategies and concluded that all strategies tested behaved similarly, so a simple random selection can be used. The algorithm then repeats the steps of picking two new base points and computing the sum of the distance vectors until the distance vector is all zero and all targets are found. In the original description, there is also the concept of a "preemptive" selection. A preemptive selection is a candidate point c such that this point directly satisfies the target row in the matrix M. If such a candidate point is found, it is immediately used as the new point and added to S.
[0278] Reyhani et al. [RMTA18a] improve the original algorithm by searching for preemptive candidates directly in each round and adding them all to a set S before adding the "real" candidates and recalculating the distance vector. They also improve the tie resolution strategy by keeping all candidates that are equally good under the Euclidean norm and recursively trying all of them, keeping the best one for the next round. In our experiments, we concluded that keeping two different candidates and recursively computing them produces good results.
[0279] Our improvement to this algorithm is to compute δ faster for moderate values of n. See Appendix B.2.
[0280] 3.3.2 When the maximum depth maxD is a required constraint
[0281] While the AIR problem can be solved simply by adding the vector of delays D of all known signals to S, the problem of finding a short circuit with fixed maxD remains quite difficult. Even if each newly added signal in S is constrained to have a depth ≤ maxD, the resulting circuit is very large in terms of the number of XOR gates, in fact much larger than what can be achieved using the no-elimination heuristic.
[0282] One idea is that if relative to the shortest distance δ i =δ(S,y i ) there is a tie, then c with the smallest delay should be adopted. However, in our simulations, it did not produce better results than the no-elimination algorithm, even with the addition of a random factor to both algorithms. We must conclude that adopting an additional maxD constraint on the cancelable heuristic remains an open problem.
[0283] 3.4 Exhaustive Search Method
[0284] In this section, we propose an algorithm for efficient exhaustive search of minimal circuits. The overall complexity is exponential in the number of input signals and linear in the number of output signals. From our experiments, we conclude that the exhaustive search algorithm is easily applicable to circuits with approximately 10-bit inputs.
[0285] 3.4.1 Notation and Data Representation
[0286] Using the same integer representation of the rows of M and the input signal x as in Section 3.3.1 i , the basic problem statement can be restated as: given an input point x i We hope to find an XOR sequence on these input points to obtain all m desired target points y with the maximum delay maxD. i , the number of rows of the matrix M. The input and output points can have different delays d i and e i .
[0287] For data structures, a set of 2 n The points are stored as plain sets and / or bit vectors. The sets allow looping over the points, while the bit mask representation is efficient for testing set membership.
[0288] 3.4.2 Basic Idea
[0289] The exhaustive search algorithm is a recursive algorithm that traverses the depths, starting at depth 1 and running until maxD. At each depth D, we try to construct new points from the previous depths, thereby constructing a circuit with exactly depth D. When all target points are found, the number of XOR gates required is checked, keeping track of the smallest solution. The following set of points will be needed:
[0290] known[maxD+1] – The set of known points at a specific depth D.
[0291] ignore[maxD+1] – The set of points at depth D that will be ignored.
[0292] targets – a set of target points.
[0293] candidates – The set of candidate points to be added to the known set at the current recursive step.
[0294] The initial set of known points is x i , where i = 0...n-1, and the target point set is y i , where i = 0...m-1. By initially taking the input point x i Place to depth d i The AOR is solved by setting the output delay e i point y i To ignore the i The solution is a list at all depth levels of .
[0295] We will now explain the steps performed at each depth of the recursion, assuming we are currently at depth D.
[0296] Step 1 – Seize a point. Check the known[D] set to see if any pair (XOR:ed) can be combined to give a target point that has not yet been found. If all targets are found, or if maxD has been reached, we return from this depth level of the recursion.
[0297] Step 2 - Collect candidates. Form all possible pairs of points from the known[0..D-1] set where at least one point is from known[D-1] and XOR these pairs to derive new points. If the derived point is in the set ignored[D], skip it, otherwise add it to the candidate set.
[0298] Step 3 - In this step, attempt to add the points in the candidate set to the known list and recursively call the algorithm again. First, attempt to add 1 point and make a recursive call. If this does not solve for the target point, then attempt to add 2 points, and so on, until all combinations (or the maximum number of combinations) of the points in the candidate set have been tried.
[0299] 3.4.3 Ignored Points and Other Optimizations
[0300] In step 2, check the candidates against the ignored[D] set (the set of ignored points at depth D). The ignored set is constructed according to a set of rules; intersect : If for all target points w i it is obtained that (w i &p)≠p, then the candidate point p should be ignored. This means that the point p covers too many input variables and is not covered by any point in the target set; Forward Propagation : All possible points at each level can be calculated, starting from the top level D = 0 with n known points and going down to D = maxD. Those points that will never appear at a certain level d are then included in the ignored[D] set. If a certain target point w has another expected maximum delay e i <maxD, then the point at subsequent depths should be ignored, i.e., add w to ignored[e i +1..maxD]; Direct input summation : If any input signal x i ,x j gives the point p = x i ⊕x j at level d, then all subsequent levels greater than d must have the point p in the ignored list; Backward Propagation : As a final check, going backwards level by level, starting from d = maxD and ending at level d = 1, for each allowed (not ignored) point at level d, check if there are still non-ignored pairs a,b (one of a or b must be at level d - 1) at the previous level such that it gives p = a⊕b. If not, then the point p should be added to the ignored[D] set; Ignore Candidates : If w is one of the candidates at a previous level less than d, then dynamically add the point w to the ignored[D] set.
[0301] 3.5 Conclusion
[0302] From our simulations, we can draw the following conclusions about searching for a minimal solution; the top matrix (with only 8 inputs) can be solved using the exhaustive eliminatable search in Section 3.4. The bottom matrix (with 18 inputs) is too large for a direct exhaustive search, and we should start with the probabilistic no-elimination heuristic in Section 3.2 and then use a completely exhaustive search for the end, when the Hamming weights of the remaining rows become small enough to perform an exhaustive search. This approach shows the best results.
[0303] 4 Linear circuit system with multiplexer
[0304] Suppose we want to find a circuit for a combinatorial SBox where the top and bottom linear matrices need to be multiplexed based on the SBox orientation. This means that the size of the circuit for combining linear expressions essentially doubles, with the addition of a set of multiplexers. In this section, we will show how to handle multiplexing systems for linear expressions. We will show that the "MUX" gates and "XOR" gates can be solved in a combinatorial manner in order to achieve a very compact circuit.
[0305] 4.1 Floating Multiplexer
[0306] Consider that for some signal Y, two linear expressions Y must be calculated for the forward SBox and the reverse SBox respectively F and Y I We then apply a multiplexer so that only one of the signals continues as Y. Assume further that signal Y F and Y I Share some part of the expression. Then, better yet, push that shared part down below the multiplexer, and the resulting solution can be simplified.
[0307] For example, suppose Y F =X0⊕X1 and Y I =X0⊕X2, then two XOR gates and one multiplexer should usually be used, resulting in Y=MUX(select,X0⊕X1,X0⊕X2) with three gates. However, the common part X0 can be pushed after the multiplexer as shown below:
[0308] Y=MUX(select,X1,X2)⊕X0,
[0309] Then, we have a circuit with only 2 gates. In general, we can take any linear combination Δ of the input signals and replace them:
[0310] Y=MUX(select,Y F ,Y I )→MUX(select,Y F ⊕Δ,YI ⊕Δ)⊕Δ,
[0311] Here, Δ is added to the linear matrix as an additional target signal to be calculated. If the substitution results in a shorter circuit, then keep the substitution. We should also choose Δ so that the overall depth does not increase. Thus, the various multiplexers will "float" in the depth of the circuit. The maximum depth of signals with Δ≠0 should be reduced by 1.
[0312] 4.1.1 Metrics and linear expressions to be solved
[0313] We have n input signals X1...X n and m output signals Y1...Y m , where each Y i In its most general form, it is represented as a triple (A i ,B i ,C i ), such that:
[0314] Y i =A i ⊕MUX(select,B i ,C i ),
[0315] Among them A i , B i and C i is a linear expression on the input signal. i Modify the above expression to (A i ⊕Δ i ,B i ⊕Δ i ,C i ⊕Δ i ), because Y i The Boolean function will not change.
[0316] Let ABC represent the description of all rows A i , B i and C i A linear matrix with i = 0...m such that
[0317] ABC×X
[0318] Given the desired linear system to be implemented using the minimum number of gates and a given maxD. By choosing a favorable Δ iThe total number of gates can be reduced by Δ , because some of the target points of ABC may become equal to each other, so ABC can reduce at least one row. In addition, some targets may become 0 or have only one bit, that is, they are equal to the corresponding input signal. These targets are also removed from the linear system because they are insignificant gates with zero cost. After the above simplification, a set of linear expressions is obtained, in which all rows are different and the Hamming weight is at least 2. As before, interpret the rows of ABC as integers and replace Δ i Add (XOR:ing) to the three lines A i , B i and C i The three target points will be changed, but the resulting Y i .
[0319] measure Searching for good combinations of Δs is computationally intensive, and computing the minimum solution for each choice quickly becomes infeasible. Therefore, it is necessary to identify a good metric that allows us to reduce the search space to a set of promising Δs. We propose a metric based on a lower bound on the number of gates of a fixed system (when choosing a value for Δ), and define this metric as the number of rows of the simplified ABC matrix, plus the minimum number of additional gates, such as multiplexers, required to complete the circuit.
[0320] In the following, we introduce several heuristics to find a good set of Δs while minimizing the metric.
[0321] 4.1.2 Iterative Algorithm for Finding Δs: Metric → Minimization
[0322] The following technique only works for small n, but in our case it is easily adapted to the 8-input top matrix of the AES SBox.
[0323] Algorithm - A(k) – Select k triplets (A i ,B i ,C i ) and try to find the matching that minimizes the metric Δ i s. If some choice results in a smaller metric, then keep that choice and continue searching with the updated ABC matrix. The algorithm loops until the metric stops decreasing. Algorithm-A(1) is quite fast and Algorithm-A(2) also has acceptable speed. For larger k, it becomes infeasible. Algorithm-A(k) is good for a very quick / short analysis of a given system, but the results are very unstable because for Δ i For random initial values of s, the resulting metric fluctuates greatly.
[0324] Algorithm-B- Unlike Algorithm-A, this algorithm attempts to construct a linear expression group, starting from an empty known set S, and then trying to add new points to S one by one until all targets of ABC become included in the set S. When testing whether a new candidate C should be added to S, loop through all (A i ,B i ,C i ) and for each try to find the Δ that minimizes the overall metric i . This heuristic is much more stable and gives reasonably good results.
[0325] But the smallest possible metric does not guarantee that the final solution will have the fewest number of gates, and the number of required non-target intermediates is unknown. Therefore, a good idea is to collect many promising systems whose metrics are as small as possible, and then try to find the smallest solution among them. We will study this in the next section.
[0326] 4.2 New General Heuristic for Linear Systems with Floating Multiplexers
[0327] If one generalizes the idea of floating multiplexers, letting them float even higher in the circuit and also sharing them more widely, one can achieve better results. In this section, a general heuristic algorithm for finding near-optimal circuits for such systems is proposed.
[0328] 4.2.1 Problem Statement
[0329] Given an n-bit input signal X n , binary matrix and Two-element vector and vector delay D n X and D m Y We want to find the minimum and shortest solution for computing an m-bit output signal Y:
[0330] Y F =M F ·(X⊕A F )
[0331] Y I =M I ·(X⊕A I )
[0332] Y=MUX(ZF;Y F ⊕B F ; Y I ⊕B I ),
[0333] Among them, each input signal X iWith input arrival delay D i X And each output signal Y j Must have at most D j Y A* and B* are constant masking vectors (not gates) for input and output signals, respectively. ZF is a multiplexer selector. When ZF=1, the first (Y F = "positive") output, otherwise select the second (Y I = "inverse") output. It is also assumed that there is a complementary signal ZI = ZF⊕1 which can also be used as an input control signal.
[0334] 4.2.2 Preliminary knowledge
[0335] Similar to the previous notation, a "point" is defined as a tuple of a point value (.p) and a delay (.d):
[0336] point:={.p=[f(1bit)|F(n bits)|i(1bit)|I(n bits)],.d=Delay}
[0337] It is then converted into a 1-bit signal by the circuit
[0338] signal:=MUX(ZF;F·X⊕f;I·X⊕i)
[0339] And has a total output delay point.d. That is, F and I are linear combinations on the n-bit input X, and F and I are the inverted bits applied to the result when the selector is "forward" or "reverse" respectively. Then the n input points are represented as:
[0340] Input point X k :={.p=[A k F |2 k |A k I |2 k ],.d=D k X}, where k = 0, ..., n-1,
[0341] The m target points are:
[0342] Target point Y k :={.p=[B k F |Y k F |B k I |Y k I ],.d=≤Dk Y}, where k = 0,...,m-1.
[0343] The following 4 unimportant points should also be included in the input set:
[0344] Signal ZF: = {.p = [1|0|0|0], .d = 0} Signal 0: = {.p = [0|0|0|0], .d = 0}
[0345] Signal ZI: = {.p = [0|0|1|0], .d = 0} Signal 1: = {.p = [1|0|1|0], .d = 0}
[0346] Given any two (ordered) points v and w, there are at most 6 possible new points that can be generated based on the following gates:
[0347] MUX(v;w):={.p=[vf|vF|wi|wI],.d=D new}
[0348] NMUX(v;w):={.p=[vf⊕1|vF|wi⊕1|wI],.d=D new}
[0349] MUX(w;v):={.p=[wf|wF|vi|vI],.d=D new}
[0350] NMUX(w;v):={.p=[wf⊕1|wF|vi⊕1|vI],.d=D new}
[0351] XOR(v;w):={.p=[wf⊕vf|wF⊕vF|wi⊕vi|wI⊕vI],.d=D new}
[0352] NXOR(v;w):={.p=[wf⊕vf⊕1|wF⊕vF|wi⊕vi⊕1|wI⊕vI],.d=D new}
[0353] Where D new = max{vd,wd}+1. Note that it is important to include the 4 insignificant points, as this limits the number of gate types to be considered. For example, a NOT gate is then implemented as an XOR(v;1), an AND gate with ZF can be implemented as a MUX(v;0), an OR gate with ZI is a MUX(v;1), and so on.
[0354] 4.2.3 Algorithm
[0355] We start with a set of input points S (of size n+4) and put all target points into a set T. At each step, a set of candidate points C generated by applying the above 6 gates to any two points in the set S is computed. Naturally, C should contain only unique points and exclude those that are already in S. We try to add a candidate point from C to S and compute the distance from S to each target point in T. Afterwards, the metrics are compared to decide which candidate point will be included in S at this step, and restart by computing possible candidates. The algorithm stops when the total distance δ-metric is 0.
[0356] measure Contains multiple values. Distance δ(S,t i ) is to obtain the target point t from the point in S i The minimum number of basic gates required (the 6 above) to make the delay at most D i Y Subsection 4.2.5 discusses how to calculate δ(S,t i ). The metrics applied and their order of importance are as follows:
[0357]
[0358]
[0359] τ = delay of adding the latest candidate point from C to S → min
[0360]
[0361] The metric γ is the expected number of gates without more shared gates; this metric should absolutely be minimized. If multiple candidates give the same value, a second metric δ is investigated.
[0362] δ is the sum of distances, excluding distances that require only 1 gate. Given a minimum γ, δ must be maximized. The larger δ is, the more opportunities there are to shrink γ. Distance 1 is excluded due to the inclusion of the preemption step described below. As mentioned above, the metrics δ and γ are similar when candidates are accepted into S one by one, but the two metrics become different when search trees are introduced in the next subsection where the size of |S| may be different.
[0363] τ selects the candidate with the smallest depth in the case where the above two metrics show the same value for two candidates. If there is no maximum depth constraint on the target point, this metric is not needed.
[0364] ν is the Euclidean norm excluding the preemption point (similar to δ). This is the last decision metric because it is not a very good predictor, and a worse value may give a better result and vice versa. However, if there are two candidates with equal metrics δ, γ, and τ, then the two candidates can be ranked based on ν. In the case of a tie, an alternative approach is to randomly select one of them.
[0365] Get ahead. If a distance δ(S,t i )=1, then immediately set the point t i into S without searching the entire candidate C. Including this step in the algorithm forces the exclusion of such points from the metrics δ and ν.
[0366] In [RMTA18a], the preemption point is included in the metric, which we believe is incorrect. For example, when two distance vectors {1,2,...} and {0,2,...} have the same predicted gate, they represent exactly the same situation in terms of possible shared gates, and they should result in the same δ, because distance 1 will be included immediately (the preemption point), so it will not have any advantage over the second choice with distance 0. Therefore, distance 1 should not be counted in δ and μ, but in the predicted gate γ.
[0367] 4.2.4 Search Tree
[0368] In addition to the above algorithm, we propose a search tree where each node is a set S with a metric. The descendants of such a node are also nodes where S' is derived from S by adding one of the candidate points (S←C). Therefore, each path from the root node to a leaf represents a sequence of accepted candidate points to the root set S. If at some point a leaf has a metric δ = 0, then the leaf represents a possible solution path.
[0369] We keep some children (in experiments, at least 20-50 best children) whose metrics are best (they may even have different expected gates γ). We also define a maximum depth TD of the search tree (in experiments, we tried TD=1..20). When constructing the tree at depth TD, we check the leaves and see where the best metric is obtained on all leaves of all different branches. Backtrack to the root and choose to keep the top branch leading to the best leaf. Remove the other top branches from the root. Then, advance the root node to the first child of the selected branch and try to extend the depth of the tree again from the remaining leaves, so that the search tree remains at a constant depth TD.
[0370] If at each depth in the tree, each leaf expands an additional 20-50 sub-branches, the number of leaves will grow exponentially. However, you can apply Truncation Algorithm Only no more than a certain number of promising leaves are kept, which will be extended to the next depth, while other less promising leaves are removed from the tree (in our experiments, the truncation level was up to 400 leaves for the whole tree). This type of truncation makes it possible to select the best top branch of the root node by "looking further" at basically any depth TD. It is worth noting that the complexity does not depend on the depth TD, but on the truncation level.
[0371] Truncation strategy In short, we keep those leaves with the best metrics, but try to distribute nearly equal leaves among different branches in order to preserve as many diverted solution paths as possible.
[0372] 4.2.5 δ(S,t i )
[0373] The "core" and key part of the algorithm is to calculate the distance δ(S,t i ), given a completely new S. There are many candidates to test at each step, and many branches to follow, so we need to make this core algorithm as fast as possible.
[0374] Note that the length of a point (.p is an integer) is 2n+2 bits, plus the delay value. The delay (.d) value is ignored when performing Boolean operations on two points. Suppose the following possible number of points is allocated:
[0375] N=2 2n+2 .
[0376] Let V k [] is a vector of length N units, each unit V k [p] corresponds to a (2n+2)th position p represented as an integer index, and the value stored in the cell will be the minimum delay pd at that point such that it can be derived from S with exactly k gates.
[0377] If p∈S, set the initial vector V0 to Otherwise, V0[p] = ∞. Thereafter, by applying the allowed 6 gates to the gates from a certain level 0≤l <k(V l ) and level kl(V k-l ), from the previously derived vectors V0...V k Derive the vector V k+1 , resulting in a total of l+(kl)+1=k+1 gates. After deriving the new V k+1 After that, we simply check if it contains the new distance value of the target from T, and repeat the process until we find all t in T. i All distances δ(S,ti A high-level description of the algorithm is given in Algorithm 1, and a more detailed description and various computational techniques that can be applied are provided in Appendix B.3.
[0378]
[0379] 5 Architecture Improvements
[0380] Most known AES SBox architectures look very similar, consisting of top and bottom linear sections and a middle nonlinear section, as described earlier in Section 2. In this section, we take the classic design and propose some improvements, while adopting a completely new architecture focused on low-depth solutions.
[0381] 5.1 Two SBox Architectures - Area and Depth
[0382] refer to Figure 2 , architecture A(area) is a classic architecture for implementing tower and composite domain based designs. It starts with an 8-bit input signal U to the top linear matrix, which produces a 22-bit signal Q (see [BP12]). We manage to reduce the number of required Q signals to 18 and restructure the multiplication and linear summation block Mul-Sum to 24 gates and depth 3. (See Appendix D.2 for equations). The output of the Mul-Sum block is a 4-bit signal X, which is a 4-bit signal to GF(2 4 ) is input to the inverse of . The output Y from the inverse is mixed nonlinearly with the Q signal derived in the top matrix and produces an 18-bit signal N. The last step is the bottom linear matrix, which takes the 18-bit N and linearly derives the output 8-bit signal R. The top and bottom matrices introduce an SBox affine transformation that depends on the direction. The new architecture D (depth) (as Figure 3A and 3B ) is a new architecture in which an attempt is made to remove the bottom matrix and thereby reduce the circuit depth as much as possible. The idea behind this is that the bottom matrix depends only on a set of multiplications of some linear combinations of the 4-bit signal Y and the 8-bit input U. Therefore, the result R can be realized as follows:
[0383] R=Y0·M0·U⊕...⊕Y3·M3·U,
[0384] Among them, each M i is an 8×8 matrix representing 8 linear equations on 8-bit input U, which will be compared with Y iThe 4×8 linear circuits can be used to perform scalar multiplication of bits. In parallel with the circuits for 4-bit Y, these 4×8 linear circuits can be calculated as a 32-bit signal L. The result R is obtained by adding the four 8-bit sub-results. Therefore, in architecture D, after the inversion step (critical path: MULL and 8XOR4 boxes), we get a depth of 3 instead of depth 5-6 in architecture A. The new architecture D requires slightly more gates, because 56 gates are required to assemble the bottom circuit: 32NAND2+8XOR4. The reward is the lower depth.
[0385] Figure 4 and Figure 5 A more detailed sketch of each of the two architectures is given, including the components, delays, and gate counts of the designs.
[0386] 5.2 Six different scenarios of MULN
[0387] In the MULN block that computes the 18-bit N signal, the 18-bit Q signal and the inversion result Y are needed as input. But the following additional linear combination of Y is also required: Y 02 =Y0⊕Y2, Y 13 =Y1⊕Y3, Y 23 =Y2⊕Y3, Y 01 =Y0⊕Y1, Y 00 =Y 01 ⊕Y 23 —These correspond to signals M41-M45 in [BP12]. Thus, the Y vector is effectively extended to 9 bits, and the delay of the N bits becomes different, depending on which Y is used in the multiplication i For example, in the worst case, Y is slower than Y1. 00 The delay is +2. Therefore, the resulting signal N will have a different output delay. However, these 5 additional Ys can be calculated in parallel with the base signals Y0,...,Y3. This will use some extra gates, but the +2 delay can be reduced to +1 or +0. In general, the following 6 scenarios can be considered:
[0388] S0. Only the base signals Y0..Y3 are calculated, and the remaining {Y 01 ,Y 23 ,Y 02 ,Y 13 ,Y 00}Computed as above by XOR. Latency is +2, but with minimal gate count.
[0389] S1. Compute {Y 01 ,Y 23}, the delay is +1.
[0390] S2. Compute {Y 02 ,Y13}, the delay is +1.
[0391] S3. Compute {Y 00}, the delay is +1.
[0392] S4. Calculate {Y 01 ,Y 23 ,Y 02 ,Y 13}, the delay is +1.
[0393] S5. Compute {Y 01 ,Y 23 ,Y 02 ,Y 13 ,Y 00}, the delay is +0 because there is no signal to calculate afterwards.
[0394] In the next subsection, we will show how to find the Boolean expression for the above scenario.
[0395] 5.3 INV.GF(2 4 )
[0396] The inverse formula is as follows:
[0397] Y0=X1X2X3⊕X0X2⊕X1X2⊕X2⊕X3
[0398] Y1=X0X2X3⊕X0X2⊕X1X2⊕X1X3⊕X3
[0399] Y2=X0X1X3⊕X0X2⊕X0X3⊕X0⊕X1
[0400] Y3=X0X1X2⊕X0X2⊕X0X3⊕X1X3⊕X1
[0401] In [BP12], circuits of depth 4 and 17 XORs were found, but we wanted to reduce the depth further by using a wider range of standard gates. Therefore, we considered each expression independently using a general depth 3 expression:
[0402] Y i =((X a op1 X b )op5(X c op2 X d ))op7((X e op3X f )op6(X g op4X h )),
[0403] Where X a-his an item from {0,1,X0,X1,X2,X3}, op 1-7 is an operator from the set of standard gates {AND, OR, XOR, NAND, NOR, XNOR}. Note that the above need not include all terms, for example, the expression AND (x,x) It's just a simple x.
[0404] The exhaustive search can be organized as follows. Let us have an object Term, which contains a 16-bit truth table TT based on the 4 bits X0..X3 and the Boolean function associated with the term. From the initial set of available terms T (0) = {0,1,X0,...,X3}, and then iteratively for the selected Y i Construct an expression. Assume that at some step k there is a set of available items T (k) , we can get the next set of items and the associated expression as follows:
[0405] T (k+1) ={T (k) ,T (k) operator T (k)},
[0406] Among them, only one item is considered. At a certain step k, its TT will be equal to the target TT (Y i )
[0407] Since we can actually i You get multiple boolean functions, so you should choose only the "best" functions that follow these criteria: no NOT gates (due to better sharing ability), there is a maximum number of gates that can be shared between the 4 expressions of Y0..Y3, small area / depth in terms of GEs.
[0408] Using this technique, we find a solution for the inversion with a depth of 3 and 15 gates. The equation is given below, where we also add 5 additional signals {Y 01 ,Y 23 ,Y 02 ,Y 13 ,Y 00} provides a depth 3 solution so that they can also share many gates in the mentioned scenarios S0-S5.
[0409]
[0410] When implementing the above circuit for scenarios S0-S5 and sharing gates in the best possible way, the following results are obtained:
[0411] Table 2: INV boxes for scenes S0-S5.
[0412]
[0413] In our best circuit, scenario S1 was used because it showed the best results in terms of area and depth. For the fast and reward circuits, S0 was used because it had the smallest area.
[0414] 5.4 Alpha-Beta Method for Top and Bottom Linear Matrices
[0415] We are using exhaustive search to solve the top matrix, and various heuristic techniques to solve the bottom matrix. The appearance of these matrices naturally affects the final number of gates in the solution. Here, we propose a simple method to try different top and bottom matrices to get the best solution.
[0416] Assume that SBox is a black box and that it executes the function (excluding the final addition of the constant):
[0417] SBox(x)=x -1 ·A 8×8 ,
[0418] where x -1 is the Rijndael field GF(2 8 ), the inverse element of the matrix A 8×8 is an affine transformation. In any domain of feature 2: squaring, square rooting, and multiplication by a constant are all linear functions, so for unimportant choices of (α, β), let:
[0419]
[0420]
[0421] If the initial top and bottom matrices of the forward SBox and the reverse SBox are T F , B F , T I 、F I , we can choose any α=1..255 and β=0..7 and transform the matrix as follows:
[0422] T' F =T F ·E·C α ·P β ·E
[0423] B' F =E·A·P β -1 ·C α ·A -1 ·E·B F
[0424] T'I =T I ·E·A·C α ·P β ·A -1 ·E
[0425] B' I =E·P β -1 ·C α ·E·B I ,
[0426] in:
[0427] E – is a 8×8 matrix that switches the bit endianness (in our circuit, input and output bits are in big endian order)
[0428] A – is the 8×8 matrix that performs the affine transformation of the SBox
[0429] C α – is an 8×8 matrix that multiplies the domain elements by the chosen constant α
[0430] P β – is to raise the elements of the Rijndael field to 2 β 8×8 matrix of power
[0431] T F / T I – are the original (unmodified) 18×8 matrices of the top linear transform of the forward / inverse SBox, respectively.
[0432] B F / B I – are the original (unmodified) 8×18 matrices of the bottom linear transform of the forward / inverse SBox, respectively.
[0433] There are 2040 choices of (α,β) pairs, each of which gives a new linear matrix. It is easy to test all of these choices and find the best combination that gives the smallest SBox circuit. For architectures A and D, this idea has been applied to both the forward SBox and the inverse SBox.
[0434] 5.4.1 Alpha-Beta Method for Combining SBoxes
[0435] For the combined SBox, the alpha-beta method can be applied independently to the forward and inverse parts. This means that there are 2040 2= 4,161,600 linear matrix variants to test. We focus on architecture D, since there is no bottom matrix and thus a more extensive search is possible. We search through all these 4 million variants and apply the heuristics from Section 4.1 as a fast analysis method to select a set of approximately 4000 promising examples. We then apply the algorithm given in Section 4.2 to find solutions with floating multiplexers. In our case with n = 8 input bits, each point is encoded with 18 bits and the distance δ(S,t i ) has a complexity of N = 2 18 A search tree with a maximum depth TD ≤ 20 and a cutoff level of 400 leaves was used in the search.
[0436] 5.5 Q-zeros of the top matrix in the combined SBox
[0437] The combined SBox needs to have multiplexers for both the top and bottom linear transforms. The top linear matrix of the forward SBox and the reverse SBox each produces an 18-bit signal Q F and Q I . This means that typically 18 multiplexers should be applied to switch between Q signals based on the selected direction signal ZF. However, there is a set of Q triplets that are always zero and are valid for both the forward and reverse SBoxes:
[0438] 0=Q0+Q11+Q12 0=Q1+Q3+Q4 0=Q4+Q9+Q10 0=Q6+Q7+Q10
[0439] 0=Q0+Q14+Q15 0=Q2+Q8+Q9 0=Q5+Q12+Q13 0=Q11+Q16+Q17
[0440] 0=Q1+Q2+Q7 0=Q3+Q6+Q8 0=Q5+Q15+Q17 0=Q13+Q14+Q16
[0441] Listing 1: Q zeros, valid for both forward and reverse SBoxes.
[0442] This knowledge can be used to compute only a subset of the Q signals, then multiplex them and compute the remaining Q signals using the zero points described above.
[0443] For example, 10 bits can be calculated for the forward SBox and the reverse SBox: {Q1, Q6, Q8, Q9, Q10, Q12, Q14, Q15, Q16, Q17}, and then 10 multiplexers are applied, after which the remaining 8 signals are derived: Q0 = Q14 + Q15, Q2 = Q8 + Q9, Q3 = Q6 + Q8, Q4 = Q9 + Q10, Q5 = Q15 + Q17, Q7 = Q6 + Q10, Q11 = Q16 + Q17, Q13 = Q14 + Q16.
[0444] Therefore, 8 multiplexers can be saved, and 2×8 rows of the combined top matrix can be deleted. However, it should be ensured that the above 8 bits are exempted outside the multiplexer and do not increase the depth of the top linear transform. Note that some signals Q1 and Q12 in the above example do not participate in the calculation of the last 8 signals, so these two signals are allowed to have +1 additional depth. That is, before applying the circuit solver algorithm, the maximum delay of each output signal should be carefully derived as a constraint for the search algorithm.
[0445] In addition to the 2040 choices of (α,β) mentioned above, 59535 variants that exploit Q-zeros were tested. We apply this approach only to architecture A.
[0446] 6 Results and comparison
[0447] In this section, the best solutions for the forward AES SBox and the combined AES SBox are provided. The inversion SBox alone may not be widely used, and these results can be found in Appendix C. We compare our area and depth using the techniques described in Appendix A, and where possible, recalculate the corresponding GEs of other academic results for easy comparison. Three different solutions are provided for each SBox (forward, inverse, and combined): "fast", "best", and "bonus". The fast solution is the one with the lowest critical path, the best solution is a well-balanced trade-off between area and speed, and bonus solutions are given to set new records in terms of minimum gate count. The exact circuit expressions for all derived solutions can be found in Appendix D, which also indicates which algorithm was used when deriving the solution.
[0448] 6.0.1 Synthesis Results
[0449] The results have been synthesized and compared with other recent academic work. The technology process is GlobalFoundries 22nm CSC20L [Glo19] and the synthesis has been performed using Synopsys’ DesignCompiler 2017 in topology mode and the compile_ultra command. In addition, the flag compile_timing_high_effort was turned on to force the compiler to generate the fastest possible circuit. In these figures, the X-axis is the clock cycles (in ps) and the Y-axis is the resulting topology estimated area (in μm 2 The number of available gates is not restricted in any way, so the compiler is free to use nonstandard gates, such as a 3-input AND-OR gate. To obtain the figures in the following subsections, we start with a 1200ps clock period (~833MHz) and then reduce the clock period by 20ps until the timing constraints cannot be met. Note that the compiler's area estimates fluctuate widely, which we believe is a result of the many different strategies the compiler has to minimize the depth. One strategy may be successful for, say, a 700ps clock period, but a different strategy (which results in significantly larger area) may be successful for 720ps. The compiler's strategy also involves an element of randomness.
[0450] Table 3: Forward SBox: comparison of results.
[0451]
[0452] Forward SBox: Previous Results
[0453]
[0454]
[0455] Forward SBox: Our Results
[0456]
[0457] 6.1 Forward SBox
[0458] We include a number of interesting prior results in Table 3 for comparison. Canright’s most famous design is widely used and cited. Our optimal SBox is both fast and small. We also include the work done by Boyar et al., as their design is the starting point for our study.
[0459] The two results published by Reyhani et al. at CHES'18 are the latest. In terms of GE, our "best" SBox has a similar area to their "lightweight" version, but is about 30% faster. The best SBox is smaller and faster than their "fast" circuit. In addition, our "fast" version is 25% faster than their "fast" version while maintaining a moderate increase in area. The fastest SBox currently completed by Ueno has 286GE and a depth of 13.772XOR, while our fast version has only 248GE and a depth of 10.597XOR, which is about 23% higher than the fastest known circuit.
[0460] We also included the current world’s smallest circuit (in terms of standard gates) completed by Boyar in 2016, which has 113 gates (231.29GE) and a depth of 27 gates. Our “bonus” circuit is even smaller, with only 108 gates and a depth of 24, a low of 200.10GE. The synthesis results are shown in Figure 6 shown.
[0461] Table 4: Combined SBox: comparison of results.
[0462]
[0463] Combining SBoxes: Previous Results
[0464]
[0465] Combining SBoxes: Our Results
[0466]
[0467]
[0468] 6.2 Combining SBoxes
[0469] Table 4 shows a comparison of our results with the two previously known best results. Our best combined SBox has a similar size to [Can05] and [RMTA18b], but is much faster because the circuit depth is much lower. This best circuit has a depth of 16 (actually only 14.413XOR) and 151 gates (296GE), while Canright's combined SBox is of size 150(+2) gates (298GE) and has a depth of 30 (25.644XOR). The bonus solution in this paper has a slightly smaller depth than the state-of-the-art result [RMTA18b], but is much smaller in size (133 standard gates vs. 149(+8) standard gates). Finally, the proposed "fast" design using architecture D has the best depth currently known, and we also include the provided Figure 7The comparison shows the design with the best synthesis results.
[0470] 7 Conclusion
[0471] In this Appendix B, we present a number of heuristics and exhaustive search methods for minimizing the circuit implementation of the AES SBox. We present new ideas on how to include the multiplexer of the combinatorial SBox in the minimization algorithm and derive smaller and faster circuit implementations for the forward, inverse, and combinatorial AES SBox. We also introduce a new architecture in which the bottom linear matrix is removed in order to derive the solution as quickly as possible.
[0472] References
[0473] [Art01] Artisan Components, Inc. TSMC 0.18μm Process 1.8V SAGE-XTM Standard Primitive Library Databook, 2001. Website: www.utdallas.edu.
[0474] [BFP18] Joan Boyar, Magnus Find, and René Peralta. Small and Low-depth Circuits for Cryptographic Applications. Cryptography and Communications, 3 November 2018.
[0475] [BHWZ94] Michael Bussieck, Hannes Hassler, Gerhard J. Woeginger, and Uwe T. Zimmermann. Fast algorithms for the maximum convolution problem. Oper. Res. Lett., 15(3): 133–141, April 1994. Available at citeseerx.ist.psu.edu.
[0476] [Boy] Joan Boyar. Circuit minimization work. URL: www.cs.yale.edu.
[0477] [BP10a] Joan Boyar and René Peralta. Novel combinatorial logic minimization techniques for cryptography. Paola Festa, ed., Experimental Algorithms, pp. 178–189, Berlin, Heidelberg, 2010. Springer BerlinHeidelberg. URL: eprint.iacr.org.
[0478] [BP10b] Joan Boyar and René Peralta. Novel combinatorial logic minimization techniques with application to cryptography. Lecture Notes in Computer Science, pp. 178–189. Springer, 2010.
[0479] [BP12] Joan Boyar and René Peralta. Small Depth-16 Circuits for the AES S-Box. Dimitris Gritzalis, Steven Furnell, and Marianthi Theoharidou, eds., SEC, IFIP Advances in Information and Communication Technologies, volume 376, pages 287–298. Springer, 2012. URL: link.springer.com. 1007 / 978-3-642-30436-1_24.
[0480] [Bus01] Business Machines Corporation. ASIC SA-27E Data Sheet, Part 1: Base Library and I / O Data Sheet, 2001. Available at people.csail.mit.edu.
[0481] [CAN05] D. Canright. Extremely Compact S-Boxes for AES. In Josyula R. Rao and Berk Sunar, eds., Cryptographic Hardware and Embedded Systems - CHES 2005, pp. 441-455, Berlin, Heidelberg, 2005. Springer BerlinHeidelberg. Available at: www.iacr.org.
[0482] [FAR06] FARADAY Technology Co. FSD0A_A 90nm Logic SP-RVT (Low K) Process, 2006. Website: www.cl.cam.ac.uk.
[0483] [Glo19] GlobalFoundries. 22nm FDX process, 2019. Website: www.globalfoundries.com.
[0484] [IT88] Toshiya Itoh and Shigeo Tsujii. A fast algorithm for computing the multiplicative inverse of GF(2M) using a normal basis. Inf. Comput., 78(3): 171-177, September 1988. URL: dx.doi.org.
[0485] [JKL10] Yong-Sung Jeon, Young-Jin Kim, and Dong-Ho Lee. A Compact Memory-Free Architecture for the AES Algorithm Using a Resource Sharing Approach. Journal of Circuits, Systems, and Computers, 19: 1109–1130, 2010.
[0486] [MNG00] Microelectronics Group, Carl F. Nielsen and Samuel R. Girgis. WPI 0.5 mm CMOS Standard Primitive Library Data Sheet, 2000. URL: lsm.epfl.ch.
[0487] [NNT+10] Yasuyuki Nogami, Kenta Nekado, Tetsumi Toyota, Naoto Hongo and Yoshitaka Morikawa. for F((2 2 ) 2 ) 2 Efficient Inversion of Mixed Basis and Transformation Matrices for AES Subbytes. Pages 234-247, August 2010.
[0488] [oST01] National Institute of Standards and Technology. Advanced Encryption Standard. NIST FIPS PUB 197, 2001.
[0489] [Paa97] Christof Paar. Optimization Algorithms for Reed-Solomon Encoders. April 1997.
[0490] [Pet] Graham Petley. Internet resource: VLSI and ASIC technology standard primitive library design. URL: www.vlsitechnology.org.
[0491] [Rij00] Vincent Rijmen. An Efficient Implementation of the Rijndael S-Box. 2000. URL: www.researchgate.net.
[0492] [RMTA18a] Arash Reyhani-Masoleh, Mostafa Taha, and Doaa Ashmawy. Shattering the AES S-Box Implementation Record. IACR Transactions on Cryptographic Hardware and Embedded Systems, 2018(2): 298–336, May 2018.
[0493] [RMTA18b] Arash Reyhani-Masoleh, Mostafa Mitaha, and Doaa Ashmawy. New Area Record for AES Combined S-Box / Inverse S-Box. 2018 IEEE 25th Annual Symposium on Arithmetic in Computers (ARITH), pages 145–152, 2018.
[0494] [Sam00] Samsung Electronics Co., Ltd. STD90 / MDL90 0.35μm 3.3V CMOS Standard Primitive Library for Pure Logic / MDL Products Data Sheet, 2000, website: www.digchip.com
[0495] [SMTM01] Akashi Satoh, Sumio Morioka, Kohji Takano, and Seiji Munetoh. An S-box-optimized compact Rijndael hardware architecture. Colin Boyd, ed., ASIACRYPT, Lecture Notes in Computer Science, volume 2248, pages 239–254. Springer, 2001. URL: antoanthongtin.vn.
[0496] [UHS+15] Rei Ueno, Naofumi Homma, Yukihiro Sugawara, Yasuyuki Nogami and Takafumi Aoki. Efficient GF based on redundant GF algorithm (2 8 ) Inverse circuit and its application in AES design. IACRCryptology ePrint Archive, 2015:763, 2015. URL: eprint.iacr.org.
[0497] Appendix to Part B of this Disclosure
[0498] A. Area and velocity measurement methods
[0499] First, we introduce some notations. The names of gates are written with capital letters GATE (e.g. AND, OR). The notation mGATEn represents m gates of type GATE, each with n inputs (e.g. XOR4, 8XOR4, NAND3, 2AND2). When the number of inputs n is missing, the gate is assumed to have the minimum number of inputs, usually just 2 (3 for MUX).
[0500] Primitives constructed as combinations of gates can be described as GATES1-GATE2, meaning that one or more gates are first executed on the first level GATES1, and then the results go into gates on the second level 2. Example: NAND2-NOR2, meaning the cell has 3 inputs (a, b, c), and the corresponding Boolean function is NOR2(a, NAND2(b, c)).
[0501] Two different circuit comparison methods are presented; a standard method and a technical method.
[0502] A.1 Standard method
[0503] Primitives. The basic elements considered in the standard approach are: {XOR, XNOR, AND, NAND, OR, NOR, MUX, NMUX, NOT}.
[0504] Negotiation of the NOT door At certain places in a circuit, it is necessary to use the inverted version of a signal. This can be achieved in a number of ways without explicitly using a NOT gate. Some of them are listed here.
[0505] Method 1. One way to implement a NOT gate is to change the previous gate that generates the signal to instead generate an inverted signal. For example, switch the XOR to an XNOR, switch the AND to a NAND, etc.
[0506] Method 2. In many technologies, there are gates that can produce both the direct signal and the inverted version. For example, the XOR gate in many implementations produces both signals at the same time, so the inverted value is available.
[0507] Method 3. The gate after the inverted signal can be changed so that given an inverted input, the resulting scheme will produce the correct result, for example using De Morgan's laws.
[0508] In summary, it is considered that NOT gates can be ignored when evaluating the circuit using standard methods; since these gates hardly count as full gates. However, for the sake of completeness, the number of NOT gates is included in the result table.
[0509] area For area comparison, count the number of primitive elements without any size distinction between them. NOT gates are ignored.
[0510] depth .The depth is counted based on the number of primitives on the circuit path. Therefore, the total depth of the circuit is the delay of the critical path. NOT gates are ignored.
[0511] A.2 Technical methods
[0512] Primitives .Some papers supplement the standard primitives with some additional combinatorial primitives that are often available in various approaches. For example, gates NAND2-NAND2, NOR2-NOR2, 2AND2-NOR2, XOR4 are very useful to improve and speed up the SBox circuit in this paper. However, to compare with previous academic work, we will keep the standard set of primitives for a fairer comparison. In this approach, we count NOT gates in both delay and area.
[0513] areaThere are many ASIC technologies (90nm, 45nm, 14nm, etc.) from different vendors (Intel, Samsung, GlobalFoundries, etc.) with different characteristics. To develop an ASIC, you need to have access to a "standard primitive library" for a specific technology, which usually contains more diverse primitives than the basic elements listed above, giving designers a wider choice of building blocks.
[0514] However, even considering a standard primitive, such as XOR, this primitive has different areas and delays for different technologies. This makes it difficult to compare two circuits of the same logic developed by two academic groups when the circuits choose to apply different technologies.
[0515] In order to fairly compare the circuit areas of various solutions in academia, the term "gate equivalent (GE)" is often used, where 1GE is the size of the smallest NAND gate. The circuit size (in terms of GE) is then calculated as area(circuit) / area(NAND)→tGE. Knowing the estimated GE value for each standard or technology primitive enables the calculation of the estimated area size of the circuit in terms of GE. Although various technologies have slightly different GEs for standard primitives, these GE numbers are still fairly close to each other.
[0516] We looked at several technologies for which datasheets were available and decided to use the GE values given in the datasheet for the Samsung STD90 / MDL90 0.35μm 3.3V CMOS technology [Sam00]. The primitives to be used had no speed x-factor.
[0517] We also consulted other data sheets for other technologies (e.g., IBM's 0.18μm [Bus01], WPI 0.5mm [MNG00], FARADAY's 90μm [FAR06], TSMC 0.18μm [Art01], web resources [Pet], etc.), and verified that the GE numbers given in [Sam00] are very fair and close to reality. This enables an approximate comparison of the effectiveness of different circuits, even though they may have been developed for different technologies.
[0518] depth .Different primitives (like XOR and NAND) differ not only in GE but also in the maximum delay of the gate.
[0519] Typically, data sheets include the delay (eg, in ns) for each gate and each input-output combination.
[0520] We propose to normalize the delay of all gates used by the delay of the XOR gate. That is, we take the worst case delay of the XOR gate as 1 unit in the measurement of the critical path. Then we look at each standard primitive and select the maximum switching characteristic for all input-output paths of that primitive and divide it by the maximum delay of the XOR gate, thus obtaining a normalized delay unit for each gate used.
[0521] For multiplexers (MUX and NMUX), we ignore the propagation delay of the select bit because in most cases, the select bit is the input of the circuit. For example, in a combinatorial SBox, the select bit controls whether the forward SBox or the reverse SBox is calculated. The select is ready as an input signal and does not switch when the circuit signal propagates, so it is a stable signal.
[0522] The method proposed above is similar to the idea of GE, but is used to calculate the depth of the circuit, normalized by the XOR delay. The reason for choosing XOR as the basic element for delay counting is that circuits often have many XOR gates, so now we can compare the depth between the standard method and the technical method. For example, in our SBox, the critical path contains 14 gates, most of which are XOR, but in fact the depth is equivalent to only 12.38 XOR delays, because the critical path also contains faster gates.
[0523] A.3 Overview of Technology Primitives
[0524] Table 5 summarizes the area and delay of Samsung STD90 / MDL90 0.35μm gates.
[0525] Table 5: Area and delay of gates based on techniques from [Sam00].
[0526]
[0527] B. Algorithm Details and Improvements
[0528] In this section, we present more details of the various algorithms described previously in the paper.
[0529] B.1 Shortest circuit for a single output bit.
[0530] This problem is a recurring goal in many algorithms. The problem statement is as follows. Given k input signals x0,...,x k-1 and the corresponding input delays d0,...,d k-1 , calculate y=x0⊕x1⊕...⊕x with the minimum possible delay k-1 .
[0531] A solution to this problem is given in [RMTA18a], which does not take input delay into account. In Algorithm 2, we extend the result to include input delay and remove the sorting step.
[0532]
[0533]
[0534] B.2 About δ(S,y in 3.3.1 i )
[0535] In each round, the algorithm tests all known pairs of points from S and computes the distance for each pair. The straightforward idea is to compute δ exhaustively, but there are better ways when the input size n is not too large.
[0536] Suppose V is a n A vector of items, each item V[t] is the minimum distance from the current S to t. Then, the single round of the algorithm is simplified a lot, and the shortest distance is:
[0537] δ(V,y i ,c)=min{V[y i ],V[y i ⊕c]+1},
[0538] where c is a candidate for adding to S (the XOR of the other two known points from S), and y i is the target point. Suppose now we decide to add c to S, then the vector V is simply updated to:
[0539] V'[t]=δ(V,t,c), all t=0,...,2 n -1.
[0540] The time complexity of updating V is O(2 n ), but in certain cases it can be compared to for each c and y in a round i Computing δ combinatorially and exhaustively is much faster, especially when using vectorized CPU instructions (such as AVX2).
[0541] B.3 Regarding δ(S,t i )
[0542] In this section, we will describe in more detail how to calculate δ(S,t i ). Algorithms 3, 4, and 5 give the methods for calculating δ(S,t i ) is a slightly reorganized collection of algorithms from .
[0543]
[0544]
[0545] Algorithm 5 Convolution of multiplexer MUX gate
[0546]
[0547] There are two convolution algorithms, one for XOR gates and one for multiplexer gates, which can be implemented independently. Multiplexer convolution can be done in linear time O(N). We first collect the minimum distances for all possible values of F and I (each with possible indices), and then the multiplexer gates can be applied to any combination, so the convolution is XOR convolution is more complicated, and generally has quadratic complexity O(N 2 ).
[0548] Algorithm Improvements Suppose that for some S, we have calculated all distances δ i =δ(S,t i ). For each candidate c from C, we add it to S so that S' = S ∪ c, and then we need to calculate all the distances δ' i =δ(S′,t i ) in order to compute the metric and decide which c is good. Note that adding a single candidate c means that for each target t i ,δ′ i ≤δ i Therefore, the algorithm Distances(S',T,maxδ) should be modified so that maxδ=max{δ i}-1, and finally check if δ′ i ==∞, then δ′ i = maxδ. This simple trick helps to avoid calculating the last vector V k And effectively speed up calculations by up to 20 times.
[0549] The generation of candidate C involves testing whether the candidate is already in C or in S, because these candidates need to be ignored. To speed up this part, a temporary vector Z[N] of length N can be used, where all primitives are initialized to ∞, and then for each point s from S, set Z[sp] = sd. Then, when a new candidate c is generated, just update the table Z[cp] = min{cd, Z[cp]}. Finally, remove the S point from Z and generate C based on Z as follows: for all i = 0..N-1, if Z[i] <∞, add candidate c = {.p = i, .d = Z[i]} to C. In this way, C is constructed with unique candidates and also has minimum depth.
[0550] Architecture improvements .MUX(a,b) and MUX(b,a) can be combined in a single MUX convolution function. In max{d1,d2}+1, the +1 operation is moved outside the convolution function and performed after the convolution instead. p⊕{.p=[1|0|1|0],.d=0} is completed to include gates with negated outputs. These operations can also be moved outside the convolution function and performed in the main function Distances() in linear time. This helps to reduce the number of operations in the critical loop of the function convolutionXOR(), essentially doubling the speed. When A=B, then in convolutionXOR(), only b needs to be run starting from a. When B is not equal to V0, convolutionXOR can only be performed on half of the values of b, because we know that all vectors V k (where k>0) is symmetric with respect to the NOT gate. When A[a]=∞ in convolutionXOR(), there is no need to enter the inner loop for b. Performing the same check for B[b]≠∞ is unreasonable because it adds an unnecessary branch in the critical loop.
[0551] Add AVX. It is obvious that convolutionMUX() can be easily refactored to use AVX vectorized instructions and take advantage of its 128-bit registers and intrinsics. However, attaching AVX to the convolutionXOR() function is a bit tricky. First, assuming that each primitive A[a], B[b] is of type char (byte), b must be aligned to 16 bytes to begin with, since registers in AVX are 128 bits long. Second, the result of p = a⊕b (where b = 0..15 mod 16) will end up at permuted position p, but the permutation only occurs in the lower 4 bits. With _mm_shuffle_epi8(), a permutation of the target 16-byte block can be done, where the permutation vector depends only on the value of a mod 16 (recall that b = 0 mod 16). These permutation vectors can be hard-coded in a constant table. The other operations in this convolutionXOR are easy to implement. AVX2 and its 256-bit long registers can also be attached to speed up the algorithm further.
[0552] B.3.1 More information on ConvolutionXOR()
[0553] It can be noted that convolutionXOR can be accomplished with the help of the following convolution:
[0554]
[0555] The operation and Therefore, we need to perform the convolution in a (min,max)-algebra. We can consider applying the Hadamard transform in O(N logN), but the problem is that this algebra has no inverse element.
[0556] In [BHWZ94] there is an algorithm "MinConv" that can be transformed into our convolution problem and is said to work in "approximately on average" O(N logN) time. The idea behind MinConv is that the A and B vectors are sorted and then we get the minimum delay at the beginning of vectors A and B. Therefore, max{A[a],B[b]} can be enumerated starting from the minimum value. In addition, care should be taken when sorting A and B to be able to find the target point p=a⊕b. Each point p that is hit for the first time receives the minimum possible delay and can therefore be skipped later. The idea behind the algorithm is that the number of predicted hits for all N points covering the result will be around N logN.
[0557] We have programmed it, but it does not show that it works on our input sizes (n=8, N=21 8 ), and actually performs slower than our AVX-modified quadratic algorithm, at least for our input sizes. Furthermore, the above algorithm cannot be parallelized.
[0558] B.3.2 O(maxDelay 2 ConvolutionXOR() in N log N) time
[0559] Usually the delay values stored in the V vector are small. This fact can be used to develop a method that is faster than O(N 2 )Faster algorithms.
[0560] The idea is very simple. Construct two vectors A x [ ] and B y [], so that if A[p] = x, then A x [p]=1, otherwise A x [p] = 0, for B y [] The same operation is performed. Then, the two Boolean vectors A are calculated by the classic Walsh-Hadamard transformation in O(N logN) x and B y The classic convolution. Let C d [] is the result of convolution and d = max{x,y}+1. Then, we know that if C d [p]≠0, then the point p can have depth d. Therefore, we just d [p] performs a linear loop and checks if Cd [p]≠0 and V[p]>d, then V[p]=d. The above operation should be repeated for all combinations of x,y=0..maxD, where the complexity of each step is O(N logN). The value of maxDelay can also be determined linearly at the beginning of the algorithm. Also note that the maxDelay of A and B may be different, so x and y may have different ranges.
[0561] B.3.3 O(|S| 2 ) time ConvolutionXOR()
[0562] When constructing a vector V1 from an initial V0, it is worth going the classic way and iterating over the point pairs of S instead of performing a full-scale convolution on N points. However, the number of newly generated points grows very quickly, and this approach can only be applied to the initial Vs (in our experiments, we only saw some "wins" in V1, and then for further Vs k (k>1), the optimized convolution algorithm has been used).
[0563] C Reverse SBox
[0564] To the best of our knowledge, the use of the inverse SBox alone is not widespread. However, we provide a comparison with previously known solutions in Table 6.
[0565] Table 6: Inverse SBox: comparison of results.
[0566]
[0567] Reverse SBox: Previous Results
[0568]
[0569]
[0570] Inverse SBox: Our Results
[0571]
[0572] D Circuit
[0573] D.1 Preliminary knowledge
[0574] In the listing below, we show six circuits of the forward, reverse, and combined SBox in two architectures, A (small) and D (fast). The symbols used are:
[0575] ##comment – comment line
[0576] @filename – indicates that code from another file called “filename” should be included, and its listing is then also given in this section.
[0577] a^b – is the common XOR gate; other gates are explicitly represented and are taken from the set {XNOR, AND, NAND, OR, NOR, MUX, NMUX, NOT}
[0578] (a op b) – In cases where the order of execution (the order in which gates are connected) is important, specify that order with parentheses.
[0579] The input to all SBoxes is 8 signals {U0..U7} and the output is 8 signals {R0..R7}. The input bits and output bits are represented in big endian order. For the combinatorial SBox, the input has additional signals ZF and ZI, ZF=1 if the forward SBox is executed, otherwise ZF=0 if the reverse SBox is executed; signal ZI is the complement signal of ZF. We have tested all the proposed circuits and verified their correctness.
[0580] according to Figure 5 ,These circuits are divided into subroutines. In Section D.2, the common shared components are described, and then for each solution, the components of the circuit (common or specific) are given.
[0581] D.2 Shared Components
[0582] Listing 2: MULX / INV / S0 / S1 / 8XOR4: shared components.
[0583]
[0584] Listing 3: MULN / MULL: shared components.
[0585]
[0586] D.3 Forward SBox (Fast)
[0587] Listing 4: Forward SBox with Minimum Latency (Fast)
[0588]
[0589] D.4 Forward SBox (Best)
[0590] Listing 5: Forward SBox circuit with area / depth tradeoff (optimal)
[0591]
[0592] D.5 Positive SBox (Reward)
[0593] The following bonus circuit is included to update the world record for the smallest SBox.
[0594] The new record is 108 gates with a depth of 24.
[0595] Listing 6: Forward SBox circuit with minimum gate count (bonus)
[0596]
[0597] D.6 Reverse SBox (Fast)
[0598] Listing 7: Reverse SBox with minimal latency (fast)
[0599]
[0600] D.7 Reverse SBox (Best)
[0601] Listing 8: Inverse SBox circuit with area / depth tradeoff (optimal)
[0602]
[0603] Note: The above 'NOT(U2)' in the file 'itop.a' can be removed by setting Q11 = U2 and negating some of the gates and variables involving Q11 exactly downwards. For example, variable Y01 should also be negated because: N0 = NAND(Y01,Q11), so all gates involving Y01s.b. are negated, which causes other Q variables to be negated, and so on.
[0604] D.8 Reverse SBox (Bonus)
[0605] Listing 9: Reverse SBox circuit with minimum gate count (bonus)
[0606]
[0607] D.9 Combined SBox (Fast)
[0608] Listing 10: Combinatorial SBox circuit with minimal delay (Fast / -S)
[0609]
[0610]
[0611]
[0612]
[0613] D.10 Combination SBox (Best)
[0614] Listing 11: Combinatorial SBox circuit with area / depth tradeoff (optimal)
[0615]
[0616]
[0617] D.11 Combination SBox (reward)
[0618] Listing 12: Combinational SBox circuit with minimum gate count (bonus)
[0619]
[0620]
[0621] Part C of this Disclosure
[0622] The results from Part A and Part B can be further extended by further investigation of the inverting circuit. The final embodiment of the SBox is a circuit with a shorter critical path.
[0623] GF(2 4 )
[0624] The inverse formula is as follows:
[0625] Y0=X1X2X3⊕X0X2⊕X1X2⊕X2⊕X3,
[0626] Y1=X0X2X3⊕X0X2⊕X1X2⊕X1X3⊕X3,
[0627] Y2=X0X1X3⊕X0X2⊕X0X3⊕X0⊕X1,
[0628] Y3=X0X1X2⊕X0X2⊕X0X3⊕X1X3⊕X1.
[0629] A circuit with depth 4 and 17 XORs was found in [BP12], but it is expected that the depth can be further reduced by using a wider range of standard gates.
[0630] Accordingly, the algorithm in Section 4.2 of Part B has been adapted to find a small solution for the INV box. The idea is simple; given a 4-bit input X0,...,X3, each Y iis a truth table of length 16 bits. We define a "point" as a 16-bit value. All standard gates (AND, OR, XOR, MUX, NOT, including their negated versions) can be applied to any combination of "known" points (S), and the distance T to the target point can be calculated in a similar manner as before. Using this slightly modified algorithm for the floating multiplexer, a solution with only 9 gates and a depth of 3 was found. The result is shown in Equation 2, and the improved circuit is shown in Appendix E.
[0631]
[0632] If it is desired to avoid multiplexers in the INV box, a set of alternative equations are also provided in this section. Each expression is considered independently, where the general depth 3 expression is used:
[0633] Y i =((X a op1 X b )op5(X c op2 X d ))op7((X e op3 X f )op6(X g op4X h )) ,
[0634] Among them, X a-h is an item from {0, 1, X0, X1, X2, X3}, op 1-7 is an operator from the standard set of gates {AND, OR, XOR, NAND, NOR, XNOR}. Note that the above need not include all terms, for example, the expression AND (x,x) It's just a simple x.
[0635] The exhaustive search can be organized as follows. Let us have an object Term, which contains a 16-bit truth table TT based on the 4 bits X0..X3 and the Boolean function associated with the term. From the initial set of available terms T (0) = {0, 1, X0, ..., X3}, and then iteratively for the selected Y i Construct an expression. Assume that at some step k there is a set of available items T (k) , we can get the next set of items and the associated expression as follows:
[0636] T(k+1)={T(k),T(k)operatorT(k)},
[0637] Among them, only one item is considered. At a certain step k, its TT will be equal to the target TT (Y i )
[0638] Since we can actually i You get multiple boolean functions, so you should choose only the "best" functions that follow these criteria: no NOT gates (due to better sharing ability), there is a maximum number of gates that can be shared between the 4 expressions of Y0..Y3, small area / depth in terms of GEs.
[0639] Using this technique, we find a solution for the inversion with a depth of 3 and 15 gates. The equation is given below, where we also add 5 additional signals {Y 01 , Y 23 , Y 02 , Y 13 , Y 00} provides a depth 3 solution so that they can also share many gates in the scenarios S0-S5 mentioned in Part B.
[0640]
[0641] Appendix E
[0642] In this section, a circuit using the improved inversion formula provided in Section C is presented.
[0643] Prerequisites
[0644] In the listings listed below, the specifications of the three circuits of the forward, reverse and combined SBoxes in the new architecture D (fast) are described. The symbols used in the following listings are as follows and have the indicated meanings:
[0645] #comment – comment line
[0646] @filename – indicates that code from another file called “filename” should be included, and its listing is then also given in this section.
[0647] a^b – is the common “exclusive OR” XOR gate; other gates are explicitly represented and are taken from the set {XNOR, AND, NAND, OR, NOR, MUX, NMUX, NOT
[0648] (a op b) – In cases where the order of execution (the order in which gates are connected) is important, specify that order with parentheses.
[0649] The input to all SBoxes is 8 signals {U0..U7} and the output is 8 signals {R0..R7}. The input bits and output bits are represented in big endian order. For the combinatorial SBox, the input has additional signals ZF and ZI, ZF=1 if the forward SBox is executed, otherwise ZF=0 if the reverse SBox is executed; signal ZI is the complement signal of ZF. All the proposed circuits have been tested and their correctness has been verified.
[0650] These circuits are divided into subroutines corresponding to Figure 5 Functionality / layers shown. The discussion begins by describing the common shared components, and then for each solution, the components of the circuit (common or specific) are described.
[0651] Shared Components
[0652] The shared components are used in multiple implementations below, so they are only described once here. Listing: MULX / 8XOR4 / INV: Shared components
[0653]
[0654] MANIFEST:MULN / MULL: Shared components.
[0655]
[0656]
[0657] Forward SBox (fast)
[0658] Listing: Forward SBox with Minimum Latency (Fast)
[0659]
[0660] Combination SBox (fast)
[0661] Listing: Combined SBox with Minimum Latency
[0662]
[0663]
[0664] Reverse SBox (fast)
[0665] Checklist: Inverse SBox circuit with minimal delay (fast)
[0666]
[0667]
Claims
1. A substitution box SBox circuit (300, 500) that, when included in a cryptographic circuit, performs an SBox calculation step, the SBox circuit (300, 500) comprising: A first circuit portion (301, 503) comprising a digital circuit for generating a 4-bit first output signal (Y) from an 8-bit input signal (U); a second circuit portion (303, 505) configured to operate in parallel with the first circuit portion (301) and to generate a 32-bit second output signal (L) based on the 8-bit input signal (U), wherein the 32-bit second output signal (L) comprises four 8-bit sub-results; and a third circuit portion (305) configured to generate four preliminary 8-bit results (K) by scalar multiplying each of the four 8-bit sub-results by a corresponding one bit of the 4-bit first output signal (Y), and to generate an 8-bit output signal (R) by adding the four preliminary 8-bit results (K), in: The first circuit portion (301, 503) is configured to generate the 4-bit first output signal (Y) according to the input signal (U) by performing a calculation including a first linear matrix operation (307), a Galois Field GF multiplication (309), and a GF inversion (311); and The second circuit portion (303, 505) is configured to generate the second output signal (L) from the input signal (U) by performing a calculation including a second linear matrix operation.
2. The SBox circuit (300, 500) according to claim 1, wherein: The third circuit portion includes a digital circuit that performs calculations according to the following equation: in: Each Mi is an 8×8 matrix representing 8 linear equations on the 8-bit input signal (U), i=0、1、2、3, L=M0·U||M1·U||M2·U||M3·U, represents the "exclusive or" XOR operation, and || indicates concatenation.
3. The SBox circuit (300, 500) according to claim 1 or 2, wherein: Each of the first circuit portion, the second circuit portion, and the third circuit portion is configured from a digital circuit selected from any one or more of the following: "Exclusive OR" XOR gate; "XNOR" gate; AND gate; "NAND" gate; "OR" gate; "NOR" gate; Multiplexer MUX; NMUX gate; NOT gate; AND-OR inverter AOI; and "OR" inverter OAI.
4. The SBox circuit (300, 500) according to claim 1 or 2, wherein: The first circuit portion (301, 503) and the second circuit portion (303, 505) are configured to generate the 4-bit first output signal (Y) and the 32-bit second output signal (L) according to a forward SBox operation.
5. The SBox circuit (300, 500) according to claim 1 or 2, wherein: The first circuit portion (301, 503) and the second circuit portion (303, 505) are configured to generate the 4-bit first output signal (Y) and the 32-bit second output signal (L) according to an inverse SBox operation.
6. The SBox circuit (300, 500) according to claim 1 or 2, wherein: The first circuit portion and the second circuit portion are configured to generate the 4-bit first output signal (Y) and the 32-bit second output signal (L) according to a forward SBox operation; and The SBox circuit further includes: A fourth circuit portion, comprising generating a replacement 4-bit output signal (Y) based on the 8-bit input signal (U) alt ) for digital circuits for reverse SBox operations; a fifth circuit portion configured to operate in parallel with the fourth circuit portion and to generate an alternative 32-bit second output signal (L) based on the 8-bit input signal (U); alt ) for the inverse SBox operation, wherein the alternative 32-bit second output signal (L alt ) includes four 8-bit sub-results; and A selection circuit (509) is controllable to connect the first circuit portion and the second circuit portion when the forward SBox operation is selected, and to connect the fourth circuit portion and the fifth circuit portion when the reverse SBox operation is selected.
7. A method (800) for performing an SBox calculation step in a cryptographic circuit, the method comprising: generating (803) a 4-bit first output signal (Y) based on an 8-bit input signal (U); In parallel with generating the 4-bit first output signal (Y), generating (805) a 32-bit second output signal (L) from the input signal (U), wherein the 32-bit second output signal (L) comprises four 8-bit sub-results; generating (807) four preliminary 8-bit results (K) by scalar multiplying each of the four 8-bit sub-results by a corresponding one bit of the 4-bit first output signal (Y); and generating (809) an 8-bit output signal (R) by adding the four preliminary 8-bit results (K), in: Generating the 4-bit first output signal (Y) according to the input signal (U) comprises: performing a calculation including a first linear matrix operation, a Galois Field GF multiplication, and a GF inversion; and Generating the second output signal (L) from the input signal (U) comprises performing a calculation comprising a second linear matrix operation.
8. The method (800) of claim 7, wherein: Generating four preliminary 8-bit results (K) by scalar multiplying each of the four 8-bit sub-results by a corresponding one bit of the 4-bit first output signal (Y) includes performing a calculation according to the following formula: in: K i =And i *L i , i=0、1、2、3, Each Y i is a 1-bit value, Each L i is an 8-bit value that satisfies L i =M i *U, Each M i is an 8×8 matrix representing 8 linear equations, and Represents the "exclusive or" XOR operation.
9. The method (800) according to any one of claims 7 and 8, wherein: The 4-bit first output signal (Y) and the 32-bit second output signal (L) are generated according to a forward SBox operation.
10. The method (800) according to any one of claims 7 and 8, wherein: The 4-bit first output signal (Y) and the 32-bit second output signal (L) are generated according to an inverse SBox operation.
11. The method (800) according to any one of claims 7 and 8, further comprising: receiving (509) a selection control signal; as well as The 4-bit first output signal (Y) and the 32-bit second output signal (L) are generated according to a forward SBox operation or a reverse SBox operation depending on the selection control signal.
12. A computer program product comprising computer program code which, when executed in an apparatus comprising one or more processors, causes the apparatus to perform the method according to any one of claims 8 to 11.
13. The computer program product of claim 12, the computer program code being stored on a computer readable storage medium.
