JP2004240299A - Hash function processor - Google Patents

Hash function processor Download PDF

Info

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
Application number
JP2003031044A
Other languages
Japanese (ja)
Inventor
Yusaku Ota
雄策 太田
Tatsuro Ikoma
達郎 生駒
Koichi Kanemura
孝一 金村
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.)
Panasonic Holdings Corp
Original Assignee
Matsushita Electric Industrial Co Ltd
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 Matsushita Electric Industrial Co Ltd filed Critical Matsushita Electric Industrial Co Ltd
Priority to JP2003031044A priority Critical patent/JP2004240299A/en
Publication of JP2004240299A publication Critical patent/JP2004240299A/en
Pending legal-status Critical Current

Links

Images

Abstract

<P>PROBLEM TO BE SOLVED: To achieve a high speed round processing in a hash function using less number of hardware resources than in the past. <P>SOLUTION: This hash function processor 10 achieves the round processing in an SHA1 algorithm using four registers 101-104 storing feedback data and one register 105 storing an intermediate result of calculation. Input data W and a constant K are read one clock cycle prior to an original reading timing, and two-stage pipeline treatment is performed by first and second operation parts 161, 162, and the resister 105, thus to achieve the high speed round processing in the hash function in apparently one clock cycle per round. By using one of the registers storing the feedback data as the register storing the intermediate result in common, the number of the registers can be reduced compared to the past. <P>COPYRIGHT: (C)2004,JPO&NCIPI

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 Patent Document 1 is known. Patent Literature 1 describes an arithmetic circuit that performs an iterative process (hereinafter, referred to as a round process) in The SecureHash Algorithm, which is a type of hash function. This arithmetic circuit performs a round process at high speed by performing a two-stage pipeline process.
[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 function processing device 10 illustrated in FIG. 1 performs a round process in The Secure Hash Algorithm 1 (hereinafter, referred to as SHA1), which is a kind of a hash function. SHA1 is a function for obtaining a 160-bit hash value from input data of an arbitrary length. In the SHA1 algorithm, input data is divided into 512 bits in order from the beginning. The input data divided into 512 bits is further divided into 16 words (one word is 32 bits), and a predetermined logical operation is performed on the 16 words to obtain 80 words. Then, the following processing (hereinafter, referred to as 80 round processing) is sequentially performed using the obtained 80 words as one unit (hereinafter, referred to as block data).
[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 function processing device 10 illustrated in FIG. 1 includes registers 101 to 107 and 111 to 115, adders 121 to 129, selectors 130 to 139, cyclic shift operation blocks 141 and 142, and logical operation blocks 151 to 154. . Among these, the adders 126 and 127 constitute the first arithmetic processing unit 161. The adders 128 and 129, the selector 130, the cyclic shift operation block 141, and the logical operation blocks 151 to 154 constitute a second operation processing unit 162.
[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 registers 101 to 104 are also referred to as a first register R1, a second register R2, a third register R3, and a fourth register R4, respectively. The register 105 stores intermediate data when performing round processing in the SHA1 algorithm. The register 106 stores 32-bit input data Wi processed in the round process in the SHA1 algorithm. The input data Wi is either data obtained by dividing original input data to be subjected to hash processing into 32 bits, or data obtained by cyclically shifting the exclusive OR of these four data to the left by one bit. The register 107 stores a predetermined constant value Ki for each round in the round processing in the SHA1 algorithm. Each of the registers 111 to 115 stores a value obtained by performing the 80 round process on the block data so far in the SHA1 algorithm.
[0016]
The adder 121 adds the value of the register 101 and the value of the register 111. The adder 122 adds the value of the register 102 and the value of the register 112. The adder 123 adds the value of the register 103 and the value of the register 113. The adder 124 adds the value of the register 104 and the value of the register 114. The adder 125 adds the value of the register 104 and the value of the register 115. The adder 126 adds the value of the register 106 and the value of the register 107. The adder 127 adds the value of the register 104 and the output of the adder 126. The adder 128 adds the output of the selector 130 and the output of the cyclic shift operation block 141. The adder 129 adds the value of the register 105 and the output of the adder 128.
[0017]
The selector 131 selects and outputs an appropriate value from the initial value As before the round processing in the SHA1 algorithm and the output of the adder 121. The selector 132 selects and outputs an appropriate value from the initial value Bs before the start of the round process in the SHA1 algorithm and the output of the adder 122. The selector 133 selects and outputs an appropriate value from the initial value Cs before the start of the round processing in the SHA1 algorithm and the output of the adder 123. The selector 134 selects and outputs an appropriate value from the initial value Ds before the round processing in the SHA1 algorithm and the output of the adder 124. The selector 135 selects and outputs an appropriate value from the initial value Es before the start of the round process in the SHA1 algorithm and the output of the adder 125.
[0018]
The selector 136 selects and outputs an appropriate value from the value of the register 111 and the output of the adder 129. The selector 137 selects and outputs an appropriate value from the value of the register 112 and the value of the register 101. The selector 138 selects and outputs an appropriate value from the value of the register 113 and the output of the cyclic shift operation block 142. The selector 139 selects and outputs an appropriate value from the value of the register 114, the value of the register 115, and the value of the register 103. The selector 130 selects and outputs an appropriate value from the outputs of the logical operation blocks 151 to 154.
Note that the selectors 130 to 139 select and output appropriate values so that round processing and the like described later can be performed correctly.
[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 logical operation block 151 performs a logical operation in the 0th to 19th rounds. The logical operation block 152 performs a logical operation in the 20th to 39th rounds. The logical operation block 153 performs a logical operation in the 40th to 59th rounds. The logical operation block 154 performs a logical operation in the 60th to 79th rounds. More specifically, the value of the register 102 is X, the value of the register 103 is Y, the value of the register 104 is Z, and the logical operations of logical sum, logical product, negation, and exclusive logical sum are respectively and and or , Not and xor, the logical operation block 151 performs a logical operation of “(XandY) or ((notX) andZ)”.
The logical operation blocks 152 and 154 perform a logical operation of “XxorYxorZ”. The logical operation block 153 performs a logical operation of “(XandY) or (XandZ) or (YandZ)”. Note that the hash function processing device 10 may not include the logical operation block 154, and the logical operation block 152 may perform the logical operation in the 60th to 79th rounds.
[0021]
The hash function processing device 10 first performs pre-hash processing on input data, then performs round processing, and finally performs post-hash processing. In the pre-hash process, a process of setting an appropriate value to a register before handling the first block data is performed. In the round processing, processing of the 0th to 78th rounds in the SHA1 algorithm and round end processing are performed on each block data. In the round end processing, (a) processing of the 79th round in the SHA1 algorithm, (b) processing of adding the value obtained this time and the value obtained up to the previous time, and (c) before processing the next block data A process of setting an appropriate value to each register is performed. However, round end processing is not performed on the last block data. In the post-hash process, the processes (a) and (b) are performed.
[0022]
FIG. 2 is a diagram showing how the values of the registers 101 to 107 and 111 to 115 are changed by the pre-hash processing, the round processing, and the post-hash processing. In FIG. 2, a minus sign indicates that the value of the register is indefinite, and an arrow indicates that the value of the register is the same as the previous clock cycle. This notation is also applied to FIG. 4 described later.
[0023]
Hereinafter, the operation of the hash function processing device 10 will be described with reference to FIG. In the following description, capturing two registers A and B with a certain value in the same clock cycle may be referred to as register A and B simultaneously capturing a value.
[0024]
(1) Hash preprocessing
The hash preprocessing is performed in two clock cycles in a state where the registers 111 to 115 store the initial values (As to Es in FIG. 2) determined by the SHA1 algorithm. In the first clock cycle, the register 104 takes in the value of the register 115 (Es in FIG. 2). At the same time, the registers 101 to 103 take in the values of the registers 111 to 113 (As to Cs in FIG. 2), respectively. At the same time, registers 106 and 107 take in input data and constant values (W0 and K0 in FIG. 2) used in the 0th round, respectively, provided from the outside.
[0025]
Next, in the second clock cycle, the register 105 takes in the output of the adder 127 ((Es + W0 + K0) in FIG. 2). At the same time, the register 104 takes in the value of the register 114 (Ds in FIG. 2). At the same time, the registers 106 and 107 take in input data and constant values (W1 and K1 in FIG. 2) used in the first round supplied from the outside.
[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 register 104 takes in the value of the register 103 in each clock cycle. At the same time, the register 103 takes in the output of the cyclic shift operation block 142. At the same time, the register 102 captures the value of the register 101. At the same time, the register 101 takes in the output of the adder 129. At the same time, the register 105 takes in the output of the adder 127. At the same time, registers 106 and 107 take in the next input data and constant value respectively given from outside. However, in the process of the 78th round, the registers 106 and 107 may take in arbitrary values.
[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 registers 101 to 104 are A0 to D0 when the processing of the fourth round is completed. , The value of the register 105 is (E0 + W5 + K5), the value of the register 106 is W6, and the value of the register 107 is K6. Therefore, in the processing of the fifth round, the register 104 captures the value C0 of the register 103. At the same time, the register 103 takes in a value obtained by cyclically shifting the value B0 of the register 102 to the left by 30 bits (in FIG. 2, described as B0 before cyclic shift; hereinafter, the same notation is used). At the same time, the register 102 takes in the value A0 of the register 101. At the same time, the register 101 takes in the output E1 of the adder 129. Here, E1 is a value obtained by substituting A0 to E0 for A to E, W5 for Wi, and K5 for Ki in equation (1). At the same time, the register 105 takes in the output (D0 + W6 + K6) of the adder 127. At the same time, the registers 106 and 107 take in the next input data W7 and the next constant value K7, respectively.
[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 register 115 takes in the output of the adder 125 (Em in FIG. 2). At the same time, the register 104 takes in the value of the register 103 (D15 in FIG. 2). At the same time, the register 103 takes in the output of the cyclic shift operation block 142 (C15 in FIG. 2). At the same time, the register 102 takes in the value of the register 101 (B15 in FIG. 2). At the same time, the register 101 takes in the output of the adder 129 (A15 in FIG. 2).
[0029]
Next, in the second clock cycle, the registers 111 to 114 take in the outputs (Am to Dm in FIG. 2) of the adders 121 to 124, respectively. Note that the registers 101 to 104 may take in an arbitrary value, and here it is assumed that the register holds the value of the immediately preceding clock cycle.
[0030]
Next, in the third clock cycle, the registers 101 to 103 take in the values (Am to Cm in FIG. 2) of the registers 111 to 113, respectively. At the same time, the register 104 takes in the value of the register 115 (Em in FIG. 2). At the same time, registers 106 and 107 take in input data and constant values (W0 and K0 in FIG. 2) used in the 0th round, respectively, provided from the outside.
[0031]
Next, in the fourth clock cycle, the register 105 takes in the output of the adder 127 ((Em + W0 + K0) in FIG. 2). At the same time, the register 104 takes in the value of the register 114 (Dm in FIG. 2). At the same time, the registers 106 and 107 take in input data and constant values (W1 and K1 in FIG. 2) used in the first round supplied from the outside. Note that the input data taken into the register 106 in the third and fourth clock cycles is data included in the next block data.
[0032]
(3) Hash post-processing
Post-hash processing is performed over two clock cycles. In the first clock cycle, the register 115 takes in the output of the adder 125 (Ee in FIG. 2). At the same time, the register 104 takes in the value of the register 103 (D15 in FIG. 2). At the same time, the register 103 takes in the output of the cyclic shift operation block 142 (C15 in FIG. 2). At the same time, the register 102 takes in the value of the register 101 (B15 in FIG. 2). At the same time, the register 101 takes in the output of the adder 129 (A15 in FIG. 2).
[0033]
Next, in the second clock cycle, the registers 111 to 114 take in the outputs (Ae to De in FIG. 2) of the adders 121 to 124, respectively. Note that the registers 101 to 104 may take in an arbitrary value, and here it is assumed that the register holds the value of the immediately preceding clock cycle.
[0034]
When the second clock cycle is completed, the values (Ae to Ee in FIG. 2) stored in the registers 111 to 115 are hash values to be obtained. Therefore, a hash value for the entire input data can be obtained by reading the values of the registers 111 to 115 using means (not shown).
[0035]
Before the second clock cycle is completed, the output of the register 115 and the adders 121 to 124 (the output signal HV shown in FIG. 1) matches the hash value to be obtained. Therefore, a 160-bit register is provided outside the hash function processing apparatus 10, and the provided register takes in the output signal HV at this time, whereby a hash value for the entire input data can be obtained.
[0036]
Hereinafter, the effects provided by the hash function processing device 10 will be described. As shown in Expression (1), in round processing in the SHA1 algorithm, input data and constant values do not depend on feedback data. Therefore, the operation shown in Expression (1) can be decomposed into two operations as shown in Expressions (2) and (3) below. However, in equations (2) and (3), Q is a 32-bit variable.
Q = E + Wi + Ki (2)
E = (A << 5) + Fi (B, C, D) + Q (3)
[0037]
Correspondingly, the hash function processing device 10 includes a first arithmetic processing unit 161 that performs the arithmetic processing shown in Expression (2) and a second arithmetic processing unit 162 that performs the arithmetic processing shown in Expression (3). And a register 105 for storing the output of the first arithmetic processing unit 161. The first arithmetic processing unit 161 and the second arithmetic processing unit 162 operate in parallel, and the output of the second arithmetic processing unit 162 is supplied from the register 105 or the like. Thus, the first arithmetic processing unit 161, the second arithmetic processing unit 162, and the register 105 perform two-stage pipeline processing. Further, in order to supply data to the pipeline at an appropriate timing, the input data Wi and the constant value Ki used in each round are read one clock cycle before the timing at which they should be read.
[0038]
In addition, the hash function processing device 10 includes four registers 101 to 104 for storing feedback data and one register 105 for storing an intermediate result of an operation in order to perform round processing in the SHA1 algorithm. . That is, the hash function processing device 10 also uses one of the five registers for storing the feedback data as the register for storing the intermediate result of the operation. Therefore, according to the hash function processing device 10, it is possible to perform the same pipeline processing as that of the related art using a smaller number of registers than in the related art.
[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 function processing device 20 shown in FIG. 3 is obtained by changing a part of a circuit included in the hash function processing device 10 according to the first embodiment. The hash function processing device 20 shown in FIG. 3 includes registers 201 to 207 and 211 to 215, adders 221 to 229, selectors 230 to 239, cyclic shift operation blocks 241 and 242, and logical operation blocks 251 to 254. . Among them, the adders 226 and 227 constitute a first arithmetic processing unit 261. The adders 228 and 229, the selector 230, the cyclic shift operation block 241, and the logical operation blocks 251 to 254 constitute a second operation processing unit 262.
[0041]
The circuit configuration of the hash function processing device 20 is different from the circuit configuration of the hash function processing device 10 according to the first embodiment in the following four points. First, the selector 236 selects and outputs an appropriate value from the value of the register 211, the output of the adder 229, and the output of the adder 221. Second, the selector 237 selects and outputs an appropriate value from the value of the register 212, the value of the register 201, and the output of the adder 222. Third, the selector 238 selects and outputs an appropriate value from the value of the register 213, the output of the cyclic shift operation block 242, and the output of the adder 223. The selector 239 selects and outputs an appropriate value from the value of the register 214, the value of the register 215, the value of the register 203, and the output of the adder 225.
[0042]
The hash function processing device 20 first performs pre-hash processing, then performs round processing, and finally performs post-hash processing on input data, similarly to the hash function processing device 10 according to the first embodiment. . The contents of these three processes are the same as those of the hash function processing device 10. FIG. 4 is a diagram showing how the values of the registers 201 to 207 and 211 to 215 change by these three processes. Hereinafter, the operation of the hash function processing device 20 will be described with reference to FIG.
[0043]
(1) Hash preprocessing
The pre-hash processing in the hash function processing device 20 is the same as the processing in the hash function processing device 10 according to the first embodiment.
[0044]
(2) Round processing
The processes in the 0th to 78th rounds in the hash function processing device 20 are the same as those in the hash function processing device 10 according to the first embodiment. 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).
[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 registers 204 and 215 capture the output of adder 225 (Em in FIG. 4). At the same time, the register 214 takes in the output of the adder 224 (Dm in FIG. 4). At the same time, the register 203 takes in the output (C15 in FIG. 4) of the cyclic shift operation block 242. At the same time, the register 202 takes in the value of the register 201 (B15 in FIG. 4). At the same time, the register 201 takes in the output of the adder 229 (A15 in FIG. 4). At the same time, the registers 206 and 207 take in input data and constant values (W0 and K0 in FIG. 4) which are used from the outside in the 0th round, respectively.
[0046]
Next, in the second clock cycle, the registers 201 and 211 both take in the output of the adder 221 (Am in FIG. 4). At the same time, both the registers 202 and 212 take in the output of the adder 222 (Bm in FIG. 4).
At the same time, both the registers 203 and 213 take in the output of the adder 223 (Cm in FIG. 4). At the same time, the register 204 takes in the value of the register 214 (Dm in FIG. 4). At the same time, the register 205 takes in the output of the adder 227 ((Em + W0 + K0) in FIG. 4). At the same time, the registers 206 and 207 fetch input data and constant values (W1 and K1 in FIG. 4) used in the 0th round, respectively, provided from the outside. The input data taken into the register 206 in the first and second clock cycles is data included in the next block data.
[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 adders 224 and 225 (De and Ee in FIG. 4). At the same time, the register 203 takes in the output (C15 in FIG. 4) of the cyclic shift operation block 242. The register 202 takes in the value of the register 201 (B15 in FIG. 4). At the same time, the register 201 takes in the output of the adder 229 (A15 in FIG. 4). The register 204 may take in an arbitrary value. Here, it is assumed that the register 204 takes in the output of the adder 225.
[0048]
Next, in the second clock cycle, the registers 211 to 213 take in the outputs (Ae to Ce in FIG. 4) of the adders 221 to 223, respectively. The registers 201 to 204 may take in arbitrary values. Here, it is assumed that the register 204 takes in the value of the register 214 and the registers 201 to 203 take in the outputs of the adders 221 to 223, respectively.
[0049]
When the second clock cycle is completed, the values (Ae to Ee in FIG. 4) stored in the registers 211 to 215 are hash values to be obtained. Therefore, by reading the values of the registers 211 to 215 using means (not shown) (or by reading the value of the output signal HV in the second clock cycle of the post-hash processing by an externally provided register), A hash value for the whole can be obtained.
[0050]
As described above, the hash function processing device 20 can correctly execute the round process in the SHA1 algorithm, despite being different from the hash function processing device 10 according to the first embodiment in the above-described four points. Further, the hash function processing device 10 according to the first embodiment performs the round termination process over four clock cycles, whereas the hash function processing device 20 performs the round termination process over two clock cycles. .
[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 function processing device 10 according to the first embodiment, the timings for setting the initial values As to Es in the registers 111 to 115, the registers 101 to 104 in the pre-hash processing, the round end processing, and the post-hash processing Various designs are possible for the update timing, the update timing of the registers 111 to 115, the values set in the registers that can take in arbitrary values, and the like. The same applies to the hash function processing device 20 according to the second embodiment.
[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.
前記第1の演算処理部は、前記第4のレジスタの値と、前記入力データ供給部から供給される入力データと、前記定数値供給部から供給される定数値とを加算することを特徴とする、請求項1に記載のハッシュ関数処理装置。The first arithmetic processing unit adds 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. The hash function processing device according to claim 1, wherein 前記第2の演算処理部は、前記第2から第4のレジスタの値に対して所定の論理演算を行い、当該演算結果と、前記中間値格納レジスタの値と、前記第1のレジスタの値を巡回シフトした値とを加算することを特徴とする、請求項1に記載のハッシュ関数処理装置。The second operation processing unit performs a predetermined logical operation on the values of the second to fourth registers, and calculates the operation result, the value of the intermediate value storage register, and the value of the first register. The hash function processing device according to claim 1, wherein a value obtained by cyclically shifting is added. 前記ハッシュ関数がSHA1(The Secure Hash Algorithm 1 )であることを特徴とする、請求項1〜3のいずれかに記載のハッシュ関数処理装置。The hash function processing device according to any one of claims 1 to 3, wherein the hash function is SHA1 (The Secure Hash Algorithm 1).
JP2003031044A 2003-02-07 2003-02-07 Hash function processor Pending JP2004240299A (en)

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)

* Cited by examiner, † Cited by third party
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

Cited By (6)

* Cited by examiner, † Cited by third party
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