The present invention relates to cryptographic methods carried out in electronic processing hardware with associated software. In particular, the invention relates to cryptographic computations performed by such electronic processing hardware that involve finite field, residue or congruence operations, and especially modular exponentiation calculations employing Chinese Remainder Theorem based techniques, with attention to variations for thwarting cryptanalysis.
Many cryptographic algorithms are based on modular exponentiation calculations of the type m≡cd (mod n) , where c and m can correspond to data of various kinds (plaintext and ciphertext messages, signatures, message digests, authentication codes, etc.) and where d and n cat correspond to elements of public or private keys for operating upon that data. The modulus n is usually the product of two very large primes p and q that are kept secret. The RSA algorithm is one example of an encryption system (and related digital signature scheme) that uses modular exponentiation. The Diffie-Hellman key agreement protocol is another.
In the RSA algorithm, a public key {e, n} and a corresponding private key {d, p, q} are provided for encryption and decryption, where d·e≡1 (mod φ(n)), n=p·q, φ(n)=(p-1) (q-1), and where integer e and φ(n) are co-prime. Alternatively, a function λ(n)=LCM(p-1,q-1) is often used in place of the original φ (n). (RSA PKCS#1 v.2.1) For encryption a ciphertext c may be obtained from a plaintext message m using the public key {e, n} according to the relation c=me (mod n). The public key exponent e is usually a small value (e.g., 3, 5, 35, or 216+1=65537) chosen for ease and speed of encryption. For decryption, the plaintext message m may be recovered from the ciphertext c using the private key {d, p, q} according to the relation m≡cd (mod (p·q)).
The Chinese Remainder Theorem (CRT) is often used to speed the modular exponentiation calculations involved in the decryption, since the otherwise secret prime factors p and q are known to the user. That theorem generally states that given a set of simultaneous congruences x≡ai (mod ni), for i=1 to r, and for which the moduli ni are pairwise relatively prime, the solution is x≡[Σi ai·bi (N/ni)] (mod N), where N=ni·n2·−nr and the bi are determined from bi (N/ni)≡1 (mod ni). For two relatively prime positive integers p and q and two integers a and b (i.e., the case r=2), there exists an integer m uniquely determined modulo p·q, such that m≡a (mod p)≡b (mod q). That is, for GCD (p, q)=1, every pair of residue classes modulo p and q corresponds to a simple residue class modulo p·q. The solution finds m≡[a·(q−1 mod p)·q+b·(p−1 mod q)·p] (mod p·g). A modular inverse of an integer x−1 modulo z is defined such that x·x−1≡1 (mod z). For a prime modulus, every nonzero integer not a multiple of the modulus has an inverse.)
CRT implementation of the RSA algorithm calculates the modular exponentiation m:=cd (mod (p·q)) as follows. First define a pair of private key derived exponents as d1:=d (mod (p-1)) and d2:=d (mod (q-1)). Then, calculate m1:=cd
Finally, m=CRT(m1, m2):=m1+p·{[(m2−m1)·R] (mod q)}, where R≡p−1 (mod q).
That last formula of the CRT implementation, namely m=CRT(m1,m2), has many variants. Three examples of these variants are:
CRT2 (m1,m2):=(m1·R1·q+m2·R2·p) (mod p·q), where R1≡q−1 (mod p) and R2≡p−1 (mod q);
CRT3(m1,m2):={[(m1·R1)(mod p)]·q+[(m2·R2) (mod q)]·p]} (mod p·q), where again R1≡q−1 (mod p) and R2≡p−1 (mod q); and
CRT4 (m1,m2):=(q·{[(m1-m2)·R4] (mod p)}+m2) (mod p·g), where R4≡p−1 (mod q).
Variant CRT implementations perform the modular exponentiation calculation in ways designed to thwart cryptanalysis, especially in the context of tokens (e.g., smart cards) where an attacker has access to the hardware carrying out the cryptographic computations. An attacker may employ noninvasive measurement and timing analysis of electromagnetic emissions, power consumption, or other accessible parameters of a device during computational processes in order to extract useful information regarding the private keys. The variant implementations typically employ pseudo-random variables at various stages of the cryptographic algorithm in order to mask the underlying mathematical operations without affecting the final result.
For example, in CRT implementations of modular exponentiation, some variants transform the message variable m or its CRT components, m1 and m2, by multiplying with a random value at some early stage in the computational process then at a later stage divide the message variable by that same random value or by a related value derived from it to obtain the true result. Other variants may transform the private key exponent d or its CRT components, d1 and d2, by adding a random multiple of (p-1) or (q-1) to obtain another (random) member of the congruence class for that private key component. The private key exponent d could likewise be reduced to transformed CRT components, d1′ and d2′, using moduli that are corresponding random multiples of (p-1) and (q-1), respectively. In all these cases, the design of the transformations are chosen to obtain a true final result, while randomly varying the intermediate calculations in a manner that take advantage of equivalences in congruence arithmetic. Unfortunately, many of these variants can be quite complex and computationally intense.
The present invention is a computer hardware-implemented cryptography method using Chinese Remainder Theorem (CRT) implemented modular operations, in which a modulus for the computations is transformed in order to blind cryptoanalytic observations of intermediate results. In particular, for a modular exponentiation operation, m=cd (mod p·q), a transformation factor s is used to transform the co-prime factors p and q into p′=s·p and q′=s·q. The CRT steps are applied using the transformed moduli p′ and q′. After obtaining an intermediate result m′, the final result m is recovered by a final reduction modulo p·q. The transformation factor s may be a random value, a random choice from a finite set of preselected fixed values, or, if security is not an issue in a given circumstance, could even be a fixed value. The method is relatively simple and less computational intense than many other variants, yet is still substantially secure against cryptanalysis. Hence, it is suitable for use in smart cards and other cryptographic token applications. It can be employed with any cryptographic algorithm that relies on modular exponentiation with CRT implementations.
The method may he implemented as a cryptography program in data processing hardware, such as smart card or other token, that comprises a cryptographic processor unit, data storage accessible to that processor unit, and pseudo-random number generating circuitry providing the random factor.
With reference to
With reference to
p′:=p·s;
q′:=q·s.
An inverse value R′:=(p′)−1 mod q is calculated (step 14) by the processing hardware in a manner similar to calculations of inverse R:=p−1 (mod q) known in prior versions of CRT-based modular exponentiation.
These transformed values p′ and q′ and the inverse R′, will be used in later steps. Each decryption session using the private key values {d, p, q} will involve a different random value s, and hence different randomized values of the moduli p′ and q′ and of the inverse R′, thereby securing cryptographic operations involving the modular exponentiation from cryptanalysis. (Note: The random value s must be co-prime with the original moduli p and q, so a standard divisibility test for co-primality should be a part of the random generation step 11 in order to weed out any unsuitable random values.) If desired, the size of the random value s may be selected to be within a specified range, so that the values p′, q′, d1 and d2 will be substantially the same size.
Alternatively, the transformation factor S could be a random choice from a finite set of preselected fixed values, instead of being randomly generated from scratch for each session. This can save substantial processing time, especially if p′, q′, and R′ are also precomputed for each possible choice of s in the set. If for any reason, cryptographic security is deemed not to be an issue in a given circumstance, the choice of factor s, and hence of p′, q′, and R′, could be a fixed value.
CRT exponents d1 and d2 are computed (step 14) from private key exponent d in the same manner as known in prior versions of CRT-based modular exponentiation, i.e.:
d
1
:=d (mod (p-1));
d
2
:=d (mod (q-1)).
If desired, this step could also be conveniently placed before the randomization of p and q, i. e. before step 12. Indeed, since the CRT exponents d1 and d2 are directly related only to the private key values d, p, and q, they can be pre-computed and loaded into the hardware data storage in place of private key exponent d, in step 10, eliminating step 16 from the session computations.
The variable C for the modular exponentiation is loaded (step 18) into data storage accessible by the processing hardware, e.g., into the RAM 12 of
The CRT steps (steps 20 and 22) are applied, using the transformed moduli p′ and q′ and transformed inverse R′, so as to obtain an intermediate message result M′. In particular, in step 20, CRT message components M1′ and M2′ are computed by the processing hardware in a manner similar to that known from prior CRT-based modular exponentiation operations, but using p′ and q′ as the moduli instead of the original private key modulus values p and q. That is,
M
1
′:=C
d
(mod p′); and
M
2
′:=C
d
(mod q′).
Then the intermediate message result M′ is computed (in step 22) by the processing hardware from the CRT message components M1′ and M2′ using the Chinese Remainder Theorem:
M′:=M
1
′+p′·{[(M2′-M1′)·R′] (mod q′)}.
Note that since p′ and q′ are randomized for each decryption session, the values M1′, M2′ and M′ are likewise randomized in each session, thwarting cryptanalysis by known text attacks (e.g., repeated use by an attacker of a known value C) and other cryptanalysis techniques that may rely upon eavesdropping on hardware emitted parameters (EM emissions, time-dependent power consumption, etc.). The computations are different each time in a random way, yet are not much more computationally intensive than the straightforward application of CRT-based modular exponentiation.
The intermediate result M′ has been obtained by applying an adapted CRT formula for CRT(M1′,M2′). Other variant CRT formulae (such as the three examples given in the Background Art section) can be applied instead, if adapted with the appropriate transformations. To transform an initial CRT formula, the general rule is to always set p′:=p·s and q′:=q·s. For all parts of the formula, like R1:=q−1 (mod p) and R2:=p−1 (mod q), we transform to R1′:=(q′)−1 (mod p) and R2′:=(p′)−1 (mod q). If p or q appears as a multiply factor in the formula, change it to p′ or q′, respectively. If p or q appears as a modulus, (mod p) or (mod q), we change it to (mod p′) or (mod q′). For example, the CRT exponents, d1 and d2, are always d1:=d (mod (p-1)) and d2:=d (mod (q-1)). However, the CRT message components M1′ and M2′ are always transformed using p′ and s′ as moduli, per the invention, as described above. Thus, for the three exemplary variants, we obtain:
M′=CRT
2′ (m1′,m2′):=(m1′·R1′·q′+m2′·R2′·p′)(mod p′·q′),
M′=CRT
3′ (m1′,m2′):={[(m1′·R1′) (mod p′)]·q′+[(m2′·2′) (mod q′)]·p′} (mod p′·q′),
M′=CRT
4′ (m1′,m2′):=q′·{[(m1′-m2′)·R4′] (mod p′)}+m2′.
Once the intermediate message result M′ is obtained, it may be easily reduced to the final message M by a basic modular reduction operation (step 24):
M:=M′(mod(p·q)):=M′ (mod n).
This final reduction modulo p·q applies to all variants. Note that the product p·q has previously been computed as part of key generation, and is simply the public key modulus n available to all parties. Thus, it need not be recomputed if n has also been loaded into data storage available to the hardware processor, such as in association with previous step 10. Moreover, since use of the public key modulus n does not reveal anything about the private keys, the final reduction can be computed without random transformations and still be secure from cryptanalysis. The final message M is the same, even though p′, q′, M′, etc. are random, since using a transformed modulus that is a random multiple s of the original modulus produces intermediate results that, while random, are still of the same congruence class as that found by using untransformed moduli.