scieee AI-readable full text Open interactive document viewer

Securing RSA hardware accelerators through residue checking

Lasheras Mas, Ana,Canal Corretger, Ramon,Rodríguez Luna, Eva,Cassano, Luca

Abstract

Circuits for the hardware acceleration of cryptographic algorithms are ubiquitously deployed in consumer and industrial products. Although being secure from a mathematical point of view, such accelerators may expose several vulnerabilities strictly related to the hardware implementation. Differential fault analysis (DFA) and hardware Trojan horses (HWTs) may be exploited to steal secret information from the circuit or to interfere with its nominal functioning. It is therefore important to protect cryptographic hardware accelerators against such attacks in an efficient way. In this paper, we propose a lightweight technique for protecting circuits implementing the RSA algorithm against DFA and HWTs at runtime. The proposed solution relies on residue checking which is a well-known technique belonging to traditional fault tolerance. Residue checking is here applied to RSA circuits in order to detect any modification of the output of the circuit possibly induced by the occurrence of a fault or the activation of a HWT. When this happens, the protection technique reacts to the attack by obfuscating the circuit's output (i.e. generating a random output). An experimental campaign (99% confidence and 1% error) demonstrated that, when dealing with DFA, the proposed solution detected 100% of the fault attacks that leaked information to the attacker. Moreover, we applied the proposed technique to all the HWT infected implementations of the RSA algorithm available in the Trust-Hub benchmark suite achieving a 100% HWT detection. The overhead introduced by the proposed solution is a maximum area increase below 3%, about 18% dynamic power consumption increase while it has no impact on the operating frequency.

Full text

Securing RSA Hardware Accelerators through Residue Checking Ana Lasherasa, Ramon Canala, Eva Rodrígueza, Luca Cassanob,∗ aDepartament d’Arquitectura de Computadors – Universitat Politecnica de Catalunya, Barcelona, Spain bDipartimento di Elettronica, Informazione e Bioingegneria – Politecnico di Milano, Italy Abstract Circuits for the hardware acceleration of cryptographic algorithms are ubiquitously deployed in consumer and industrial products. Although being secure from a mathematical point of view, such accelerators may expose several vulnerabilities strictly related to the hardware implementation. Differential fault analysis (DFA) and hardware Trojan horses (HWTs) may be exploited to steal secret information from the circuit or to interfere with its nominal functioning. It is therefore important to protect cryptographic hardware accelerators against such attacks in a efficient way. In this paper, we propose a lightweight technique for protecting circuits implementing the RSA algorithm against DFA and HWTs at runtime. The proposed solution relies on residue checking which is a well-known technique belonging to traditional fault tolerance. Residue checking is here applied to RSA circuits in order to detect any modification of the output of the circuit possibly induced by the occurrence of a fault or the activation of a HWT. When this happens the protection technique reacts to the attack by obfuscating the circuit’s output (i.e. generating a random output). An experimental campaign (99% confidence and 1% error) demonstrated that, when dealing with DFA, the proposed solution detected 100% of the fault attacks that leaked information to the attacker. Moreover, we applied the proposed technique to all the HWT infected implementations of the RSA algorithm available in the Trust-Hub benchmark suite achieving a 100% HWT detection. The overhead introduced by the proposed solution is a maximum area increase below 3%, about 18% dynamic power consumption increase while it has no impact on the operating frequency. Keywords: Cryptographic Accelerators, Differential Fault Analysis, Fault Attacks, Hardware Trojans, Hardware Security, Residue Checking, RSA, Third Party Intellectual Property Cores (3PIPs) 1. Introduction Hardware accelerators for cryptographic algorithms are widely employed in those consumer products, such as smart phones and smart cards, that expose both security and performance requirements. Although modern cryptographic algorithms are secure from the mathematical point of view [1], their implementations often suffer from a number of vulnerabilities. In particular, differential fault analysis (DFA) has been demonstrated to be a very efficient way to leak secret information from cryptographic hardware accelerators [2, 3]. Moreover, the increasing complexity of integrated circuits (ICs) and the seek for low production cost and short time-to-market, led to the globalization of the design and fabrication process of silicon devices [4] also ∗Corresponding author Email addresses: [email protected] (Ana Lasheras), [email protected] (Ramon Canal), [email protected] (Eva Rodríguez), [email protected] (Luca Cassano) in the market of cryptographic hardware accelerators. More and more often the design of some of the hardware modules is outsourced, third-party intellectual property cores (3PIPs) are bought, and sometimes also masks and the final chip fabrication are outsourced [5]. On the one hand, this globalization allows for a significant reduction of design cost and time, but it comes with a significant loss of trust in the delivered ICs [6]. It is very hard to ensure the trustworthiness of all the parties involved in such a globalized supply chain. As a consequence, the product is exposed to a huge number of threats, among which overproduction [7], counterfeiting [8], 3PIPs licenses violation and abuse [9] and Hardware Trojan Horses (HWTs) [10]. A HWT is a very-hard-to-detect modification of a design that stays silent most of the time, while in specific (usually rare) conditions it alters the behavior of the system or it steals secret information. HWTs may be inserted by vendors in the purchased 3PIP core [11], by employees in the developed HDL code, by CAD tools [12] and by mask Preprint submitted to Elsevier December 21, 2020 ©2020 Elsevier. This manuscript version is made available under the CC-BY-NC-ND 4.0 license http://creativecommons.org/licenses/by-nc-nd/4.0/ providers and silicon foundries in the final layout [13]. This paper focuses on RSA (Rivest-Shamir-Adleman) which is a widely adopted public-key encryption algorithm [14]. We propose a runtime solution aimed at protecting RSA hardware accelerators against DFA and HWTs. By monitoring circuit’s behavior, the proposed solution is able to detect at runtime a tentative fault attack and the activation of a HWT. Each time a possible threat condition is detected, the proposed solution substitutes the output of the circuit with a random one in order not to expose sensitive information that could then be used by the attacker to retrieve the secret key. The proposed attack detection technique borrows residue checking from classical fault detection techniques. The basic idea behind our proposal is to pair the conventional RSA implementation with a replica of the RSA algorithm (dubbed the modulo RSA) that uses a smaller number of input bits. The inputs of the modulo RSA are the results of a modulo operation of the inputs of the conventional RSA (i.e. their residue values). The properties of the modulo operation ensure that, at the end of the execution of both replicas, the result of the modulo operation on the output of the conventional RSA will match the output of the modulo RSA only if no alteration of the nominal processing occurred, e.g., no HWT activated and changed the output of the nominal RSA or no faults occurred during the nominal RSA processing. Whenever a perturbation of the behavior of the nominal RSA happens and modifies its output, this check will fail. This would be the case of a HWT activation or the occurrence of an either random or intentional fault. It is worth mentioning that the proposed technique works at the logic-level, thus it can be applied regardless of the underlying technology, e.g., FPGA or ASIC. A preliminary version of the proposed approach has been applied to protect AES, SHA-2 and RSA from fault attacks in [15, 16]. An experimental campaign (99% confidence and 1% error) demonstrated that the proposed countermeasure allowed to detect 100% of the fault attacks that leaked information to the attacker plus, all the HWTs in all the RSA infested circuits available in the TrustHub benchmark [17]. The cost of our solution is an area overhead below 3%, about 18% power consumption increase and no operating frequency reduction. The remainder of this paper is organized as follows: Section 2 introduces the basics of the RSA algorithm; Section 3 discusses the considered threat models; Section 4 presents the proposed protection technique; Section 5 reports the results from an experimental campaign and a qualitative comparison against state of the art approaches, Section 6 presents a security analysis and discusses the limitations of the proposed solution; Section 7 presents the related work. Finally, Section 8 concludes the paper. 2. The RSA algorithm RSA (Rivest-Shamir-Adleman) is a public-key cryptographic (or asymmetric) algorithm [14]. Two keys are employed: the public key is used for encryption and the private key, which is kept secret by the owner, is used for decryption. In the remainder of the paper, we will use the following notation: mdenotes the plain message (also dubbed as plaintext), cdenotes the encrypted message (also dubbed as ciphertext), sdenotes a signature when RSA is used for integrity instead of confidentiality, n=p∗qdenotes the public modulus, where pand q are large prime numbers, edenotes the public exponent, and dthe private (secret) exponent. The public key consists of nand e, while the private key of the secret d. It is worth mentioning that e,dand nmust be chosen such that for all integers m(with 0≤m≤n) the following equation holds: (me)d≡mmod n(1) as well as: (md)e≡mmod n(2) For the sake of space, we do not mention how e,dand nare generated. Once eand nhave been distributed, they can be used for encryption. Given a plaintext m, the corresponding cyphertext ccan be computed as: c≡memod n(3) The only way to decrypt cis by using the private key associated with the public key used to encrypt the original plaintext. In other words, only the owner of dcan decrypt cby computing: cd≡(me)d≡mmod n(4) In case RSA is used for generating a message signature sthe following equation is computed: s≡mdmod n(5) The signature sassociated with a message mis considered to be valid if and only if: se≡(md)e≡mmod n(6) This means that the signature is valid if and only if it has been produced with the right private key (and thus by the right person) and the message has not been modified. 2 3. Threat model Here we present the considered threat models in terms of fault attacks specific for RSA accelerators and possible HWTs. 3.1. Fault Attacks against RSA As reported in [18], fault injection techniques can be divided into low-cost (below 3,000US$) and high-cost (3,000US$ up to millions of dollars). High cost techniques, that rely on very precise laser or ion beams or light pulse generators, allow the attacker to very accurately determine the injection location and time. It is extremely difficult to protect the system in case the attacker has access to such fault injection facilities. On the other hand, low cost fault injection may be carried out by down- or over-scaling power supply, tampering the clock signal and over-heating the circuit. Such techniques only provide either time or space accuracy, but, given their low cost, and their wide applicability, are the ones addressed by most proposed circuit protection techniques. When dealing with RSA two families of low cost attacks exist: one aims at either factoring n(to discover the prime numbers pand q) or directly recovering d; the other aims at decrypting an encrypted message cwithout knowing d. A detailed discussion on DFA against RSA (and other cryptographic algorithms) may be found in [18]. The first family of attacks aims at retrieving the private key (or the prime numbers from which it is generated) during a decryption or the computation of a signature. The first type of attacks belonging to this family attempts to discover the entire secret information with a single injected fault. Such attack, dubbed the Bellcore attack [19], injects the fault trying to induce the system to compute e sinstead of s, being sthe expected fault-free signature and e s=s+δ. After e sand scalculation, the attacker is able to retrieve one of the secret prime numbers from which the key has been generated (and thus also the secret key) by simply calculating the greatest common divisor between (e s−s)and n. A similar attack has been proposed in [20] where fault injection happens during signature checking: this attack allows to recover the prime number by calculating the greatest common divisor between (e se−m)and n. The great advantage of such attack w.r.t. the Bellcore attack is not to require the fault-free signature s. A second type of attacks belonging to the first family aims at leaking one bit of the secret key at a time. Such attacks work under the following assumptions: i) the attacker has arbitrary access to the circuit; ii) the attacker can select the circuit’s input; iii) there is no limitation to the number of fault injection attempts the attacker can perform (in other words, the fault injection activity is assumed not to be destructive). An attack belonging to this family has been proposed in [21]. Several faults are injected during several signature computations where each fault allows to leak a single bit of the private key. Indeed, a fault injected during signature computation may be such that the corrupted output signature is either e s=sd−2ior e s=sd+2i(depending on whether the induced bit-flip was a 0-to-1 or a 1-to-0) where i∈[0,v−1] and vis the number of bits of the private key. Once e shas been computed, the attacker can calculate the ith bit of the secret key as either m2imod n=s/e smod nor m2imod n=e s/smod n. In the last type of attacks belonging to this first family (the so-called safe error attacks [22, 23]) the attacker only exploits the knowledge of whether the injected fault had an effect on the produced output or not to retrieve the key. More in details, in case a fault is injected in a register storing one of the bits of the key, the produced output will be unaltered w.r.t. the expected output in case the bit of the key was 0 (flipped to 1 by the fault). Conversely, the produced output will differ from the expected output in case the bit of the key was 1 (flipped to 0 by the fault). This attack is extremely effective but it has been demonstrated to be impractical [24]. Indeed, the fault injector is required to have both location and timing precision at the same time in order the safe error attack to be successfully carried out. The goal of the second family of attacks to RSA is decrypting an encrypted message without the private key. This is achieved by injecting faults during encryption [24]. Like in the Bellcore attack, the retrieved corrupted cyphertext is either e c=ce−2ior e c=ce+2iwhere, again, cis the expected cyphertext, i∈[0,v−1] and vis the number of bits of the public key. Given the correct cyphertext cand the faulty onee c, and after computing inverses over Z, the attacker can then calculate c·e c−1mod n, thus, easily retrieving the plaintext associated with c. The protection solution proposed in the current paper represents an effective and lightweight countermeasure against all the previously mentioned types of fault attacks except for the safe error one that, as we mentioned, is very unlikely to be deployed in a real-world scenario. 3.2. Hardware Trojans A HWT is a very-hard-to-detect malicious modification of a digital circuit/system. HWTs may be classified according to the untrusted entity in the circuit’s supply chain that inserts the Trojan, i.e., IP vendors, internal designers, CAD tools, silicon foundry. 3 Based on the triggering mechanism, HWTs may be divided in triggered HWTs and always-on ones. As the name suggests, always-on HWTs are always active in the infested circuit. Triggered HWTs, on the other hand, become active as soon as their triggering condition is verified. The activation of a triggered HWT may be controlled by a specific (generally rare) configuration of the signals of the circuit, by internal physical conditions of the circuit (e.g., temperature and voltage) or by externally received signals and messages. A final classification may be done based on the effect of the HWT after its activation [25]. In this sense, HWTs may be divided into: •change-functionality: HWTs that modify the behavior of the system. •denial-of-service: HWTs that halt the functioning of the system by draining power supply, deactivating I/O interfaces or overloading processing units. •information-stealing: HWTs that leak secret information and send it to the output or through a covert side-channel. In this work, the entities considered as untrusted are the external providers of 3PIPs implementing the RSA HW accelerator. On the other hand, the system integrator (and thus the modulo RSA designers) and silicon foundries are assumed to be trusted. The detection technique presented in this paper addresses all those HWTs in externally purchased IP cores that modify the internal signals of the circuit to change or deny its functionality or to leak information, irrespective of the triggering mechanism (both triggered and always-on HWTs are considered). HWTs that modify the internal signals of the circuit without modifying its output signals are not considered since they can neither modify/halt the normal functioning of the circuit nor use the available output signals to sneak stolen information. Similarly, HWTs that leak information by sending it to a covert side-channel and HWTs that deny the functioning of the circuit by acting on the power supply or the communication interfaces are beyond the scope of this work. Collusion between 3PIPs belonging to the same vendor, i.e., a core activates a HWT installed in another core, is also taken into account by the proposed technique as long as the unwanted malicious interaction between the two untrusted 3PIPs falls in one of the above mentioned modifications of the circuit’s behavior. As a last consideration, it has to be mentioned that the applicability of the proposed detection technique is constrained by the availability of either the HDL source &RQYHQWLRQDO56$ 0RGXOR56$ NH\ LQSXW text &KHFNHU 5DQGRP2XWSXW *HQHUDWRU RXWSXW WH[W YDOLGLQYDOLG Figure 1: Block Diagram of RSA + Protection Circuit code or the netlist of the considered 3PIP. In other words, the proposed technique is applicable to whitebox netlists. We believe that this is a reasonable assumption in a scenario where the IP provider may disclose IP cores to allow the customer to verify the fulfilment of a previously agreed trustworthiness level. Such assumption is the same as in several hardware securityrelated papers working both at the HDL [26, 27] and netlist level [28, 29]. Finally, in the increasing trend of Open Hardware, it is common to share IP designs. As of real-world commercial products, the Cobham Gaisler LEON [30] and NOEL [31] CPUs, are also sold as "white-box" IP cores. 4. The proposed Protection Architecture We propose to enhance a system hosting a 3PIP that implements the RSA algorithm (light grey block in Figure 1) with a surrounding architecture (dark grey blocks in Figure 1). Our proposal is aimed at detecting at runtime the occurrence of a fault attack or the activation a HWT. More in details, we pair the purchased 3PIP implementation of the RSA algorithm (the conventional RSA) with an ad hoc designed much smaller replica (the modulo RSA). The outputs of the two replicas are then checked: in case no difference is observed, no fault attack or Trojan activation is assumed to have occurred and thus the output of the conventional RSA is forwarded as the output of the system. In case the two output values are different, a random output is generated and forwarded in order to make differential fault analysis (and more in general, information stealing) unfeasible. It is worth mentioning that we here consider the conventional RSA as the component possibly under attack. Indeed, when considering fault attacks, the conventional RSA is the only component that executes the actual algorithm, and thus it is the only source of information for the attacker. On the other hand, no information would 4 be retrieved by attacking the modulo RSA. Similarly, when considering HWTs, the conventional RSA is the only externally purchased 3PIP and thus it is the only untrusted component in the system. On the other hand, the modulo RSA is assumed to be trusted since it is implemented by the internal design team (as previously discussed, we here consider the design team, the employed CAD tools and the foundry to be trusted). In case the attacker injects faults in the modulo RSA, instead of the conventional RSA, the faults would also be detected thus leading the system to output a random value instead of the uncorrupted output of the conventional RSA. This may allow the attacker to perform a denial-of-service attack to the system. Since this attack would not expose any secret information to the attacker, we leave this situation out of the scope of the paper. Finally, a severe source of threat would be the injection of multiple faults, but this would be discussed in depth later, in the Section 6. In the remainder of this section, we provide additional details about the proposed protection technique. We first recall the basics of residue checking and how to use it to detect signals modifications and we then discuss how to select the best modulo value and how a HW implementation of RSA can be enhanced with the proposed residue checking-based detection mechanism. 4.1. Detecting Signal Modifications through Residue Checking Given two positive integers aand n(where nis dubbed the modulo value), we can calculate aas: a=n∗q+r(7) where both qand rare positive integers (qis the quotient and ris the residue). The operation modulo(a, n) is defined as the residue of the integer division of aby n (represented as |a|n) and it returns r. Residue Checking is a lightweight mathematical mechanism for statically validating the results produced by arithmetic units. It detects changes on the output data based on the calculation of the residue. For instance, an addition can be checked by testing the equality of Equation 8. |a+b|n=||a|n+|b|n|n(8) Indeed, if both sides of the equation are equal, no error occurred. On the other hand, the occurrence of a fault during the processing would for sure make the check fail. Thus, when used to detect errors, residue checking guarantees that there are no false positives. Residue checking works as described for any arithmetical operator. As a consequence, it also works for the modular exponentiation that is a key component of the RSA algorithm. On the other hand, it is worth noting that residue checking does not work for logical operators [32]. 4.2. Selection of the modulo value One of the key aspects of a fault detection mechanism based on residue checking is the selection of the modulo value. The chosen modulo value strongly affects both the fault detection capability and the introduced overhead. Breveglieri et al. [33] showed that the detection capability depends on the magnitude of the modulo value when transmitting information (i.e. no arithmetic operation involved between residue values). Below, we describe the particularities of power of 2 and non power of 2 values considering the implementation overhead and the detection capabilities. Figure 4 in Section 3 shows the fault detection percentage of for all the modulo values analyzed. A modulo value nthat is a power of 2 (i.e. n=2w) can be implemented as a logical masking operation, thus reducing the introduced overhead. When the modulo value is a power of 2, given an integer athe modulo operation can be expressed as: |a|n=a& (2w−1) (9) Consequently, the residue value can be expressed in w−1bits (if treated as an unsigned integer when designing the circuit). This choice significantly simplifies the implementation while, on the other hand, it makes the fault detection much less effective. For any power of 2 modulo value, the residue checking operation will miss any modification of the upper bits (i.e. the masked bits). Therefore, the smaller the modulo value, the smaller the introduced overhead but also the lower the fault detection capability (as we will see in in Section 3). When the modulo is a non-power of 2 value, the calculation of the residue requires the use of all the bits in aand the fault detection capability does not depend on the chosen modulo value. A naive implementation of the modulo operation for non power of 2 modulo values simply computes the division and then makes a subtraction. Such implementation, although being straightforward, introduces a very high area overhead. Much more optimized implementations with fewer hardware requirements exist [34]. In this line, we rely on the optimized implementation of the modulo operation provided by the Xilinx Vivado™ [35] synthetizer. 5 Figure 2: Block Diagram of RSA + Protection Circuit 4.3. Architectural details The implementation of the conventional RSA is based on the implementation of the modular multiplication operation. As it has been discussed in Section 2, the RSA encryption performs the exponent operation shown in equation (3) and the decryption performs the exponent operation shown in equation (4). Given two positive integers xand y,xy(referenced in the text as Pow(x, y)) can be computed as the result of the following recursive algorithm: Pow(x,y)=              x,if y= 1 Pow(x2,y/2),if yis even x×Pow(x2,(y−1)/2),if y>2 is odd This algorithm is much faster than the ordinary method to perform the exponent calculation. Indeed, when multiplying xby itself, calculating xyrequires yoperations. On the other hand, when implementing the algorithm shown above, only log2(y)operations are needed. The circuit implementing the conventional RSA based on such an algorithm for the exponent calculation only counts one multiplier and one square. The feedback loop that brings the output back to the input multiplexer (also shown in Figure 2) implements the recursivity of the algorithm. A high-level representation of the overall secured system is shown in Figure 2: dark grey blocks belong to the conventional RSA while the light grey are added to implement the modulo RSA. More in details, the modulo RSA is composed of: i) the modulo operation (modN), ii) the reduced size multiplicator (MULw), iii) the square (X2 w) block, iv) the necessary muxes, v) the comparator, and vi) the random output generator . It is worth mentioning that w=dlog2(n)erepresents the number of bits needed to represent the modulo value N. Note that Figure 2 shows already the breakdown of the RSA algorithm into the (recursive) modular multiplication blocks (MUL and X2for the conventional RSA and MULwand X2 wfor the replica). The circuit takes an input text (either plain or encrypted) and a key (either public or private) and it produces an output text (either encrypted or plain depending on the requested operation or randomly generated in case of an attack has been detected). The conventional RSA takes in input the data to be encrypted/decrypted; The modulo RSA uses the results of a modulo operation of the inputs of the conventional RSA (mod N block). Both the conventional modular multiplication and the replica modular multiplication are performed in parallel. The modN value of the result of the conventional modular multiplication is compared to the output of the replica modular multiplication. Should this comparison fail, a random output is forwarded to the output of the circuit in order to make differential fault analysis or information leaking unfeasible. To avoid power side-channel attacks, the random number generator is always on. 5. Experimental results We carried out a series of experiment aimed at assessing the capability of the proposed methodology to protect against DFA and HWT and to measure the introduced overhead in terms of area and power consumption increase and working frequency reduction. 5.1. Experimental Setup In order to assess the effectiveness of the proposed methodology we considered a real-world HW implementation of the RSA algorithm freely available in the TrustHub repository [17, 36]. To analyse the fault detection capability we implemented a VHDL-level fault simulator that allowed us to emulate the occurrence of bit-flips in both the registers and the output of the conventional RSA circuit. For the HWT detection analysis we considered the four HW Trojans-infested RSA benchmark circuits available in the TrustHub repository [17, 36]. T100 and T300 Trojans leak the secret key by sending it through the primary output of the circuit after a certain number of encyption operations (T300) or when the input plain text is 32’h44444444 (T100); T300 and T400 Trojans are both denial-of-service Trojans activated after a given number of encryption/decryption operations: T300 denies the service by disabling encryption/decryption, while T400 denies the service by 6 Table 1 Number of required simulations per confidence and error margin value Confidence Level 99% 95% Error Margin 10% 5% 1% 10% 5% 1% #RSA simulations 638 2551 63756 370 1477 36910 replacing the secret key with a new key only known by the attacker. All the RSA benchmark circuit implementations have then been extended with the proposed residue checkingbased detection mechanism. We used Xilinx Vivado™ [35] as a development and synthesis environment and we then employed the accompanying Device Utilization Summary and Power Estimator tools for area, power and time analysis. In order to have a wide analysis of the efficiency of the proposed technique, we considered two target devices: the Virtex UltraScale+ FPGA (model: xcvu13p-fhga2104-3-e) and the Artix 7 (model: xc7a50tcsg324-1). 5.2. Effectiveness Analysis Here we first report results referred to the analysis of the fault detection and then to HWT detection. 5.2.1. Fault Attack Detection Capability We first analysed the effectiveness of the proposed countermeasure in detecting faults in the conventional RSA and the impact of the modulo value on the fault detection capability. When dealing with simulation, as in our case, statistically significant results are usually understood as 99% confidence level at 5% error margin. Based on such a target, the authors in [37] defined the number of experiments, based on the input signals, needed to reach the selected goal. Table 1 shows the number of simulation setups (i.e. different combinations of input values and fault injection location and fault injection clock cycle) required to achieve the desired statistical significance. All circuits (i.e. all modulo values) use the same list of simulation setups. In the remainder of the discussion we report results for 99% confidence and 1% error margin. To do so, we performed about 64000 simulations for each modulo value (which takes roughly 16 minutes to complete in our server when using the batch mode of Vivado™). It is worth mentioning that we randomly chose the circuit’s inputs and the FF or wire and the clock cycle where the fault is injected. It is well known that because of logical and temporal masking, not every injected fault leads to an error Figure 3: No-effect faults and error-inducing faults in the output1. From a DFA protection point of view the critical faults are only those that propagate to the output of the circuit, thus providing information to the attacker. Figure 3 reports the percentage of faults injected in the conventional RSA that modified (and did not modify) circuit’s output2. It is worth noting that the adopted implementation of the RSA algorithm is already able to tolerate 72% of the injected faults. On the other hand, the remaining 28% of the injected faults are actually able to modify the output of the conventional RSA circuit, thus bringing information to the attacker. For this reason, these faults (now errors) are the ones that we used in the subsequent experiments to assess the effectiveness of the proposed detection technique. We implemented several versions of the protected RSA circuit with several power of 2 and non-power of 2 modulo values to assess the detection capability w.r.t. the chosen modulo value. We performed a set of fault injection experiments where we injected only the previously identified faults that are able to generate errors in the circuit’s output. In each fault injection experiment, a fault was randomly injected in either a flip-flop or an output bit of the conventional RSA at a random clock cycle. Figure 4 reports the percentage of detected errors as a function of the number of bits of the chosen modulo value. For each given number of bits (x-axis), two modulo values have been analyzed: 2w(grey squares) and 1This percentage will be increased by electrical masking when the circuit is working in the field (this cannot be simulated directly with Vivado™) 2We did not inject faults in the modulo RSA because this does not bring any advantage to the DFA attacker. As the residue checking will detect also a mismatch in this case. 7 Figure 4: Fault Detection as a function of the modulo value 2w−1(black diamonds). It is worth noting that, if the modulo value is a power of 2 then the modulo computation is just a mask operation; otherwise, it requires a full computation with all the bits of the source value (this is actually the advantage of the modulo computation we rely on). Figure 4 clearly shows that any non-power of two modulo value allows to detect all the errors in the output signals while a conventional power of 2 modulo value is unable to do so. As we previously mentioned, when a power of 2 modulo value is used, only the lower wbits are stored for checking. Thus, any fault in the upper bits is not detected. Consequently, the detection capabilities of power of 2 modulo values are fundamentally linear to the number of considered bits. Obviously, when all the bits are considered (i.e. full replication of the circuit), the percentage of detected errors reaches 100%. 5.2.2. Hardware Trojans Detection Capability In order to assess the capability of the proposed methodology in detecting the activation of “real-world” HWTs, we extended the four Trojan-infested RSA circuits available on the Trust-Hub benchmark suite (RSA T100, T200, T300 and T400) with the proposed detection mechanism. We chose the 232 −1non power of 2 modulo value to present the worst-case scenario in terms of introduced overhead (discussed in the next subsection). The result of this analysis has been that for all the considered Trojan-infested circuits the proposed technique has been able to detect and signal the activation of the HW Trojan. 5.3. Efficiency Analysis We measured the area and power consumption increase and the working frequency reduction caused by the proposed detection technique. As a baseline, we considered the hardware implementation of the RSA algorithm available on Trust-Hub. When implemented on both the considered FPGA devices we did not observe any increase of the number of Table 2 Power consumption overhead UltraScale+ Artix 7 Static Dynamic Static Dynamic RSA 3.067 W 0.018 W 0.070 W 0.0110 W RSA+ 3.067 W 0.021 W 0.070 W 0.0129 W used flip-flops and I/O pins, while the number of used LUTs increases from 596 to 613 (2.85% more, which, in our opinion, is totally reasonable for a secured system). Table 2 reports the static and dynamic power consumption for the baseline (row RSA) and the protected RSA (row RSA+) for both the considered FPGA devices. As a first consideration, it can be observed how different are the static power consumption values for the two considered FPGA devices. This is due to the extremely different amount of resources that the two FP- GAs have and that the standard compilation is not power gating the unused resources to limit static power consumption. It can also be observed that, in both cases, the proposed protection technique does not affect the static power consumption at all. On the other hand, our solution causes a dynamic power consumption increase of 16.67% and 17.27% in the UltraScale+ and the Artix 7, respectively. Such a significant increase of the dynamic power consumption is mainly due (two-thirds) to the random number generator. Finally, we analysed the increase of the critical path delay and thus the operating frequency reduction. Both the baseline RSA circuit and the protected one have a maximum operating frequency of 134 MHz on the UlstraScale+ device and of about 116 MHz on the Artix 7 device. Therefore, the proposed technique does not reduce at all the operating frequency of the protected system. This result may be explained by considering that the FPGA implementation of both designs is dominated by the path from the input flip-flop, through the multiplier, into the output multiplexor and back to the flipflop (that stores the partial results). Therefore, the delay observed in the FPGA is mainly caused by the wiring of this path. The modulo RSA and the output check work in parallel with the conventional RSA, therefore, the overall effect is not visible in terms of critical path delay. It is worth pointing out that the lower operting frequency of the Artix 7 and the smaller energy consumption due to the unavailability of CARRY8 blocks, contribute to the lower dynamic power of the Artix 7 implementation against the Ultrascale+ one. 8 5.4. Comparison We here report a qualitative comparison of the proposed protection technique against the most recent and relevant related work both for fault attacks protection and for HWT detection. 5.4.1. Fault Attacks Protection Most of the countermeasures that have been proposed to protect RSA against DFA work at the algorithm level and not at the circuit level. This means that they aim at modifying the algorithm itself or the way it is computed or implemented in order to make the obtained circuit fault-resistant [38, 39, 40]. Therefore, they introduce no (or negligible) area overhead, while the area overhead introduced by the here proposed methodology is 2.85%. Conversely, while algorithm level protection techniques introduce a relevant time overhead (12.50% up to 137.50%), our approach has no impact on circuit’s timing since it does not affect the working frequency of the system. 5.4.2. Hardware Trojan Protection We compared against [41] and [42] which, in our opinion, are the most recent and relevant work related to the proposal in the current paper. Indeed, they both are runtime monitoring techniques working at the system level and they both exploit redundancy. We only provide a qualitative comparison as none of these works evaluate the RSA algorithm. We can observe that in [42] the average area overhead is 95.85% and the average power overhead is 117.40%; no operating frequency reduction is reported. In [41], the introduced area overhead ranges from 15% to 31% with an operating frequency reduction between 1% and 4.20% (no power consumption increase is reported). When compared with these techniques our proposal introduces much smaller area and dynamic power consumption overheads and a no operating frequency reduction. This is of course due to the fact that our methodology is specifically tailored and optimized for the RSA algorithm. On the other hand, our technique cannot be applied to generic circuits as explained in Section 4.1. 6. Security Analysis and Limitations Here we highlight the limitations of the proposed detection mechanism w.r.t. fault attacks and HWTs. It is worth mentioning that, as for most security countermeasures, we assume that the attacker knows all the details of the adopted solution. 6.1. Multi-bit Fault Attacks While single-bit fault attacks can be addressed by fault injection (as performed in this paper), multi-bit fault attacks need a careful execution as it is shown in [43] for the AES algorithm. Specifically, the authors of [43] revise the representativeness of published multi-fault attack models and they evaluate the impact of choosing a given model on the results obtained after fault injections. In this work, we reported single-bit fault attacks. Yet, we have conducted experiments with two-bits fault attacks in the conventional RSA module. The proposed technique is still able to capture 100% of the feasible attacks (for non power of 2 modulo values) and a slightly higher number of attacks for the configurations with a smaller number of bits with power of 2 modulo values. This makes total sense as, for instance, the probability of detecting two bit-flips when just looking at -let’s say- 8 bits out of 32 is higher than detecting a single bit flip by looking at 8 bits out of 32. As the number of bits used increases, the detection capabilities converge. Another threat is the case where the attacker is able to inject faults in both the conventional and the modulo RSA and induce the two modules to generate the same modulo output (so the corrupted value is forwarded to the output). In such case, the proposed protection technique would fail. Yet the occurrence of such an event should be confirmed, at least, through a a realistic modelling of the final circuit and laser capabilities [43]. We performed an initial analytical study of the vulnerability of the proposed solution. First, we concluded that the best place for a multi-bit fault attack would target not only the RSA circuitry but also the final modulo values comparison to make the detection fail (i.e. the produced modulo outputs would be equal and the output multiplexer would forward the corrupted output of the conventional RSA to the output of the system). Table 3 reports the probability of identifying the right bit(s) to flip in one modulo value that -when flippedmatch the other modulo value. This probability is the division of the number of combinations that an attack can perform (e.g. "up to 2" means flipping any combination of 0, 1 or 2 bits in the modulo value) by the total number of possibilities (i.e. "up to n", where nis the number of bits of the modulo value). We report results for attacks able to flip up to 2, up to 5, and up to 10 bits; for several modulo value lengths. By looking at the numbers reported in the table, it is clear that the modulo value needs to be long enough to offer enough protection. This is an initial approximation of the vulnerability. The final value will be affected by the distribution of the real values in the inputs, the bits attacked in the RSA, the physical layout 9