System and method for protecting a cryptographic device against fault attacks while performing cryptographic non-linear operations using linear error correcting codes
10673610 ยท 2020-06-02
Assignee
Inventors
Cpc classification
H04L9/0631
ELECTRICITY
H04L2209/34
ELECTRICITY
International classification
H04L9/00
ELECTRICITY
H04L9/06
ELECTRICITY
H04L9/32
ELECTRICITY
Abstract
A system, method and computer-readable storage medium with instructions for protecting an electronic device against fault attack. Given a data represented as an input codeword of a systematic linear error correcting code, the technology provides the secure computation of the output codeword corresponding to the result of the non-linear function applied to this data. Other systems and methods are disclosed.
Claims
1. A cryptography device protected from fault attacks while performing a cryptographic operation f, comprising: a memory, a hardware processor and instruction storage storing instruction executable by the hardware processor to perform cryptography operations, the instructions includinginstructions to generate a codeword cw in a code C from an input quantity x wherein the codeword comprises a systematic portion equal to the quantity x and a redundancy portion R x derived from the quantity x using a first redundancy-portion mapping function; instructions to determine f(x) from x using a cryptography-operation mapping function; instructions to determine a unique index value using a linear index-value mapping that uniquely maps the combination of the systematic portion x and the redundancy portion R x to said unique index value; instructions to compute a second redundancy portion R f(x) as a function of the unique index value wherein the combination off(x) and the second redundancy portion is a codeword in C corresponding tof(x) using a second redundancy-portion mapping function; instructions to verify, the absence of a fault in the computation off by verifying the second redundancy portion (R f(x)) against an expected value for the second redundancy portion; and in response to detecting a fault by determining a mismatch between the second redundancy portion and the expected value for the second redundancy portion, taking a corrective action to thwart a threat from a potential fault attack.
2. The cryptography device of claim 1, wherein at least one of the codeword cw, the value f(x), the index value uniquely corresponding to the combination of the systematic portion x and the redundancy portion R_x, or the second redundancy portion is determined using lookup table.
3. The cryptography device of claim 2, wherein the lookup table for determining at least one of the codeword cw, the value f(x), the index value uniquely corresponding to the combination of the systematic portion x and the redundancy portion R_x, or the second redundancy portion is determined using lookup table is stored in permanent storage of the cryptography device.
4. The cryptography device of claim 1, wherein the unique index value is a function (l) that is a mapping of inputs x and R_x such that l(x,R_x) determines uniquely x and the instructions to compute a second redundancy portion comprises computing R_f(x) using a mapping of l(x,R_x) to R_f(x).
5. The cryptography device to claim 1, wherein f is a nonlinear operation in a cryptographic operation.
6. The cryptography device to claim 5, wherein the cryptography non-linear operation is an operation on a cryptography state word.
7. The cryptography device to claim 1, wherein the second mapping function is defined such that given as input the output of the index-value mapping the second redundancy-portion mapping function produces the same output as the first redundancy-portion mapping function produces using the output from the cryptography-operation mapping; and wherein instructions to verify the absence of a fault in the computation of f by verifying the second redundancy portion against an expected value for the second redundancy portion comprises computing a verification value for the redundancy portion based solely on f(x) (R_f(x)) and comparing the verification value for the redundancy portion against the second redundancy portion computed as a function of the unique index value (R_f(x)).
8. The cryptography device to claim 1, wherein instructions to verify the absence of a fault in the computation of f by verifying the second redundancy portion against an expected value for the second redundancy portion comprises computing by determining that a codeword composed of a systematic portion f(x) and the second redundancy portion is a valid codeword in C.
9. A method for operating a cryptography device having a processor and instruction storage, the method protecting the cryptography device against fault attacks, the device operable to perform a cryptographic operation f on an input quantity x of a cryptographic process, the input quantity not represented in plaintext and protected against fault attacks, the method comprising: generating a codeword cw in a code C from an input quantity x wherein the codeword comprises a systematic portion equal to the quantity x and a redundancy portion R_x derived from the quantity x using a first redundancy-portion mapping function; determining f(x) from x using a cryptography-operation mapping function; determining a unique index value using a linear index-value mapping that uniquely maps the combination of the systematic portion x and the redundancy portion R_x to said unique index value; computing a second redundancy portion R_f(x) as a function of the unique index value wherein the combination of f(x) and the second redundancy portion is a codeword in C corresponding to f(x) using a second redundancy-portion mapping function; and verifying the absence of a fault in the computation of f by verifying the second redundancy portion (R_f(x)) against an expected value for the second redundancy portion; and in response to detecting a fault by determining a mismatch between the second redundancy portion and the expected value for the second redundancy portion, taking a corrective action to thwart a threat from a potential fault attack.
10. The method for operating a cryptography device having a processor and instruction storage of claim 9, wherein at least one of the generating a codeword cw, determining the value f(x) from x, the determining the index value uniquely corresponding to the combination of the systematic portion x and the redundancy portion R_x, or the determining the second redundancy portion is determined using lookup table.
11. The method for operating a cryptography device having a processor and instruction storage of claim 10, wherein the lookup table for determining at least one of the codeword cw, the value f(x), the index value uniquely corresponding to the combination of the systematic portion x and the redundancy portion R_x, or the second redundancy portion is determined using lookup table is stored in permanent storage of the cryptography device.
12. The method for operating a cryptography device having a processor and instruction storage of claim 9, wherein the unique index value is a function (l) that is a mapping of inputs x and R_x such that l(x,R_x) determines uniquely x and the instructions to compute a second redundancy portion comprises computing R_f(x) using a mapping of l(x,R_x) to R_f(x).
13. The method for operating a cryptography device having a processor and instruction storage of claim 9, wherein f is a non-linear operation in a cryptographic operation.
14. The method for operating a cryptography device having a processor and instruction storage of claim 9, wherein the second mapping function is defined such that given as input the output of the index-value mapping the second redundancy-portion mapping function produces the same output as the first redundancy-portion mapping function produces using the output from the cryptography-operation mapping; and wherein verifying the absence of a fault in the computation of f by verifying the second redundancy portion against an expected value for the second redundancy portion comprises computing a verification value for the redundancy portion based solely on f(x) (R_f(x)) and comparing the verification value for the redundancy portion against the second redundancy portion computed as a function of the unique index value (R_f(x)).
15. The method for operating a cryptography device having a processor and instruction storage of claim 9, wherein verifying the absence of a fault in the computation of f by verifying the second redundancy portion against an expected value for the second redundancy portion comprises computing by determining that a codeword composed of a systematic portion f(x) and the second redundancy portion is a valid codeword in C.
16. The cryptography device of claim 2, wherein the unique index value is a function (l) that is a mapping of inputs x and R_x such that l(x,R_x) determines uniquely x and the instructions to compute a second redundancy portion comprises computing R_f(x) using a mapping of l(x,R_x) to R_f(x).
17. The cryptography device of claim 3, wherein the unique index value is a function (l) that is a mapping of inputs x and R_x such that l(x,R_x) determines uniquely x and the instructions to compute a second redundancy portion comprises computing R_f(x) using a mapping of l(x,R_x) to R_f(x).
18. The cryptography device to of claim 2, wherein f is a nonlinear operation in a cryptographic operation.
19. The cryptography device to of claim 3, wherein f is a nonlinear operation in a cryptographic operation.
20. The cryptography device to of claim 4, wherein f is a nonlinear operation in a cryptographic operation.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
(1)
(2)
(3)
(4)
(5)
(6)
(7)
(8)
(9)
(10)
(11)
DETAILED DESCRIPTION OF THE INVENTION
(12) In the following detailed description, reference is made to the accompanying drawings that show, by way of illustration, specific embodiments in which the invention may be practiced. These embodiments are described in sufficient detail to enable those skilled in the art to practice the invention. It is to be understood that the various embodiments of the invention, although different, are not necessarily mutually exclusive. For example, a particular feature, structure, or characteristic described herein in connection with one embodiment may be implemented within other embodiments without departing from the spirit and scope of the invention. In addition, it is to be understood that the location or arrangement of individual elements within each disclosed embodiment may be modified without departing from the spirit and scope of the invention. The following detailed description is, therefore, not to be taken in a limiting sense, and the scope of the present invention is defined only by the appended claims, appropriately interpreted, along with the full range of equivalents to which the claims are entitled. In the drawings, like numerals refer to the same or similar functionality throughout the several views.
(13) The present technology provides a mechanism for protecting non-linear step of cryptographic operations with linear error correcting codes, filling the gap of the prior art. In an embodiment of the invention, a technology is provided that protects cryptographic devices, for example, smart cards, or other portable security devices, against fault attacks when these cryptographic devices perform cryptographic non-linear operations such as SubBytes and XTime that are particularly vulnerable to fault attacks.
(14) Smart cards are plastic cards with an embedded microprocessor and a secure storage. They are portable, secure, and tamper-resistant. Smart cards provide security services in many domains including telecommunication, banking, commerce, and citizen identity. Smart cards can take different forms, such as credit card shaped cards with electrical connectors to connect the smart card to a smart card reader, USB tokens with embedded smart cards, and SIM cards for use in mobile telephones and tablet devices. Smart cards are used herein as examples of portable security devices that may be used in implementations of the technology described herein. Other examples of portable security devices include smart memory cards, flash memory, etc. In a preferred embodiment, the portable security device has a processor, a memory for storing programs and data, and some security features to make the device relatively tamper-proof. Smart cards are used herein as examples of such devices.
(15) While the mechanism for masking a cryptographic calculation described herein may be used advantageously in smart cards and other portable security tokens used for performing cryptographic calculations, the same mechanisms may also be used with other cryptographic processors including full-sized personal computers and network servers. Thus, smart cards are used herein for illustrative purposes only.
(16) Cryptographic calculations are some of the more important functions that smart cards provide. The smart card stores private or shared secret keys in its secure storage and performs cryptographic operations, for example, to encrypt or to decrypt a given input. A smart card works with a host device, such as a personal computer (PC), cell phone, tablet device or banking terminal. A PC application, such as an email client or a web browser, typically works with a smart card to sign, encrypt, or decrypt a document. The cryptographic operation may be part of a challenge-response mechanism for user authentication. The PC application and the smart card interact through some cryptographic API called middleware, which is designed to communicate with the smart card. In this scenario, the smart card provides services locally to the PC.
(17)
(18) While
(19)
(20) In alternative embodiments, the connection between the host computer 103 and the portable security device 109 is wireless, for example, using near-field communication (NFC) or other radio or microwave communication technologies.
(21) The NVM 205 and/or ROM 204 may include computer programs 301 as is illustrated in
(22) The portable security device 109 programs 301 may include a cryptography module 213, a user authentication module 215, a communications module 217, and the operating system OS 219.
(23) Thus, the portable security device 109 may receive a document or message via the connector 211. The processor 201, by executing instructions of the cryptography module 213, may digitally sign the document/message or may decrypt the document/message using the shared secret key 210. Using functionality provided through the communications module 217, the processor 201 may receive and transmit communications with the host computer 103.
(24)
(25) To perform the SubBytes operation, the output value is obtained by retrieving it from a lookup table, here the SBox Lookup Table 403 using x as an index into the table. Similarly, the Xtime operation is performed by looking up the value from the XTime table 405.
(26) AES is only used herein as an illustrative example. The techniques described herein may be applied to other cryptography technologies. Similarly, SubBytes and XTime, while advantageously implemented using lookup tables, are only example functions. The cryptographic operations, which may include SBox and XTime tables, are generically referred to herein as the operation f.
(27)
(28) In a first step, a codeword X in a code C is computed from a byte x of the current cryptographic state, Step 601. Mathematically, let G be a generator matrix for the code C. Then, Xx.G. The codeword X is composed of the systematic portion x and the redundancy portion R_x.
(29) In a preferred embodiment, the technique is applied to a cipher that operates on states composed of a number of bytes (8 bits). The code to be used needs to have a dimension that is equal to 8. In a preferred embodiment, for example, in the application to AES, the length of the codeword produced is 16.
(30) According to a preferred embodiment, a linear code is used to detect possible fault attacks against cryptographic operations, including AES operations.
(31) For a systematic linear code C[n,k,d], G, the generator matrix, typically has the form [Id_k/R] where Id_k is a (kk) identity matrix, and R is a (k(nk)) matrix that represents the redundancy part R_x of the codeword X. When applied to x as x.G, the result X is x/R_x.
(32) In a preferred embodiment, illustrated in
(33) In a preferred embodiment, the code is a C[16,8,5] error correcting code. The code encodes 1-byte input quantities, the produced codewords are 2-byte words, and the Hamming distance is at least 5. The example table 602 of
(34) Step 601, may be applied to every state byte to transform the state byte to a codeword in order to detect faults introduced into the state byte (or the corresponding redundancy portion).
(35) Some faults in the codewords X may be detected by applying a parity check matrix H. For example, if the code C is a Hamming Code C[16, 8, 3], the distance d is equal to 3. That allows for fault detection of errors with a Hamming weight that is less than d, i.e., HW(e)<=d1, where e is the error and HW is the Hamming weight. In other words, an alteration of two bits may be detected; whereas alterations of more than two bits, a fault could change one codeword to another legal codeword and this cannot be detected.
(36) The parity check matrix H for G is [R.sup.T|Id_nk] where R.sup.T is the transpose of R and Id_nk is the (nknk) identity matrix. Fault detection is performed by applying the parity check matrix Has follows. If X is a codeword, X.H.sup.T is equal to 0, where H.sup.T is the transpose of H. Then, above from Step 601, for the codeword X, if X.H.sup.T=0, the codeword X is in C and is not corrupted or a fault in x or R_x has not been detected.
(37) In any portion of the technology described herein where the codeword X is used, it may be verified using the parity check matrix. Alternatively, the codeword X=x|R_x may be verified as not corrupted by determining a check value, call it R_x, from the lookup table 602 and comparing that for the low bytes (R_x) in a codeword X, i.e., if R_x=R_x, corruption of X has not been detected.
(38) Given the value X=x|R_x, f(x) is computed conventionally, Step 607, producing the output f(x) 610. I.e., if f is a SubBytes or XTime operation, the operation may be performed using the SBox or XTime lookup tables defined in AES,
(39) A redundancy portion R_f(x), corresponding to the value f(x) is also computed, Step 609, from the systematic portion x (i.e., the input state byte x) and the redundancy portion R_x. The concept is to compute a redundancy portion corresponding to f(x), call it R_f(x), so that f(x) may be confirmed to not have been corrupted because a codeword f(x)|R_f(x) should also be in the code C.
(40) It may not be possible to go directly from R_x to R_f(x) because for some linear codes two distinct values x1 and x2 could verify R_x1=R_x2. Most of the linear codes satisfy this property. In this case, an embodiment includes additional mappings, namely, a first (linear) mapping l of x and R_x such that for each two distinct values x1 and x2, l(x1, R_x1)l(x2, R_x2) and a second mapping from l(x, R_x) to R_f(x). This technique is discussed in greater detail herein below.
(41) For example, if the code is a C[16,8,5], a table mapping the 16-bit quantity X (i.e., x|R_x) to f(x)|R_f(x) would be prohibitively large for many applications. Therefore, in a preferred embodiment, the systematic portion, f(x), is separated out from the redundancy portion R_f(x), and the result may be combined into f(x)|R_f(x). Each of these two calculations is performed separately using unique mappings. In the case of f(x), the mapping is simply the cryptographic non-linear operation f because by definition the operation f is such that for all x1x2, f(x1)f(x2). However, R_f(x) is not a uniquely defined by R_x. Therefore, to be able to compute R_f(x) requires additional input beyond R_x: R_f(x) is computed from x and R_x as inputs, Step 609.
(42) That R_x is not uniquely defined by x, since depending on the choice of the code, one might have x1x2 and R_x1=R_x2 (in other words, the same redundancy for two different systematic part). This can be seen by examining, for example, the first and last elements of the example table of
(43) In the embodiment of
(44) If at any time during the execution of the cryptographic function 401c, the quantity f(x) needs to be verified, the codeword f(x)|R_f(x) may be verified as belonging to the code C using the parity matrix H as discussed above, Step 611.
(45) Alternatively, given the value f(x), it is possible to use table T0 602 (which is the same table as table 602) to determine the expected value of R_f(x). Thus the verification 611 may look up the expected value for R_f(x), call it R_f(x) 613 from the table 602. The value R_f(x) may then be compared to R_f(x), Step 615. In other words, given a codeword X, it may be verified as belonging to the code C using the parity matrix H or it may be verified by determining if the systematic portion and the redundancy portion match as expected.
(46) Conversely, if the codeword f(x)|R_f(x) is not verified as correct, the device may take action to thwart a threat from a potential fault attack, Step 613. The attack-thwarting action may include terminating the process, alerting the user of the cryptographic device that a fault has been detected, transmitting a warning message to an authorized entity, disabling device, etc.
(47) While the verification Step 611 is illustrated here as following the computation steps, in actual implementations, the verification step may be applied at any point in the computation where a codeword X is being used as an input or an output to an operation. The verification operation is, for example, advantageously employed at the beginning or end of each AES round operation so as to verify that no fault injection has occurred during the previous operation or during the operation itself. Final results may also be verified.
(48) Turning now to the generation of the tables T1 608 and T2 614.
(49) As discussed, T1 is typically just an indexed collection of the outputs from the non-linear f operation. For example, the AES standard includes published values for the Sbox and XTime lookup tables.
(50) I.e., T1 may be computed using the following pseudocode:
(51) loop i over all values of byte x
(52) T1[i]=f(i)
(53) The computation of T2 is more involved. For all values of x, f(x) is computed. The redundancy portion of X, i.e., R_x, is computed from x, i.e., x.G. The linear mapping l(x,R_x) is computed. Then, f(x).G is computed to determine the corresponding redundancy portion R_f(x). The resulting value is stored in T2, indexed by l(x,R_x).
(54) The following pseudocode may be used to compute T2:
(55) loop i over all values of byte x
(56) compute R_i from i.G (or use the lookup table T0)
(57) compute indexValue=l(i,R_i)
(58) compute R_f(i)=f(i).G
(59) T2[indexValue]=R_f(i)
(60) To construct a cryptography device, which is illustrated at a high-level in
(61) Turning now to code modifications for implementing the technologies described hereinabove. Consider, for example, the AES encryption technology. AES operates on a 16 bytes state. According to the technology to protect cryptography devices from fault attacks as described herein, these state bytes are encoded into codewords, for example, as in a preferred embodiment, using the error correcting code C[16,8,5] code. To operate on such codewords round operations are modified.
(62) The encryption process may be implemented using the pseudocode listed in Appendix A.
(63)
(64) In
(65) For all i from 0 to 15,
(66) si=T1[bi]
(67)
(68) R_bi is obtained by applying table T0 602 with input bi. An example of table T0 602 corresponding to the code C[16,8,5] is given in
(69) For all i from 0 to 15,
(70) R_bi=T0[bi]
(71) Construct codeword (bi|R_bi)
(72)
(73) For the redundancy part of the output (R_si), the mapping l 612 is used. In case of a code C[16,8,5], one possible choice for the mapping l is a xor operation between the systematic part bi and the redundancy R_bi. The output result is l(bi, R_bi). This will be the index input of table T2 614 (Step 2 in pseudo code below). The output of this table is the redundancy part (Step 3 in pseudo code below). The following code illustrates the process of
(74) For all l from 0 to 15,
(75) 1. si=T1[bi]
(76) 2. Index_i=l(bi, R_bi)
(77) 3. R_si=T2[Index_i]
(78) 4. Construct codeword (si|R_si)
(79)
(80) Now turning to how the herein-described technology allows for error detection, for example, errors introduced during fault attacks.
(81) In the context of the use case examples provided in
(82) For all l from 0 to 15,
(83) Test if R_bi is equal to T0[bi] for input
(84) Additionally or alternatively the verification test may be performed on the output by:
(85) For all l from 0 to 15,
(86) Test if R_si is equal to T0[si] for output
(87) An error correcting code C[16,8,5], allows the detection of errors with a Hamming weight up (d1)=4 (d is the Hamming distance; in this case, 5). Consider the cryptographic operation of
(88) The same result is obtained from the following method. Suppose the codeword (x|R_x), i.e., a correct codeword based on x. The detection capability is given by the verification: T0_C_16_8_5[x]==R_x (right part) where T0_C_16_8_5 is the table T0 602 for looking up the redundancy portion R_x from a given x. With the fault injection, instead of the codeword (x|R_x) the given fault injection results in a 16-bit word ((x{circumflex over ()}e1)|(R_x{circumflex over ()}e2)). The faults would remain undetected as a valid codeword, if R_(x{circumflex over ()}e1) is equal to (R_x{circumflex over ()}e2). This means that, before applying the T1 and T2 tables, the faults would be undetected if:
(89) (R_x{circumflex over ()}e2)=R_(x{circumflex over ()}e1)
(90) (R_xe2)=R_x{circumflex over ()}R_e1 (linear code)
(91) Simplifying with (R_x), result is: e2=R_e1, the condition to be verified in order not to detect a fault. Conversely, if e2R_e1, the fault would be detected.
(92) Consider a second scenario, illustrated in
(93) Suppose that a fault e1 is injected to x after its value is used for XOR 612 (is used as an example) and a fault e2 modifies the result of the xor ((x{circumflex over ()}R_x){circumflex over ()}e2). In order for the faults to be undetected, the following should hold:
(94) (x{circumflex over ()}R_x){circumflex over ()}e2=R_(x{circumflex over ()}e1){circumflex over ()}x{circumflex over ()}e1
(95) e2=R_e1{circumflex over ()}e1
(96) Note that if the Hamming weight of the result e=z.Ht is less or equal to (d1) it is possible to detect the error. Furthermore, if Hamming weight of the result is less than (d1)/2 the error can be corrected. For example, with the code C[16, 8, 5], if the codeword is faulty and two bits have been flipped, xoring codeword with the corresponding row of the generator matrix corrects the error. For example, if e=10000100, than xor row 1 and 6 of matrix G to the faulty codeword to correct.
(97) From the foregoing it is evident that a mechanism is presented herein that provides an efficient countermeasure to fault attacks by using linear error correcting code codes to protect cryptography values during performance of cryptography operations thereby protecting against detection of the key material used in encryption and decryption operations.
(98) The above-described mechanism has been described in the context of the AES encryption standard. The mechanism is readily adapted to other cryptography techniques.
(99) Although specific embodiments of the invention have been described and illustrated, the invention is not to be limited to the specific forms or arrangements of parts so described and illustrated. The invention is limited only by the claims.