JP2005031472A - Method and device for arithmetic processing - Google Patents

Method and device for arithmetic processing Download PDF

Info

Publication number
JP2005031472A
JP2005031472A JP2003271527A JP2003271527A JP2005031472A JP 2005031472 A JP2005031472 A JP 2005031472A JP 2003271527 A JP2003271527 A JP 2003271527A JP 2003271527 A JP2003271527 A JP 2003271527A JP 2005031472 A JP2005031472 A JP 2005031472A
Authority
JP
Japan
Prior art keywords
calculation
monpro
arithmetic
determined
arithmetic processing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP2003271527A
Other languages
Japanese (ja)
Inventor
Hiromi Nobukata
浩美 信方
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sony Corp
Original Assignee
Sony Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Sony Corp filed Critical Sony Corp
Priority to JP2003271527A priority Critical patent/JP2005031472A/en
Publication of JP2005031472A publication Critical patent/JP2005031472A/en
Pending legal-status Critical Current

Links

Images

Abstract

<P>PROBLEM TO BE SOLVED: To reduce the total number of operation cycles by reducing the execution frequency of multiple-length subtract processing in product-sum operation in Montgomery arithmetic. <P>SOLUTION: In an arithmetic processing method, the combination of high order bits constituting the value of t and m obtained as an intermediate value in Montgomery product (MonPro) arithmetic processing is discriminated, a calculation expression for the value u in the MonPro arithmetic expression is modified and executed based on the discriminated data, and execution probability of the processing based on an expression dispensing with the multiple-length subtract processing for calculating u is enhanced. Thus, not only when u<R is indicated but also when u>N is indicated, subtraction in the MonPro arithmetic can be omitted to speed up the arithmetic processing. <P>COPYRIGHT: (C)2005,JPO&NCIPI

Description

本発明は、暗号処理演算の高速化手法に関する。特に、多倍長のべき剰余演算にモンゴメリ法を適用した演算における演算サイクル数を削減して演算の高速化を実現する演算処理方法、および演算処理装置に関する。   The present invention relates to a technique for speeding up cryptographic processing operations. In particular, the present invention relates to an arithmetic processing method and an arithmetic processing device that reduce the number of arithmetic cycles in an arithmetic operation in which the Montgomery method is applied to a multiple-precision power arithmetic, thereby realizing a high-speed arithmetic operation.

データ記憶、データ通信などの際の情報漏えいを防止する技術として、データの暗号化がある。暗号化方式には、大別して共通鍵方式、公開鍵方式がある。共通鍵方式は、対称暗号方式ともよばれ、発信者、受信者の双方で共通の鍵を保有する。共通鍵方式の代表的な方法として、DES(Data Encryption Standard)がある。DESアルゴリズムの特徴は、暗号化と復号化とをほぼ同じアルゴリズムで実行可能なことである。   As a technique for preventing information leakage during data storage, data communication, etc., there is data encryption. Encryption methods are roughly classified into a common key method and a public key method. The common key method is also called a symmetric encryption method, and both the sender and the receiver have a common key. As a typical method of the common key method, there is DES (Data Encryption Standard). A feature of the DES algorithm is that encryption and decryption can be executed by almost the same algorithm.

この共通鍵暗号に対して、発信者と受信者の鍵を異なるものとした構成が公開鍵方式または非対称暗号方式である。公開鍵暗号方式では、暗号化、復号化に共通の鍵を用いる共通鍵暗号方式と異なり、秘密に保つ必要のある秘密鍵は、特定の1人が持てばよいため鍵の管理において有利である。ただし、公開鍵暗号方式は共通鍵暗号方式に比較してデータ処理速度が遅く、一般には、共通鍵暗号の秘密鍵の配送、ディジタル署名等のデータ量の少ない対象に多く用いられている。公開鍵暗号方式の代表的なものにはRSA(Rivest-Shamir-Adleman)暗号がある。これは非常に大きな2つの素数(例えば150桁)の積を用いるものであり、大きな2つの素数(例えば150桁)の積の素因数分解する処理の困難さを利用している。   The public key system or the asymmetric encryption system is a configuration in which the sender and receiver have different keys for the common key encryption. Unlike the common key cryptosystem that uses a common key for encryption and decryption, the public key cryptosystem is advantageous in key management because the secret key that needs to be kept secret must be held by a specific person. . However, the public key cryptosystem has a slower data processing speed than the common key cryptosystem, and is generally used for a small amount of data such as the distribution of the secret key of the common key cryptosystem and the digital signature. A typical public key cryptosystem is RSA (Rivest-Shamir-Adleman) cryptography. This uses a product of two very large prime numbers (for example, 150 digits), and utilizes the difficulty of the process of factoring the product of two large prime numbers (for example, 150 digits).

公開鍵暗号方式では、不特定多数に公開鍵を使用可能とする構成であり、配布する公開鍵が正当なものであるか否かを証明する証明書、いわゆる公開鍵証明書を使用する方法が多く用いられている。例えば、利用者Aが公開鍵、秘密鍵のペアを生成して、生成した公開鍵を認証局に対して送付して公開鍵証明書を認証局から入手する。利用者Aは公開鍵証明書を一般に公開する。不特定のユーザは公開鍵証明書から所定の手続きを経て公開鍵を入手して文書等を暗号化して利用者Aに送付する。利用者Aは秘密鍵を用いて暗号化文書等を復号する、等のシステムである。また、利用者Aは、秘密鍵を用いて文書等に署名を付け、不特定のユーザが公開鍵証明書から所定の手続きを経て公開鍵を入手して、その署名の検証を行なうシステムである。   In the public key cryptosystem, a public key can be used by an unspecified number of people, and there is a method of using a certificate that certifies whether or not a public key to be distributed is valid, a so-called public key certificate. Many are used. For example, the user A generates a public key / private key pair, sends the generated public key to the certificate authority, and obtains a public key certificate from the certificate authority. User A makes the public key certificate public. An unspecified user obtains a public key from a public key certificate through a predetermined procedure, encrypts a document or the like, and sends it to user A. User A is a system that decrypts an encrypted document or the like using a secret key. User A is a system in which a document or the like is signed using a private key, an unspecified user obtains a public key from a public key certificate through a predetermined procedure, and verifies the signature. .

公開鍵証明書は、公開鍵暗号方式における認証局あるいは発行局(CA:Certificate AuthorityまたはIA:Issuer Authority)が発行する証明書であり、ユーザが自己のID、公開鍵等を認証局に提出することにより、認証局側が認証局のIDや有効期限等の情報を付加し、さらに認証局による署名を付加して作成される証明書である。   A public key certificate is a certificate issued by a certificate authority or issuing authority (CA: Certificate Authority or IA: Issuer Authority) in the public key cryptosystem, and a user submits his ID, public key, etc. to the certificate authority. Accordingly, the certificate authority side creates a certificate created by adding information such as the certificate authority ID and expiration date, and adding a signature by the certificate authority.

上述のRSA暗号では、メッセージ文を"M",暗号文を"C"、公開鍵を"e"、秘密鍵を"d"、剰余数を"N"としたとき、
暗号化:C=M mod N
復号化:M=C mod N
により暗号化・復号化をおこなう。この演算は、例えば1024[bit]のRSA暗号の暗号化の場合、公開鍵をe=Σi=0 1023・2とした場合、暗号化は以下の手順で行なわれる。
C=1
fori=1023 to 0
C:=C×C mod N
if e=1 then C:=C×M mod N
next i
なお、上記暗号化演算フローで、[:=]は、右辺の演算結果を左辺の変数に代入する事を表す。
In the RSA cipher described above, when the message text is “M”, the ciphertext is “C”, the public key is “e”, the secret key is “d”, and the remainder number is “N”,
Encryption: C = M e mod N
Decryption: M = C d mod N
Encrypt / decrypt with For example, in the case of encryption of 1024 [bit] RSA encryption, when the public key is e = Σ i = 0 1023 e i · 2 i , the calculation is performed according to the following procedure.
C = 1
fori = 1023 to 0
C: = C × C mod N
if e i = 1 then C: = C × M mod N
next i
In the encryption calculation flow, [: =] indicates that the calculation result on the right side is assigned to the variable on the left side.

このような暗号化演算を実行する暗号処理モジュールとしては、IC等の演算処理装置が用いられる。ICは半導体によって構成され、暗号演算の実行時には、演算処理シーケンスに従った電気的な処理を行うことになる。従って、このような半導体モジュールにおいて暗号処理が実行される際の電力消費を解析することで、暗号処理手順が解析されてしまうという恐れがある。暗号解読攻撃としては、処理時間を解析することにより秘密情報を推定するタイムアタック[Timing attack(TA)]、暗号処理時の消費電力の観測により秘密情報を推定するシンプルパワー解析[Simple Power Analysis(SPA)]、さらに、大量のデータに対する暗号処理における消費電力を測定し、それらの測定データを統計的に解析することにより秘密情報を推定する差分電力解析[Differential Power Analysis(DPA)]等がある。   An arithmetic processing device such as an IC is used as the cryptographic processing module for executing such an encryption operation. The IC is composed of a semiconductor, and performs electrical processing in accordance with an arithmetic processing sequence when executing cryptographic operations. Therefore, by analyzing the power consumption when cryptographic processing is executed in such a semiconductor module, the cryptographic processing procedure may be analyzed. As a cryptanalysis attack, a time attack [Timing attack (TA)] that estimates secret information by analyzing processing time, a simple power analysis [Simple Power Analysis (SPA) that estimates secret information by observing power consumption during encryption processing] In addition, there is a differential power analysis (DPA) that measures power consumption in cryptographic processing for a large amount of data and estimates the secret information by statistically analyzing the measured data.

これらの攻撃に対する耐性を高めるために、暗号処理演算シーケンス中にダミー演算を挿入し、解析困難性を高める手法が知られている。例えば、上述のRSA暗号化において、ダミー演算を挿入した演算手順は、以下の様になる。
C=1
for i=1023 to 0
C:=C×C mod N
D:=C×M mod N
if e=1 then C:=D
next i
In order to increase resistance against these attacks, a technique is known in which a dummy operation is inserted into a cryptographic processing operation sequence to increase analysis difficulty. For example, in the RSA encryption described above, a calculation procedure in which a dummy calculation is inserted is as follows.
C = 1
for i = 1023 to 0
C: = C × C mod N
D: = C × M mod N
if e i = 1 then C: = D
next i

上記式において、e=0のときの[D:=C×M mod N]の演算がダミーの演算処理である。この演算は、例えばビット長が1024bitと大きな数値であるため、剰余演算に時間がかかるという問題がある。 In the above equation, the calculation of [D: = C × M mod N] when e i = 0 is a dummy calculation process. For example, since this operation is a large numerical value with a bit length of 1024 bits, there is a problem that it takes time to perform the remainder operation.

RSA暗号方式では、鍵長の長いこと、演算速度が遅いという問題がある。RSA暗号の演算時間を短縮する方法の1つとしてモンゴメリ(Montgomery)法が使われる。このモンゴメリ法は、Nによる剰余演算の代わりに、Nより大きい2のべき乗値での剰余演算を行なう。2のべき乗値による剰余演算は、演算処理装置においてはビットシフト処理として実現可能であり、演算サイクル数は大幅に削減される。   The RSA encryption method has a problem that the key length is long and the calculation speed is slow. The Montgomery method is used as one method for shortening the computation time of the RSA encryption. In this Montgomery method, instead of a remainder operation by N, a remainder operation with a power of 2 greater than N is performed. The remainder calculation by the power of 2 can be realized as a bit shift process in the arithmetic processing unit, and the number of arithmetic cycles is greatly reduced.

モンゴメリ(Montgomery)法を用いた1024bitのRSA暗号の演算では、
R=21024、N'=−N−1 mod Rとしたとき、
タイムアタック(Time Attack)対策を施した演算フローは、以下のようになる。
:=R mod N
:=M×R mod N
for i=1023 to 0
:=MonPro(x,x
:=MonPro(M,x
if e=1 then x:=y
next i
C:=MonPro(1,x
In the operation of the 1024-bit RSA cipher using the Montgomery method,
When R = 2 1024 and N ′ = − N −1 mod R,
The calculation flow with countermeasures against time attack is as follows.
x * : = R mod N
M * : = M × R mod N
for i = 1023 to 0
x * : = MonPro (x * , x * )
y * : = MonPro (M * , x * )
if e i = 1 then x * : = y *
next i
C: = MonPro (1, x * )

ここで、モンプロ(MonPro)演算、すなわち、MonPro(a,b)は、下記の演算処理である。 Here, the monpro (MonPro) operation, that is, MonPro (a * , b * ) is the following arithmetic processing.

MonPro(a,b):
t=a×b
m=t×N' mod R
u=(t+m×N)/R
if u≧N then return u−N
else return u
MonPro (a * , b * ):
t = a * × b *
m = t × N ′ mod R
u = (t + m × N) / R
if u ≧ N then return u−N
else return u

乗算器のビット幅をω[bit]、データのワード数をDL(=1024/ω)、r=2ω、演算の途中で出てくる中間値"t"をt=Σi=0 DL-1・2ω・i、パラメータ"N'"をN'=Σi=0 DL-1N'・2ω・iとした時、モンプロ(MonPro)演算、すなわち、MonPro(a,b)は、下記の演算処理としても示される。
MonPro(a,b):
t=a×b=Σi=0 2×DL-1・2ω・i
for i=0 to DL−1
m=t×N'mod r
t:=(t+m×N)/r
next i
if t≧N then return t−N
else return t
となる。
The bit width of the multiplier is ω [bit], the number of data words is DL (= 1024 / ω), r = 2 ω , and the intermediate value “t” that appears in the middle of the operation is t = Σ i = 0 DL− 1 t i · 2 ω · i and parameter “N ′” as N ′ = Σi = 0 DL-1 N ′ i · 2 ω · i , MonPro operation, that is, MonPro (a * , b * ) is also indicated as the following arithmetic processing.
MonPro (a * , b * ):
t = a * × b * = Σ i = 0 2 × DL-1 t i · 2 ω · i
for i = 0 to DL-1
m = t 0 × N ′ 0 mod r
t: = (t + m × N) / r
next i
if t ≧ N then return t−N
else return t
It becomes.

このモンプロ(MonPro)演算において、
if t≧N then t:=t−N
の処理のために、"t"と"N"の大小関係を取得することが求められ、以下の様な補足演算を実行することが必要となる。
Temp =t−N
if Temp≧0 then return Temp
else return t
In this MonPro operation,
if t ≧ N then t: = t−N
For this processing, it is required to acquire the magnitude relationship between “t” and “N”, and it is necessary to execute the following supplementary calculation.
Temp = t-N
if Temp ≧ 0 then return Temp
else return t

このように、モンゴメリ(Montgomery)演算を行なう場合に実行されるモンプロ(MonPro)演算では、演算結果"t"と剰余数"N"の大小判定のための補足演算として、最後に多倍長の減算処理を行なうことが必要となる。1回の多倍長減算のサイクル数は、剰余数のビット幅が1024[bit]で加算器のビット幅が32bitの場合、最低でも1024/32=32サイクル[cycle]必要となる。   As described above, in the MontPro operation executed when the Montgomery operation is performed, as a supplementary operation for determining the magnitude of the operation result “t” and the remainder number “N”, a multiple length is finally added. It is necessary to perform subtraction processing. The number of cycles for one multiple-length subtraction requires at least 1024/32 = 32 cycles [cycle] when the bit width of the remainder is 1024 [bit] and the bit width of the adder is 32 bits.

タイムアタック(Time Attack)のためのダミー演算を含む演算フローでは、各ループで2回の上記したモンプロ(MonPro)演算を行なうことが必要となるため、暗号化・復号化の度に2×1024=2048回の多倍長減算が必要となり、32×2048=約65K cycleの、演算サイクル数・演算時間が増加することになる。   In an operation flow including a dummy operation for time attack, it is necessary to perform the above-described MonPro operation twice in each loop. Therefore, 2 × 1024 = every encryption / decryption is required. This requires 2048 multiple length subtractions, which increases the number of operation cycles and the operation time of 32 × 2048 = about 65 K cycles.

モンゴメリ(Montgomery)法を用いた演算の場合、演算ループの途中であれば、演算の途中結果"x*"," y*"が剰余数"N"より大きくても、パラメータ"R"より小さければ最終的な演算結果に影響を与えないことが特許文献1に示されている。なお、パラメータ"R"は、R=21024で示される。 In the case of an operation using the Montgomery method, if it is in the middle of the operation loop, the intermediate result “x * ”, “y * ” must be smaller than the parameter “R” even if it is larger than the remainder “N”. For example, Patent Document 1 shows that the final calculation result is not affected. The parameter “R” is indicated by R = 2 1024 .

特許文献1は、モンゴメリ(Montgomery)法を用いた演算の場合、演算ループの途中であれば、演算の途中結果"x*"," y*"が剰余数"N"より大きくても、パラメータ"R"より小さければ最終的な演算結果に影響を与えないことを数学的に示している。すなわち、モンプロ(MonPro)演算のフローにおいて、中間値tと剰余数Nとの比較、すなわち、
if t≧N then return t−N
ではなく、中間値tとパラメータRとの比較、すなわち、
if t≧R then return t−N
を行なう手法を開示している。
In the case of calculation using the Montgomery method, Patent Document 1 discloses that if the calculation result “x * ”, “y * ” is greater than the remainder number “N” in the middle of the calculation loop, It is mathematically shown that if it is smaller than “R”, the final calculation result is not affected. That is, in the flow of MonPro operation, the comparison between the intermediate value t and the remainder number N, that is,
if t ≧ N then return t−N
Rather, the comparison between the intermediate value t and the parameter R, i.e.
if t ≧ R then return t−N
A method for performing the above is disclosed.

この手法を適用する場合、直前の積和演算でのキャリーの有無でtとRの大小関係が得られるため、大小比較のための引算は不要で、したがって、t<Rが成立する場合は、一切の多倍長減算は必要なくなり、ある程度演算サイクル数・演算時間を短縮することができる。   When this method is applied, since the magnitude relationship between t and R is obtained by the presence / absence of carry in the previous product-sum operation, subtraction for size comparison is unnecessary, and therefore, when t <R holds No multiple-precision subtraction is required, and the number of calculation cycles and calculation time can be shortened to some extent.

しかし、上記手法を適用した場合においても、t<Rが成立しない場合、すなわちt≧Rの場合には、多倍長の減算が必要となり、これらの多倍長減算による演算サイクル数・演算時間の増加という問題を解決するものには至っていない。
特開平9−274560
However, even when the above method is applied, when t <R does not hold, that is, when t ≧ R, multiple length subtraction is required, and the number of operation cycles and the calculation time by these multiple length subtraction are required. It has not yet been able to solve the problem of increase.
JP-A-9-274560

本発明は、上記、問題点に鑑みてなされたものであり、モンゴメリ(Montgomery)法を用いた暗号処理演算において、演算サイクル数・演算時間を短縮した演算処理方法、および演算処理装置を提供するものである。   The present invention has been made in view of the above problems, and provides an arithmetic processing method and an arithmetic processing device in which the number of arithmetic cycles and the arithmetic time are shortened in cryptographic processing arithmetic using the Montgomery method. Is.

本発明は、特に、モンゴメリ(Montgomery)法を用いた暗号処理におけるモンプロ(MonPro)演算における多倍長減算の実行回数を削減することにより演算サイクル数を削減し、演算時間短縮を実現する演算処理方法、および演算処理装置を提供するものである。   In particular, the present invention reduces the number of operation cycles by reducing the number of executions of multi-precision subtraction in the MontPro operation in the encryption processing using the Montgomery method, thereby reducing the operation time. A method and an arithmetic processing apparatus are provided.

本発明の第1の側面は、
メッセージ文をM,暗号文をC、公開鍵をe、秘密鍵をd、剰余数をNとし、
暗号化:C=M mod N
復号化:M=C mod N
により暗号化・復号化を行うRSA暗号においてモンゴメリ法を適用し、Rを2のべき乗、N'=−N−1modRとして、下記演算式[演算式A][演算式1]に従ったモンプロ演算を実行する演算処理方法であり、
[演算式A]
MonPro(a*,b*):
t=a*×b*
m=t×N' mod R
[演算式1]
u=(t+m×N)/R
if Carry=1 then return u−N
else return u
上記モンプロ演算における中間値として取得されるt,mの値を構成する上位ビットの組み合わせを判別し、該判別データに基づいて、上記式における値uの算出式を変更して実行することを特徴とする演算処理方法にある。
The first aspect of the present invention is:
The message text is M, the cipher text is C, the public key is e, the secret key is d, the remainder is N,
Encryption: C = M e mod N
Decryption: M = C d mod N
Montgomery method is applied to RSA encryption that performs encryption / decryption by R, and R is a power of 2 and N ′ = − N −1 modR. An arithmetic processing method for executing an arithmetic operation,
[Calculation formula A]
MonPro (a * , b * ):
t = a * × b *
m = t × N ′ mod R
[Calculation Formula 1]
u = (t + m × N) / R
if Carry = 1 then return u-N
else return u
A combination of high-order bits constituting the values of t and m acquired as an intermediate value in the monpro operation is determined, and the calculation formula of the value u in the above formula is changed and executed based on the determination data. It is in the arithmetic processing method.

さらに、前記演算処理方法の一実施態様において、前記[演算式A]中のt,mの上位ビットの組み合わせを判別し、該判別データに基づいてu>Nであると判定される場合に、モンプロ演算のuの算出を、下記[演算式2]
[演算式2]
u=(t−(R−m)×N)/R
に従って実行し、
u<Rであると判定される場合に、
モンプロ演算を、下記[演算式3]
[演算式3]
u=(t+m×N)/R
に従って実行することを特徴とする。
Furthermore, in an embodiment of the arithmetic processing method, when the combination of the upper bits of t and m in the [arithmetic expression A] is determined and it is determined that u> N based on the determination data, The calculation of monpro calculation u is as follows: [Equation 2]
[Calculation formula 2]
u = (t− (R−m) × N) / R
Run according to
If it is determined that u <R,
The monpro calculation is the following [Expression 3]
[Calculation Formula 3]
u = (t + m × N) / R
It is characterized by performing according to.

さらに、前記演算処理方法の一実施態様において、t,mの最上位ビットの組み合わせが、(t,m)=(1,1)であるときu<Rであると判定し、モンプロ演算のuの算出を、前記[演算式3]に従って実行し、t,mの最上位ビットの組み合わせが、(t,m)=(0,0)であるとき、u>Nであると判定し、モンプロ演算を、前記[演算式2]に従って実行することを特徴とする。   Furthermore, in one embodiment of the arithmetic processing method, when the combination of the most significant bits of t and m is (t, m) = (1, 1), it is determined that u <R, and u of monpro arithmetic When the combination of the most significant bits of t and m is (t, m) = (0, 0), it is determined that u> N. The calculation is performed according to the above [Calculation Formula 2].

さらに、前記演算処理方法の一実施態様において、前記演算処理方法は、t,mの最上位ビットまたは上位複数ビットの組み合わせに基づいて、u>Nであると判定されるか、u<Rであると判定されるか、いずれとも判定できないかを判定し、u>Nであると判定される場合には、モンプロ演算のuの算出を、前記[演算式2]に従って実行し、u<Rあると判定される場合には、モンプロ演算のuの算出を、前記[演算式3]に従って実行し、いずれとも判定できない場合には、モンプロ演算のuの算出を、前記[演算式1]に従って実行することを特徴とする。   Furthermore, in one embodiment of the arithmetic processing method, the arithmetic processing method is determined as u> N based on a combination of the most significant bit or the higher-order multiple bits of t and m, or u <R. It is determined whether or not both are determined, and if it is determined that u> N, the calculation of u of the monpro calculation is executed according to the above [Expression 2], and u <R If it is determined that there is, the calculation of u of the monpro operation is executed according to the above [Calculation Equation 3], and if neither can be determined, the calculation of u of the monpro operation is performed according to the above [Operation Equation 1]. It is characterized by performing.

さらに、本発明の第2の側面は、
メッセージ文をM,暗号文をC、公開鍵をe、秘密鍵をd、剰余数をNとし、
暗号化:C=M mod N
復号化:M=C mod N
により暗号化・復号化を行うRSA暗号において、モンゴメリ法を適用し、RをNより大きい2のべき乗値、N'=−N−1modRとして、下記演算式[演算式A][演算式1]に従ったモンプロ演算を実行する演算処理装置であり、
[演算式A]
MonPro(a*,b*):
t=a*×b*
m=t×N' mod R
[演算式1]
u=(t+m×N)/R
if Carry=1 then return u−N
else return u
前記[演算式1]における値uの算出処理を実行する乗算器および加算器を有するとともに、前記乗算器の一方のデータ入力段に反転器およびセレクタを設けた演算部と、
前記モンプロ演算における中間値として取得されるt,mの値を構成する上位ビットの組み合わせに基づいて、前記乗算器の一方の入力データを反転データまたは非反転データとして選択入力するように演算部に制御信号を出力する制御部と、
を有することを特徴とする演算処理装置にある。
Furthermore, the second aspect of the present invention provides
The message text is M, the cipher text is C, the public key is e, the secret key is d, the remainder is N,
Encryption: C = M e mod N
Decryption: M = C d mod N
In the RSA encryption that performs encryption / decryption by using the Montgomery method, R is a power of 2 greater than N, and N ′ = − N −1 modR, and the following arithmetic expression [calculation expression A] [calculation expression 1 Is an arithmetic processing unit that executes a monpro calculation according to
[Calculation formula A]
MonPro (a * , b * ):
t = a * × b *
m = t × N ′ mod R
[Calculation Formula 1]
u = (t + m × N) / R
if Carry = 1 then return u-N
else return u
An arithmetic unit having a multiplier and an adder for executing the calculation process of the value u in [Operational Formula 1], and having an inverter and a selector at one data input stage of the multiplier;
Based on a combination of upper bits constituting the values of t and m acquired as intermediate values in the monpro operation, the arithmetic unit is configured to selectively input one input data of the multiplier as inverted data or non-inverted data. A control unit for outputting a control signal;
There is an arithmetic processing unit characterized by having

さらに、前記演算処理装置の一実施態様において、前記演算部は、さらに、前記反転器およびセレクタ間に桁上げ(Carry)信号による+1処理を実行する加算器を有し、前記制御部は、前記乗算器入力が共に最下位ワードである場合に、前記加算器による桁上げ(Carry)を実行し、該桁上げ処理後のデータを前記乗算器に入力するように前記演算部の制御を実行する構成を有することを特徴とする。   Furthermore, in one embodiment of the arithmetic processing apparatus, the arithmetic unit further includes an adder that performs +1 processing by a carry signal between the inverter and the selector, and the control unit includes the controller When both the multiplier inputs are the least significant word, carry by the adder is carried, and control of the arithmetic unit is executed so that the data after the carry processing is input to the multiplier. It has the structure.

さらに、前記乗算器と加算器の間に反転・非反転制御回路を有し、前記モンプロ演算における中間値として取得されるt,mの値を構成する上位ビットの組合せに基づいて、前記乗算器の出力データを反転データまたは非反転データとして前記加算器の一方へ選択入力するように演算部に制御信号を出力する制御部と、
を有することを特徴とする演算処理装置にある。
Further, an inversion / non-inversion control circuit is provided between the multiplier and the adder, and the multiplier is based on a combination of upper bits constituting a value of t and m acquired as an intermediate value in the monpro operation. A control unit that outputs a control signal to the arithmetic unit so as to selectively input the output data as inverted data or non-inverted data to one of the adders;
There is an arithmetic processing unit characterized by having

さらに、前記演算処理装置の一実施態様において、前記制御部は、前記[演算式A]中のt,mの上位ビットの組み合わせを判別し、該判別データに基づいてu>Nであると判定される場合に、モンプロ演算を、下記[演算式2]
[演算式2]
u=(t−(R−m)×N)/R
に従って実行するように前記演算部を制御し、
u<Rであると判定される場合に、
モンプロ演算を、下記[演算式3]
[演算式3]
u=(t+m×N)/R
に従って実行するように、前記演算部の制御を実行する構成であることを特徴とする。
Furthermore, in an embodiment of the arithmetic processing unit, the control unit determines a combination of upper bits of t and m in the [arithmetic expression A] and determines that u> N based on the determination data. When the monpro calculation is performed, the following [Expression 2]
[Calculation formula 2]
u = (t− (R−m) × N) / R
Controlling the arithmetic unit to execute according to
If it is determined that u <R,
The monpro calculation is the following [Expression 3]
[Calculation Formula 3]
u = (t + m × N) / R
It is the structure which performs control of the said calculating part so that it may perform according to.

さらに、前記演算処理装置の一実施態様において、前記制御部は、t,mの最上位ビットの組み合わせが、(t,m)=(1,1)であるとき、u<Rであると判定し、モンプロ演算のuの算出を、前記[演算式3]に従って実行するように前記演算部を制御し、t,mの最上位ビットの組み合わせが、(t,m)=(0,0)であるとき、u>Nであると判定し、モンプロ演算のuの算出を、前記[演算式2]に従って実行するように前記演算部の制御を実行する構成であることを特徴とする。   Furthermore, in one embodiment of the arithmetic processing unit, the control unit determines that u <R when the combination of the most significant bits of t and m is (t, m) = (1, 1). Then, the arithmetic unit is controlled so that the calculation of u of the monpro operation is executed according to the above [Operational Expression 3], and the combination of the most significant bits of t and m is (t, m) = (0, 0) When it is, it is determined that u> N, and the control of the calculation unit is executed so that the calculation of u of the monpro calculation is executed according to the [Calculation Formula 2].

さらに、前記演算処理装置の一実施態様において、前記制御部は、t,mの最上位ビットまたは上位複数ビットの組み合わせに基づいて、u>Nであると判定されるか、u<Rであると判定されるか、いずれとも判定できないかを判定し、u>Nである場合には、モンプロ演算のuの算出を、前記[演算式2]に従って実行するように前記演算部を制御し、u<Rである場合には、モンプロ演算のuの算出を、前記[演算式3]に従って実行するように前記演算部を制御し、いずれとも判定できない場合には、モンプロ演算のuの算出を、前記[演算式1]に従って実行するように前記演算部を制御する構成であることを特徴とする。   Furthermore, in one embodiment of the arithmetic processing unit, the control unit determines that u> N or u <R based on a combination of the most significant bit of t and m or a combination of higher-order multiple bits. Or if it cannot be determined, and if u> N, the calculation unit is controlled so that the calculation of u of the monpro calculation is performed according to the [Calculation Formula 2], When u <R, the calculation unit is controlled to execute calculation of u of the monpro calculation according to the [calculation expression 3], and when neither can be determined, the calculation of u of the monpro calculation is calculated. The arithmetic unit is controlled so as to be executed according to the [arithmetic expression 1].

本発明の構成によれば、モンプロ演算プロセスにおける中間値として取得されるt,mの値を構成する上位ビットの組み合わせを判別し、該判別データに基づいて、モンプロ演算式における値uの算出式を変更して実行する構成とするとともに、uの算出において多倍長の減算処理を不要とした式に基づく処理の実行確率を高めたので、モンゴメリ(Montgomery)演算での積和演算での多倍長の減算処理の実行回数が削減され、トータルの演算サイクル数の削減が実現される。   According to the configuration of the present invention, the combination of the upper bits constituting the values of t and m acquired as the intermediate value in the monpro calculation process is determined, and the calculation formula for the value u in the monpro calculation formula is based on the determination data. The execution probability of processing based on an expression that eliminates the need for multiple-precision subtraction processing in the calculation of u has been increased, so that the product-sum operation in the Montgomery operation The number of executions of double-length subtraction processing is reduced, and the total number of operation cycles is reduced.

本発明の構成によれば、u<Rの場合のみならず、u>Nであることが示される場合においても、モンプロ(MonPro)演算における減算処理を省略することが可能となり、演算の高速化が実現される。   According to the configuration of the present invention, not only when u <R but also when u> N is indicated, it is possible to omit the subtraction process in the MonPro calculation, and the calculation speed is increased. Is realized.

以下、本発明の演算処理方法、および演算処理装置について詳細に説明する。   The arithmetic processing method and arithmetic processing device of the present invention will be described in detail below.

説明は、以下の項目に分けて行う。
1.本発明の演算シーケンス
2.具体的な演算プロセス例
3.本発明の演算処理および装置と従来構成との比較
The description is divided into the following items.
1. 1. Operation sequence of the present invention 2. Specific calculation process example Comparison between arithmetic processing and apparatus of the present invention and conventional configuration

[1.本発明の演算シーケンス]
まず、本発明の演算処理装置、および演算処理方法において適用する運算シーケンスについて説明する。本発明は、RSA暗号の演算時間の短縮手法として知られているモンゴメリ(Montgomery)法において実行するモンプロ(MonPro)演算において実行される多倍長減算の実行回数を削減することにより演算サイクル数を削減し、演算時間短縮を実現したものである。
[1. Operation sequence of the present invention]
First, an arithmetic sequence applied in the arithmetic processing device and the arithmetic processing method of the present invention will be described. The present invention reduces the number of operation cycles by reducing the number of executions of multiple length subtraction executed in the MontPro operation executed in the Montgomery method known as a technique for shortening the operation time of the RSA encryption. This reduces the calculation time.

従来技術の欄においても説明したように、モンゴメリ(Montgomery)法を用いた1024bitのRSA暗号の演算は、R=21024、N'=−N−1 mod Rとしたとき、タイムアタック(Time Attack)対策を施した演算フローは、以下のようになる。
:=R mod N
:=M×R mod N
for i=1023 to 0
:=MonPro(x,x
:=MonPro(M,x
if e=1 then x:=y
next i
C:=MonPro(1,x
As described in the section of the prior art, the calculation of the 1024-bit RSA cipher using the Montgomery method is time attack (Time Attack) when R = 2 1024 and N ′ = − N −1 mod R. The calculation flow with countermeasures is as follows.
x * : = R mod N
M * : = M × R mod N
for i = 1023 to 0
x * : = MonPro (x * , x * )
y * : = MonPro (M * , x * )
if e i = 1 then x * : = y *
next i
C: = MonPro (1, x * )

ここで、モンプロ(MonPro)演算、すなわち、MonPro(a,b)は、下記の演算処理として実行される。 Here, MonPro (MonPro) calculation, that is, MonPro (a * , b * ) is executed as the following calculation process.

MonPro(a,b):
t=a×b
m=t×N' mod R
u=(t+m×N)/R
if u≧N then return u−N
else return u
MonPro (a * , b * ):
t = a * × b *
m = t × N ′ mod R
u = (t + m × N) / R
if u ≧ N then return u−N
else return u

ここで、乗算器のビット幅をω[bit]、データのワード数をDL(=1024/ω)、r=2ω、演算の途中で出てくる中間値"t"をt=Σi=0 2×DL-1・2ω・i、パラメータ"N'"をN'=Σi=0 DL-1N'・2ω・iとした時、
MonPro(a,b):
t=a×b
for i=0 to DL−1
m=t×N'mod r
t:=(t+m×N)/r
next i
if t≧N then return t−N
else return t
とも表わされる。
Here, the bit width of the multiplier is ω [bit], the number of data words is DL (= 1024 / ω), r = 2 ω , and the intermediate value “t” that appears in the middle of the operation is t = Σ i = 0 2 × DL-1 t i · 2 ω · i and parameter “N ′” is N ′ = Σ i = 0 DL-1 N ′ i · 2 ω · i
MonPro (a * , b * ):
t = a * × b *
for i = 0 to DL-1
m = t 0 × N ′ 0 mod r
t: = (t + m × N) / r
next i
if t ≧ N then return t−N
else return t
It is also expressed.

このモンプロ(MonPro)演算において、
if t≧N then t:=t−N
の演算プロセスでは、"t"と"N"の大小関係の取得のために、以下の様な補足演算が必要となり、実行される。
Temp =t−N
if Temp≧0 then return Temp
else return t
In this MonPro operation,
if t ≧ N then t: = t−N
In the above calculation process, the following supplementary calculation is required and executed in order to obtain the magnitude relationship between “t” and “N”.
Temp = t-N
if Temp ≧ 0 then return Temp
else return t

このように、モンゴメリ(Montgomery)演算を行なう場合に実行されるモンプロ(MonPro)演算では、演算結果"t"と剰余数"N"の大小判定のための補足演算として、最後に多倍長の減算を行なうことが必要となる。1回の多倍長減算のサイクル数は、剰余数のビット幅が1024[bit]で加算器のビット幅ωが32bitの場合、最低でも1024/32=32サイクル[cycle]必要となる。   As described above, in the MontPro operation executed when the Montgomery operation is performed, as a supplementary operation for determining the magnitude of the operation result “t” and the remainder number “N”, a multiple length is finally added. It is necessary to perform subtraction. When the bit width of the remainder number is 1024 [bit] and the bit width ω of the adder is 32 bits, the number of cycles for one multiple length subtraction is 1024/32 = 32 cycles [cycle] at a minimum.

本発明の演算シーケンスでは、上述のモンプロ(MonPro)演算における多倍長減算処理の実行回数を削減するものである。   In the calculation sequence of the present invention, the number of executions of the multiple length subtraction process in the above-described MonPro calculation is reduced.

本発明の演算シーケンスについて説明する。従来技術の欄で説明したように、モンゴメリ(Montgomery)法を用いた演算の場合、演算ループの途中であれば、演算の途中結果"x*"," y*"が剰余数"N"より大きくても、パラメータ"R"より小さければ最終的な演算結果に影響を与えないことが証明されている(特開平9−274560)。すなわち、モンプロ(MonPro)演算のフローにおける補足演算において、中間値tと剰余数Nとの比較を、
if t≧N then return t−N
ではなく、
中間値tとパラメータRとの比較、すなわち、
if t≧R then return t−N
と設定して行なう手法が有効であることが示されている。
The calculation sequence of the present invention will be described. As described in the section of the prior art, in the case of an operation using the Montgomery method, if it is in the middle of the operation loop, the intermediate result “x * ”, “y * ” is obtained from the remainder number “N”. It has been proved that even if the value is larger than the parameter “R”, the final calculation result is not affected (Japanese Patent Laid-Open No. 9-274560). That is, in the supplementary operation in the flow of the MonPro operation, the comparison between the intermediate value t and the remainder number N is
if t ≧ N then return t−N
not,
Comparison of the intermediate value t with the parameter R, ie
if t ≧ R then return t−N
It is shown that the method of setting and is effective.

この手法を適用すると、モンゴメリ(Montgomery)演算として実行されるモンプロ(MonPro)演算は、下記のシーケンスに従って実行されることになる。
MonPro(a,b):
t=a×b
m=t×N' mod R
u=(t+m×N)/R
Temp=u−N
if u≧R then return Temp(=u−N)
else return u
When this method is applied, a MontPro operation executed as a Montgomery operation is executed according to the following sequence.
MonPro (a * , b * ):
t = a * × b *
m = t × N ′ mod R
u = (t + m × N) / R
Temp = u-N
if u ≧ R then return Temp (= u−N)
else return u

本発明においては、さらに、上記モンプロ(MonPro)演算における中間値である下記の2値、すなわち、
t=a×bと、
m=t×N' mod R
これらt,mの上位ビット(MSB〜数ビット)の値を調べ、t,mの上位ビットの組合せに基づいて、以下に示す演算:[演算式1]〜[演算式3]のうちの1つを選択して実行する。この処理により、多倍長減算の実行回数を削減する。
In the present invention, the following two values which are intermediate values in the above MonPro calculation,
t = a * × b * ,
m = t × N ′ mod R
The value of the upper bits (MSB to several bits) of these t and m are examined, and one of the following operations: [Calculation Formula 1] to [Calculation Formula 3] based on the combination of the upper bits of t and m Select one and run it. With this process, the number of executions of multiple length subtraction is reduced.

[演算式1]
u=(t+m×N)/R
if Carry=1 then return u−N
[演算式2]
u=(t−(R−m)×N)/R
[演算式3]
u=(t+m×N)/R
[Calculation Formula 1]
u = (t + m × N) / R
if Carry = 1 then return u-N
[Calculation formula 2]
u = (t− (R−m) × N) / R
[Calculation Formula 3]
u = (t + m × N) / R

以下、上記[演算式1]〜[演算式3]のいずれかを選択して実行する本発明の演算処理について説明する。   Hereinafter, the calculation processing of the present invention executed by selecting any one of the above [Calculation Formula 1] to [Calculation Formula 3] will be described.

上述したように、モンゴメリ(Montgomery)演算には、以下の演算式で示されるモンプロ演算が含まれる。
MonPro(a*,b*):
t=a*×b* ・・・・・(数式1)
m=t×N' mod R ・・・(数式2)
u=(t+m×N)/R ・・(数式3)
if Carry=1 then return u−N
else return u ・・(数式4)
As described above, the Montgomery calculation includes the Montpro calculation indicated by the following calculation expression.
MonPro (a * , b * ):
t = a * × b * (Formula 1)
m = t × N ′ mod R (Formula 2)
u = (t + m × N) / R (Equation 3)
if Carry = 1 then return u-N
else return u (Formula 4)

ここで、RSA暗号のビット数は、剰余数"N"のビット数"L"[bit] で規定されるが、これをワード数(1ワード=ωビット)で表したものをDL(=L/ω)とするとき、R=2ω・DL と設定する。そして、(数式1)で計算される"t"は、a*(<N)とb*(<N)の積であるため、そのビット長は2×ω×DLとなる。この時"t"は、
t=tH×2ω・DL +tL=tH×R+tL・・・(数式5)
と表わせる。tHはtのR以上のビット、tLはtのR未満のビットである。
Here, the number of bits of the RSA cipher is defined by the number of bits “L” [bit] of the remainder number “N”, which is expressed by the number of words (1 word = ω bits) by DL (= L / Ω), R = 2ω · DL is set. Since “t” calculated by (Equation 1) is a product of a * (<N) and b * (<N), the bit length is 2 × ω × DL. At this time, "t"
t = tH × 2 ω · DL + tL = tH × R + tL (Equation 5)
It can be expressed as tH is a bit greater than or equal to R in t, and tL is a bit less than R in t.

このとき、uとNの比較において、
Temp1=u−N=(t+m×N)/R−N
=(tH×R+tL−(R−m)×N)/R
=tH+tL/R−(R−m)×N/R・・・(数式6)
となる。
At this time, in the comparison of u and N,
Temp1 = u−N = (t + m × N) / RN
= (TH × R + tL− (R−m) × N) / R
= TH + tL / R- (Rm) * N / R (Formula 6)
It becomes.

また、uとRの比較において、
Temp2=u−R=(t+m×N)/R−R
=(tH×R+tL+m×N)/R−R
=m×N/R−(R−tH−tL/R)・・・(数式7)
となる。
In comparison between u and R,
Temp2 = u−R = (t + m × N) / R−R
= (TH × R + tL + m × N) / R−R
= MxN / R- (R-tH-tL / R) (Formula 7)
It becomes.

これらの式で、0≦tL<Rであるため、0≦tL/R<1である。従って、(数式6)のTemp1、と(数式7)のTemp2の式において、以下の関係式が成り立つ。   In these equations, since 0 ≦ tL <R, 0 ≦ tL / R <1. Therefore, the following relational expression is established in the expression of Temp1 of (Expression 6) and Temp2 of (Expression 7).

Temp1=u−N≧tH−(R−m)×N/R・・(数式8)
Temp2=u−R<m×N/R−(R−tH−1)・・(数式9)
Temp1 = u−N ≧ tH− (R−m) × N / R (Equation 8)
Temp2 = u−R <m × N / R− (R−tH−1) (Equation 9)

これらの式で、剰余数"N"の最上位ビット(MSB)は"1"であるため、0.5<N/R<1である。(数式8)で、"tH"と"R−m"の関係に基づき、
Temp1>0
が示せる場合、u>Nであるため、(数式3)の"u"の計算式の代わりに"u−N"の計算を実行し、それを"u"とすれば(数式4)の判定及び多倍長の減算を行なう必要がなくなる。
In these equations, since the most significant bit (MSB) of the remainder number “N” is “1”, 0.5 <N / R <1. Based on the relationship between “tH” and “Rm” in (Equation 8),
Temp1> 0
Since u> N, the calculation of “u−N” is executed instead of the calculation expression of “u” in (Equation 3), and if it is set to “u”, the determination of (Equation 4) In addition, it is not necessary to perform multiple length subtraction.

この場合、すなわち、"tH"と"R−m"の関係に基づき、Temp1>0が示され、u>Nであると判定される場合は、前述の
[演算式2]
u=(t−(R−m)×N)/R
を適用してモンプロ(MonPro)演算を実行する。
すなわち、モンプロ(MonPro)演算は、以下の処理となる。
MonPro(a*,b*):
t=a*×b* ・・・・・・・・・・(数式10)
m=t×N' mod R ・・・・・・・(数式11)
u=(t−(R−m)×N)/R ・・(数式12)
In this case, that is, when Temp1> 0 is indicated based on the relationship between “tH” and “Rm” and it is determined that u> N, the above-described [Calculation Formula 2]
u = (t− (R−m) × N) / R
Is applied to execute the MonPro operation.
That is, the MonPro calculation is as follows.
MonPro (a * , b * ):
t = a * × b * (Equation 10)
m = t × N ′ mod R (Equation 11)
u = (t− (R−m) × N) / R (Equation 12)

この場合、uはN以下となっているため、減算処理は不要である。(数式12)は、"t"から、"m"の2の補数を取った値と"N"の乗算値を引き、その結果を"R"で割る(ビットシフト)事により演算結果を得る事ができる。この場合、"m"の2の補数計算は、ビット反転と"1"の加算で実現できる。具体的な演算方法については後述する。   In this case, since u is N or less, subtraction processing is not necessary. (Equation 12) is obtained by subtracting the 2's complement of "m" and the multiplication value of "N" from "t" and dividing the result by "R" (bit shift) to obtain the operation result. I can do things. In this case, the 2's complement calculation of “m” can be realized by bit inversion and addition of “1”. A specific calculation method will be described later.

次に、Temp2を示す上記(数式9)で、"m" と"R−tH−1"の関係に基づいて、
Temp2=u−R<0、
すなわち、
u<R
であることが示される場合は、前述の
[演算式3]
u=(t+m×N)/R
を適用してモンプロ(MonPro)演算を実行する。
すなわち、モンプロ(MonPro)演算は、以下の処理となる。
MonPro(a*,b*):
t=a*×b* ・・・・・・・・(数式13)
m=t×N' mod R ・・・・(数式14)
u=(t+m×N)/R ・・・(数式15)
Next, in the above (Formula 9) indicating Temp2, based on the relationship between “m” and “R−tH−1”,
Temp2 = u−R <0,
That is,
u <R
If it is shown that [Calculation Formula 3]
u = (t + m × N) / R
Is applied to execute the MonPro operation.
That is, the MonPro calculation is as follows.
MonPro (a * , b * ):
t = a * × b * (Equation 13)
m = t × N ′ mod R (Expression 14)
u = (t + m × N) / R (Formula 15)

この場合、uはR以下となっている。uはN以上の場合もあるが、R以下であるため、この後に減算処理を行なわないで、この演算結果を次のモンプロ(MonPro)演算に用いても不具合は生じないため省略することができる。このことは、従来技術の欄で説明したように、特開平9−274560に示されている。   In this case, u is equal to or less than R. Although u may be greater than or equal to N, since it is less than or equal to R, no subtraction process is performed after this, and this calculation result can be omitted for use in the next MonPro calculation, and can be omitted. . This is shown in Japanese Patent Laid-Open No. 9-274560 as described in the prior art section.

特開平9−274560においては、u<Rの場合においてのみ、モンプロ(MonPro)演算における減算処理、すなわち、
Temp=u−N
if u≧R then return Temp(=u−N)
else return u
を省略するものであったが、本発明の構成においては、"tH"と"R−m"の関係に基づき、
Temp1=u−N>0、すなわち、u>Nであることが示される場合においても、上記モンプロ(MonPro)演算における減算処理を省略することが可能となる。
In Japanese Patent Laid-Open No. 9-274560, only when u <R, subtraction processing in the MonPro operation, that is,
Temp = u-N
if u ≧ R then return Temp (= u−N)
else return u
In the configuration of the present invention, based on the relationship between “tH” and “Rm”,
Even when Temp1 = u−N> 0, that is, when u> N is indicated, it is possible to omit the subtraction process in the MonPro operation.

本発明のモンプロ(MonPro)演算の実行シーケンスについて、図1を参照して説明する。ステップS101において、
t=a*×b*=tH×R+tL
m=t×N' mod R
としてそれぞれの値を算出する。上述した説明における(数式1)、(数式2)に相当する。
An execution sequence of the MonPro operation according to the present invention will be described with reference to FIG. In step S101,
t = a * × b * = tH × R + tL
m = t × N ′ mod R
As a result, the respective values are calculated. This corresponds to (Equation 1) and (Equation 2) in the above description.

ステップS102において、演算プロセスにおける中間値に基づくtH"と"R−m"の上位ビットの比較に基づき、u>Nが成立するか否かを判定する。u>Nと判定される場合は、ステップS104において[演算式2]の演算、すなわち、
u=(t−(R−m)×N)/R
を実行する。
この演算処理においては、u,Nの大小判定のための補足演算としての多倍長減算は不要となる。
In step S102, it is determined whether or not u> N is satisfied based on a comparison between the upper bits of tH "and" R-m "based on the intermediate value in the arithmetic process. In step S104, the calculation of [Expression 2], that is,
u = (t− (R−m) × N) / R
Execute.
In this calculation process, multiple length subtraction as a supplementary calculation for determining the size of u and N is not necessary.

ステップS102において、u>Nと判定されない場合は、ステップS103に進み、"m" と"R−tH−1"の上位ビットの比較に基づいて、u<Rが成立するか否かを判定する。   If it is not determined in step S102 that u> N, the process proceeds to step S103, and it is determined whether u <R is satisfied based on the comparison between the upper bits of “m” and “R−tH−1”. .

u<Rが成立する場合は、ステップS105において[演算式3]の演算、すなわち、
u=(t+m×N)/R
を実行する。
この演算処理においては、u,Nの大小判定のための補足演算としての多倍長減算は不要となる。
When u <R is satisfied, the calculation of [Expression 3] in step S105, that is,
u = (t + m × N) / R
Execute.
In this calculation process, multiple length subtraction as a supplementary calculation for determining the size of u and N is not necessary.

ステップS103において、u<Rと判定されない場合は、ステップS106に進み、[演算式1]の演算、すなわち、
u=(t+m×N)/R
Temp=u−N
if Carry=1 then return u−N
else return u
を実行する。
この[演算式1]の演算処理においてのみ、u,Nの大小判定のための補足演算としての多倍長減算を実行することになる。
If it is not determined in step S103 that u <R, the process proceeds to step S106, and the calculation of [Calculation Formula 1], that is,
u = (t + m × N) / R
Temp = u-N
if Carry = 1 then return u-N
else return u
Execute.
Only in the calculation process of [Calculation Formula 1], multiple length subtraction is performed as a supplementary calculation for determining the magnitude of u and N.

このように、本発明においては、u>Nと判定される場合、および、u<Rと判定される場合、いずれの場合においても、モンプロ(MonPro)演算における減算処理を省略することが可能となり、演算サイクル数が削減され、処理の高速化が実現される。   As described above, according to the present invention, it is possible to omit the subtraction process in the MonPro calculation when u> N is determined and when u <R is determined. The number of operation cycles is reduced, and the processing speed is increased.

[2.具体的な演算プロセス例]
次に、本発明の演算処理の具体的な処理例について説明する。上述したように、本発明の演算シーケンスにおいては、モンプロ(MonPro)演算における中間値である下記の2値、すなわち、
t=a×bと、
m=t×N' mod R
これらt,mの上位ビット(MSB〜数ビット)の値を調べ、t,mの上位ビットの組合せに基づいて、前述の[演算式1]〜[演算式3]のうちの1つを選択して実行する。t,mの上位ビットの組合せに基づいて、u>Nと判定される場合は[演算式2]が適用可能であり、u<Rであると判定される場合には、[演算式3]が適用可能であり、いずれの場合にも減算処理を省略することが可能となる。
[2. Specific calculation process example]
Next, a specific processing example of the arithmetic processing according to the present invention will be described. As described above, in the calculation sequence of the present invention, the following two values, which are intermediate values in the MonPro calculation,
t = a * × b * ,
m = t × N ′ mod R
The value of the upper bits (MSB to several bits) of these t and m are examined, and one of the above-mentioned [Calculation Formula 1] to [Calculation Formula 3] is selected based on the combination of the upper bits of t and m And run. [Expression 2] is applicable when u> N is determined based on the combination of the upper bits of t and m, and [Expression 3] when u <R is determined. Can be applied, and in any case, the subtraction process can be omitted.

以下、"t"と"m"の上位ビットの組合せに基づいて、[演算式1]〜[演算式3]を選択して実行する処理の具体例について説明する。以下、
(a)."t"と"m"の最上位ビット(MSB)の組み合わせに基づく処理
(b)."t"と"m"の上位2ビットの組み合わせに基づく処理
(c)."t"と"m"の上位3ビットの組み合わせに基づく処理
の各処理例について説明する。
In the following, a specific example of processing to be executed by selecting [Calculation Formula 1] to [Calculation Formula 3] based on the combination of the upper bits of “t” and “m” will be described. Less than,
(A). Processing based on the combination of the most significant bit (MSB) of “t” and “m” (b). Processing based on combination of upper 2 bits of “t” and “m” (c). Each processing example based on the combination of the upper 3 bits of “t” and “m” will be described.

(a)"t"と"m"の最上位ビット(MSB)の組み合わせに基づく処理   (A) Processing based on the combination of the most significant bit (MSB) of “t” and “m”

"t"と"m"の最上位ビット(MSB)の組み合わせは、図2に示すように、t=0,1、m=0,1の2通り×2通りの組み合わせであり、全部で4通りの組み合わせがある。図2に示すように、"t"と"m"の最上位ビット(MSB)の組み合わせが(0,0)であれば、u<Rと判定され、(1,1)であれば、u>Nと判定され、これらの組み合わせの場合には、前述の[演算式2]または[演算式3]の適用が可能となり、減算処理を省略することができる。図中[?]の示された組み合わせ、すなわち、"t"と"m"の最上位ビット(MSB)の組み合わせが(0,1)または(1,0)の場合には、u<Rが成立する事もu>Nが成立する事も示せないため、前述の[演算式1]を適用した処理、すなわち減算処理を伴う演算を実行することになる。   As shown in FIG. 2, the combination of the most significant bit (MSB) of “t” and “m” is a combination of 2 types × 2 types of t = 0, 1, m = 0, 1, and 4 in total. There are street combinations. As shown in FIG. 2, if the combination of the most significant bits (MSB) of “t” and “m” is (0, 0), it is determined that u <R, and if (1, 1), u If it is determined that> N and these combinations are used, the above-described [Calculation Formula 2] or [Calculation Formula 3] can be applied, and the subtraction process can be omitted. [? ], That is, when the combination of the most significant bit (MSB) of “t” and “m” is (0, 1) or (1, 0), u <R may be satisfied. Since it is not possible to show that u> N is satisfied, a process to which the above-described [Calculation Expression 1] is applied, that is, a calculation involving a subtraction process is executed.

以下、"t"と"m"の最上位ビット(MSB)の各組み合わせにおいて、u<Rまたはu>Nが成立することが示される組み合わせ、または成立することが示されない組み合わせについて説明する。   Hereinafter, in each combination of the most significant bit (MSB) of “t” and “m”, a combination that indicates that u <R or u> N is satisfied or a combination that does not indicate that is satisfied will be described.

前述したように、RSA暗号のビット数は、剰余数"N"のビット数"L"[bit] で規定されるが、これをワード数(1ワード=ωビット)で表したものをLD(=L/ω)とするとき、R=2ω・DL と定義できる。そして、(数式1)で計算される"t"は、a*(<N)とb*(<N)の積であるため、そのビット長は2×ω×DLとなる。この時"t"は、
t=tH×2ω・DL +tL=tH×R+tL
と表わせる。
tHはtのR以上のビット、tLはtのR未満のビットである。
As described above, the number of bits of the RSA cipher is defined by the number of bits “L” [bit] of the remainder number “N”, which is expressed as LD (1 word = ω bits). = L / ω), it can be defined as R = 2ω · DL . Since “t” calculated by (Equation 1) is a product of a * (<N) and b * (<N), the bit length is 2 × ω × DL. At this time, "t"
t = tH × 2 ω · DL + tL = tH × R + tL
It can be expressed as
tH is a bit greater than or equal to R in t, and tL is a bit less than R in t.

tの最上位ビットが1である場合とは、tH>2ω・DL −1である場合であり、tの最上位ビットが0である場合とは、tH<2ω・DL −1である場合となる。同様に、mの最上位ビットが1である場合とは、m>2ω・DL −1である場合であり、mの最上位ビットが0である場合とは、m<2ω・DL −1である場合となる。以下、t,mの最上位ビットの組み合わせが、(1,1)、(1,0)、(0,1)、(0,0)の場合に、u<Rまたはu>Nが成立するか否かについて説明する。 A case where the most significant bit of t is 1 is a case where tH> 2ω · DL −1 , and a case where the most significant bit of t is 0 is that tH <2 ω · DL −1 . A case. Similarly, a case where the most significant bit of m is 1 is a case where m> 2 ω · DL −1 , and a case where the most significant bit of m is 0 is that m <2 ω · DL −. 1 is the case. Hereinafter, when the combination of the most significant bits of t and m is (1, 1), (1, 0), (0, 1), (0, 0), u <R or u> N holds. Whether or not will be described.

(a−1)"t"のMSB=1"m"のMSB=1
この場合は、tH>2ω・DL −1,m>2ω・DL −1の場合に相当する。
この場合、
R−m <2ω・DL −2ω・DL −1=2ω・DL −1
であり、
なおかつ、N/R<1であるため、
tH > (R−m)×N/Rとなる。
この場合、(数式8)より、
u>Nとなる。
(A-1) MSB of “t” = 1 MSB of “m” = 1
This case corresponds to the case of tH> 2ω · DL −1 and m> 2 ω · DL −1 .
in this case,
Rm <2 ω · DL −2 ω · DL −1 = 2 ω · DL −1
And
Furthermore, since N / R <1,
tH> (Rm) × N / R.
In this case, from (Formula 8),
u> N.

このように、"t"のMSB=1"m"のMSB=1の場合、u>Nが成立し、前述の[演算式2]の演算を実行可能であり、減算処理の省略が可能となる。   In this way, when MSB of “t” = 1 and MSB = 1 of “m”, u> N is established, the above-described operation of [Calculation Formula 2] can be executed, and the subtraction process can be omitted. Become.

(a−2)"t"のMSB=1"m"のMSB=0
この場合は、tH >2ω・DL−1,m <2ω・DL−1の場合に相当する。
この場合、
R−m >2ω・DL −2ω・DL −1=2ω・DL −1
であり、"tH "も"R−m"も両方2ω・DL−1より大きい。
この場合、(数式8)より、"tH "と"m"の最上位ビットだけではuとNの大小関係は判定できない。
また、
R−tH <2ω・DL −2ω・DL −1=2ω・DL −1
であり、"m"も"R−tH"も両方2ω・DL−1より小さい。この場合、(数式9)より、"tH "と"m"の最上位ビットだけではuとRの大小関係は判定できない。
(A-2) MSB of “t” = 1 MSB of “m” = 0
This case corresponds to the case of tH> 2ω · DL-1 and m < 2ω · DL-1 .
in this case,
Rm> 2 ω · DL −2 ω · DL −1 = 2 ω · DL −1
Both “tH” and “Rm” are larger than 2 ω · DL-1 .
In this case, from (Equation 8), the magnitude relationship between u and N cannot be determined only by the most significant bits of “tH” and “m”.
Also,
R-tH <2 ω · DL −2 ω · DL −1 = 2 ω · DL −1
Both “m” and “R−tH” are smaller than 2 ω · DL−1 . In this case, from (Equation 9), the magnitude relationship between u and R cannot be determined only by the most significant bits of “tH” and “m”.

この場合、前述した[演算式1]で演算を実行することが必要となり、(数式3)の演算結果でキャリー(Carry)が発生した場合のみNの減算処理を行なう。   In this case, it is necessary to execute the calculation according to [Calculation Formula 1] described above, and the N subtraction process is performed only when a carry occurs as a result of the calculation of Formula 3.

(a−3)"t"のMSB=0"m"のMSB=1
この場合は、tH <2ω・DL−1,m >2ω・DL−1の場合に相当する。
この場合、
R−m <2ω・DL −2ω・DL −1=2ω・DL −1
であり、"tH "も"R−m"も両方2ω・DL−1より小さい。この場合、(数式8)より、"tH "と"m"の最上位ビットだけではuとNの大小関係は判定できない。
また、
R−tH >2ω・DL −2ω・DL −1=2ω・DL −1
であり、"m"も"R−tH"も両方2ω・DL−1より大きい。この場合、(数式9)より、"tH "と"m"の最上位ビットだけではuとRの大小関係は判定できない。
(A-3) MSB of "t" = 0 MSB of "m" = 1
This case corresponds to the case of tH <2ω · DL-1 , m> 2ω · DL-1 .
in this case,
Rm <2 ω · DL −2 ω · DL −1 = 2 ω · DL −1
Both “tH” and “Rm” are smaller than 2 ω · DL−1 . In this case, from (Equation 8), the magnitude relationship between u and N cannot be determined only by the most significant bits of “tH” and “m”.
Also,
R-tH> 2 ω · DL −2 ω · DL −1 = 2 ω · DL −1
Both “m” and “R−tH” are larger than 2 ω · DL−1 . In this case, from (Equation 9), the magnitude relationship between u and R cannot be determined only by the most significant bits of “tH” and “m”.

この場合、前述した[演算式1]で演算を実行することが必要となり、(数式3)の演算結果でキャリー(Carry)が発生した場合のみNの減算処理を行なう。   In this case, it is necessary to execute the calculation according to [Calculation Formula 1] described above, and the N subtraction process is performed only when a carry occurs as a result of the calculation of Formula 3.

(a−4)"t"のMSB=0"m"のMSB=0
この場合は、tH <2ω・DL−1,m <2ω・DL−1 の場合に相当する。
この場合、
R−tH >2ω・DL −2ω・DL −1=2ω・DL −1
であり、"m "は2ω・DL−1以下で、N/R<1より"m×N/R"は2ω・DL−1以下である。一方、"R−tH "は2ω・DL −1以上であるため、(数式9)式より、
u<R
となる。
(A-4) MSB of “t” = 0 MSB = 0 of “m”
This case corresponds to the case of tH <2ω · DL−1 and m < 2ω · DL-1 .
in this case,
R-tH> 2 ω · DL −2 ω · DL −1 = 2 ω · DL −1
"M" is 2 ω · DL-1 or less, and from N / R <1, "m × N / R" is 2 ω · DL-1 or less. On the other hand, since “R−tH” is 2 ω · DL −1 or more, from Equation (9),
u <R
It becomes.

このように、"t"のMSB=0"m"のMSB=0の場合、u<Rが成立し、前述の[演算式3]の演算を実行可能であり、減算処理の省略が可能となる。   Thus, when MSB of “t” = 0 and MSB = 0 of “m”, u <R is established, and the above-described operation of [Calculation Equation 3] can be executed, and the subtraction process can be omitted. Become.

以上、説明した、"tH"と "m"の最上位1ビットに着目したときの、"u"と "N" または"R"との大小関係を示したのが、図2である。   FIG. 2 shows the magnitude relationship between “u” and “N” or “R” when focusing on the most significant 1 bit of “tH” and “m” described above.

図2に示すように、"t"と"m"の最上位ビット(MSB)の組み合わせが(0,0)であれば、u<Rが示され、(1,1)であれば、u>Nが示され、これらの組み合わせの場合には、前述の[演算式2]または[演算式3]の適用が可能となり、減算処理を省略することができる。図中[?]の示された組み合わせ、すなわち、"t"と"m"の最上位ビット(MSB)の組み合わせが(0,1)または(1,0)の場合には、u<Rまたはu>Nであることが示されず、前述の[演算式1]を適用した処理、すなわちキャリーが発生した場合にNの減算処理を伴う演算を実行することになる。   As shown in FIG. 2, if the combination of the most significant bits (MSB) of “t” and “m” is (0, 0), u <R is indicated, and if (1, 1), u > N is shown, and in the case of a combination of these, the above-described [Calculation Formula 2] or [Calculation Formula 3] can be applied, and the subtraction process can be omitted. [? ], That is, when the combination of the most significant bit (MSB) of “t” and “m” is (0, 1) or (1, 0), u <R or u> N If it is not shown, the process to which the above-described [Calculation Formula 1] is applied, that is, the operation involving the subtraction process of N is executed when a carry occurs.

(b)"t"と"m"の上位2ビットの組み合わせに基づく処理   (B) Processing based on combination of upper 2 bits of “t” and “m”

"t"と"m"の上位2ビットの組み合わせは、図3に示すように、t=00〜11、m=00〜11の4通り×4通りの組み合わせであり、全部で16通りの組み合わせがある。図3に示すように、"t"と"m"の上位2ビットの組み合わせが(t,m)=(00,00)、(00,01)、(00,10)、(01,00)、(01,01)、(10,00)であれば、u<Rが示され、(t,m)=(01,11)、(10,10)、(10,11)、(11,01)、(11,10)、(11,11)、であれば、u>Nが示され、これらの組み合わせの場合には、前述の[演算式2]または[演算式3]の適用が可能となり、減算処理を省略することができる。図中[?]の示された組み合わせ、すなわち、(t,m)=(00,11)、(01,10)、(10,01)、(11,00)の場合には、u<Rまたはu>Nであることが示されず、前述の[演算式1]を適用した処理、すなわち必要に応じて減算処理を伴う演算を実行することになる。   As shown in FIG. 3, the combinations of the upper 2 bits of “t” and “m” are four combinations of t = 00 to 11, m = 00 to 11, and 16 combinations in total. There is. As shown in FIG. 3, the combination of the upper 2 bits of “t” and “m” is (t, m) = (00, 00), (00, 01), (00, 10), (01, 00). , (01,01), (10:00), u <R is indicated, and (t, m) = (01,11), (10,10), (10,11), (11, If (01), (11, 10), (11, 11), u> N is indicated. In the case of a combination of these, the above-described [Calculation Formula 2] or [Calculation Formula 3] is applied. The subtraction process can be omitted. [? ], I.e., (t, m) = (00,11), (01,10), (10,01), (11.00), u <R or u> N In other words, a process to which the above-described [Calculation Formula 1] is applied, that is, an operation involving a subtraction process is executed as necessary.

以下、"t"と"m"の上位2ビットの各組み合わせにおいて、u<Rまたはu>Nが成立することが示される組み合わせ、または成立することが示されない組み合わせについて説明する。   Hereinafter, in each combination of the upper two bits of “t” and “m”, a combination that indicates that u <R or u> N is satisfied or a combination that is not indicated to be satisfied will be described.

なお、前述の(a)"t"と"m"の最上位ビット(MSB)の組み合わせに基づく処理において、t,mのMSBが両者とも0の場合は、u<Rが成立し、両者とも1の場合は、u>Nが成立することが証明されているので、これらの場合以外の組み合わせについて説明する。図3における太線枠で示す8パターンについて説明する。   In the processing based on the combination of the most significant bit (MSB) of (a) “t” and “m” described above, if both the MSBs of t and m are 0, u <R holds, and both In the case of 1, since it is proved that u> N holds, combinations other than these cases will be described. The eight patterns indicated by the thick frame in FIG. 3 will be described.

(b−1)tの上位2ビット=11、mの上位2ビット=01
この場合は、2ω・DL >tH >3×2ω・DL−2,2ω・DL−2<m<2ω・DL−1の場合に相当する。
この場合、
3×2ω・DL-2 >R−m >2ω・DL-1
であり、
なおかつ、N/R<1であるため、(R−m)×N/Rは3×2ω・DL-2 以下である。一方、tH は3×2ω・DL-2 以上であるため、(数式8)より、
u>N
となる。
(B-1) upper 2 bits of t = 11, upper 2 bits of m = 01
This case corresponds to the case of 2ω · DL >tH> 3 × 2ω · DL-2 , 2ω · DL-2 <m < 2ω · DL-1 .
in this case,
3 × 2 ω · DL-2 >Rm> 2 ω · DL-1
And
Moreover, since N / R <1, (R−m) × N / R is 3 × 2 ω · DL−2 or less. On the other hand, since tH is 3 × 2 ω · DL-2 or more, from (Equation 8),
u> N
It becomes.

このように、tの上位2ビット=11、mの上位2ビット=01の場合、u>Nが成立し、前述の[演算式2]の演算を実行可能であり、減算処理の省略が可能となる。   Thus, when the upper 2 bits of t = 11 and the upper 2 bits of m = 01, u> N is established, and the above-described operation of [Expression 2] can be executed, and the subtraction process can be omitted. It becomes.

(b−2)tの上位2ビット=11、mの上位2ビット=00
この場合は、2ω・DL >tH >3×2ω・DL−2,0<m<2ω・DL−2 の場合に相当する。
この場合、
ω・DL >R−m >3×2ω・DL-2
である。
この場合、"u"と"N"の大小関係の判定はできない。また、0 <R−tH <2ω・DL-2である。この場合、"u"と"R"の大小関係の判定はできない。
(B-2) upper 2 bits of t = 11, upper 2 bits of m = 00
This case corresponds to the case of 2ω · DL >tH> 3 × 2ω · DL-2 , 0 <m < 2ω · DL-2 .
in this case,
2 ω ・ DL >Rm> 3 × 2 ω ・ DL-2
It is.
In this case, the magnitude relationship between “u” and “N” cannot be determined. 0 <R-tH <2ω · DL-2 . In this case, the magnitude relationship between “u” and “R” cannot be determined.

この場合、前述した[演算式1]で演算を実行することが必要となり、(数式3)の演算結果でキャリー(Carry)が発生した場合のみNの減算処理を行なう。   In this case, it is necessary to execute the calculation according to [Calculation Formula 1] described above, and the N subtraction process is performed only when a carry occurs as a result of the calculation of Formula 3.

(b−3)tの上位2ビット=10、mの上位2ビット=01
この場合は、3×2ω・DL−2>tH >2ω・DL−1,2ω・DL−2<m<2ω・DL−1 の場合に相当する。
この場合、
3×2ω・DL-2 >R−m >2ω・DL-1
である。
この場合、"u"と"N"の大小関係の判定はできない。また、
ω・DL-2 <R−tH <2ω・DL-1
である。この場合、"u"と"R"の大小関係の判定はできない。
(B-3) upper 2 bits of t = 10, upper 2 bits of m = 01
This case corresponds to the case of 3 × 2ω · DL−2 >tH> 2ω · DL−1 , 2ω · DL−2 <m < 2ω · DL-1 .
in this case,
3 × 2 ω · DL-2 >Rm> 2 ω · DL-1
It is.
In this case, the magnitude relationship between “u” and “N” cannot be determined. Also,
2 ω ・ DL-2 <R-tH <2 ω ・ DL-1
It is. In this case, the magnitude relationship between “u” and “R” cannot be determined.

この場合、前述した[演算式1]で演算を実行することが必要となり、(数式3)の演算結果でキャリー(Carry)が発生した場合のみNの減算処理を行なう。   In this case, it is necessary to execute the calculation according to [Calculation Formula 1] described above, and the N subtraction process is performed only when a carry occurs as a result of the calculation of Formula 3.

(b−4)tの上位2ビット=10、mの上位2ビット=00
この場合は、3×2ω・DL−2>tH >2ω・DL−1,0<m<2ω・DL−2 の場合に相当する。
N/R<1であるため、m×N/Rは2ω・DL-2 以下である。
一方、2ω・DL-2 <R−tH <2ω・DL-1であるため、R−tH は2ω・DL-2 以上である。このため、(数式9)より、
u<Rとなる。
(B-4) upper 2 bits of t = 10, upper 2 bits of m = 00
This case corresponds to the case of 3 × 2ω · DL−2 >tH> 2ω · DL−1 and 0 <m < 2ω · DL−2 .
Since N / R <1, m × N / R is 2 Ω · DL−2 or less.
On the other hand, since 2ω · DL-2 <R-tH <2ω · DL-1 , R-tH is equal to or greater than 2ω · DL-2 . For this reason, from (Equation 9),
u <R.

この場合は、u<Rが成立し、前述の[演算式3]の演算を実行可能であり、減算処理の省略が可能となる。   In this case, u <R is established, and the above-described calculation of [Expression 3] can be executed, and the subtraction process can be omitted.

(b−5)tの上位2ビット=01、mの上位2ビット=11
この場合は、2ω・DL-2 <tH <2ω・DL−1,2ω・DL>m>3×2ω・DL−2 の場合に相当する。
この場合、
<R−m <2ω・DL-2
である。
N/R<1であるため、(R−m)×N/Rは2ω・DL-2 以下である。一方、tH は2ω・DL-2 以上であるため、(数式8)より、
u>Nとなる。
(B-5) upper 2 bits of t = 01, upper 2 bits of m = 11
This case corresponds to the case of 2ω · DL-2 <tH <2ω · DL-1 and 2ω · DL >m> 3 × 2ω · DL-2 .
in this case,
0 <Rm <2 ω ・ DL-2
It is.
Since N / R <1, (Rm) × N / R is 2 ω · DL−2 or less. On the other hand, since tH is 2 ω · DL-2 or more, from (Equation 8),
u> N.

この場合、u>Nが成立し、前述の[演算式2]の演算を実行可能であり、減算処理の省略が可能となる。   In this case, u> N is established, and the above-described calculation of [Expression 2] can be executed, and the subtraction process can be omitted.

(b−6)tの上位2ビット=01、mの上位2ビット=10
この場合は、2ω・DL-2 <tH <2ω・DL−1,3×2ω・DL-2>m>2ω・DL−1 の場合に相当する。
この場合、
ω・DL-2 <R−m <2ω・DL-1
である。
この場合、"u"と"N"の大小関係の判定はできない。また、
3×2ω・DL-2>R−tH >2ω・DL-1
である。この場合、"u"と"R"の大小関係の判定はできない。
(B-6) upper 2 bits of t = 01, upper 2 bits of m = 10
This case corresponds to the case of 2ω · DL-2 <tH <2ω · DL-1 and 3 × 2ω · DL-2 >m> 2ω · DL-1 .
in this case,
2 ω ・ DL-2 <Rm <2 ω ・ DL-1
It is.
In this case, the magnitude relationship between “u” and “N” cannot be determined. Also,
3 × 2 ω ・ DL-2 >R-tH> 2 ω ・ DL-1
It is. In this case, the magnitude relationship between “u” and “R” cannot be determined.

この場合、前述した[演算式1]で演算を実行することが必要となり、(数式3)の演算結果でキャリー(Carry)が発生した場合のみNの減算処理を行なう。   In this case, it is necessary to execute the calculation according to [Calculation Formula 1] described above, and the N subtraction process is performed only when a carry occurs as a result of the calculation of Formula 3.

(b−7)tの上位2ビット=00、mの上位2ビット=11
この場合は、0 <tH <2ω・DL−2,2ω・DL>m>3×2ω・DL−2 の場合に相当する。
この場合、
<R−m <2ω・DL-2
である。
この場合、"u"と"N"の大小関係の判定はできない。また、
ω・DL >R−tH >3×2ω・DL-2
である。この場合、"u"と"R"の大小関係の判定はできない。
(B-7) upper 2 bits of t = 00, upper 2 bits of m = 11
In this case, 0 This corresponds to the case of <tH <2ω · DL-2 , 2ω · DL >m> 3 × 2ω · DL-2 .
in this case,
0 <Rm <2 ω ・ DL-2
It is.
In this case, the magnitude relationship between “u” and “N” cannot be determined. Also,
2 ω ・ DL >R-tH> 3 × 2 ω ・ DL-2
It is. In this case, the magnitude relationship between “u” and “R” cannot be determined.

この場合、前述した[演算式1]で演算を実行することが必要となり、(数式3)の演算結果でキャリー(Carry)が発生した場合のみNの減算処理を行なう。   In this case, it is necessary to execute the calculation according to [Calculation Formula 1] described above, and the N subtraction process is performed only when a carry occurs as a result of the calculation of Formula 3.

(b−8)tの上位2ビット=00、mの上位2ビット=10
この場合は、0 <tH <2ω・DL−2,3×2ω・DL-2>m>2ω・DL−1 の場合に相当する。
N/R<1であるため、m×N/Rは3×2ω・DL-2 以下である。一方、
ω・DL >R−tH >3×2ω・DL-2
であるため、R−tH は3×2ω・DL-2 以上である。このため、(数式9)より
u<R
となる。
(B-8) upper 2 bits of t = 00, upper 2 bits of m = 10
In this case, 0 This corresponds to the case of <tH <2ω · DL-2 , 3 × 2ω · DL-2 >m> 2ω · DL-1 .
Since N / R <1, m × N / R is 3 × 2 ω · DL−2 or less. on the other hand,
2 ω ・ DL >R-tH> 3 × 2 ω ・ DL-2
Therefore, R-tH is 3 × 2 ω · DL−2 or more. Therefore, from (Equation 9), u <R
It becomes.

この場合は、u<Rが成立し、前述の[演算式3]の演算を実行可能であり、減算処理の省略が可能となる。   In this case, u <R is established, and the above-described calculation of [Expression 3] can be executed, and the subtraction process can be omitted.

以上、説明した、"tH"と "m"の上位2ビットに着目したときの、"u"と "N" または"R"との大小関係を示したのが、図3である。   FIG. 3 shows the magnitude relationship between “u” and “N” or “R” when focusing on the upper 2 bits of “tH” and “m” described above.

図3に示すように、"t"と"m"の上位2ビットの組み合わせパターン16通り中、6通りにおいてu<Rが示され、他の6通りにおいてu>Nが示され、これら12通りの組み合わせの場合には、前述の[演算式2]または[演算式3]の適用が可能となり、減算処理を省略することができる。図中[?]の示された4通りの組み合わせのみが、u<Rまたはu>Nであることが証明されず、前述の[演算式1]を適用した処理、すなわちキャリーが発生した場合にNの減算処理を伴う演算を実行することになる。   As shown in FIG. 3, among 16 combinations of the upper two bits of “t” and “m”, u <R is shown in 6 ways, u> N is shown in the other 6 ways, and these 12 ways In the case of this combination, the above-mentioned [Calculation Formula 2] or [Calculation Formula 3] can be applied, and the subtraction process can be omitted. [? ] Are not proved to be u <R or u> N, and the processing to which the above-mentioned [Calculation Expression 1] is applied, that is, when carry occurs, N is subtracted. An operation involving is performed.

"t"と"m"の最上位ビット(MSB)のみを検討した場合は、4通り中、2通り、すなわち、50%の組み合わせにおいて、[演算式2]または[演算式3]の適用が可能となり、減算処理を省略することができるという結果であったが、"t"と"m"の上位2ビットを検討した場合は、16通り中、12通り、すなわち、75%の組み合わせにおいて、[演算式2]または[演算式3]の適用が可能となり、減算処理を省略することができるという結果を得ることができる。   When only the most significant bit (MSB) of “t” and “m” is considered, it is possible to apply [Calculation 2] or [Calculation 3] in 2 out of 4 combinations, that is, in 50% of combinations. As a result, the subtraction process can be omitted. However, when the upper 2 bits of “t” and “m” are considered, 12 out of 16 patterns, that is, 75% of combinations, It is possible to apply [Calculation Formula 2] or [Calculation Formula 3] and obtain a result that the subtraction process can be omitted.

"t"と"m"の上位3ビットに着目し、組み合わせデータ毎に、u<Rまたはu>Nが成立するか否かを示した図が図4である。図4に示すように、t=000〜111、m=000〜111の8通り×8通りの組み合わせであり、全部で64通りの組み合わせがある。図4に示すように、"t"と"m"の上位3ビットに着目した場合は、64通り中、56通り、すなわち、87.5%の組み合わせにおいて、[演算式2]または[演算式3]の適用が可能となり、減算処理を省略することができるという結果を得ることができる。   FIG. 4 shows whether or not u <R or u> N holds for each combination data, focusing on the upper 3 bits of “t” and “m”. As shown in FIG. 4, there are 8 combinations of t = 000 to 111 and m = 000 to 111, and there are 64 combinations in total. As shown in FIG. 4, when attention is paid to the upper 3 bits of “t” and “m”, 56 out of 64, that is, 87.5% of combinations, [Calculation 2] or [Calculation 3] can be applied, and the result that the subtraction process can be omitted can be obtained.

このように、本発明においては、モンプロ(MonPro)演算における中間値として算出される"t"と"m"の上位ビットの組み合わせに基づいてu>Nであるか、または、u<Rであることが示される場合に、減算処理を伴う[演算式1]を実行することなく、[演算式2]または[演算式3]を適用した演算を実行する構成としたので、演算サイクルが削減され、処理の高速化が実現される。   As described above, in the present invention, u> N or u <R based on the combination of the upper bits of “t” and “m” calculated as the intermediate value in the MonPro operation. In such a case, the calculation cycle is reduced because the calculation applying [calculation expression 2] or [calculation expression 3] is executed without executing [calculation expression 1] accompanied by the subtraction process. High speed processing is realized.

なお、上述した例では、モンプロ(MonPro)演算における中間値として算出される"t"と"m"の最上位〜3ビットの組み合わせについて説明したが、さらに、上位4ビット以上の多ビット情報を検出し、それらの検出ビットに基づいて、実行演算式を決定する構成としてもよい。着目する最上位ビット数を増やすほど、"u"と "N" または"R"との大小関係が特定できない組合せの比率が減少し、積和演算後の Carry 発生時に、多倍長減算を実行する回数が減少する。   In the above-described example, the combination of “t” and “m”, which are calculated as the intermediate value in the MonPro operation, is described in combination with the most significant bit to 3 bits. It is good also as a structure which detects and determines an execution arithmetic expression based on those detection bits. As the number of most significant bits increases, the ratio of combinations where the magnitude relationship between “u” and “N” or “R” cannot be specified decreases, and multiple length subtraction is performed when Carry occurs after product-sum operation The number of times to do decreases.

[3.本発明の演算処理および装置と従来構成との比較]
次に、本発明の演算処理および装置について、従来構成との比較に基づいて、説明する。いわゆる、従来からの改良モンゴメリ(Montgomery)法は、通常のモンゴメリ(Montgomery)法が、剰余及び除算を2DL・ωで実行するのに対し、演算器のビット幅である2ωで行なうことで、演算サイクル数を削減した演算手法である。従来の改良モンゴメリ(Montgomery)法に基づく演算フローを以下に示す。
[3. Comparison between arithmetic processing and apparatus of the present invention and conventional configuration]
Next, the arithmetic processing and apparatus of the present invention will be described based on a comparison with a conventional configuration. The so-called improved Montgomery method is based on the fact that the normal Montgomery method performs the remainder and division with 2 DL · ω, but with 2 ω which is the bit width of the arithmetic unit. This is a calculation method in which the number of calculation cycles is reduced. The calculation flow based on the conventional improved Montgomery method is shown below.

MonPro(a*,b*):
t=a*×b* ・・・・・・・・・・・・(数式16)
for i = 0 to DL−1
m=t0×N0' mod r ・・・・・・(数式17)
t:=(t+m×N)/r ・・・・(数式18)
next i
if Carry=1 then return t−N
else return t ・・(数式19)
MonPro (a * , b * ):
t = a * × b * (Equation 16)
for i = 0 to DL-1
m = t 0 × N 0 'mod r (Equation 17)
t: = (t + m × N) / r (Expression 18)
next i
if Carry = 1 then return t-N
else return t (Equation 19)

このフローで、
DL :剰余数"N"のワード数
r :演算器の幅をω[bit]とした時、r=2ω
t0:演算の中間値"t"をt=Σi=0 DL-1i・2ω・i とした時の、0ワード目の値
0':パラメータ"N'"をN'=Σi=0 DL-1N'i・2ω・i とした時の、0ワード目の値を表わす。このフローでは、ループの最後の演算でキャリー(Carry)が発生した場合、ループの演算結果"t"から剰余数"N"を引いたものを演算結果としている。
In this flow,
DL: Number of words of remainder number “N” r: When the width of the arithmetic unit is ω [bit], r = 2 ω
t 0 : Value of the 0th word when the intermediate value “t” of the operation is t = Σ i = 0 DL-1 t i · 2 ω · i N 0 ': Parameter "N'" is N '= Σ i = 0 DL-1 N ′ i · 2 ω · i represents the value of the 0th word. In this flow, when a carry occurs in the last calculation of the loop, a calculation result obtained by subtracting the remainder “N” from the calculation result “t” of the loop is used.

これに対して本発明に係る改良モンゴメリ(Montgomery)法において、演算フローは以下のようになる。
MonPro(a*,b*):
t=a*×b* ・・・・・・・・・・・・(数式20)
for i = 0 to DL−2
m=t0×N0' mod r ・・・・・・(数式21)
t:=(t+m×N)/r ・・・・(数式22)
next i
m=t0×N0' mod r ・・・・・・・・(数式23)
(mとtの上位ビットから、(t+m×N)/r>Nと判断できる場合)
u=(t−(r−m)×N)/r ・・・(数式24)
(mとtの上位ビットから、(t+m×N)/r<Rと判断できる場合)
u=(t+m×N)/r ・・・・・・・(数式25)
(mとtの上位ビットから、上記どちらの判断もできない場合)
u=(t+m×N)/r ・・・・・・・(数式26)
if Carry=1 then return u−N
else return u ・・・(数式27)
In contrast, in the improved Montgomery method according to the present invention, the calculation flow is as follows.
MonPro (a * , b * ):
t = a * × b * (Equation 20)
for i = 0 to DL-2
m = t 0 × N 0 'mod r (Formula 21)
t: = (t + m × N) / r (Expression 22)
next i
m = t 0 × N 0 'mod r (Equation 23)
(When it is possible to determine (t + m × N) / r> N from the upper bits of m and t)
u = (t− (r−m) × N) / r (Equation 24)
(When it can be determined from the upper bits of m and t that (t + m × N) / r <R)
u = (t + m × N) / r (Equation 25)
(If neither of the above can be determined from the upper bits of m and t)
u = (t + m × N) / r (Equation 26)
if Carry = 1 then return u-N
else return u (Formula 27)

上述の演算フローにおいて、(数式24)の演算は、"m"の2の補数と"N"の乗算値を"t"から引き、その結果を1ワードずらす処理により行なう。実際の演算方法は後述する。   In the above calculation flow, the calculation of (Equation 24) is performed by subtracting the 2's complement of “m” and the multiplication value of “N” from “t” and shifting the result by one word. The actual calculation method will be described later.

上述した本発明の改良モンゴメリ(Montgomery)法を実行する演算処理装置の構成例を図5に示す。   FIG. 5 shows a configuration example of an arithmetic processing unit that executes the above-described improved Montgomery method of the present invention.

図5に示すように、演算処理装置は、制御部101、演算部102、メモリ入出力制御部103、および第1〜第4メモリ111〜114を有する。制御部101は演算部102に対して様々な制御信号、例えば桁上げに伴う処理を実行させるための制御信号、前述の[演算式1]〜[演算式3]を選択的に実行させるための制御信号などを出力する。   As illustrated in FIG. 5, the arithmetic processing device includes a control unit 101, a calculation unit 102, a memory input / output control unit 103, and first to fourth memories 111 to 114. The control unit 101 causes the calculation unit 102 to selectively execute various control signals, for example, control signals for executing processing associated with carry, the above-described [Calculation Formula 1] to [Calculation Formula 3]. Output control signals.

演算部102には、メモリ入出力制御部103を介して第1〜第4メモリ111〜114から演算処理対象データが入力される。第1〜第4メモリ111〜114には、乗数・被乗数・被加算値、演算結果等がそれぞれ格納される。この例では、各メモリからの入力データは32ビット構成であり、各メモリに対するデータ指定用アドレスは10ビットデータとした例を示している。   Arithmetic processing target data is input to the arithmetic unit 102 from the first to fourth memories 111 to 114 via the memory input / output control unit 103. The first to fourth memories 111 to 114 store multipliers, multiplicands, added values, calculation results, and the like. In this example, input data from each memory has a 32-bit configuration, and a data designation address for each memory is 10-bit data.

この構成で、多倍長の積和演算を行なう演算フローとしては、下記の(1)、(2)の2種類ある。   With this configuration, there are two types of calculation flows (1) and (2) below for performing multiple-length product-sum operations.

(1)例えば乗数の1ワードに着目し、被乗数との多倍長乗算を行ない、それと平行して被加算値をメモリから読出して乗算結果と加算を行ない、結果をメモリに格納する。次に、乗数のワードを1ワード上位の値として被乗数との多倍長乗算を行ない、それと平行して被加算値をメモリから読出して乗算結果と加算を行ない、結果をメモリに格納する。これを、乗数のワードが最上位ワードになるまで繰り返す。   (1) For example, paying attention to one word of the multiplier, multi-precision multiplication with the multiplicand is performed, and in parallel with this, the added value is read from the memory, the multiplication result and addition are performed, and the result is stored in the memory. Next, a multiple length multiplication with the multiplicand is performed with the multiplier word as a value one word higher, and the added value is read from the memory in parallel with the multiplication result, the multiplication result and addition are performed, and the result is stored in the memory. This is repeated until the multiplier word becomes the most significant word.

(2)乗算結果の桁数が同じになる乗数、被乗数の組合せでの乗算を行なう。この乗算の前に、乗算結果と同じ桁となる被加算値をメモリから読出して、加算器にセットして、乗算結果と加算をしていく。それと平行して乗算結果と同じ桁となる被加算値をメモリから読出して加算し、その後下位ワードをメモリに格納し、上位ワードを加算器の下位ワードに移し、乗算結果の桁数が1ワード上となる乗算を行なう。これを、乗数、被乗数が共に最上位になるまで繰り返す。   (2) Multiplication is performed with a combination of a multiplier and a multiplicand in which the number of digits of the multiplication result is the same. Before this multiplication, an added value having the same digit as the multiplication result is read from the memory, set in an adder, and added to the multiplication result. In parallel, the added value that has the same digit as the multiplication result is read from the memory and added, then the lower word is stored in the memory, the upper word is moved to the lower word of the adder, and the number of digits of the multiplication result is one word. Perform the upper multiplication. This is repeated until both the multiplier and multiplicand become the highest.

上記(1)の演算方法では、同じサイクルで同一メモリから演算の途中結果を読出して乗算結果と加算してその結果をメモリに書込む必要があり、高速なメモリが必要となる。一方、(2)の多倍長乗算手法は、このような高速メモリは必ずしも必要とはならない。   In the calculation method of (1), it is necessary to read out the intermediate result of the calculation from the same memory in the same cycle, add it to the multiplication result, and write the result into the memory, which requires a high-speed memory. On the other hand, the multiple multiplication method of (2) does not necessarily require such a high-speed memory.

(2)の多倍長乗算手法を実現する多倍長積和演算の演算部の構成および演算処理について、図6〜図9を参照して説明する。   The configuration of the arithmetic unit and the arithmetic processing of the multiple-precision product-sum operation that implements the multiple-precision multiplication method (2) will be described with reference to FIGS.

上述した本発明の演算、すなわち、モンプロ(MonPro)演算における中間値として算出される"t"と"m"の上位ビットの組み合わせに基づいてu>Nであるか、または、u<Rであることが示される場合に、減算処理を伴う[演算式1]を実行することなく、[演算式2]または[演算式3]を適用した演算を実行する演算処理装置構成、および処理について、従来型の演算処理装置構成と処理と対比しながら説明する。   Based on the combination of the upper bits of “t” and “m” calculated as an intermediate value in the above-described operation of the present invention, that is, the MonPro operation, u> N or u <R. For the arithmetic processing unit configuration and the processing for executing the operation to which the [arithmetic expression 2] or the [arithmetic expression 3] is applied without executing the [arithmetic expression 1] accompanied by the subtraction process, A description will be given while comparing the configuration and processing of the type arithmetic processing unit.

まず、図6および図7を参照して多倍長の積和演算、
u=t+m×N
の演算処理について説明する。
First, referring to FIG. 6 and FIG.
u = t + m × N
The calculation process will be described.

演算処理装置の外部から演算命令が発行され、演算処理装置に入力されると、制御部からの制御により、乗数・被乗数・被加算値の格納されているメモリをアクセスし、必要なデータを演算部にセットすると共に、演算結果をメモリに格納する。   When an arithmetic instruction is issued from the outside of the arithmetic processing unit and input to the arithmetic processing unit, the memory storing the multiplier / multiplicand / added value is accessed under the control of the control unit, and necessary data is calculated. The result of the operation is stored in the memory.

この例では、乗数及び被乗数(m,N)は4ワード構成であり、図6に示す[データ1]、[データ2]として設定され、被加算値(t)は8ワードであり、図6に示す[データ3]として設定される。演算結果が[データ4]となる。   In this example, the multiplier and multiplicand (m, N) have a 4-word configuration, and are set as [data 1] and [data 2] shown in FIG. 6, and the added value (t) is 8 words. [Data 3] shown in FIG. The calculation result is [Data 4].

まず、被加算値(t)の構成ワードt0,t1,t2 が[データ3]としてセレクタ214を介して加算器215にセットされ、乗数及び被乗数(m,N)の構成ワードm0とN0が[データ1]、[データ2]として、ラッチ211を介して乗算器212にセットされ、乗算が開始される。 First, the constituent words t 0 , t 1 , t 2 of the added value (t) are set to the adder 215 via the selector 214 as [Data 3], and the constituent words m 0 of the multiplier and multiplicand (m, N) are set. And N 0 are set as [data 1] and [data 2] in the multiplier 212 via the latch 211, and multiplication is started.

乗算器212における乗算結果"mN00L","mN00H"は、ラッチ213を介して加算器215に入力されて、t0,t1と加算され、キャリーが発生した場合は、t2が+1される。この演算結果の各ワードをu0,u1,u2 とすると、各ワードu0,u1,u2 は、ラッチ216を介して加算器215から出力され、ワードu0は、演算結果としてメモリに出力される。また、ワードu1とu2 は1ワードずつ下位側にシフトしてセレクタ214を介して加算器215の下位2ワードにセットされると共に、加算器215の最上位にt3がセットされる。 The multiplication results “mN 00L ” and “mN 00H ” in the multiplier 212 are input to the adder 215 via the latch 213 and added to t 0 and t 1, and when carry occurs, t 2 becomes +1. Is done. If each word of the operation result is u 0 , u 1 , u 2 , each word u 0 , u 1 , u 2 is output from the adder 215 via the latch 216, and the word u 0 is output as the operation result. Output to memory. The words u 1 and u 2 are shifted one word at a time to the lower side and set to the lower two words of the adder 215 via the selector 214, and t 3 is set to the uppermost position of the adder 215.

一方、乗算器212には、ラッチ211を介してm1とN0がセットされて乗算が実行され、乗算結果"mN10L","mN10H"はu1,u2 と加算される。この加算でキャリーが発生した場合、t3が+1される。この演算結果をu1',u2',u3'とした場合、これらは加算器215の一方にセットされ、乗算器212には m0 と N1 がセットされて乗算が実行され、乗算結果"mN01L","mN01H"はu1',u2'と加算される。この加算でキャリーが発生した場合、u3'が+1される。 On the other hand, in the multiplier 212, m 1 and N 0 are set via the latch 211, multiplication is performed, and the multiplication results “mN 10L ” and “mN 10H ” are added to u 1 and u 2 . When a carry is generated by this addition, t 3 is incremented by one. When this calculation result is u 1 ′, u 2 ′, u 3 ′, these are set in one of the adders 215, m 0 and N 1 are set in the multiplier 212, and multiplication is performed. The results “mN 01L ” and “mN 01H ” are added to u 1 ′ and u 2 ′. When a carry is generated by this addition, u 3 ′ is incremented by one.

この演算結果をu1'',u2'',u3''とした場合、u1''はメモリに出力され、u2''とu3 ''は1ワードずつ下位側にシフトして加算器215の下位2ワードにセットされると共に、加算器215の最上位にt4 がセットされる。そして、乗算器212にはm2 と N0 がセットされて次の桁の積和演算が実行される。 When the result of this operation is u 1 ″, u 2 ″, u 3 ″, u 1 ″ is output to the memory, and u 2 ″ and u 3 ″ are shifted one word at a time to the lower side. Are set in the lower two words of the adder 215 and t 4 is set in the most significant bit of the adder 215. Then, m 2 and N 0 are set in the multiplier 212, and the product-sum operation for the next digit is executed.

以下、同様に図7に示す演算フローに従って多倍長の積和演算が実行され、最終的にキャリーを含めて9ワードの演算結果[Carry〜u0]が得られるが、モンゴメリ(Montgomery)演算では下位4ワードは"0"となるため、有効な値は下位5ワード目より上位の値である。そして、この演算結果が剰余数"N"より大きければ、"N"を引いた値を演算結果とする。また、このモンゴメリ(Montgomery)演算がルーブ(Loop)の途中であれば、キャリー(Carry)が発生した場合のみ"N"を引いて演算結果とし、これを次のモンゴメリ(Montgomery)演算に用いる。   Similarly, a multiple-length multiply-accumulate operation is executed according to the operation flow shown in FIG. 7, and finally a 9-word operation result [Carry to u0] including carry is obtained. In the Montgomery operation, Since the lower 4 words are “0”, the effective value is higher than the lower 5 words. If this calculation result is larger than the remainder number “N”, a value obtained by subtracting “N” is set as the calculation result. If this Montgomery operation is in the middle of a loop, only when a carry occurs, “N” is subtracted to obtain the operation result, which is used for the next Montgomery operation.

一方、本発明の演算処理、すなわち、モンプロ(MonPro)演算における中間値として算出される"t"と"m"の上位ビットの組み合わせに基づいてu>Nであるか、または、u<Rであることが示される場合に、減算処理を伴う[演算式1]を実行することなく、[演算式2]または[演算式3]を適用した演算を実行する演算処理装置構成、および処理について、図8、図9を参照して説明する。   On the other hand, u> N based on the combination of upper bits of “t” and “m” calculated as an intermediate value in the arithmetic processing of the present invention, that is, the MonPro operation, or u <R. When it is shown that there is an arithmetic processing device configuration and a process for executing an arithmetic operation to which [arithmetic expression 2] or [arithmetic expression 3] is applied without executing [arithmetic expression 1] accompanied by a subtraction process, This will be described with reference to FIGS.

本発明の演算処理を実現するための演算部(図8)には、図6に示す従来の積和演算器にない追加構成として、反転器311、加算器312、セレクタ313、反転・非反転回路314を持つ。このうち、311〜313の回路は、乗算器212の一方の入力、すなわち入力信号[データ1]の入力部に設けられている。   The arithmetic unit (FIG. 8) for realizing the arithmetic processing of the present invention has an inverter 311, an adder 312, a selector 313, an inverting / non-inverting as an additional configuration not provided in the conventional product-sum calculator shown in FIG. A circuit 314 is included. Among these, the circuits 311 to 313 are provided at one input of the multiplier 212, that is, the input portion of the input signal [data 1].

すなわち、本発明の演算処理装置は、乗算器212の一方の入力が、入力信号[データ1]と、その値の反転信号とを選択して入力する構成を採り、[データ1]に入力される多倍長データで最下位のワードが[データ1]にセットされた時のみ、加算器214のキャリー(Carry)入力["Cry1"]が"1"に制御される。   That is, the arithmetic processing unit of the present invention employs a configuration in which one input of the multiplier 212 selects and inputs the input signal [data 1] and the inverted signal of the value, and is input to [data 1]. The carry input ["Cry1"] of the adder 214 is controlled to "1" only when the least significant word in the multiple length data is set to [Data 1].

乗算器212における乗算結果を加算器215に入力するとき、乗算結果とその反転信号を選択して入力する構成を採り、反転信号を選択した場合、多倍長演算の最初の時のみ、加算器215のキャリー(Carry)入力["Cry2"]が"1"に制御される。これらの構成が付加されている点が図6に示す従来の積和演算器と異なる点である。   When the multiplication result in the multiplier 212 is input to the adder 215, the multiplication result and its inverted signal are selected and input. When the inverted signal is selected, the adder is only in the first stage of the multiple length operation. The Carry input ["Cry2"] of 215 is controlled to "1". The point that these configurations are added is different from the conventional product-sum calculator shown in FIG.

この図8に示す演算器でモンゴメリ(Montgomery)演算を行なう場合、乗数及び被乗数、すなわち、[データ1]、[データ2]に対応する"m"と"t"の上位ビットの組合せで積和演算結果"u"が"u>N"と判定されない場合、[データ1]はそのまま乗算器に入力され、乗算結果は反転する事無くそのまま加算器に入力され、通常の積和演算と同じように演算される。   When the Montgomery operation is performed by the arithmetic unit shown in FIG. 8, a product sum is obtained by a combination of the higher bits of “m” and “t” corresponding to the multiplier and multiplicand, that is, [Data 1] and [Data 2]. When the operation result “u” is not determined as “u> N”, [Data 1] is input to the multiplier as it is, and the multiplication result is input to the adder as it is without being inverted, as in the normal product-sum operation. Is calculated.

一方、"m"と"t"の上位ビットの組合せで積和演算結果"u"が"u>N"と判定される場合、[データ1]は反転され、[データ1]が最下位ワードの場合は反転データに+1した値が、それ以外の場合は反転データが乗算器に入力される。乗算結果は反転して加算器に入力され、乗算器入力が共に最下位ワードの場合のみ加算器のキャリー(Carry)入力["Cry2"]が"1"に固定され、それ以外の場合には"0"に固定され、
u=(t−(R−m)×N)/R
が実行される。
On the other hand, when the product-sum operation result “u” is determined to be “u> N” with the combination of the upper bits of “m” and “t”, [Data 1] is inverted and [Data 1] is the least significant word. In this case, the value obtained by adding 1 to the inverted data is input to the multiplier. In other cases, the inverted data is input to the multiplier. The result of multiplication is inverted and input to the adder. The carry input ["Cry2"] of the adder is fixed to "1" only when both multiplier inputs are the least significant word. Fixed to "0",
u = (t− (R−m) × N) / R
Is executed.

演算結果"u"は"N"以下となっているため、その後の多倍長の減算は不要となる。この時の演算フローを図9に示す。この演算フローにおいて、m'は以下の式で表される
m'=Σi=0 3 i'・2ω・i =R−Σi=0 3 i・2ω・i
Since the calculation result “u” is equal to or less than “N”, subsequent multiple length subtraction is not necessary. The calculation flow at this time is shown in FIG. In this calculation flow, m ′ is expressed by the following equation: m ′ = Σ i = 0 3 m i ′ · 2 ω · i = R−Σ i = 0 3 m i · 2 ω · i

改良 Montgomery 演算を用いる場合、"m"と"t"の上位ビットの組合せで積和演算結果"u"が"u>N"と判定されない場合、[データ1]はそのまま乗算器に入力され、乗算結果は反転すること無くそのまま加算器に入力され、通常の積和演算と同じように演算される。   When the improved Montgomery operation is used, if the product-sum operation result “u” is not determined as “u> N” by the combination of the upper bits of “m” and “t”, [Data 1] is directly input to the multiplier, The multiplication result is directly input to the adder without being inverted, and is calculated in the same manner as a normal product-sum operation.

一方、"m"と"t"の上位ビットの組合せで積和演算結果"u"が"u>N"と判定される場合、[データ1]は反転され、"m"は1ワードであるため反転データに+1した値が乗算器の一方に入力される。乗算結果は反転して加算器に入力され、乗算器入力が共に最下位ワードの場合のみ加算器のキャリー(Carry)入力["Cry2"]が"1"に固定され、それ以外の場合には"0"に固定され、
u=(t−(r−m)×N)/r
が実行される。
On the other hand, when the product-sum operation result “u” is determined as “u> N” by the combination of the upper bits of “m” and “t”, [Data 1] is inverted, and “m” is one word. Therefore, a value obtained by adding 1 to the inverted data is input to one of the multipliers. The result of multiplication is inverted and input to the adder. The carry input ["Cry2"] of the adder is fixed to "1" only when both multiplier inputs are the least significant word. Fixed to "0",
u = (t− (r−m) × N) / r
Is executed.

演算結果"u"は"N"以下であるため、その後の多倍長の減算は不要となる。   Since the calculation result “u” is equal to or less than “N”, subsequent multiple length subtraction is not necessary.

以上、説明したように、本発明の演算処理構成によれば、モンゴメリ(Montgomery)演算での積和演算で、その後の多倍長の減算を実行する回数を削減し、暗号演算のトータルの演算サイクル数を削減することができる。   As described above, according to the arithmetic processing configuration of the present invention, the total number of cryptographic operations can be reduced by reducing the number of times of subsequent multiple-precision subtraction in the product-sum operation in the Montgomery operation. The number of cycles can be reduced.

なお、図8に示す演算部に対して、データ1の反転データを入力するか、非反転データを入力するか、さらに桁上げを実行するか否かの制御信号は、図5に示す制御部101から演算部102に対して出力される。   In addition, the control signal indicating whether inverted data of data 1 is input, non-inverted data is input, or carry is further executed is the control unit shown in FIG. 101 is output to the calculation unit 102.

すなわち、本発明の演算処理装置は、メッセージ文をM,暗号文をC、公開鍵をe、秘密鍵をd、剰余数をNとし、暗号化:C=M mod N、復号化:M=C mod Nにより暗号化・復号化を行うRSA暗号において、モンゴメリ法を適用し、RをNより大きい2のべき乗値、N'=−N−1modRとして、下記演算式[演算式1]
MonPro(a*,b*):
t=a*×b*
m=t×N' mod R
u=(t+m×N)/R
if Carry=1 then return u−N
else return u
に従ったモンプロ演算を実行する演算処理装置であり、モンプロ演算プロセスにおける中間値として取得されるt,mの値を構成する上位ビットの組み合わせに基づいて、制御部101から制御信号を演算部102に出力し、演算部102は、制御信号に従って、前述の[演算式1]〜[演算式3]のいずれかの演算処理を選択的に実行する構成である。
That is, the arithmetic processing unit of the present invention uses M as the message text, C as the ciphertext, e as the public key, d as the secret key, and N as the remainder, and encryption: C = M e mod N, decryption: M = In RSA encryption that performs encryption / decryption with C d mod N, Montgomery method is applied, and R is a power of 2 greater than N, and N ′ = − N −1 mod R ]
MonPro (a * , b * ):
t = a * × b *
m = t × N ′ mod R
u = (t + m × N) / R
if Carry = 1 then return u-N
else return u
Is a calculation processing device that executes a monpro operation according to the control unit 101, based on a combination of upper bits constituting the values of t and m acquired as an intermediate value in the monpro calculation process. The calculation unit 102 is configured to selectively execute any one of the above-described [Calculation Formula 1] to [Calculation Formula 3] according to the control signal.

演算部102は、図8に示すように、上記[演算式1]における値uの算出処理を実行する乗算器212および加算器215を有するとともに、乗算器212の一方のデータ入力段に反転器311および、加算器312、セレクタ313及び反転・非反転回路314を設けた構成である。制御部101は、モンプロ演算プロセスにおける中間値として取得されるt,mの値を構成する上位ビットの組み合わせに基づいて、乗算器212の一方の入力データを反転データまたは非反転データとして選択入力するように演算部102に制御信号を出力する。   As shown in FIG. 8, the arithmetic unit 102 includes a multiplier 212 and an adder 215 that execute the calculation process of the value u in the above [Operational Expression 1], and an inverter at one data input stage of the multiplier 212. 311, an adder 312, a selector 313, and an inverting / non-inverting circuit 314. The control unit 101 selectively inputs one input data of the multiplier 212 as inverted data or non-inverted data based on a combination of upper bits constituting t and m values acquired as intermediate values in the monpro calculation process. In this manner, a control signal is output to the calculation unit 102.

さらに、制御部101は、データ1の入力が最下位ワードである場合に、加算器312による桁上げ(Carry)を実行し、該桁上げ処理後のデータを乗算器212に入力するように演算部102の制御を実行する。   Further, when the input of data 1 is the least significant word, the control unit 101 performs a carry by the adder 312 and performs an operation so as to input the data after the carry processing to the multiplier 212. The control of the unit 102 is executed.

また、制御部101は、前記[演算式1]中のt,mの上位ビットの組み合わせを判別し、判別データに基づいてTemp1=u−N>0であると判定される場合に、下記[演算式2]
u=(t−(R−m)×N)/R
に従って実行するように演算部102を制御し、
Temp2=u−R<0であると判定される場合に、
下記[演算式3]
u=(t+m×N)/R
に従って実行するように、演算部102の制御を実行する。
Further, the control unit 101 determines the combination of the upper bits of t and m in [Calculation Formula 1], and when it is determined that Temp1 = u−N> 0 based on the determination data, the following [ Formula 2]
u = (t− (R−m) × N) / R
Control the arithmetic unit 102 to execute according to
When it is determined that Temp2 = u−R <0,
[Calculation formula 3] below
u = (t + m × N) / R
The control of the calculation unit 102 is executed so as to execute according to the above.

例えば、制御部101は、t,mの最上位ビットの組み合わせが、(t,m)=(1,1)であるとき、Temp2=u−R<0であると判定し、前記[演算式3]に従って実行するように演算部102を制御し、t,mの最上位ビットの組み合わせが、(t,m)=(0,0)であるとき、Temp1=u−N>0であると判定し、前記[演算式2]に従って実行するように演算部102の制御を実行する。   For example, when the combination of the most significant bits of t and m is (t, m) = (1, 1), the control unit 101 determines that Temp 2 = u−R <0, and 3], and when the combination of the most significant bits of t and m is (t, m) = (0, 0), Temp1 = u−N> 0 The control of the calculation unit 102 is executed so as to execute the determination according to [Calculation Formula 2].

また、制御部101は、t,mの最上位ビットまたは上位複数ビットの組み合わせに基づいて、Temp1=u−N>0であるか、Temp2=u−R<0であるか、いずれでもないかを判定し、Temp1=u−N>0である場合には、モンプロ演算を、前記[演算式2]に従って実行するように演算部102を制御し、Temp2=u−R<0である場合には、モンプロ演算を、前記[演算式3]に従って実行するように演算部102を制御し、いずれでもない場合には、モンプロ演算を、前記[演算式1]に従って実行するように演算部102を制御する。   Further, the control unit 101 determines whether Temp1 = u−N> 0 or Temp2 = u−R <0 based on the combination of the most significant bit or the upper multiple bits of t and m. When Temp1 = u−N> 0 is satisfied, the arithmetic unit 102 is controlled to execute the monpro operation according to the above [Calculation Expression 2], and when Temp2 = u−R <0. Controls the arithmetic unit 102 to execute the monpro operation according to the [arithmetic expression 3], and if not, the arithmetic unit 102 is executed to execute the monpro arithmetic according to the [arithmetic expression 1]. Control.

以上、特定の実施例を参照しながら、本発明について詳解してきた。しかしながら、本発明の要旨を逸脱しない範囲で当業者が該実施例の修正や代用を成し得ることは自明である。すなわち、例示という形態で本発明を開示してきたのであり、限定的に解釈されるべきではない。本発明の要旨を判断するためには、冒頭に記載した特許請求の範囲の欄を参酌すべきである。   The present invention has been described in detail above with reference to specific embodiments. However, it is obvious that those skilled in the art can make modifications and substitutions of the embodiments without departing from the gist of the present invention. In other words, the present invention has been disclosed in the form of exemplification, and should not be interpreted in a limited manner. In order to determine the gist of the present invention, the claims section described at the beginning should be considered.

以上、説明したように、本発明の構成によれば、モンプロ演算プロセスにおける中間値として取得されるt,mの値を構成する上位ビットの組み合わせを判別し、該判別データに基づいて、モンプロ演算式における値uの算出式を変更して実行する構成とするとともに、uの算出において多倍長の減算処理を不要とした式に基づく処理の実行確率を高めたので、モンゴメリ(Montgomery)演算での積和演算での多倍長の減算処理の実行回数が削減され、トータルの演算サイクル数の削減が実現され、高速処理の要請される暗号処理デバイスにおいて適用可能である。   As described above, according to the configuration of the present invention, the combination of the upper bits constituting the values of t and m acquired as the intermediate value in the monpro calculation process is determined, and the monpro calculation is performed based on the determination data. Since the calculation formula of the value u in the formula is changed and executed, and the execution probability of the processing based on the formula that does not require the multiple length subtraction processing in the calculation of u is increased, the Montgomery operation The number of executions of multiple length subtraction processing in the product-sum operation is reduced, the total number of operation cycles is reduced, and the invention can be applied to cryptographic processing devices that require high-speed processing.

本発明の構成によれば、Temp2=u−R<0の場合のみならず、Temp1=u−N>0、すなわち、u>Nであることが示される場合においても、モンプロ(MonPro)演算における減算処理を省略することが可能となり、演算の高速化が実現され高速処理の要請される暗号処理デバイスにおいて適用可能である。   According to the configuration of the present invention, not only when Temp2 = u−R <0, but also when Temp1 = u−N> 0, that is, when u> N is indicated, in the MonPro operation. The subtraction process can be omitted, and the calculation can be speeded up and can be applied to a cryptographic processing device that requires high-speed processing.

本発明の演算処理装置において実行するモンプロ演算処理シーケンスを説明するフロー図である。It is a flowchart explaining the monpro arithmetic processing sequence performed in the arithmetic processing apparatus of this invention. モンプロ演算における中間値t,mの最上位ビットの各組み合わせにおいてu<Rまたはu>Nの得られる組み合わせを示す図である。It is a figure which shows the combination from which u <R or u> N is obtained in each combination of the most significant bits of the intermediate values t and m in the monpro operation. モンプロ演算における中間値t,mの上位2ビットの各組み合わせにおいてu<Rまたはu>Nの得られる組み合わせを示す図である。It is a figure which shows the combination from which u <R or u> N is obtained in each combination of the high-order 2 bits of the intermediate values t and m in the monpro operation. モンプロ演算における中間値t,mの上位3ビットの各組み合わせにおいてu<Rまたはu>Nの得られる組み合わせを示す図である。It is a figure which shows the combination from which u <R or u> N is obtained in each combination of the upper 3 bits of the intermediate values t and m in the monpro operation. モンゴメリ法を実行可能な積和演算処理を実行する演算処理装置構成を示す図である。It is a figure which shows the arithmetic processing unit structure which performs the product-sum calculation process which can perform the Montgomery method. モンゴメリ法を実行可能な積和演算処理を実行する演算処理装置における演算部構成を示す図である。It is a figure which shows the calculating part structure in the arithmetic processing apparatus which performs the product-sum arithmetic processing which can perform the Montgomery method. 図6に示す演算部を用いて実行する積和演算処理シーケンスについて説明する図である。It is a figure explaining the product-sum operation process sequence performed using the calculating part shown in FIG. モンゴメリ法を実行可能な積和演算処理を実行し、中間値t,mの上位ビットの各組み合わせに基づく効率的な演算を実行可能とした演算処理装置における演算部構成を示す図である。It is a figure which shows the calculating part structure in the arithmetic processing unit which performed the product-sum calculation process which can perform the Montgomery method, and was able to perform the efficient calculation based on each combination of the high-order bit of intermediate value t and m. 図8に示す演算部を用いて実行する積和演算処理シーケンスについて説明する図である。It is a figure explaining the product-sum calculation process sequence performed using the calculating part shown in FIG.

符号の説明Explanation of symbols

101 制御部
102 演算部
103 メモリ入出力制御部
111〜114 メモリ
211 ラッチ
212 乗算器
213 ラッチ
214 セレクタ
215 加算器
216 ラッチ
311 反転器
312 加算器
313 セレクタ
314 反転・非反転回路
DESCRIPTION OF SYMBOLS 101 Control part 102 Operation part 103 Memory input / output control part 111-114 Memory 211 Latch 212 Multiplier 213 Latch 214 Selector 215 Adder 216 Latch 311 Inverter 312 Adder 313 Selector 314 Inversion / non-inversion circuit

Claims (10)

メッセージ文をM,暗号文をC、公開鍵をe、秘密鍵をd、剰余数をNとし、
暗号化:C=M mod N
復号化:M=C mod N
により暗号化・復号化を行うRSA暗号においてモンゴメリ法を適用し、RをNより大きい2のべき乗値、N'=−N−1modRとして、下記演算式[演算式A][演算式1]に従ったモンプロ演算を実行する演算処理方法であり、
[演算式A]
MonPro(a*,b*):
t=a*×b*
m=t×N' mod R
[演算式1]
u=(t+m×N)/R
if Carry=1 then return u−N
else return u
上記モンプロ演算における中間値として取得されるt,mの値を構成する上位ビットの組み合わせを判別し、該判別データに基づいて、上記式における値uの算出式を変更して実行することを特徴とする演算処理方法。
The message text is M, the cipher text is C, the public key is e, the secret key is d, the remainder is N,
Encryption: C = M e mod N
Decryption: M = C d mod N
The Montgomery method is applied to the RSA cipher that performs encryption / decryption by the following equation, R is a power of 2 greater than N, and N ′ = − N −1 modR: Is an arithmetic processing method for executing a monpro operation according to
[Calculation formula A]
MonPro (a * , b * ):
t = a * × b *
m = t × N ′ mod R
[Calculation Formula 1]
u = (t + m × N) / R
if Carry = 1 then return u-N
else return u
A combination of upper bits constituting the values of t and m acquired as an intermediate value in the Montpro calculation is determined, and based on the determination data, the calculation formula of the value u in the above formula is changed and executed. An arithmetic processing method.
前記演算処理方法において、
前記[演算式A]中のt,mの上位ビットの組み合わせを判別し、該判別データに基づいてu>Nであると判定される場合に、
モンプロ演算のuの算出を、下記[演算式2]
[演算式2]
u=(t−(R−m)×N)/R
に従って実行し、
u<Rであると判定される場合に、
モンプロ演算のuの算出を、下記[演算式3]
[演算式3]
u=(t+m×N)/R
に従って実行することを特徴とする請求項1に記載の演算処理方法。
In the arithmetic processing method,
When the combination of the upper bits of t and m in the [arithmetic expression A] is determined and it is determined that u> N based on the determination data,
The calculation of monpro calculation u is as follows: [Equation 2]
[Calculation formula 2]
u = (t− (R−m) × N) / R
Run according to
If it is determined that u <R,
The calculation of u in the monpro operation is as follows: [Equation 3]
[Calculation Formula 3]
u = (t + m × N) / R
The calculation processing method according to claim 1, wherein the calculation processing method is executed according to:
t,mの最上位ビットの組み合わせが、(t,m)=(1,1)であるとき、
u<Rであると判定し、モンプロ演算のuの算出を、前記[演算式3]に従って実行し、
t,mの最上位ビットの組み合わせが、(t,m)=(0,0)であるとき、
u>Nであると判定し、モンプロ演算のuの算出を、前記[演算式2]に従って実行することを特徴とする請求項2に記載の演算処理方法。
When the combination of the most significant bits of t and m is (t, m) = (1, 1),
It is determined that u <R, and the calculation of u of the Montpro calculation is executed according to the above [Calculation Formula 3].
When the combination of the most significant bits of t and m is (t, m) = (0, 0),
The calculation processing method according to claim 2, wherein it is determined that u> N, and calculation of u of the monpro calculation is executed according to the [calculation expression 2].
前記演算処理方法は、
t,mの最上位ビットまたは上位複数ビットの組み合わせに基づいて、u>Nであると判定されるか、u<Rであると判定されるか、いずれとも判定できないかを判断し、
u>Nであると判定される場合には、モンプロ演算のuの算出を、前記[演算式2]に従って実行し、
u<Rであると判定される場合には、モンプロ演算のuの算出を、前記[演算式3]に従って実行し、
いずれとも判定できない場合には、モンプロ演算を、前記[演算式1]に従って実行することを特徴とする請求項2に記載の演算処理方法。
The arithmetic processing method is:
Based on the combination of the most significant bit or the upper multiple bits of t and m, determine whether u> N, u <R, or neither can be determined,
When it is determined that u> N, the calculation of u in the monpro calculation is executed according to the above [Calculation Formula 2],
When it is determined that u <R, the calculation of u of the monpro operation is executed according to the above [Operational Formula 3],
3. The arithmetic processing method according to claim 2, wherein if neither of the determinations is possible, the monpro operation is executed according to the [calculation expression 1].
メッセージ文をM,暗号文をC、公開鍵をe、秘密鍵をd、剰余数をNとし、
暗号化:C=M mod N
復号化:M=C mod N
により暗号化・復号化を行うRSA暗号において、モンゴメリ法を適用し、RをNより大きい2のべき乗値、N'=−N−1modRとして、下記演算式[演算式A][演算式1]に従ったモンプロ演算を実行する演算処理装置であり、
[演算式A] MonPro(a*,b*):
t=a*×b*
m=t×N' mod R
[演算式1] u=(t+m×N)/R
if Carry=1 then return u−N
else return u
前記[演算式1]における値uの算出処理を実行する乗算器および加算器を有するとともに、前記乗算器の一方のデータ入力段に反転器およびセレクタを設けた演算部と、
前記モンプロ演算における中間値として取得されるt,mの値を構成する上位ビットの組み合わせに基づいて、前記乗算器の一方の入力データを反転データまたは非反転データとして選択入力するように演算部に制御信号を出力する制御部と、
を有することを特徴とする演算処理装置。
The message text is M, the cipher text is C, the public key is e, the secret key is d, the remainder is N,
Encryption: C = M e mod N
Decryption: M = C d mod N
In the RSA encryption that performs encryption / decryption by using the Montgomery method, R is a power of 2 greater than N, and N ′ = − N −1 modR, and the following arithmetic expression [calculation expression A] [calculation expression 1 Is an arithmetic processing unit that executes a monpro calculation according to
[Operational Formula A] MonPro (a * , b * ):
t = a * × b *
m = t × N ′ mod R
[Calculation Formula 1] u = (t + m × N) / R
if Carry = 1 then return u-N
else return u
An arithmetic unit having a multiplier and an adder for executing the calculation process of the value u in [Operational Formula 1], and having an inverter and a selector at one data input stage of the multiplier;
Based on a combination of upper bits constituting the values of t and m acquired as intermediate values in the monpro operation, the arithmetic unit is configured to selectively input one input data of the multiplier as inverted data or non-inverted data. A control unit for outputting a control signal;
An arithmetic processing apparatus comprising:
前記演算部は、さらに、
前記反転器およびセレクタ間に桁上げ(Carry)信号による+1処理を実行する加算器を有し、
前記制御部は、前記乗算器入力が共に最下位ワードである場合に、前記加算器による桁上げ(Carry)を実行し、該桁上げ処理後のデータを前記乗算器に入力するように前記演算部の制御を実行する構成を有することを特徴とする請求項5に記載の演算処理装置。
The calculation unit further includes:
An adder for performing +1 processing by a carry signal between the inverter and the selector;
The controller executes the carry by the adder when both of the multiplier inputs are the least significant word, and inputs the data after the carry processing to the multiplier. The arithmetic processing apparatus according to claim 5, wherein the arithmetic processing apparatus has a configuration for executing control of a unit.
前記演算部はさらに、
前記乗算器と加算器の間に反転・非反転制御回路を有し、
前記モンプロ演算における中間値として取得されるt,mの値を構成する上位ビットの組合せに基づいて、
前記乗算器の出力データを反転データまたは非反転データとして前記加算器の一方へ選択入力するように演算部に制御信号を出力する制御部と、
を有することを特徴とする請求項5に記載の演算処理装置。
The calculation unit further includes:
Having an inversion / non-inversion control circuit between the multiplier and the adder;
Based on the combination of the upper bits constituting the values of t and m acquired as intermediate values in the monpro operation,
A control unit that outputs a control signal to the arithmetic unit so as to selectively input the output data of the multiplier as inverted data or non-inverted data to one of the adders;
The arithmetic processing apparatus according to claim 5, comprising:
前記制御部は、
前記[演算式A]中のt,mの上位ビットの組み合わせを判別し、該判別データに基づいてu>Nであると判定される場合に、
モンプロ演算のuの算出を、下記[演算式2]
[演算式2]
u=(t−(R−m)×N)/R
に従って実行するように前記演算部を制御し、
u<Rであると判定される場合に、
モンプロ演算のuの算出を、下記[演算式3]
[演算式3]
u=(t+m×N)/R
に従って実行するように、前記演算部の制御を実行する構成であることを特徴とする請求項5乃至7いずれかに記載の演算処理装置。
The controller is
When the combination of the upper bits of t and m in the [arithmetic expression A] is determined and it is determined that u> N based on the determination data,
The calculation of monpro calculation u is as follows: [Equation 2]
[Calculation formula 2]
u = (t− (R−m) × N) / R
Controlling the arithmetic unit to execute according to
If it is determined that u <R,
The calculation of u in monpro calculation is as follows: [Equation 3]
[Calculation Formula 3]
u = (t + m × N) / R
The arithmetic processing apparatus according to claim 5, wherein the arithmetic processing unit is configured to execute control of the arithmetic unit so that the arithmetic processing unit is executed according to the control unit.
前記制御部は、
t,mの最上位ビットの組み合わせが、(t,m)=(1,1)であるとき、
u<Rであると判定し、モンプロ演算のuの算出を、前記[演算式3]に従って実行するように前記演算部を制御し、
t,mの最上位ビットの組み合わせが、(t,m)=(0,0)であるとき、
u>Nであると判定し、モンプロ演算のuの算出を、前記[演算式2]に従って実行するように前記演算部の制御を実行する構成であることを特徴とする請求項8に記載の演算処理装置。
The controller is
When the combination of the most significant bits of t and m is (t, m) = (1, 1),
It is determined that u <R, and the calculation unit is controlled so as to execute the calculation of u of the monpro calculation according to [Calculation Formula 3],
When the combination of the most significant bits of t and m is (t, m) = (0, 0),
9. The configuration according to claim 8, wherein it is determined that u> N and the control of the calculation unit is executed so that the calculation of u of the monpro calculation is executed according to the [calculation expression 2]. Arithmetic processing device.
前記制御部は、
t,mの最上位ビットまたは上位複数ビットの組み合わせに基づいて、u>Nであると判定されるか、u<Rであると判定されるか、いずれとも判定できないかを判定し、
u>Nであると判定される場合には、モンプロ演算のuの算出を、前記[演算式2]に従って実行するように前記演算部を制御し、
u<Rであると判定される場合には、モンプロ演算のuの算出を、前記[演算式3]に従って実行するように前記演算部を制御し、
いずれでもない場合には、モンプロ演算を、前記[演算式1]に従って実行するように前記演算部を制御する構成であることを特徴とする請求項9に記載の演算処理装置。
The controller is
determining whether u> N, u <R, or neither can be determined based on the combination of the most significant bits or the upper multiple bits of t and m,
When it is determined that u> N, the calculation unit is controlled to execute the calculation of the monpro calculation u according to the [calculation expression 2],
If it is determined that u <R, the calculation unit is controlled so as to execute the calculation of the monpro calculation u according to [Calculation Formula 3],
10. The arithmetic processing apparatus according to claim 9, wherein if not any of the above, the arithmetic processing unit is configured to control the arithmetic unit so that a monpro arithmetic is executed according to the [arithmetic expression 1].
JP2003271527A 2003-07-07 2003-07-07 Method and device for arithmetic processing Pending JP2005031472A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2003271527A JP2005031472A (en) 2003-07-07 2003-07-07 Method and device for arithmetic processing

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2003271527A JP2005031472A (en) 2003-07-07 2003-07-07 Method and device for arithmetic processing

Publications (1)

Publication Number Publication Date
JP2005031472A true JP2005031472A (en) 2005-02-03

Family

ID=34209368

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2003271527A Pending JP2005031472A (en) 2003-07-07 2003-07-07 Method and device for arithmetic processing

Country Status (1)

Country Link
JP (1) JP2005031472A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9811318B2 (en) 2014-03-31 2017-11-07 Samsung Electronics Co., Ltd. Montgomery multiplication method for performing final modular reduction without comparison operation and montgomery multiplier

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9811318B2 (en) 2014-03-31 2017-11-07 Samsung Electronics Co., Ltd. Montgomery multiplication method for performing final modular reduction without comparison operation and montgomery multiplier

Similar Documents

Publication Publication Date Title
TWI386818B (en) Cryptographically secure modular polynomial reduction method and computational hardware for executing the same
JP4668931B2 (en) Encryption processor with tamper resistance against power analysis attacks
US7903811B2 (en) Cryptographic system and method for encrypting input data
JP4909403B2 (en) How to request data safely
CN109039640B (en) Encryption and decryption hardware system and method based on RSA cryptographic algorithm
CN107040362A (en) Modular multiplication apparatus and method
US8300810B2 (en) Method for securely encrypting or decrypting a message
JP2009500892A (en) Apparatus and method for protecting a data processing device against attack or analysis
JP5182364B2 (en) Cryptographic processing method with tamper resistance against side channel attack
JP2009500710A (en) Apparatus and method for protecting a data processing device against attack or analysis
KR100442218B1 (en) Power-residue calculating unit using montgomery algorithm
Hutter et al. NaCl’s crypto_box in hardware
US8781112B2 (en) Signed montgomery arithmetic
JP4351987B2 (en) Montgomery conversion device, arithmetic device, IC card, encryption device, decryption device, and program
KR20080014857A (en) Randomized modular polynomial reduction method and hardware therefor
JP2010139544A (en) Apparatus and method for calculating remainder
US7983415B2 (en) Method for performing iterative scalar multiplication which is protected against address bit attack
JP2004004341A (en) Apparatus and method for modulo exponentiation calculation, and program
US7113593B2 (en) Recursive cryptoaccelerator and recursive VHDL design of logic circuits
TW201802666A (en) Non-modular multiplier, method for non-modular multiplication and computational device
JP2005031472A (en) Method and device for arithmetic processing
JP3904421B2 (en) Remainder multiplication arithmetic unit
US10318245B2 (en) Device and method for determining an inverse of a value related to a modulus
WO2008013154A1 (en) Extension filed multiplication program and extension filed multiplication device
JP4664514B2 (en) Prime number generating apparatus and program