SYSTEM AND METHOD FOR ONE-TIME CHINESE-REMAINDER-THEOREM EXPONENTIATION FOR CRYPTOGRAPHIC ALGORYTHMS
20170257211 · 2017-09-07
Assignee
Inventors
Cpc classification
H04L9/003
ELECTRICITY
G06F2207/7261
PHYSICS
International classification
H04L9/00
ELECTRICITY
Abstract
A system, method and computer-readable storage medium with instructions for protecting an electronic device against fault attack. The technology includes operating the electronic device to determine two half-size exponents, dp and dq, from the exponent d; to split the base m into two sub-bases mp and mq determined from the base m; and to iteratively compute a decryption result S by repeatedly multiplying an accumulator A by m, mp, mq or 1 depending on the values of the i-th bit of dp and dq for each iteration I′. Other systems and methods are disclosed.
Claims
1. A method for operating a cryptography apparatus to perform a decryption operation having an exponentiation operation X, the method protecting the apparatus from revealing information in regard to the exponentiation operation X when the operation is exposed to a fault attack while being executed on the cryptography apparatus, the method comprising producing a result equivalent to the exponentiation by: receiving, on the cryptography apparatus, a message m on which to perform a cryptographic operation equivalent to the exponentiation operation S=m.sup.d mod n; determining two half-size exponents from the exponent d; splitting the base m into two sub-bases mp and mq determined from the base m; iteratively computing S by repeatedly multiplying an accumulator A by m, mp, mq or 1 depending on the values of the i-th bit of dp and dq for each iteration i; returning as the value S the final value of the accumulator A; and completing the cryptographic operation using the value S obtained from the operation.
2. The method of claim 1 wherein the two half-sized exponents are dp and dq such that dp=d mod (p−1) and dq=d mod (q−1) where p and q are prime numbers such that n=pq.
3. The method of claim 1 wherein:
mp=1+q*iq*(m−1)mod n; and
mq=1+(1−q*iq)*(m−1)mod n wherein
iq=q.sup.−1 mod p.
4. The method of claim 1 wherein dp and dq have bits indexed from 0 to k and the iteration is an iteration from 0 to k performing the calculations: A=A*A mod n IF (dp.sub.i=0 && dq.sub.i 0) A=A*1 mod n IF (dp.sub.i=1=&& dq.sub.i 0) A=A*mp mod n IF (dp.sub.i=0 && dq.sub.i 1) A=A*mq mod n IF (dp.sub.i=1 && dq.sub.i 1) A=A*m mod n.
5. (canceled)
6. The method of claim 2 wherein:
mp=1+q*iq*(m−1)mod n; and
mq=1+(1−q*iq)*(m−1)mod n wherein
iq=q.sup.−1 mod p.
7. The method of claim 2 wherein dp and dq have bits indexed from 0 to k and the iteration is an iteration from 0 to k performing the calculations: A=A*A mod n IF (dp.sub.i=0 && dq.sub.i 0) A=A*1 mod n IF (dp.sub.i=1 && dq.sub.i 0) A=A*mp mod n IF (dp.sub.i=0 && dq.sub.i 1) A=A*mq mod n IF (dp.sub.i=1 && dq.sub.i 1) A=A*m mod n.
8. The method of claim 3 wherein dp and dq have bits indexed from 0 to k and the iteration is an iteration from 0 to k performing the calculations: A=A*A mod n IF (dp.sub.i=0 && dq.sub.i 0) A=A*1 mod n IF (dp.sub.i=1 && dq.sub.i 0) A=A*mp mod n IF (dp.sub.i=0 && dq.sub.i 1) A=A*mq mod n IF (dp.sub.i=1 && dq.sub.i 1) A=A*m mod n.
9. The method of claim 6 wherein dp and dq have bits indexed from 0 to k and the iteration is an iteration from 0 to k performing the calculations: A=A*A mod n IF (dp.sub.i=0 && dq.sub.i 0) A=A*1 mod n IF (dp.sub.i=1 && dq.sub.i 0) A=A*mp mod n IF (dp.sub.i=0 && dq.sub.i 1) A=A*mq mod n IF (dp.sub.i=1 && dq.sub.i 1) A=A*m mod n.
10. An electronic device protected from fault attack and comprising: a central processing unit, memory, and an instruction storage wherein the instruction storage contains instructions to cause the central processing unit to perform: receiving, on by the central processing unit of the electronic device, a message m on which to perform a cryptographic operation equivalent to the exponentiation operation S=m.sup.d mod n; determining two half-size exponents from the exponent d; splitting the base m into two sub-bases mp and mq determined from the base m; iteratively computing S by repeatedly multiplying an accumulator A by m, mp, mq or 1 depending on the values of the i-th bit of dp and dq for each iteration i; returning as the value S the final value of the accumulator A; and completing the cryptographic operation using the value S obtained from the operation.
11. The electronic device protected from fault attack of claim 10, wherein the two half-sized exponents are dp and dq such that dp=d mod (p−1) and dq=d mod (q−1) where p and q are prime numbers such that n=pq.
12. The electronic device protected from fault attack of claim 10, wherein:
mp=1+q*iq*(m−1)mod n; and
mq=1+(1−q*iq)*(m−1)mod n wherein
iq=q.sup.−1 mod p.
13. The electronic device protected from fault attack of claim 11, wherein:
mp=1+q*iq*(m−1)mod n; and
mq=1+(1−q*iq)*(m−1)mod n wherein
iq=q.sup.−1 mod p.
14. The electronic device protected from fault attack of claim 10, wherein dp and dq have bits indexed from 0 to k and the iteration is an iteration from 0 to k performing the calculations: A=A*A mod n IF (dp.sub.i=0 && dq.sub.i 0) A=A*1 mod n IF (dp.sub.i=1 && dq.sub.i 0) A=A*mp mod n IF (dp.sub.i=0 && dq.sub.i 1) A=A*mq mod n IF (dp.sub.i=1 && dq.sub.i 1) A=A*m mod n.
15. The electronic device protected from fault attack of claim 11, wherein dp and dq have bits indexed from 0 to k and the iteration is an iteration from 0 to k performing the calculations: A=A*A mod n IF (dp.sub.i=0 && dq.sub.i 0) A=A*1 mod n IF (dp.sub.i=1 && dq.sub.i 0) A=A*mp mod n IF (dp.sub.i=0 && dq.sub.i 1) A=A*mq mod n IF (dp.sub.i=1 && dq.sub.i 1) A=A*m mod n.
16. The electronic device protected from fault attack of claim 12, wherein dp and dq have bits indexed from 0 to k and the iteration is an iteration from 0 to k performing the calculations: A=A*A mod n IF (dp.sub.i=0 && dq.sub.i 0) A=A*1 mod n IF (dp.sub.i=1 && dq.sub.i 0) A=A*mp mod n IF (dp.sub.i=0 && dq.sub.i 1) A=A*mq mod n IF (dp.sub.i=1 && dq.sub.i 1) A=A*m mod n.
17. The electronic device protected from fault attack of claim 13, wherein dp and dq have bits indexed from 0 to k and the iteration is an iteration from 0 to k performing the calculations: A=A*A mod n IF (dp.sub.i=0 && dq.sub.i 0) A=A*1 mod n IF (dp.sub.i=1 && dq.sub.i 0) A=A*mp mod n IF (dp.sub.i=0 && dq.sub.i 1) A=A*mq mod n IF (dp.sub.i=1 && dq.sub.i 1) A=A*m mod n.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
[0027]
[0028]
[0029]
[0030]
[0031]
[0032]
DETAILED DESCRIPTION OF THE INVENTION
[0033] 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 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.
[0034] In an embodiment of the invention, a technology is provided that enables the use of smart cards, or other portable security devices, to be used to digitally sign documents or to decrypt encrypted documents or messages using private keys stored on the smart cards in a manner that efficiently reduces the risk of differential power analysis attacks.
[0035] 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.
[0036] 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. Thus, smart cards are used herein for illustrative purposes only.
[0037] Digital signature and other cryptography are examples of functions that smart cards provide. The smart card stores private or shared secret keys in its secure storage and performs cryptographic operations to generate a digital signature for a given input 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.
[0038]
[0039] While
[0040]
[0041] 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.
[0042] The NVM 205 and/or ROM 204 may include computer programs 301 as is illustrated in
[0043] 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.
[0044] 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 private key 209 or 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.
[0045]
[0046] An alternative prior art approach implements the CryptoFunction ( ) using the Chinese Remainder Theorem to perform a cryptographic operation; it includes modular exponentiation calculations 401 on half-size elements.
[0047] As a person skilled in the art would appreciate, this operation would be reduced to lower level arithmetic statements for the sake of efficiency. A common approach for efficiently calculating M.sup.dp mod p is the Square-and-MultiplyAlways algorithm.
dp=d mod(p−1)
dq=d mod(q−1)
iq=q.sup.−1 mod p
[0048] wherein dp and dq are written in the binary representations
dp=[dp.sub.n-1,dp.sub.n-2, . . . ,dp.sub.2,dp.sub.1,dp.sub.0]
and
dq=[dq.sub.n-1,dq.sub.n-2, . . . ,dq.sub.2,dq.sub.1,dq.sub.0]
[0049] S may then be computed using Garner's formula, step 503:
S=Sq+q*(iq*(Sp−Sq)mod p
[0050] The algorithm of
[0051] According to an embodiment of the invention described herein below, the crypto module 213′ (
[0052]
[0053] The inputs to the algorithm are:
[0054] m—the message to be decrypted
[0055] q and p—the two large prime numbers that are multiplied to compute n
[0056] The exponentiation calculation 401c begins by performing three preliminary calculations, 601:
iq=q.sup.−1 mod p
mq=1+q*iq*(m−1)mod n
mp=1+(1−q*iq)*(m−1)mod n
[0057] It may be shown through modular arithmetic that from the above calculations, the following relationships hold:
mq mod p=1
mq mod q=m mod q
mp mod q=1
mp mod p=m mod p
[0058] The calculation also uses the quantities dp and dq, which are defined from quantities p and q, respectively, as is described above, as:
dp=d mod(p−1)
dq=d mod(q−1)
[0059] An accumulator value A is initialized to 1, Step 603.
[0060] Next, with the binary representation of dp as dp=[dp.sub.o, dp.sub.1, . . . , dp.sub.k-1, dp.sub.k] and dq=[dq.sub.o, dq.sub.1, . . . , dq.sub.k-1, dq.sub.k], S is computed iteratively (loop 605) modifying the accumulator A over the bits of dp and dq and depending on the value of each bit dp.sub.i and dq.sub.i performing updates of the value A, as follows:
[0061] At the beginning of each iteration, A is set to A=A*A mod n, step 607.
[0062] The value pair dp.sub.i and dq.sub.i present four possible mutually exclusive alternatives: dp.sub.i=0 and dq.sub.i=0, dp.sub.i=1 and dq.sub.i=0, dp.sub.i=0 and dq.sub.i=1, and dp.sub.i=1 and dq.sub.i=1.
[0063] For the first of these alternatives (dp.sub.i=0 and dq.sub.i=0), A is set to A=A*1 mod n, steps 609. As this is an identity operation, in an actual implementation, the step is bypassed by doing nothing as the operation does not change the value of A. [0053] For the second alternative (dp.sub.i=1 and dq.sub.i=0), A is set to A=A*mp mod n, steps 611.
[0064] For the third alternative (dp.sub.i=0 and dq.sub.i=1), A is set to A=A*mq mod n, steps 613.
[0065] For the fourth alternative (dp.sub.i=1 and dq.sub.i=1), A is set to A=A*m mod n, steps 615.
[0066] At the conclusion, after all bits of dp.sub.i and dq.sub.i have been processed by the loop 605, the result held in A holds the value S=m.sup.D mod n and may be returned to the calling routine as the signed message S, Step 617.
[0067] At each iteration i of the exponentiation, the accumulator A is equal to S.sub.i such that:
S.sub.i mod p=m.sup.(dp0 dp1 dp2 . . . dpi)mod p
S.sub.i mod q=m.sup.(dq0 dq1 dq2 . . . dqi)mod q
[0068] These relationships are true because:
[0069] in step 615, when multiplying by m, the multiplication of the accumulator A*m is taken modulo p*q because n is defined as n=pq
[0070] in step 611, when multiplying by mp, the multiplication of accumulator A*mp is equivalent to A*m modulo p because the multiplication is 1 modulo q; consequently there is so no change in A due to q
[0071] in step 613, when multiplying by mq, the multiplication of the accumulator A*mq is equivalent to A*m modulo q because the multiplication is 1 modulo p; consequently there is no change in A due to p
[0072] in step 609, when multiplying by 1, the multiplication of A*1 the multiplication is A*1 modulo p and q; consequently there is no change due to either modulo p nor modulo q
[0073] Thus, after the final iteration—i.e., where i=k:
Sp=S.sub.k mod p=m.sup.dp mod p
Sq=S.sub.k mod q=.sup.dq mod q
[0074] In other words, because
Sp=S mod p
Sq=S mod q
it follows that
S=S.sub.k=A
[0075] From the foregoing it is evident that a mechanism is presented herein that computes the signed message S in a highly efficient manner using half-size exponent values without exposing multiple exponentiations to fault attacks thereby protecting against detection of the key material used in the encryption.
[0076] The above-described mechanism has been described in the context of the square-and-multiply-always technique. The mechanism is readily adapted to other exponentiation techniques.
[0077] 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.