JP2004240299A - Hash function processor - Google Patents
Hash function processor Download PDFInfo
- Publication number
- JP2004240299A JP2004240299A JP2003031044A JP2003031044A JP2004240299A JP 2004240299 A JP2004240299 A JP 2004240299A JP 2003031044 A JP2003031044 A JP 2003031044A JP 2003031044 A JP2003031044 A JP 2003031044A JP 2004240299 A JP2004240299 A JP 2004240299A
- Authority
- JP
- Japan
- Prior art keywords
- register
- value
- hash function
- input data
- registers
- 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
Links
Images
Abstract
Description
【0001】
【発明の属する技術分野】
本発明は、ハッシュ関数処理装置に関し、より特定的には、情報通信等の分野においてセキュリティを保護するために、任意長のデータから、逆変換が困難な固定長の値(ハッシュ値)を求めるハッシュ関数処理装置に関する。
【0002】
【従来の技術】
近年、FTTH(Fiber To The Home )やADSL(Asymmetric Digital Subscriber Line)に代表される広帯域なIP(Internet Protocol )インフラが、家庭等にも普及している。これに伴い、高速性が要求されるIP伝送路上においても、メッセージの改竄防止等、セキュリティ技術に対する需要が高まっている。メッセージ改竄防止技術の代表例として、例えば、ハッシュ関数を用いる方法が知られている。ハッシュ関数とは、任意長のメッセージから、そのメッセージに固有な固定長の値(以下、ハッシュ値という)を求める関数である。ハッシュ関数を用いて得られたハッシュ値には、極めて高いランダム性がある。すなわち、異なるメッセージに対しては、極めて高い確率で異なるハッシュ値が得られる。このような特徴を有するハッシュ関数は、メッセージの改竄を検出するための手段として利用することができる。
【0003】
従来、ハッシュ関数の処理装置としては、例えば、特許文献1に記載された演算回路が知られている。特許文献1には、ハッシュ関数の一種であるThe SecureHash Algorithm における繰り返し処理(以下、ラウンド処理という)を行う演算回路が記載されている。この演算回路は、2段のパイプライン処理を行うことにより、ラウンド処理を高速に行う。
【0004】
【特許文献1】
特開2002−287635号公報
【0005】
【発明が解決しようとする課題】
しかしながら、上記従来の演算回路は、ハッシュ関数におけるラウンド処理を行うために、フィードバックデータを格納する5個のレジスタと、演算の中間結果を格納する1個以上のレジスタとを備えている。このように、この演算回路には、回路規模の増大やコストの増加という課題がある。
【0006】
それ故に、本発明は、より少ないハードウェアリソースを用いて、ハッシュ関数におけるラウンド処理を高速に実行するハッシュ関数処理装置を提供することを目的とする。
【0007】
【課題を解決するための手段および発明の効果】
第1の発明は、入力データに対して、ハッシュ関数で定められた繰り返し処理を行うハッシュ関数処理装置であって、フィードバックデータを格納する第1から第4のレジスタと、所定長の入力データを供給する入力データ供給部と、ハッシュ関数で定められた定数値を供給する定数値供給部と、第4のレジスタの値と、入力データ供給部から供給される入力データと、定数値供給部から供給される定数値とに対して、所定の演算処理を行う第1の演算処理部と、第1の演算処理部による演算結果を格納する中間値格納レジスタと、第1から第4のレジスタの値と、中間値格納レジスタの値とに対して、所定の演算処理を行う第2の演算処理部とを備え、第1および第2の演算処理部は並列に動作し、かつ、中間値格納レジスタが第1の演算処理部による演算結果を取り込む動作と、第1のレジスタが第2の演算処理部による演算結果を取り込む動作と、第2のレジスタが第1のレジスタの値を取り込む動作と、第3のレジスタが第2のレジスタの値を巡回シフトした値を取り込む動作と、第4のレジスタが第3のレジスタの値を取り込む動作と、入力データ供給部が次の入力データを取得する動作と、定数値供給部が次の定数値を取り込む動作とが、1つのクロックサイクル内で並列に行われることを特徴とする。
このような第1の発明によれば、第1および第2の演算回路は並列に動作し、第1の演算回路の出力は中間値格納レジスタに書き込まれ、第2の演算回路の入力は中間値格納レジスタ等から供給される。これにより、第1および第2の演算回路と中間値格納レジスタとにより、2段のパイプライン処理が行われる。また、パイプラインに適切なタイミングでデータを供給するために、繰り返し処理で使用される入力データおよび定数値は、本来取得すべきタイミングよりも1クロックサイクル前に取得される。したがって、ハッシュ関数における繰り返し処理を、外見上1ラウンドあたり1クロックサイクルで高速に実行することができる。これに加えて、フィードバックデータを格納するレジスタの数を削減し、従来よりも少ないハードウェアリソースを用いて、ハッシュ関数における繰り返し処理を高速に実行することができる。
【0008】
第2の発明は、第1の発明において、第1の演算処理部は、第4のレジスタの値と、入力データ供給部から供給される入力データと、定数値供給部から供給される定数値とを加算することを特徴とする。
【0009】
第3の発明は、第1の発明において、第2の演算処理部は、第2から第4のレジスタの値に対して所定の論理演算を行い、当該演算結果と、中間値格納レジスタの値と、第1のレジスタの値を巡回シフトした値とを加算することを特徴とする。
【0010】
第4の発明は、第1ないし第3のいずれかの発明において、ハッシュ関数がSHA1(The Secure Hash Algorithm 1 )であることを特徴とする。
このような第2ないし第4の発明によれば、SHA1アルゴリズムにおける繰り返し処理を、外見上1ラウンドあたり1クロックサイクルで高速に実行することができる。
【0011】
【発明の実施の形態】
(第1の実施形態)
図1は、本発明の第1の実施形態に係るハッシュ関数処理装置の論理回路図である。図1に示すハッシュ関数処理装置10は、ハッシュ関数の一種であるThe Secure Hash Algorithm 1 (以下、SHA1という)におけるラウンド処理を行う。SHA1は、任意長の入力データから、160ビットのハッシュ値を求める関数である。SHA1アルゴリズムでは、入力データは、先頭から順に512ビットずつに分割される。512ビットに分割された入力データは、さらに16個の語(1語は32ビット)に分割され、16個の語に対して所定の論理演算を行うことにより、80個の語が求められる。その上で、求めた80個の語を1つの単位(以下、ブロックデータという)として、以下に示す処理(以下、80ラウンド処理という)が順次行われる。
【0012】
80ラウンド処理では、32ビットの変数A、B、C、DおよびEが使用される。各ブロックデータに対して80ラウンド処理を行う前に、変数A〜Eには、所定の初期値As〜Es(最初のブロックデータである場合)、または、これまでのブロックデータに対する80ラウンド処理で求めた変数A〜Eの値(最初のブロックデータでない場合)のいずれかが設定される。その上で、変数iを0から79まで1ずつ順に増加させながら、次式(1)に示す演算が80回行われ、これと同時に、変数Eには変数Dの値が、変数Dには変数Cの値が、変数Cには変数Bの値を左に30ビット巡回シフトした値が、変数Bには変数Aの値がそれぞれ代入される。
E=(A<<<5)+Fi(B,C,D)+E+Wi+Ki …(1)
ただし、上式(1)において、<<< は左巡回シフトを表し、Fi、WiおよびKiは、それぞれ、i回目の演算における論理演算、32ビットの入力データ、および32ビットの定数値を表す。なお、SHA1アルゴリズムの詳細は、例えば、米国商務省:”Secure Hash Standard”, National Institue of Standardsand Technology, Federal Information Processing Standard (FIPS) 180−1, April 17, 1995. に記載されている。
【0013】
図1に示すハッシュ関数処理装置10は、レジスタ101〜107および111〜115、加算器121〜129、セレクタ130〜139、巡回シフト演算ブロック141および142、並びに論理演算ブロック151〜154を備えている。このうち、加算器126および127は、第1の演算処理部161を構成している。また、加算器128および129、セレクタ130、巡回シフト演算ブロック141、並びに論理演算ブロック151〜154は、第2の演算処理部162を構成している。
【0014】
図1に示す信号線のデータ幅は、160ビットの出力信号HVを除き、いずれも32ビットである。また、図1では、SHA1アルゴリズムにおけるラウンド処理を制御するための制御信号や制御回路は、図面の簡単化のために省略されている。なお、この記法は、後述する図3にも適用される。
【0015】
図1において、レジスタ101〜104は、それぞれ、SHA1アルゴリズムにおけるラウンド処理で使用されるフィードバックデータを格納する。レジスタ101〜104は、順に、第1のレジスタR1、第2のレジスタR2、第3のレジスタR3、および第4のレジスタR4とも呼ばれる。レジスタ105は、SHA1アルゴリズムにおけるラウンド処理を行うときの中間データを格納する。レジスタ106は、SHA1アルゴリズムにおけるラウンド処理で処理される、32ビットの入力データWiを格納する。入力データWiは、ハッシュ処理の対象となる元の入力データを32ビットずつに分割したデータ、または、このデータ4個の排他的論理和を左に1ビット巡回シフトしたデータのいずれかである。レジスタ107は、SHA1アルゴリズムにおけるラウンド処理で各ラウンド毎に予め定められた定数値Kiを格納する。レジスタ111〜115は、それぞれ、SHA1アルゴリズムにおける、これまでのブロックデータに対する80ラウンド処理で求めた値を格納する。
【0016】
加算器121は、レジスタ101の値とレジスタ111の値とを加算する。加算器122は、レジスタ102の値とレジスタ112の値とを加算する。加算器123は、レジスタ103の値とレジスタ113の値とを加算する。加算器124は、レジスタ104の値とレジスタ114の値とを加算する。加算器125は、レジスタ104の値とレジスタ115の値とを加算する。加算器126は、レジスタ106の値とレジスタ107の値とを加算する。加算器127は、レジスタ104の値と加算器126の出力とを加算する。加算器128は、セレクタ130の出力と巡回シフト演算ブロック141の出力とを加算する。加算器129は、レジスタ105の値と加算器128の出力とを加算する。
【0017】
セレクタ131は、SHA1アルゴルリズムにおけるラウンド処理開始前の初期値Asと、加算器121の出力とから、適切な値を選択して出力する。セレクタ132は、SHA1アルゴルリズムにおけるラウンド処理開始前の初期値Bsと、加算器122の出力とから、適切な値を選択して出力する。セレクタ133は、SHA1アルゴルリズムにおけるラウンド処理開始前の初期値Csと、加算器123の出力とから、適切な値を選択して出力する。セレクタ134は、SHA1アルゴルリズムにおけるラウンド処理開始前の初期値Dsと、加算器124の出力とから、適切な値を選択して出力する。セレクタ135は、SHA1アルゴルリズムにおけるラウンド処理開始前の初期値Esと、加算器125の出力とから、適切な値を選択して出力する。
【0018】
セレクタ136は、レジスタ111の値と、加算器129の出力とから、適切な値を選択して出力する。セレクタ137は、レジスタ112の値と、レジスタ101の値とから、適切な値を選択して出力する。セレクタ138は、レジスタ113の値と、巡回シフト演算ブロック142の出力とから、適切な値を選択して出力する。セレクタ139は、レジスタ114の値と、レジスタ115の値と、レジスタ103の値とから、適切な値を選択して出力する。セレクタ130は、論理演算ブロック151〜154の出力から、適切な値を選択して出力する。
なお、セレクタ130〜139は、後述するラウンド処理等を正しく行えるように、適切な値を選択して出力する。
【0019】
巡回シフト演算ブロック141および142は、SHA1アルゴリズムに従い、巡回シフト演算を行う。より詳細には、巡回シフト演算ブロック141は、入力を左に5ビット巡回シフトする。巡回シフト演算ブロック142は、入力を左に30ビット巡回シフトする。なお、巡回シフト演算ブロック141および142におけるシフト方向は、入力に含まれる各ビットを左側が上位となるように並べたときの左方向である。
【0020】
論理演算ブロック151〜154は、SHA1アルゴリズムにおけるラウンド処理で予め定められた4種類の論理演算のうち、いずれかを行う。具体的には、論理演算ブロック151は、第0〜第19ラウンドにおける論理演算を行う。論理演算ブロック152は、第20〜第39ラウンドにおける論理演算を行う。論理演算ブロック153は、第40〜第59ラウンドにおける論理演算を行う。論理演算ブロック154は、第60〜第79ラウンドにおける論理演算を行う。より詳細には、レジスタ102の値をX、レジスタ103の値をY、レジスタ104の値をZとし、論理和、論理積、否定および排他的論理和の各論理演算を、それぞれ、and、or、notおよびxorと表すとき、論理演算ブロック151は、「(XandY)or((notX)andZ)」なる論理演算を行う。
論理演算ブロック152および154は、「XxorYxorZ」なる論理演算を行う。論理演算ブロック153は、「(XandY)or(XandZ)or(YandZ)」なる論理演算を行う。なお、ハッシュ関数処理装置10は論理演算ブロック154を備えず、論理演算ブロック152が第60〜第79ラウンドにおける論理演算を行うこととしてもよい。
【0021】
ハッシュ関数処理装置10は、入力データに対して、まずハッシュ前処理を行い、次にラウンド処理を行い、最後にハッシュ後処理を行う。ハッシュ前処理では、最初のブロックデータを扱う前にレジスタに適切な値を設定する処理が行われる。ラウンド処理では、各ブロックデータに対して、SHA1アルゴリズムにおける第0〜第78ラウンドの処理と、ラウンド終端処理とが行われる。ラウンド終端処理では、(a)SHA1アルゴリズムにおける第79ラウンドの処理と、(b)今回求めた値と前回までに求めた値とを加算する処理と、(c)次のブロックデータを扱う前に各レジスタに適切な値を設定する処理とが行われる。ただし、最後のブロックデータに対しては、ラウンド終端処理は行われない。ハッシュ後処理では、上記(a)および(b)の処理が行われる。
【0022】
図2は、ハッシュ前処理、ラウンド処理、およびハッシュ後処理によって、レジスタ101〜107および111〜115の値が変化する様子を示す図である。図2において、マイナス記号は、レジスタの値が不定であることを表し、矢印は、レジスタの値が1つ前のクロックサイクルと同じであることを表す。なお、この記法は、後述する図4にも適用される。
【0023】
以下、図2を適宜参照しながら、ハッシュ関数処理装置10の動作を説明する。なお、以下の説明では、2つのレジスタAとBとが同じクロックサイクルでそれぞれある値を取り込むことを、レジスタAとBとは同時に値を取り込む、と表現する場合がある。
【0024】
(1)ハッシュ前処理
ハッシュ前処理は、レジスタ111〜115にSHA1アルゴリズムで定められた初期値(図2ではAs〜Es)が格納された状態で、2クロックサイクルをかけて行われる。第1のクロックサイクルでは、レジスタ104は、レジスタ115の値(図2ではEs)を取り込む。同時に、レジスタ101〜103は、それぞれ、レジスタ111〜113の値(図2ではAs〜Cs)を取り込む。同時に、レジスタ106および107は、それぞれ、外部から与えられた第0ラウンドで使用される入力データおよび定数値(図2ではW0およびK0)を取り込む。
【0025】
次に、第2のクロックサイクルでは、レジスタ105は、加算器127の出力(図2では(Es+W0+K0))を取り込む。同時に、レジスタ104は、レジスタ114の値(図2ではDs)を取り込む。同時に、レジスタ106および107は、それぞれ、外部から与えられた第1ラウンドで使用される入力データおよび定数値(図2ではW1およびK1)を取り込む。
【0026】
(2)ラウンド処理
第0〜第78ラウンドの処理は、1ラウンドあたり1クロックサイクルをかけて(すなわち、各ブロックデータに対して79クロックサイクルをかけて)行われる。第0〜第78ラウンドの処理では、各クロックサイクルにおいて、レジスタ104は、レジスタ103の値を取り込む。同時に、レジスタ103は、巡回シフト演算ブロック142の出力を取り込む。同時に、レジスタ102は、レジスタ101の値を取り込む。同時に、レジスタ101は、加算器129の出力を取り込む。同時に、レジスタ105は、加算器127の出力を取り込む。同時に、レジスタ106および107は、それぞれ、外部から与えられた、次の入力データおよび定数値を取り込む。ただし、第78ラウンドの処理では、レジスタ106および107は、任意の値を取り込んでもよい。
【0027】
例として、図2に示す第5ラウンドの処理を説明する。第0〜第4ラウンドの処理で求めた値を、順にE0、D0、C0、B0およびA0とするとき、第4ラウンドの処理を完了した時点で、レジスタ101〜104の値はそれぞれA0〜D0、レジスタ105の値は(E0+W5+K5)、レジスタ106の値はW6、レジスタ107の値はK6となっている。そこで、第5ラウンドの処理では、レジスタ104は、レジスタ103の値C0を取り込む。同時に、レジスタ103は、レジスタ102の値B0を左に30ビット巡回シフトした値(図2では、巡回シフト前と同じくB0と記載;以下、同様の記法を用いる)を取り込む。同時に、レジスタ102は、レジスタ101の値A0を取り込む。同時に、レジスタ101は、加算器129の出力E1を取り込む。ここで、E1は、式(1)において、A〜EにA0〜E0を、WiにW5を、KiにK5を代入したときに得られる値である。同時に、レジスタ105は、加算器127の出力(D0+W6+K6)を取り込む。同時に、レジスタ106および107は、それぞれ、次の入力データW7および次の定数値K7を取り込む。
【0028】
一方、ラウンド終端処理は、各ブロックデータに対して4クロックサイクルをかけて行われる。第1のクロックサイクルでは、レジスタ115は、加算器125の出力(図2ではEm)を取り込む。同時に、レジスタ104は、レジスタ103の値(図2ではD15)を取り込む。同時に、レジスタ103は、巡回シフト演算ブロック142の出力(図2ではC15)を取り込む。同時に、レジスタ102は、レジスタ101の値(図2ではB15)を取り込む。同時に、レジスタ101は、加算器129の出力(図2ではA15)を取り込む。
【0029】
次に、第2のクロックサイクルでは、レジスタ111〜114は、それぞれ、加算器121〜124の出力(図2ではAm〜Dm)を取り込む。なお、レジスタ101〜104は、任意の値を取り込んでもよく、ここでは1つ前のクロックサイクルの値を保持するものとする。
【0030】
次に、第3のクロックサイクルでは、レジスタ101〜103は、それぞれ、レジスタ111〜113の値(図2ではAm〜Cm)を取り込む。同時に、レジスタ104は、レジスタ115の値(図2ではEm)を取り込む。同時に、レジスタ106および107は、それぞれ、外部から与えられた第0ラウンドで使用される入力データおよび定数値(図2ではW0およびK0)を取り込む。
【0031】
次に、第4のクロックサイクルでは、レジスタ105は、加算器127の出力(図2では(Em+W0+K0))を取り込む。同時に、レジスタ104は、レジスタ114の値(図2ではDm)を取り込む。同時に、レジスタ106および107は、それぞれ、外部から与えられた第1ラウンドで使用される入力データおよび定数値(図2ではW1およびK1)を取り込む。なお、第3および第4のクロックサイクルでレジスタ106に取り込まれる入力データは、次のブロックデータに含まれるデータである。
【0032】
(3)ハッシュ後処理
ハッシュ後処理は、2クロックサイクルをかけて行われる。第1のクロックサイクルでは、レジスタ115は、加算器125の出力(図2ではEe)を取り込む。同時に、レジスタ104は、レジスタ103の値(図2ではD15)を取り込む。同時に、レジスタ103は、巡回シフト演算ブロック142の出力(図2ではC15)を取り込む。同時に、レジスタ102は、レジスタ101の値(図2ではB15)を取り込む。同時に、レジスタ101は、加算器129の出力(図2ではA15)を取り込む。
【0033】
次に、第2のクロックサイクルでは、レジスタ111〜114は、それぞれ、加算器121〜124の出力(図2ではAe〜De)を取り込む。なお、レジスタ101〜104は、任意の値を取り込んでもよく、ここでは1つ前のクロックサイクルの値を保持するものとする。
【0034】
第2のクロックサイクルが完了した時点でレジスタ111〜115に格納されている値(図2ではAe〜Ee)が、求めるべきハッシュ値となる。したがって、図示しない手段を用いてレジスタ111〜115の値を読み出すことにより、入力データ全体に対するハッシュ値を得ることができる。
【0035】
また、第2のクロックサイクルが完了する前の、レジスタ115および加算器121〜124の出力(図1に示す出力信号HV)は、求めるべきハッシュ値に一致する。したがって、ハッシュ関数処理装置10の外部に160ビットのレジスタを設け、設けたレジスタがこのときの出力信号HVを取り込むことにより、入力データ全体に対するハッシュ値を得ることができる。
【0036】
以下、ハッシュ関数処理装置10が奏する効果について説明する。式(1)に示すように、SHA1アルゴリズムにおけるラウンド処理では、入力データおよび定数値はフィードバックデータに依存しない。したがって、式(1)に示す演算は、次式(2)および(3)に示すように、2つの演算に分解することができる。ただし、式(2)および(3)では、Qは32ビットの変数である。
Q=E+Wi+Ki …(2)
E=(A<<<5)+Fi(B,C,D)+Q …(3)
【0037】
これに対応して、ハッシュ関数処理装置10は、式(2)に示す演算処理を行う第1の演算処理部161と、式(3)に示す演算処理を行う第2の演算処理部162と、第1の演算処理部161の出力を格納するレジスタ105とを備えている。また、第1の演算処理部161と第2の演算処理部162とは並列に動作し、第2の演算処理部162の出力はレジスタ105等から供給される。これにより、第1の演算処理部161と、第2の演算処理部162と、レジスタ105とよって、2段のパイプライン処理が行われる。また、パイプラインに適切なタイミングでデータを供給するために、各ラウンドで使用される入力データWiおよび定数値Kiは、本来読み込むべきタイミングよりも1クロックサイクル前に読み込まれる。
【0038】
また、ハッシュ関数処理装置10は、SHA1アルゴリズムにおけるラウンド処理を行うために、フィードバックデータを格納する4個のレジスタ101〜104と、演算の中間結果を格納する1個のレジスタ105とを備えている。つまり、ハッシュ関数処理装置10は、フィードバックデータを格納する5個のレジスタのうち1つを、演算の中間結果を格納するレジスタと兼用している。したがって、ハッシュ関数処理装置10によれば、従来よりも少ない個数のレジスタを用いて、従来と同様のパイプライン処理を行うことができる。
【0039】
以上のことから、本実施形態に係るハッシュ関数処理装置によれば、従来よりも少ないハードウェアリソースを用いて、SHA1アルゴリズムにおけるラウンド処理を、外見上1ラウンドあたり1クロックサイクルで高速に実行することができる。
【0040】
(第2の実施形態)
図3は、本発明の第2の実施形態に係るハッシュ関数処理装置の論理回路図である。図3に示すハッシュ関数処理装置20は、第1の実施形態に係るハッシュ関数処理装置10に含まれる回路の一部を変更したものである。図3に示すハッシュ関数処理装置20は、レジスタ201〜207および211〜215、加算器221〜229、セレクタ230〜239、巡回シフト演算ブロック241および242、並びに論理演算ブロック251〜254を備えている。このうち、加算器226および227は、第1の演算処理部261を構成している。また、加算器228および229、セレクタ230、巡回シフト演算ブロック241、並びに論理演算ブロック251〜254は、第2の演算処理部262を構成している。
【0041】
ハッシュ関数処理装置20の回路構成は、第1の実施形態に係るハッシュ関数処理装置10の回路構成と、次の4つの点で相違する。第1に、セレクタ236は、レジスタ211の値と、加算器229の出力と、加算器221の出力とから、適切な値を選択して出力する。第2に、セレクタ237は、レジスタ212の値と、レジスタ201の値と、加算器222の出力とから、適切な値を選択して出力する。第3に、セレクタ238は、レジスタ213の値と、巡回シフト演算ブロック242の出力と、加算器223の出力とから、適切な値を選択して出力する。セレクタ239は、レジスタ214の値と、レジスタ215の値と、レジスタ203の値と、加算器225の出力とから、適切な値を選択して出力する。
【0042】
ハッシュ関数処理装置20は、第1の実施形態に係るハッシュ関数処理装置10と同様に、入力データに対して、まずハッシュ前処理を行い、次にラウンド処理を行い、最後にハッシュ後処理を行う。これら3つの処理の内容は、ハッシュ関数処理装置10と同じである。図4は、これら3つの処理によって、レジスタ201〜207および211〜215の値が変化する様子を示す図である。以下、図4を適宜参照しながら、ハッシュ関数処理装置20の動作を説明する。
【0043】
(1)ハッシュ前処理
ハッシュ関数処理装置20におけるハッシュ前処理は、第1の実施形態に係るハッシュ関数処理装置10における処理と同じである。
【0044】
(2)ラウンド処理
ハッシュ関数処理装置20における第0〜第78ラウンドの処理は、第1の実施形態に係るハッシュ関数処理装置10における処理と同じである。第0〜第78ラウンドの処理は、1ラウンドあたり1クロックサイクルをかけて(すなわち、各ブロックデータに対して79クロックサイクルをかけて)行われる。
【0045】
一方、ラウンド終端処理は、各ブロックデータに対して2クロックサイクルをかけて行われる。第1のクロックサイクルでは、レジスタ204および215は、いずれも、加算器225の出力(図4ではEm)を取り込む。同時に、レジスタ214は、加算器224の出力(図4ではDm)を取り込む。同時に、レジスタ203は、巡回シフト演算ブロック242の出力(図4ではC15)を取り込む。同時に、レジスタ202は、レジスタ201の値(図4ではB15)を取り込む。同時に、レジスタ201は、加算器229の出力(図4ではA15)を取り込む。同時に、レジスタ206および207は、それぞれ、外部から与えられた第0ラウンドで使用される入力データおよび定数値(図4ではW0およびK0)を取り込む。
【0046】
次に、第2のクロックサイクルでは、レジスタ201および211は、いずれも、加算器221の出力(図4ではAm)を取り込む。同時に、レジスタ202および212は、いずれも、加算器222の出力(図4ではBm)を取り込む。
同時に、レジスタ203および213は、いずれも、加算器223の出力(図4ではCm)を取り込む。同時に、レジスタ204は、レジスタ214の値(図4ではDm)を取り込む。同時に、レジスタ205は、加算器227の出力(図4では(Em+W0+K0))を取り込む。同時に、レジスタ206および207は、それぞれ、外部から与えられた第0ラウンドで使用される入力データおよび定数値(図4ではW1およびK1)を取り込む。なお、第1および第2のクロックサイクルでレジスタ206に取り込まれる入力データは、次のブロックデータに含まれるデータである。
【0047】
(3)ハッシュ後処理
ハッシュ後処理は、2クロックサイクルをかけて行われる。第1のクロックサイクルでは、レジスタ214および215は、加算器224および225の出力(図4ではDeおよびEe)を取り込む。同時に、レジスタ203は、巡回シフト演算ブロック242の出力(図4ではC15)を取り込む。レジスタ202は、レジスタ201の値(図4ではB15)を取り込む。同時に、レジスタ201は、加算器229の出力(図4ではA15)を取り込む。レジスタ204は、任意の値を取り込んでもよく、ここでは加算器225の出力を取り込むものとする。
【0048】
次に、第2のクロックサイクルでは、レジスタ211〜213は、それぞれ、加算器221〜223の出力(図4ではAe〜Ce)を取り込む。レジスタ201〜204は、任意の値を取り込んでもよく、ここでは、レジスタ204は、レジスタ214の値を取り込み、レジスタ201〜203は、それぞれ、加算器221〜223の出力を取り込むものとする。
【0049】
第2のクロックサイクルが完了した時点でレジスタ211〜215に格納されている値(図4ではAe〜Ee)が、求めるべきハッシュ値となる。したがって、図示しない手段を用いてレジスタ211〜215の値を読み出すことにより(あるいは、外部に設けたレジスタがハッシュ後処理の第2のクロックサイクルにおける出力信号HVの値を取り込むことにより)、入力データ全体に対するハッシュ値を得ることができる。
【0050】
このようにハッシュ関数処理装置20は、上述した4つの点で第1の実施形態に係るハッシュ関数処理装置10と異なるにも関わらず、SHA1アルゴリズムにおけるラウンド処理を正しく実行することができる。また、第1の実施形態に係るハッシュ関数処理装置10は、4クロックサイクルをかけてラウンド終端処理を行うのに対して、ハッシュ関数処理装置20は、2クロックサイクルをかけてラウンド終端処理を行う。
【0051】
以上のことから、本実施形態に係るハッシュ関数処理装置によれば、第1の実施形態に係るハッシュ関数処理装置が奏する効果に加えて、ラウンド終端処理にかかるクロックサイクル数を減らし、ラウンド処理をより高速に実行できるという効果がある。
【0052】
なお、本発明のハッシュ関数処理装置は、上述したパイプライン処理によって第0〜第78ラウンドの処理を行うものであればよく、上記各実施形態で示した装置以外の変形例を構成することができる。例えば、第1の実施形態に係るハッシュ関数処理装置10について言えば、初期値As〜Esをレジスタ111〜115に設定するタイミング、ハッシュ前処理、ラウンド終端処理、およびハッシュ後処理におけるレジスタ101〜104の更新タイミング、レジスタ111〜115の更新タイミング、任意の値を取り込んでよいレジスタに設定される値等については、種々の設計が可能である。第2の実施形態に係るハッシュ関数処理装置20についても、これと同様である。
【0053】
また、上記各実施形態では、ハッシュ関数としてSHA1を使用することとしたが、ハッシュ関数として他のアルゴリズムを使用してもよいことは言うまでもない。
【図面の簡単な説明】
【図1】本発明の第1の実施形態に係るハッシュ関数処理装置の論理回路図である。
【図2】本発明の第1の実施形態に係るハッシュ関数処理装置に含まれるレジスタの値が変化する様子を示す図である。
【図3】本発明の第2の実施形態に係るハッシュ関数処理装置の論理回路図である。
【図4】本発明の第2の実施形態に係るハッシュ関数処理装置に含まれるレジスタの値が変化する様子を示す図である。
【符号の説明】
10、20…ハッシュ関数処理装置
101〜107、111〜115、201〜207、211〜215…レジスタ
121〜129、221〜229…加算器
130〜139、230〜239…セレクタ
141、142、241、242…巡回シフト演算ブロック
151〜154、251〜254…論理演算ブロック
161、261…第1の演算処理部
162、262…第2の演算処理部[0001]
TECHNICAL FIELD OF THE INVENTION
The present invention relates to a hash function processing device, and more particularly, to obtain a fixed-length value (hash value) that is difficult to reverse-transform from arbitrary-length data in order to protect security in the field of information communication and the like. The present invention relates to a hash function processing device.
[0002]
[Prior art]
In recent years, broadband IP (Internet Protocol) infrastructures represented by FTTH (Fiber To The Home) and ADSL (Asymmetric Digital Subscriber Line) have become widespread in homes and the like. Along with this, demands for security techniques, such as prevention of message tampering, have been increasing even on IP transmission paths that require high speed. As a typical example of the message tampering prevention technique, for example, a method using a hash function is known. The hash function is a function for obtaining a fixed-length value (hereinafter, referred to as a hash value) unique to a message of an arbitrary length. The hash value obtained by using the hash function has extremely high randomness. That is, different hash values are obtained with extremely high probability for different messages. A hash function having such characteristics can be used as a means for detecting tampering of a message.
[0003]
Conventionally, as a hash function processing device, for example, an arithmetic circuit described in
[0004]
[Patent Document 1]
JP 2002-287635 A
[0005]
[Problems to be solved by the invention]
However, the above-mentioned conventional arithmetic circuit includes five registers for storing feedback data and one or more registers for storing intermediate results of the operation in order to perform a round process in the hash function. As described above, this arithmetic circuit has a problem that the circuit scale increases and the cost increases.
[0006]
Therefore, an object of the present invention is to provide a hash function processing device that executes round processing in a hash function at high speed using less hardware resources.
[0007]
Means for Solving the Problems and Effects of the Invention
A first invention is a hash function processing device that performs iterative processing defined by a hash function on input data, the first to fourth registers storing feedback data, and input data having a predetermined length. An input data supply unit for supplying, a constant value supply unit for supplying a constant value determined by a hash function, a value of a fourth register, input data supplied from the input data supply unit, and a constant value supply unit. A first arithmetic processing unit that performs a predetermined arithmetic processing on the supplied constant value, an intermediate value storage register that stores an arithmetic result of the first arithmetic processing unit, and a first to a fourth register. A second arithmetic processing unit for performing predetermined arithmetic processing on the value and the value of the intermediate value storage register, wherein the first and second arithmetic processing units operate in parallel and store the intermediate value. Register is the first operation The first register takes in the operation result of the second operation processing unit, the second register takes in the value of the first register, and the third register takes in the operation result of the first register. An operation of acquiring a value obtained by cyclically shifting the value of the second register, an operation of acquiring the value of the third register by the fourth register, an operation of acquiring the next input data by the input data supply unit, and an operation of supplying a constant value. The operation in which the unit takes in the next constant value is performed in parallel within one clock cycle.
According to the first aspect, the first and second arithmetic circuits operate in parallel, the output of the first arithmetic circuit is written to the intermediate value storage register, and the input of the second arithmetic circuit is the intermediate value. It is supplied from a value storage register or the like. Thus, two-stage pipeline processing is performed by the first and second arithmetic circuits and the intermediate value storage register. Further, in order to supply data to the pipeline at an appropriate timing, input data and a constant value used in the repetitive processing are acquired one clock cycle before the timing at which the data should be acquired. Therefore, the iterative process in the hash function can be executed at a high speed with one clock cycle per round in appearance. In addition to this, the number of registers for storing feedback data can be reduced, and iterative processing in the hash function can be executed at high speed using fewer hardware resources than in the past.
[0008]
In a second aspect based on the first aspect, the first arithmetic processing unit includes a fourth register value, input data supplied from the input data supply unit, and a constant value supplied from the constant value supply unit. And is added.
[0009]
In a third aspect based on the first aspect, the second arithmetic processing section performs a predetermined logical operation on the values of the second to fourth registers, and outputs the operation result and the value of the intermediate value storage register. And a value obtained by cyclically shifting the value of the first register.
[0010]
A fourth invention is characterized in that in any one of the first to third inventions, the hash function is SHA1 (The Secure Hash Algorithm 1).
According to the second to fourth aspects, the repetitive processing in the SHA1 algorithm can be executed at a high speed with one clock cycle per apparently one round.
[0011]
BEST MODE FOR CARRYING OUT THE INVENTION
(1st Embodiment)
FIG. 1 is a logic circuit diagram of the hash function processing device according to the first embodiment of the present invention. The hash
[0012]
In the 80 round process, variables A, B, C, D and E of 32 bits are used. Before performing the 80 round processing on each block data, the variables A to E have predetermined initial values As to Es (when the block data is the first block data) or the 80 round processing on the block data so far. One of the obtained values of the variables A to E (if not the first block data) is set. Then, the operation shown in the following equation (1) is performed 80 times while increasing the variable i by 1 from 0 to 79 in order. At the same time, the value of the variable D is stored in the variable E, and the value of the variable D is stored in the variable D. The value of the variable C is substituted into the variable C by a value obtained by cyclically shifting the value of the variable B to the left by 30 bits, and the value of the variable A is substituted into the variable B.
E = (A << 5) + Fi (B, C, D) + E + Wi + Ki (1)
Here, in the above equation (1), <<<< represents a left cyclic shift, and Fi, Wi, and Ki represent a logical operation in the i-th operation, 32-bit input data, and a 32-bit constant value, respectively. . The details of the SHA1 algorithm are described, for example, in the United States Department of Commerce: “Secure Hash Standard”, National Institute of Standards and Technology, Federal Information Processing Standard (180S, 1917, FIPS. It is described in.
[0013]
The hash
[0014]
The data width of each of the signal lines shown in FIG. 1 is 32 bits except for the output signal HV of 160 bits. In FIG. 1, control signals and control circuits for controlling round processing in the SHA1 algorithm are omitted for simplification of the drawing. This notation is also applied to FIG. 3 described later.
[0015]
In FIG. 1, registers 101 to 104 store feedback data used in round processing in the SHA1 algorithm. The
[0016]
The
[0017]
The
[0018]
The
Note that the
[0019]
The cyclic shift operation blocks 141 and 142 perform a cyclic shift operation according to the SHA1 algorithm. More specifically, the cyclic shift operation block 141 cyclically shifts the input to the left by 5 bits. The cyclic shift operation block 142 cyclically shifts the input to the left by 30 bits. Note that the shift direction in the cyclic shift operation blocks 141 and 142 is the left direction when the bits included in the input are arranged such that the left side is higher.
[0020]
The logical operation blocks 151 to 154 perform any one of four types of predetermined logical operations in the round processing in the SHA1 algorithm. Specifically, the
The logical operation blocks 152 and 154 perform a logical operation of “XxorYxorZ”. The
[0021]
The hash
[0022]
FIG. 2 is a diagram showing how the values of the
[0023]
Hereinafter, the operation of the hash
[0024]
(1) Hash preprocessing
The hash preprocessing is performed in two clock cycles in a state where the
[0025]
Next, in the second clock cycle, the
[0026]
(2) Round processing
The processing of the 0th to 78th rounds is performed in one clock cycle per round (that is, 79 clock cycles for each block data). In the processing of the 0th to 78th rounds, the
[0027]
As an example, the processing of the fifth round shown in FIG. 2 will be described. When the values obtained in the processing of the 0th to 4th rounds are E0, D0, C0, B0, and A0, respectively, the values of the
[0028]
On the other hand, the round termination processing is performed over four clock cycles for each block data. In the first clock cycle, the
[0029]
Next, in the second clock cycle, the
[0030]
Next, in the third clock cycle, the
[0031]
Next, in the fourth clock cycle, the
[0032]
(3) Hash post-processing
Post-hash processing is performed over two clock cycles. In the first clock cycle, the
[0033]
Next, in the second clock cycle, the
[0034]
When the second clock cycle is completed, the values (Ae to Ee in FIG. 2) stored in the
[0035]
Before the second clock cycle is completed, the output of the
[0036]
Hereinafter, the effects provided by the hash
Q = E + Wi + Ki (2)
E = (A << 5) + Fi (B, C, D) + Q (3)
[0037]
Correspondingly, the hash
[0038]
In addition, the hash
[0039]
As described above, according to the hash function processing device according to the present embodiment, the round processing in the SHA1 algorithm can be executed at a high speed with one clock cycle per round apparently using less hardware resources than in the past. Can be.
[0040]
(Second embodiment)
FIG. 3 is a logic circuit diagram of the hash function processing device according to the second embodiment of the present invention. The hash
[0041]
The circuit configuration of the hash
[0042]
The hash
[0043]
(1) Hash preprocessing
The pre-hash processing in the hash
[0044]
(2) Round processing
The processes in the 0th to 78th rounds in the hash
[0045]
On the other hand, the round termination processing is performed by taking two clock cycles for each block data. In the first clock cycle, both
[0046]
Next, in the second clock cycle, the
At the same time, both the
[0047]
(3) Hash post-processing
Post-hash processing is performed over two clock cycles. In the first clock cycle, registers 214 and 215 capture the outputs of
[0048]
Next, in the second clock cycle, the
[0049]
When the second clock cycle is completed, the values (Ae to Ee in FIG. 4) stored in the
[0050]
As described above, the hash
[0051]
From the above, according to the hash function processing device according to the present embodiment, in addition to the effects achieved by the hash function processing device according to the first embodiment, the number of clock cycles required for round termination processing is reduced, and round processing is performed. There is an effect that execution can be performed at higher speed.
[0052]
Note that the hash function processing device of the present invention may be any device that performs the processes of the 0th to 78th rounds by the above-described pipeline process, and may constitute a modified example other than the devices described in the above embodiments. it can. For example, regarding the hash
[0053]
Further, in each of the above embodiments, SHA1 is used as the hash function, but it goes without saying that another algorithm may be used as the hash function.
[Brief description of the drawings]
FIG. 1 is a logic circuit diagram of a hash function processing device according to a first embodiment of the present invention.
FIG. 2 is a diagram illustrating a state where a value of a register included in the hash function processing device according to the first embodiment of the present invention changes.
FIG. 3 is a logic circuit diagram of a hash function processing device according to a second embodiment of the present invention.
FIG. 4 is a diagram illustrating a state where a value of a register included in a hash function processing device according to a second embodiment of the present invention changes.
[Explanation of symbols]
10, 20 ... Hash function processing device
101-107, 111-115, 201-207, 211-215 ... registers
121-129, 221-229 ... adder
130-139, 230-239 ... selector
141, 142, 241, 242 ... cyclic shift operation block
151-154, 251-254 ... Logical operation block
161, 261: first arithmetic processing unit
162, 262: second arithmetic processing unit
Claims (4)
フィードバックデータを格納する第1から第4のレジスタと、
所定長の入力データを供給する入力データ供給部と、
ハッシュ関数で定められた定数値を供給する定数値供給部と、
前記第4のレジスタの値と、前記入力データ供給部から供給される入力データと、前記定数値供給部から供給される定数値とに対して、所定の演算処理を行う第1の演算処理部と、
前記第1の演算処理部による演算結果を格納する中間値格納レジスタと、
前記第1から第4のレジスタの値と、前記中間値格納レジスタの値とに対して、所定の演算処理を行う第2の演算処理部とを備え、
前記第1および第2の演算処理部は並列に動作し、かつ、前記中間値格納レジスタが前記第1の演算処理部による演算結果を取り込む動作と、前記第1のレジスタが前記第2の演算処理部による演算結果を取り込む動作と、前記第2のレジスタが前記第1のレジスタの値を取り込む動作と、前記第3のレジスタが前記第2のレジスタの値を巡回シフトした値を取り込む動作と、前記第4のレジスタが前記第3のレジスタの値を取り込む動作と、前記入力データ供給部が次の入力データを取得する動作と、前記定数値供給部が次の定数値を取り込む動作とが、1つのクロックサイクル内で並列に行われることを特徴とする、ハッシュ関数処理装置。A hash function processing device that performs iterative processing defined by a hash function on input data,
First to fourth registers for storing feedback data;
An input data supply unit for supplying input data of a predetermined length,
A constant value supply unit that supplies a constant value determined by a hash function,
A first arithmetic processing unit that performs predetermined arithmetic processing on the value of the fourth register, input data supplied from the input data supply unit, and a constant value supplied from the constant value supply unit When,
An intermediate value storage register for storing a calculation result by the first calculation processing unit;
A second arithmetic processing unit that performs predetermined arithmetic processing on the values of the first to fourth registers and the value of the intermediate value storage register;
The first and second arithmetic processing units operate in parallel, and the intermediate value storage register fetches the operation result by the first arithmetic processing unit, and the first register performs the second arithmetic operation. An operation of capturing the operation result by the processing unit, an operation of the second register capturing the value of the first register, and an operation of the third register capturing a value obtained by cyclically shifting the value of the second register. An operation in which the fourth register acquires the value of the third register, an operation in which the input data supply unit acquires the next input data, and an operation in which the constant value supply unit acquires the next constant value. A hash function processing device, wherein the hash function processing is performed in parallel within one clock cycle.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2003031044A JP2004240299A (en) | 2003-02-07 | 2003-02-07 | Hash function processor |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2003031044A JP2004240299A (en) | 2003-02-07 | 2003-02-07 | Hash function processor |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2004240299A true JP2004240299A (en) | 2004-08-26 |
Family
ID=32957758
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2003031044A Pending JP2004240299A (en) | 2003-02-07 | 2003-02-07 | Hash function processor |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2004240299A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2005208400A (en) * | 2004-01-23 | 2005-08-04 | Mitsubishi Electric Corp | Hash value calculation apparatus and arithmetic unit |
JP2007166279A (en) * | 2005-12-14 | 2007-06-28 | Nippon Telegr & Teleph Corp <Ntt> | IPsec CIRCUIT AND IPsec PROCESSING METHOD |
JP2011133916A (en) * | 2011-04-07 | 2011-07-07 | Mitsubishi Electric Corp | Arithmetic unit |
CN108427575A (en) * | 2018-02-01 | 2018-08-21 | 深圳市安信智控科技有限公司 | Fully pipelined architecture SHA-2 extension of message optimization methods |
-
2003
- 2003-02-07 JP JP2003031044A patent/JP2004240299A/en active Pending
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2005208400A (en) * | 2004-01-23 | 2005-08-04 | Mitsubishi Electric Corp | Hash value calculation apparatus and arithmetic unit |
JP2007166279A (en) * | 2005-12-14 | 2007-06-28 | Nippon Telegr & Teleph Corp <Ntt> | IPsec CIRCUIT AND IPsec PROCESSING METHOD |
JP4647479B2 (en) * | 2005-12-14 | 2011-03-09 | 日本電信電話株式会社 | IPsec circuit and IPsec processing method |
JP2011133916A (en) * | 2011-04-07 | 2011-07-07 | Mitsubishi Electric Corp | Arithmetic unit |
CN108427575A (en) * | 2018-02-01 | 2018-08-21 | 深圳市安信智控科技有限公司 | Fully pipelined architecture SHA-2 extension of message optimization methods |
CN108427575B (en) * | 2018-02-01 | 2022-03-15 | 深圳市安信智控科技有限公司 | Full-flow-structure SHA-2 message expansion optimization method |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US7991152B2 (en) | Speeding up Galois Counter Mode (GCM) computations | |
Stoffelen | Efficient cryptography on the RISC-V architecture | |
CN109791517B (en) | Protecting parallel multiplication operations from external monitoring attacks | |
Kounavis et al. | Novel table lookup-based algorithms for high-performance CRC generation | |
US7139900B2 (en) | Data packet arithmetic logic devices and methods | |
CN112650471A (en) | Processor and method for processing masked data | |
Seo et al. | Compact LEA and HIGHT implementations on 8-bit AVR and 16-bit MSP processors | |
JP2004240299A (en) | Hash function processor | |
JP4567753B2 (en) | Parity generation circuit, counting circuit, and counting method | |
JP5175983B2 (en) | Arithmetic unit | |
CN114615069B (en) | Quartet lightweight encryption algorithm implementation device and method | |
KR101977873B1 (en) | Hardware-implemented modular inversion module | |
JP2004240298A (en) | Hash function processor | |
JP4206205B2 (en) | High speed arithmetic circuit for SHA operation | |
CN113505383A (en) | ECDSA algorithm execution system and method | |
CN113630236A (en) | SM3 data encryption method and related device | |
JP2017067859A (en) | Scalar multiplication device and scalar multiplication method | |
US6941448B2 (en) | Data-driven processor having multiple-precision data processing function and data processing method thereof | |
CN113971015B (en) | UIA2 computing circuit, data processing method, chip, electronic device and storage medium | |
Cardoso dos Santos et al. | An evaluation of the multi-platform efficiency of lightweight cryptographic permutations | |
KR102587719B1 (en) | Circuits, computing chips, data processing devices and methods for performing hash algorithms | |
KR100761132B1 (en) | Apparatus and method for computing SHA-1 | |
CN112861154A (en) | SHA algorithm execution method, storage medium and electronic device for data flow architecture | |
JP2006053770A (en) | Data processor, data recovery device, data processing method, and data processing program | |
JP2004226516A (en) | Power remainder computing method and program for the same |