1. Field of the Invention
The present invention relates to a modular operation apparatus provided with a modular operation function, and particularly to a technique effective for encrypting and decrypting by a Montgomery multiplier.
2. Description of Related Art
A cryptographic algorithm is used in various information equipments from the need to improve security in a ubiquitous network society that anyone can access information anywhere at any time. In connection with this, research and development for the cryptographic algorithm and implementation with better efficiency are progressing. However, while the cryptographic algorithm is actively studied and developed, studies and researches for vulnerability in the cryptographic algorithm and an implementation of the cryptographic algorithm are also active. The research for the side channel attack, which is an attack on the implementation, is receiving considerable publicity in academic conferences, especially in recent years.
The side channel attack is an attack attempting to obtain internal confidential information from side channel information such as power consumption, electromagnetic wave, processing time during processes or the like other than original communication paths (channels). Timing analysis is one method of the side channel attacks. This method focuses attention on the point that the processing time differs depending on the value to calculate in order to derive the internal confidential information.
When an algorithm is vulnerably implemented, such as RSA (Rivest-Shamir-Adleman)™ method which is generally recognized as a secure algorithm that uses a modular exponentiation operation, a secret key may easily be guessed by the side channel attack (especially timing analysis). That is, not only a safe cryptographic algorithm but a safe implementation of the cryptographic algorithm is required. In order to realize a safe implementation, a tamper resistance of the implementation circuit must be improved.
The modular exponentiation operation is used for the calculation of encrypting and decrypting process of a public key cryptosystem explained below, for example. The RSA™ method is mainly used at the moment for public key cryptosystem. The RSA method is a cryptosystem that utilizes the difficulty in the factorization into prime factors of the number N, which is a product of two arbitrary prime numbers, and also utilizes various different features of an algebraic number modulo N. Modular exponentiation operations (Me mod N) are implemented for encryption and decryption.
The modular exponentiation operation is usually transposed to a repetition process of the following modular multiplication operation.
For example, when e=19
By decomposing the exponent e as above, the count of multiplication can be reduced more than when simply multiplying M for e−1 times, and thereby reducing the operation time. Note that the above decomposition method of the exponent e is called binary exponentiation, and is a general decomposition method of e.
However, in the above modular multiplication operation, the number of digits in the operation doubles by the multiplication, and the multiplication result is divided by N, thus it is difficult to effectively process either by hardware or software. Therefore, an operation method that uses an algorithm called Montgomery multiplication is known as a method to increase the efficiency of a modular multiplication operation.
C=M
19 mod N=(((M2)2)2×M)2×M mod N
The above C can be calculated as indicated in
First, prior calculation of (1) is carried out, then as in (2) to (7), Montgomery multiplication of a multiplication and a square operation are repeated according to the decomposed number e, and in the last Montgomery multiplication of (8), 1 is multiplied to remove 2n to calculate C.
In the computation example of a modular exponentiation operation of
As explained above, the modular exponentiation operation usually uses the Montgomery multiplication (A×B×2−n mod N and A2×2−n mod N) to repeatedly calculate.
One of main features of the Montgomery multiplication is that it is possible to calculate without substantial division. An operation result S of the Montgomery multiplication 0<=S<2N, as illustrated in (f) of the Montgomery multiplication algorithm of
In the prior art, the modular operation apparatus illustrated in
The abovementioned Montgomery multiplication process flow is explained hereinafter.
Next, in S116, it is determined whether to continue repeating the Montgomery multiplication according to the decomposed exponent. If all the Montgomery multiplications are completed according to the decomposed exponent, the process proceeds to “Complete repeating operation of Montgomery multiplication” in S120. If the Montgomery multiplication is continued to repeat, in S117, the decomposed exponent is referred to determine whether the next Montgomery multiplication is a multiplication or a square operation. If the next Montgomery multiplication is a square operation, in S118, it is A=B=S. If the next Montgomery multiplication is a multiplication, in S119, it is A=S. Then the process proceeds to the Montgomery multiplication and the comparison between the operation results S and N in S112.
Furthermore, in order to carry out a modular calculation with a smaller circuit at a higher speed, for signed binaries A and B, Japanese Unexamined Patent Application Publication No. 2007-34038 discloses a technique to compare the operation result A−B and A as unsigned binaries, and selectively outputs the smaller one.
In the related art, as illustrated in
To explain with RSA™ method, an exponent value (for example the abovementioned e) at the time of decrypting is a secret key, and it must be confidential to the others. However the secret key may leak by the abovementioned timing analysis. The reason for such situation to occur is that it is unable to determine whether a reduction is required or not unless a Montgomery multiplication is completed. That is, in the related art, as illustrated in
An exemplary aspect of an embodiment of the present invention is a modular operation apparatus that includes an operator that carries out a Montgomery multiplication according to one of a first multiplicand and a second multiplicand, a multiplier, and a divisor, a first multiplicand register that stores an operation result of the Montgomery multiplication as the first multiplicand, a subtractor that subtracts the divisor from the operation result of the Montgomery multiplication, a second multiplicand register that stores a subtraction result of the subtractor as the second multiplicand, and a selector that outputs one of a value of the first multiplicand register and a value of the second multiplicand register according to a comparison result between the operation result of the Montgomery multiplication and the divisor.
This configuration enables to force a reduction during the operation of a Montgomery multiplication, hold both values before and after the reduction, and select one of these values. Thus the reduction period can be made invisible apparently. The apparent invisible of the reduction period improves the tamper resistance to the side channel attack.
Another exemplary aspect of an embodiment of the present invention is a method of modular operation that includes carrying out a Montgomery multiplication according to a multiplicand, a multiplier, and a divisor, storing an operation result of the Montgomery multiplication as a first multiplicand, subtracting the divisor from the operation result of the Montgomery multiplication, and storing a subtraction result as a second multiplicand, selecting one of a value of the first multiplicand register and a value of the second multiplicand register according to a comparison result between the operation result of the Montgomery multiplication and the divisor, and carrying out a Montgomery multiplicand according to the selected multiplicand, the multiplier, and the divisor.
This modular operation method enables to force a reduction during the operation of the Montgomery multiplication, hold both values before and after the reduction, and select one of these values, thereby making the reduction period invisible apparently. Making the reduction period invisible apparently improves the tamper resistance to the side channel attacks.
The present invention enables to improve the tamper resistance to the side channel attack to the modular operation apparatus.
The above and other exemplary aspects, advantages and features will be more apparent from the following description of certain exemplary embodiments taken in conjunction with the accompanying drawings, in which:
Hereafter, an exemplary embodiment of the present invention is described with reference to the drawings.
A modular operation apparatus 10 includes an operator 1 that performs a Montgomery multiplication based on one of a first multiplicand and a second multiplicand, a multiplier, and a divisor, a first multiplicand register 2 that stores the operation result of the Montgomery multiplication as the first multiplicand, and a subtractor 6 that subtracts the divisor from operation result of the Montgomery multiplication. The modular operation apparatus further includes a second multiplicand register 3 that stores the subtraction result of the subtractor 6 as the second multiplicand, and a selector 8 that outputs either the value of the first multiplicand register or the value of the second multiplicand register to the operator 1 according to the comparison result between the operation result of the Montgomery multiplication and the divisor.
To be more specific, the modular operation apparatus 10 includes the operator 1 that calculates S=P(AB)N before reduction and outputs an operation result S, the first multiplicand register 2 (hereinafter also referred to as a multiplicand A register) that stores a multiplicand A, the second multiplicand register 3 (hereinafter also referred to as a multiplicand S_tmp register) that similarly stores a multiplicand S_tmp, a multiplier register 4 that stores a multiplier B, and a divisor register 5 that stores a divisor N. The modular operation apparatus 10 further includes the subtractor 6 that performs S_tmp=S−N and outputs the subtraction result Strap, and the selector 8 that selects an output from the multiplicand A register 2 if a borrow signal 7 is “1” and selects an output of the multiplicand S_tmp register 3 if the borrow signal 7 is “0”.
An output signal of the selector 8 is connected to an A input of the operator 1, an output signal of the multiplier B register 4 is connected to a B input of the operator 1, and an output signal of the divisor N register 5 is connected to an N input of the operator 1. An S output of the operator 1 outputs the operation result S from the lower bit side in a time-sharing manner by each bit length S.
The S output of the operator 1 is connected to an S input of the subtractor 6, and the output signal of the divisor N register 5 is connected to the N input. From the subtraction result of S-N, the subtractor 6 sets the borrow signal to “1” if S<N, and sets the borrow signal to “0” in other cases. The borrow signal 7 is output to the selector 8. An S_tmp output of the subtractor 6 outputs a subtraction result S_tmp from a lower bit side in a time-sharing manner by a certain bit length.
The multiplicand A register 2 has a function to write or read data from a CPU via a data bus 9, and to write the output S of the operator 1. Further, the multiplicand A register 2 outputs the holding data to the operator 1 via the selector 8 in a time-sharing manner by a certain bit length.
The multiplicand S_tmp register 3 has a function to write or read data from a CPU via a data bus 9 and also writes the output S_tmp of the subtractor 6. Further, the multiplicand S_tmp register 3 outputs the holding data to the operator 1 via the selector 8 in a time-sharing manner by a certain bit length from the lower bit side.
The multiplier B register 4 and the divisor N register 5 have a function to write and read data from the CPU via the database 9.
The selector 8 inputs the borrow signal 7, and outputs to the operator 1 either the value of the multiplicand A register 2 or the value of the multiplicand S_tmp register 3 according to the borrow signal.
This exemplary embodiment of the present invention processes a Montgomery multiplication by the modular operation apparatus 10 of
The abovementioned Montgomery multiplication process flow is explained hereinafter.
First, a repeated calculation of a Montgomery multiplication of S1 is started according to the decomposed exponent. However, it is A=B=M′ as described above.
In the following S2, the Montgomery multiplication is performed and a reduction is also forced. Then, the operation result S of the Montgomery multiplication and the reduction result S_tmp are stored at the same time.
Next, in S3, it is confirmed whether a borrow is generated (Borrow=1) or not (Borrow=0) when the abovementioned reduction result S_tmp is calculated. If a borrow is generated (Borrow=1), that is if the operation result S of the Montgomery multiplication is smaller than the divisor N, a normal result S′ of the Montgomery multiplication is the operation result S of the Montgomery multiplication performed in S2, as indicated in S4. Further, if a borrow is not generated (Borrow=0), the normal result S′ of the Montgomery multiplication is the reduction result S_tmp performed in S2, as indicated in S5.
Next, in S6, it is determined whether to continue repeating the Montgomery multiplication according to the decomposed exponent. If all the repeating Montgomery multiplications are completed according to the decomposed exponent, the process proceeds to S10, which is a completion of the repeated calculation of the Montgomery multiplication. If the Montgomery multiplication is continued to repeat, in S7, the decomposed exponent is referred to determine whether the next Montgomery multiplication is a multiplication or a square operation. If the next Montgomery multiplication is a square operation, it is A=B=S′ in S8, and, in the case of multiplication, it is A=S′ in S9. Then in S2, the Montgomery multiplication and the reduction are performed again.
That is, the modular operation method according to this exemplary embodiment firstly performs a Montgomery multiplication based on the multiplicand, the multiplier, and the divisor.
Next, the operation result of the Montgomery multiplication is stored as the first multiplicand.
The divisor is subtracted from the operation result of the Montgomery multiplication, and the subtracted result is stored as the second multiplicand.
Then, either the value of the first multiplicand register or the value of the second multiplicand register is selected according to the operation result of the Montgomery multiplication and the comparison result of the divisor.
The Montgomery multiplication is performed again according to the selected multiplicand, multiplier and divisor.
Based on the abovementioned Montgomery multiplication process flow of
In
The subtractor 6, that is composed of a combinational circuit, performs a reduction of S, which is the operation result output from the operator 1 in a time-sharing manner, and an input N by S-N in a time-sharing manner, and outputs the subtracted result S_tmp from the lower bit side in a time-sharing manner by each bit length. The timing of the subtraction result S_tmp is indicated as S_tmp in the subtractor 6 in
The operation result S output from the operator 1 in a time-sharing manner is stored as needed to the multiplicand A register 2. At the same time, the subtraction result S_tmp output from the subtractor 6 in a time-sharing manner is stored to the multiplicand S_tmp register 3 as needed. Timings of the multiplicand A register 2 and the multiplicand S_tmp register 3 are illustrated in the multiplicand A register 2 and the multiplicand S_tmp register 3 of
When all the time-sharing operations are completed in the operator 1 and the subtractor 6 that output the operation results in a time-sharing manner, all bits of the operation result S are stored to the multiplicand A register 2. At the same time, all bits of the reduction result are stored to the multiplicand S_tmp register 3. At the same time, the subtractor 6 generates the borrow signal 7 that indicates whether a borrow is generated or not in the operation result of S−N eventually. The borrow signal 7 is “1” if a borrow is generated, and the borrow signal 7 is “0” if a borrow is not generated.
S12 and S22 of
If the borrow signal 7 is “1”, it means that the Montgomery multiplication did not require a reduction and a normal operation result is held in the multiplicand A register 2. If the borrow signal 7 is “0”, it means that the Montgomery multiplication required a reduction and a normal operation result is held in the multiplicand S_tmp register 3.
By the way, as illustrated in the modular exponentiation operation algorithm of
The modular operation apparatus 10 of this exemplary embodiment forces a reduction during the calculation of the Montgomery multiplication and holds both of the values before and after the reduction. This enables the S−N reduction period, which is visible in the related art of
Further, even when the result of a Montgomery multiplication does not require a reduction, by performing a dummy reduction and simply performing a reduction after completing each Montgomery multiplication, the same effect as this exemplary embodiment of the present invention can be achieved. However, if the multiplier, the multiplicand, and the divisor are multiple-precision integers, and a dummy reduction is performed for an RSA™ method that performs a Montgomery multiplication for 1500 or 3000 times, for example, it is unavoidable that the processing performance of the entire modular exponentiation operation is reduced.
The present invention according to this exemplary embodiment does not need the abovementioned dummy process, which reduces the processing performance, to improve the tamper resistance. Further, the amount of process data can be reduced by the cutdown of the reduction period after a Montgomery multiplication and thus improving the processing performance of the modular exponentiation operation.
As described above, the modular operation apparatus according to this exemplary embodiment forces a reduction during the calculation of the Montgomery multiplication and holds the result of the forced reduction and the result before reduction to each of storage apparatuses. Then, the modular operation apparatus determines which is a normal operation result according to the value of the borrow signal generated according to the reduction result.
By forcing a reduction during the operation period not after completing the Montgomery multiplication, the reduction period is made invisible apparently, and this disables to easily guess whether the reduction is performed or not by the timing analysis.
The present invention is not limited to the above exemplary embodiment, and may be modified within the scope of the present invention.
The above exemplary embodiment explained the case of applying the binary exponentiation to the decomposition method of e. However the same effect as the abovementioned exemplary embodiment can be achieved by other decomposition method of e.
By applying an efficient decomposition method of e that enables to reduce the count of Montgomery multiplication, it is possible to keep the effects of the abovementioned exemplary embodiment of the present invention and also to improve the processing performance of a modular exponentiation operation.
Further, the abovementioned exemplary embodiment explained a means to hold the multiplier, the multiplicand, the divisor, and the Montgomery multiplication result by a register. However it is not limited to the register but can be a circuit or an apparatus that can hold them.
Accordingly, the modular operation apparatus of this exemplary embodiment disables to detect whether a reduction exists or not from the difference of processing time in the timing analysis, which is one of the method for the side channel attack, thus making it difficult to guess a secret key and improving the tamper resistance to the side channel attack.
Further, it is possible to improve the tamper resistance without inserting a dummy reduction process, that could cause to reduce the processing performance.
Cutting out the reduction period after Montgomery multiplication enables to reduce the processing time and thus improve the processing performance of the modular exponentiation operation.
As the public key cryptosystem is based on the modular exponentiation operation, the exemplary embodiment of the present invention can be applied to all the public key cryptosystems that require modular an exponentiation operation such as elliptic curve cryptosystem and digital signature.
Moreover, by applying the present invention to an information processing system that requires a Montgomery multiplication, not only to a cryptosystem, the amount of process data can be reduced and thus enabling to improve the processing performance of a modular exponentiation operation.
While the invention has been described in terms of several exemplary embodiments, those skilled in the art will recognize that the invention can be practiced with various modifications within the spirit and scope of the appended claims and the invention is not limited to the examples described above.
Further, the scope of the claims is not limited by the exemplary embodiments described above.
Furthermore, it is noted that, Applicant's intent is to encompass equivalents of all claim elements, even if amended later during prosecution.
Number | Date | Country | Kind |
---|---|---|---|
2008-313112 | Dec 2008 | JP | national |