JP2004240298A - Hash function processor - Google Patents

Hash function processor Download PDF

Info

Publication number
JP2004240298A
JP2004240298A JP2003031043A JP2003031043A JP2004240298A JP 2004240298 A JP2004240298 A JP 2004240298A JP 2003031043 A JP2003031043 A JP 2003031043A JP 2003031043 A JP2003031043 A JP 2003031043A JP 2004240298 A JP2004240298 A JP 2004240298A
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
JP2003031043A
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 JP2003031043A priority Critical patent/JP2004240298A/en
Publication of JP2004240298A publication Critical patent/JP2004240298A/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. <P>SOLUTION: In the round processing in an MD5 algorithm, input data and constant values are not dependent on feed back data. Considering this point, two-stage pipeline processing is performed by first and second processing parts 361 and 362, and a register 305. To supply the pipeline with data at an appropriate timing, the input data X and constant value T are read one clock cycle prior to the timing originally to read. The two-stage pipeline processing enables high speed round processing in the hash function apparently in one clock cycle per round. <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サイクル前のフィードバックデータとを用いて演算器で演算処理を施す間に、次サイクルの入力データおよび設定数部からの出力データに対する演算処理をオーバーラップして行うことを特徴とする。
【0004】
【特許文献1】
特開2002−72879号公報
【0005】
【発明が解決しようとする課題】
しかしながら、上記従来の処理装置では、ハッシュ関数における繰り返し処理(以下、ラウンド処理という)を行うために、最速の場合でも1ラウンドあたり2クロックサイクルが必要とされる。このため、上記従来の処理装置は、高速処理が要求されるアプリケーションには不向きである。また、オーバーラップ処理を実現するために、パイプライン処理を複数段に分割する必要があり、レジスタ等のハードウェアリソースが多く必要とされる。このように、上記従来の処理装置には、回路規模の増大やコストの増加という課題もある。
【0006】
それ故に、本発明は、ハッシュ関数におけるラウンド処理を、1ラウンドあたり1クロックサイクルで高速に実行するハッシュ関数処理装置を提供することを目的とする。また、本発明は、少ないハードウェアリソースを用いて、ハッシュ関数におけるラウンド処理を高速に実行するハッシュ関数処理装置を提供することを目的とする。
【0007】
【課題を解決するための手段および発明の効果】
第1の発明は、入力データに対して、ハッシュ関数で定められた繰り返し処理を行うハッシュ関数処理装置であって、フィードバックデータを格納する第1から第4のレジスタと、所定長の入力データを供給する入力データ供給部と、ハッシュ関数で定められた定数値を供給する定数値供給部と、第1のレジスタの値と、入力データ供給部から供給される入力データと、定数値供給部から供給される定数値とに対して、所定の演算処理を行う第1の演算処理部と、第1の演算処理部による演算結果を格納する中間値格納レジスタと、第2から第4のレジスタの値と、中間値格納レジスタの値とに対して、所定の演算処理を行う第2の演算処理部とを備え、第1および第2の演算処理部は並列に動作し、かつ、中間値格納レジスタが第1の演算処理部による演算結果を取り込む動作と、第2のレジスタが第2の演算処理部による演算結果を取り込む動作と、第3のレジスタが第2のレジスタの値を取り込む動作と、第1および第4のレジスタが第3のレジスタの値を取り込む動作と、入力データ供給部が次の入力データを取得する動作と、定数値供給部が次の定数値を取得する動作とが、1つのクロックサイクル内で並列に行われることを特徴とする。
このような第1の発明によれば、第1および第2の演算回路は並列に動作し、第1の演算回路の出力は中間値格納レジスタに書き込まれ、第2の演算回路の入力は中間値格納レジスタ等から供給される。これにより、第1および第2の演算回路と中間値格納レジスタとにより、2段のパイプライン処理が行われる。また、パイプラインに適切なタイミングでデータを供給するために、繰り返し処理で使用される入力データおよび定数値は、本来取得すべきタイミングよりも1クロックサイクル前に取得される。したがって、ハッシュ関数における繰り返し処理を、外見上1ラウンドあたり1クロックサイクルで高速に実行することができる。
【0008】
第2の発明は、入力データに対して、ハッシュ関数で定められた繰り返し処理を行うハッシュ関数処理装置であって、フィードバックデータを格納する第1から第3のレジスタと、所定長の入力データを供給する入力データ供給部と、ハッシュ関数で定められた定数値を供給する定数値供給部と、第1のレジスタの値と、入力データ供給部から供給される入力データと、定数値供給部から供給される定数値とに対して、所定の演算処理を行う第1の演算処理部と、第1の演算処理部による演算結果を格納する中間値格納レジスタと、第1から第3のレジスタの値と、中間値格納レジスタの値とに対して、所定の演算処理を行う第2の演算処理部とを備え、第1および第2の演算処理部は並列に動作し、かつ、中間値格納レジスタが第1の演算処理部による演算結果を取り込む動作と、第2のレジスタが第2の演算処理部による演算結果を取り込む動作と、第3のレジスタが第2のレジスタの値を取り込む動作と、第1のレジスタが第3のレジスタの値を取り込む動作と、入力データ供給部が次の入力データを取得する動作と、定数値供給部が次の定数値を取得する動作とが、1つのクロックサイクル内で並列に行われることを特徴とする。
このような第2の発明によれば、第1および第2の演算回路は並列に動作し、第1の演算回路の出力は中間値格納レジスタに書き込まれ、第2の演算回路の入力は中間値格納レジスタ等から供給される。これにより、第1および第2の演算回路と中間値格納レジスタとにより、2段のパイプライン処理が行われる。また、パイプラインに適切なタイミングでデータを供給するために、繰り返し処理で使用される入力データおよび定数値は、本来取得すべきタイミングよりも1クロックサイクル前に取得される。したがって、ハッシュ関数における繰り返し処理を、外見上1ラウンドあたり1クロックサイクルで高速に実行することができる。これに加えて、フィードバックデータを格納するレジスタの数を削減し、少ないハードウェアリソースを用いて、ハッシュ関数における繰り返し処理を高速に実行することができる。
【0009】
第3の発明は、第1または第2の発明において、第1の演算処理部は、第1のレジスタの値と、入力データ供給部から供給される入力データと、定数値供給部から供給される定数値とを加算することを特徴とする。
【0010】
第4の発明は、第1の発明において、第2の演算処理部は、第2から第4のレジスタの値に対して所定の論理演算を行い、当該演算結果と中間値格納レジスタの値との加算結果を所定のビット数だけ巡回シフトした上で、第2のレジスタの値と加算することを特徴とする。
【0011】
第5の発明は、第2の発明において、第2の演算処理部は、第1から第3のレジスタの値に対して所定の論理演算を行い、当該演算結果と中間値格納レジスタの値との加算結果を所定のビット数だけ巡回シフトした上で、第2のレジスタの値と加算することを特徴とする。
【0012】
第6の発明は、第1ないし第5のいずれかの発明において、ハッシュ関数がMD5(Message Digest 5)であることを特徴とする。
このような第3ないし第6の発明によれば、MD5アルゴリズムにおける繰り返し処理を、外見上1ラウンドあたり1クロックサイクルで高速に実行することができる。
【0013】
【発明の実施の形態】
(第1の実施形態)
図1は、本発明の第1の実施形態に係るハッシュ関数処理装置の論理回路図である。図1に示すハッシュ関数処理装置10は、ハッシュ関数の一種であるMessage Digest 5(以下、MD5という)におけるラウンド処理を行う。MD5は、任意長の入力データから、128ビットのハッシュ値を求める関数である。MD5アルゴリズムでは、入力データは、先頭から順に512ビットずつに分割される。その上で、分割後の各入力データ(以下、ブロックデータという)について、以下に示す処理(以下、64ラウンド処理という)が順次行われる。
【0014】
64ラウンド処理では、32ビットの変数A、B、CおよびDが使用される。各ブロックデータに対して64ラウンド処理を行う前に、変数A〜Dには、所定の初期値As〜Ds(最初のブロックデータである場合)、または、これまでのブロックデータに対する64ラウンド処理で求めた変数A〜Dの値(最初のブロックデータでない場合)のいずれかが設定される。その上で、変数iを0から63まで1ずつ順に増加させながら、次式(1)に示す演算が64回行われる。
α=β+((α+Fi(β,γ,Δ)+Xi+Ti)<<<Si) …(1)
ただし、式(1)において、<<< は左巡回シフトを表し、Fi、Xi、TiおよびSiは、それぞれ、i回目の演算における論理演算、32ビットの入力データ、32ビットの定数値、およびシフト数を表す。また、α〜Δは、iを4で割った余りjが0である場合には、順にA、B、C、Dであり、jが1である場合には、順にD、A、B、Cであり、jが2である場合には、順にC、D、A、Bであり、jが3である場合には、順にB、C、D、Aである。
【0015】
以下、式(1)を用いたi回目の演算を、第iラウンドの処理という。各ブロックデータについて第63ラウンドの処理が完了した後、変数A〜Dの値は、これまでのブロックデータに対する64ラウンド処理で求めた変数A〜Dの値と加算される。入力データに含まれるすべてのブロックデータについて64ラウンド処理を行ったとき、最後の加算で得られた結果が、求めるべきハッシュ値となる。なお、MD5アルゴリズムの詳細は、例えば、R.Rivest, ”The MD5 Message Digest Algorithm”, IETF RFC1321, 1992. に記載されている。
【0016】
図1に示すハッシュ関数処理装置10は、レジスタ101〜107および111〜114、加算器121〜128、セレクタ131〜139、巡回シフト演算ブロック141、並びに論理演算ブロック151〜154を備えている。このうち、加算器125および126は、第1の演算処理部161を構成している。また、加算器127および128、セレクタ139、巡回シフト演算ブロック141、並びに、論理演算ブロック151〜154は、第2の演算処理部162を構成している。
【0017】
図1に示す信号線のデータ幅は、128ビットの出力信号HVを除き、いずれも32ビットである。また、図1では、MD5アルゴリズムにおけるラウンド処理を制御するための制御信号や制御回路は、図面の簡単化のために省略されている。なお、この記法は、後述する図3、図5および図7にも適用される。
【0018】
図1において、レジスタ101〜104は、それぞれ、MD5アルゴリズムにおけるラウンド処理で使用されるフィードバックデータを格納する。レジスタ101〜104は、順に、第1のレジスタR1、第4のレジスタR4、第3のレジスタR3、および第2のレジスタR2とも呼ばれる。レジスタ105は、MD5アルゴリズムにおけるラウンド処理を行うときの中間データを格納する。レジスタ106は、MD5アルゴリズムにおけるラウンド処理で処理される、32ビットずつに分割された入力データXiを格納する。レジスタ107は、MD5アルゴリズムにおけるラウンド処理で各ラウンド毎に予め定められた定数値Tiを格納する。レジスタ111〜114は、それぞれ、MD5アルゴリズムにおける、これまでのブロックデータに対する64ラウンド処理で求めた値を格納する。
【0019】
加算器121は、レジスタ101の値とレジスタ111の値とを加算する。加算器122は、レジスタ102の値とレジスタ112の値とを加算する。加算器123は、レジスタ103の値とレジスタ113の値とを加算する。加算器124は、レジスタ104の値とレジスタ114の値とを加算する。加算器125は、レジスタ106の値とレジスタ107の値とを加算する。加算器126は、レジスタ101の値と加算器125の出力とを加算する。加算器127は、レジスタ105の値とセレクタ139の出力とを加算する。加算器128は、レジスタ104の値と巡回シフト演算ブロック141の出力とを加算する。
【0020】
セレクタ131は、MD5アルゴルリズムにおけるラウンド処理開始前の初期値Asと、加算器121の出力とから、適切な値を選択して出力する。セレクタ132は、MD5アルゴルリズムにおけるラウンド処理開始前の初期値Dsと、加算器122の出力とから、適切な値を選択して出力する。セレクタ133は、MD5アルゴルリズムにおけるラウンド処理開始前の初期値Csと、加算器123の出力とから、適切な値を選択して出力する。セレクタ134は、MD5アルゴルリズムにおけるラウンド処理開始前の初期値Bsと、加算器124の出力とから、適切な値を選択して出力する。
【0021】
セレクタ135は、レジスタ111の値と、レジスタ102の値と、レジスタ103の値とから、適切な値を選択して出力する。セレクタ136は、レジスタ112の値と、レジスタ103の値とから、適切な値を選択して出力する。セレクタ137は、レジスタ113の値と、レジスタ104の値とから、適切な値を選択して出力する。セレクタ138は、レジスタ114の値と、加算器128の出力とから、適切な値を選択して出力する。セレクタ139は、論理演算ブロック151〜154の出力から、適切な値を選択して出力する。なお、セレクタ131〜139は、後述するラウンド処理等を正しく行えるように、適切な値を選択して出力する。
【0022】
巡回シフト演算ブロック141は、MD5アルゴリズムに従い、巡回シフト演算を行う。より詳細には、巡回シフト演算ブロック141は、MD5アルゴリズムにおけるラウンド処理で各ラウンド毎に指定された値だけ、入力を左に巡回シフトする。なお、巡回シフト演算ブロック141におけるシフト方向は、入力に含まれる各ビットを左側が上位となるように並べたときの左方向である。
【0023】
論理演算ブロック151〜154は、MD5アルゴリズムにおけるラウンド処理で予め定められた4種類の論理演算のうち、いずれかを行う。具体的には、論理演算ブロック151は、第0〜第15ラウンドにおける論理演算を行う。論理演算ブロック152は、第16〜第31ラウンドにおける論理演算を行う。論理演算ブロック153は、第32〜第47ラウンドにおける論理演算を行う。論理演算ブロック154は、第48〜第63ラウンドにおける論理演算を行う。より詳細には、レジスタ104の値をX、レジスタ103の値をY、レジスタ102の値をZとし、論理和、論理積、否定および排他的論理和の各論理演算を、それぞれ、and、or、notおよびxorと表すとき、論理演算ブロック151は、「(XandY)or((notX)andZ)」なる論理演算を行う。論理演算ブロック152は、「(XandZ)or(Yand(notZ))」なる論理演算を行う。論理演算ブロック153は、「XxorYxorZ」なる論理演算を行う。論理演算ブロック154は、「Yxor(Xor(notZ)」なる論理演算を行う。
【0024】
ハッシュ関数処理装置10は、入力データに対して、まずハッシュ前処理を行い、次にラウンド処理を行い、最後にハッシュ後処理を行う。ハッシュ前処理では、最初のブロックデータを扱う前にレジスタに適切な値を設定する処理が行われる。ラウンド処理では、各ブロックデータに対して、MD5アルゴリズムにおける第0〜第62ラウンドの処理と、ラウンド終端処理とが行われる。ラウンド終端処理では、(a)MD5アルゴリズムにおける第63ラウンドの処理と、(b)今回求めた値と前回までに求めた値とを加算する処理と、(c)次のブロックデータを扱う前に各レジスタに適切な値を設定する処理とが行われる。ただし、最後のブロックデータに対しては、ラウンド終端処理は行われない。ハッシュ後処理では、上記(a)および(b)の処理が行われる。
【0025】
図2は、ハッシュ前処理、ラウンド処理、およびハッシュ後処理によって、レジスタ101〜107および111〜114の値が変化する様子を示す図である。図2において、マイナス記号は、レジスタの値が不定であることを表し、矢印は、レジスタの値が1つ前のクロックサイクルと同じであることを表す。なお、この記法は、後述する図4、図6および図8にも適用される。
【0026】
以下、図2を適宜参照しながら、ハッシュ関数処理装置10の動作を説明する。なお、以下の説明では、2つのレジスタAとBとが同じクロックサイクルでそれぞれある値を取り込むことを、レジスタAとBとは同時に値を取り込む、と表現する場合がある。
【0027】
(1)ハッシュ前処理
ハッシュ前処理は、レジスタ111〜114にMD5アルゴリズムで定められた初期値(図2ではAsおよびDs〜Bs)が格納された状態で、2クロックサイクルをかけて行われる。第1のクロックサイクルでは、レジスタ101〜104は、それぞれ、レジスタ111〜114の値(図2ではAsおよびDs〜Bs)を取り込む。同時に、レジスタ106および107は、それぞれ、外部から与えられた第0ラウンドで使用される入力データおよび定数値(図2ではX0およびT0)を取り込む。
【0028】
次に、第2のクロックサイクルでは、レジスタ105は、加算器126の出力(図2では(As+X0+T0))を取り込む。同時に、レジスタ101は、レジスタ102の値(図2ではDs)を取り込む。同時に、レジスタ106および107は、それぞれ、外部から与えられた第1ラウンドで使用される入力データおよび定数値(図2ではX1およびT1)を取り込む。
【0029】
(2)ラウンド処理
第0〜第62ラウンドの処理は、1ラウンドあたり1クロックサイクルをかけて(すなわち、各ブロックデータに対して63クロックサイクルをかけて)行われる。第0〜第62ラウンドの処理では、各クロックサイクルにおいて、レジスタ101および102は、いずれも、レジスタ103の値を取り込む。同時に、レジスタ103は、レジスタ104の値を取り込む。同時に、レジスタ104は、加算器128の出力を取り込む。同時に、レジスタ105は、加算器126の出力を取り込む。同時に、レジスタ106および107は、それぞれ、外部から与えられた、次の入力データおよび定数値を取り込む。ただし、第62ラウンドの処理では、レジスタ106および107は、任意の値を取り込んでもよい。
【0030】
例として、図2に示す第4ラウンドの処理を説明する。第0〜第3ラウンドの処理で求めた値を、順にA0、D0、C0およびB0とするとき、第3ラウンドの処理を完了した時点で、レジスタ101および102の値はD0、レジスタ103の値はC0、レジスタ104の値はB0、レジスタ105の値は(A0+X4+T4)、レジスタ106の値はX5、レジスタ107の値はT5となっている。そこで、第4ラウンドの処理では、レジスタ101および102は、いずれも、レジスタ103の値C0を取り込む。同時に、レジスタ103は、レジスタ104の値B0を取り込む。同時に、レジスタ104は、加算器128の出力A1を取り込む。ここで、A1は、式(1)において、α〜ΔにA0〜D0を、XiにX4を、TiにT4を代入したときに得られる値である。同時に、レジスタ105は、加算器126の出力(D0+X5+T5)を取り込む。同時に、レジスタ106および107は、それぞれ、次の入力データX6および次の定数値T6を取り込む。
【0031】
一方、ラウンド終端処理は、各ブロックデータに対して4クロックサイクルをかけて行われる。第1のクロックサイクルでは、レジスタ111は、加算器121の出力(図2ではAm)を取り込む。同時に、レジスタ102および103は、それぞれ、レジスタ103および104の値(図2ではD15およびC15)を取り込む。同時に、レジスタ104は、加算器128の出力(図2ではB15)を取り込む。なお、レジスタ101は、任意の値を取り込んでもよく、ここではレジスタ103の値を取り込むものとする。
【0032】
次に、第2のクロックサイクルでは、レジスタ112〜114は、それぞれ、加算器122〜124の出力(図2ではDm〜Bm)を取り込む。なお、レジスタ101〜104は、任意の値を取り込んでもよく、ここでは1つ前のクロックサイクルの値を保持するものとする。
【0033】
次に、第3のクロックサイクルでは、レジスタ101〜104は、それぞれ、レジスタ111〜114の値(図2ではAmおよびDm〜Bm)を取り込む。同時に、レジスタ106および107は、それぞれ、外部から与えられた第0ラウンドで使用される入力データおよび定数値(図2ではX0およびT0)を取り込む。
【0034】
次に、第4のクロックサイクルでは、レジスタ105は、加算器126の出力(図2では(Am+X0+T0))を取り込む。同時に、レジスタ101は、レジスタ102の値(図2ではDm)を取り込む。同時に、レジスタ106および107は、それぞれ、外部から与えられた第1ラウンドで使用される入力データおよび定数値(図2ではX1およびT1)を取り込む。なお、第3および第4のクロックサイクルでレジスタ106に取り込まれる入力データは、次のブロックデータに含まれるデータである。
【0035】
(3)ハッシュ後処理
ハッシュ後処理は、2クロックサイクルをかけて行われる。第1のクロックサイクルでは、レジスタ111は、加算器121の出力(図2ではAe)を取り込む。同時に、レジスタ102および103は、それぞれ、レジスタ103および104の値(図2ではD15およびC15)を取り込む。同時に、レジスタ104は、加算器128の出力(図2ではB15)を取り込む。なお、レジスタ101は、任意の値を取り込んでもよく、ここではレジスタ103の値を取り込むものとする。
【0036】
次に、第2のクロックサイクルでは、レジスタ112〜114は、それぞれ、加算器122〜124の出力(図2ではDe〜Be)を取り込む。なお、レジスタ101〜104は、任意の値を取り込んでもよく、ここでは1つ前のクロックサイクルの値を保持するものとする。
【0037】
第2のクロックサイクルが完了した時点でレジスタ111〜114に格納されている値(図2ではAeおよびDe〜Be)が、求めるべきハッシュ値となる。したがって、図示しない手段を用いてレジスタ111〜114の値を読み出すことにより、入力データ全体に対するハッシュ値を得ることができる。
【0038】
また、第2のクロックサイクルが完了する前の、レジスタ111および加算器122〜124の出力(図1に示す出力信号HV)は、求めるべきハッシュ値に一致する。したがって、ハッシュ関数処理装置10の外部に128ビットのレジスタを設け、設けたレジスタがこのときの出力信号HVを取り込むことにより、入力データ全体に対するハッシュ値を得ることができる。
【0039】
以下、ハッシュ関数処理装置10が奏する効果について説明する。式(1)に示すように、MD5アルゴリズムにおけるラウンド処理では、入力データおよび定数値はフィードバックデータに依存しない。したがって、式(1)に示す演算は、次式(2)および(3)に示すように、2つの演算に分解することができる。ただし、式(2)および(3)において、Qは32ビットの変数である。
Q=α+Xi+Ti …(2)
α=β+((Q+Fi(β,γ,Δ))<<<Si) …(3)
【0040】
これに対応して、ハッシュ関数処理装置10は、式(2)に示す演算処理を行う第1の演算処理部161と、式(3)に示す演算処理を行う第2の演算処理部162と、第1の演算処理部161の出力を格納するレジスタ105とを備えている。また、第1の演算処理部161と第2の演算処理部162とは並列に動作し、第2の演算処理部162の入力はレジスタ105から供給される。これにより、第1の演算処理部161と、第2の演算処理部162と、レジスタ105とによって、2段のパイプライン処理が行われる。また、パイプラインに適切なタイミングでデータを供給するために、各ラウンドで使用される入力データXiおよび定数値Tiは、本来読み込むべきタイミングよりも1クロックサイクル前に読み込まれる。さらに、ラウンド処理を実行中に正しくデータが供給されるように、ハッシュ関数処理装置10は、レジスタ102を経由せずに、レジスタ103の値をレジスタ101に直接書き込む経路も有している。
【0041】
以上のことから、本実施形態に係るハッシュ関数処理装置によれば、2段のパイプライン処理を行うことにより、MD5アルゴリズムのラウンド処理を、外見上1ラウンドあたり1クロックサイクルで高速に実行することができる。
【0042】
(第2の実施形態)
図3は、本発明の第2の実施形態に係るハッシュ関数処理装置の論理回路図である。図3に示すハッシュ関数処理装置20は、第1の実施形態に係るハッシュ関数処理装置10に含まれる回路の一部を変更したものである。ハッシュ関数処理装置20は、レジスタ201〜207および211〜214、加算器221〜228、セレクタ231〜239、巡回シフト演算ブロック241、並びに論理演算ブロック251〜254を備えている。このうち、加算器225および226は、第1の演算処理部261を構成している。また、加算器227および228、セレクタ239、巡回シフト演算ブロック241、並びに、論理演算ブロック251〜254は、第2の演算処理部262を構成している。
【0043】
ハッシュ関数処理装置20の回路構成は、第1の実施形態に係るハッシュ関数処理装置10の回路構成と、次の4つの点で相違する。第1に、セレクタ235は、レジスタ211の値と、レジスタ202の値と、レジスタ203の値と、加算器221の出力と、加算器222の出力とから、適切な値を選択して出力する。第2に、セレクタ236は、レジスタ212の値と、レジスタ203の値と、加算器222の出力とから、適切な値を選択して出力する。第3に、セレクタ237は、レジスタ213の値と、レジスタ204の値と、加算器223の出力とから、適切な値を選択して出力する。第4に、セレクタ238は、レジスタ214の値と、加算器228の出力と、加算器224の出力とから、適切な値を選択して出力する。ハッシュ関数処理装置20の上記以外の構成要素は、ハッシュ関数処理装置10と同じであるので、ここでは説明を省略する。
【0044】
ハッシュ関数処理装置20は、第1の実施形態に係るハッシュ関数処理装置10と同様に、入力データに対して、まずハッシュ前処理を行い、次にラウンド処理を行い、最後にハッシュ後処理を行う。これら3つの処理の内容は、ハッシュ関数処理装置10と同じである。図4は、これら3つの処理によって、レジスタ201〜207および211〜214の値が変化する様子を示す図である。以下、図4を適宜参照しながら、ハッシュ関数処理装置20の動作を説明する。
【0045】
(1)ハッシュ前処理
ハッシュ関数処理装置20におけるハッシュ前処理は、第1の実施形態に係るハッシュ関数処理装置10における処理と同じである。
【0046】
(2)ラウンド処理
ハッシュ関数処理装置20における第0〜第62ラウンドの処理は、第1の実施形態に係るハッシュ関数処理装置10における処理と同じである。第0〜第62ラウンドの処理は、1ラウンドあたり1クロックサイクルをかけて(すなわち、各ブロックデータに対して63クロックサイクルをかけて)行われる。
【0047】
一方、ラウンド終端処理は、各ブロックデータに対して2クロックサイクルをかけて行われる。第1のクロックサイクルでは、レジスタ201および211は、いずれも、加算器221の出力(図4ではAm)を取り込む。同時に、レジスタ202および203は、それぞれ、レジスタ203および204の値(図4ではD15およびC15)を取り込む。同時に、レジスタ204は、加算器228の出力(図4ではB15)を取り込む。同時に、レジスタ206および207は、それぞれ、外部から与えられた第0ラウンドで使用される入力データおよび定数値(図4ではX0およびT0)を取り込む。
【0048】
次に、第2のクロックサイクルでは、レジスタ201、202および212は、いずれも、加算器222の出力(図4ではDm)を取り込む。同時に、レジスタ203および213は、いずれも、加算器223の出力(図4ではCm)を取り込む。同時に、レジスタ204および214は、いずれも、加算器224の出力(図4ではBm)を取り込む。同時に、レジスタ205は、加算器226の出力(図4では(Am+X0+T0))を取り込む。同時に、レジスタ206および207は、それぞれ、外部から与えられた第1ラウンドで使用される入力データおよび定数値(図4ではX1およびT1)を取り込む。なお、第1および第2のクロックサイクルでレジスタ206に取り込まれる入力データは、次のブロックデータに含まれるデータである。
【0049】
(3)ハッシュ後処理
ハッシュ後処理は、2クロックサイクルをかけて行われる。第1のクロックサイクルでは、レジスタ211は、加算器221の出力(図4ではAe)を取り込む。同時に、レジスタ202および203は、それぞれ、レジスタ203および204の値(図4ではD15およびC15)を取り込む。同時に、レジスタ204は、加算器228の出力(図4ではB15)を取り込む。なお、レジスタ201は、任意の値を取り込んでもよく、ここでは加算器221の出力を取り込むものとする。
【0050】
次に、第2のクロックサイクルでは、レジスタ212〜214は、それぞれ、加算器222〜224の出力(図4ではDe〜Be)を取り込む。なお、レジスタ201〜204は、任意の値を取り込んでもよく、ここでは、レジスタ201は、加算器222の出力を取り込み、レジスタ202〜204は、それぞれ、加算器222〜224の出力を取り込むものとする。
【0051】
第2のクロックサイクルが完了した時点でレジスタ211〜214に格納されている値(図4ではAe〜De)が、求めるべきハッシュ値となる。したがって、図示しない手段を用いてレジスタ211〜214の値を読み出すことにより(あるいは、外部に設けたレジスタがハッシュ後処理の第2のクロックサイクルにおける出力信号HVの値を取り込むことにより)、入力データ全体に対するハッシュ値を得ることができる。
【0052】
このようにハッシュ関数処理装置20は、上述した4つの点で第1の実施形態に係るハッシュ関数処理装置10と異なるにも関わらず、MD5アルゴリズムにおけるラウンド処理を正しく実行することができる。また、第1の実施形態に係るハッシュ関数処理装置10は、4クロックサイクルをかけてラウンド終端処理を行うのに対して、ハッシュ関数処理装置20は、2クロックサイクルをかけてラウンド終端処理を行う。
【0053】
以上のことから、本実施形態に係るハッシュ関数処理装置によれば、第1の実施形態に係るハッシュ関数処理装置が奏する効果に加えて、ラウンド終端処理にかかるクロックサイクル数を減らし、ラウンド処理をより高速に実行できるという効果がある。
【0054】
(第3の実施形態)
図5は、本発明の第3の実施形態に係るハッシュ関数処理装置の論理回路図である。図5に示すハッシュ関数処理装置30は、第1の実施形態に係るハッシュ関数処理装置10に含まれる回路の一部を変更したものである。ハッシュ関数処理装置30は、レジスタ302〜307および311〜314、加算器321〜328、セレクタ331〜334および336〜339、巡回シフト演算ブロック341、並びに論理演算ブロック351〜354を備えている。このうち、加算器325および326は、第1の演算処理部361を構成している。また、加算器327および328、セレクタ339、巡回シフト演算ブロック341、並びに、論理演算ブロック351〜354は、第2の演算処理部362を構成している。
【0055】
ハッシュ関数処理装置30の回路構成は、第1の実施形態に係るハッシュ関数処理装置10の回路構成と、次の3つの点で相違する。第1に、ハッシュ関数処理装置10のレジスタ101およびセレクタ135は、ハッシュ関数処理装置20では削除されている。第2に、セレクタ336は、レジスタ311の値と、レジスタ312の値と、レジスタ303の値とから、適切な値を選択して出力する。第3に、加算器321は、レジスタ302の値とレジスタ311の値とを加算する。ハッシュ関数処理装置30の上記以外の構成要素は、ハッシュ関数処理装置10と同じであるので、ここでは説明を省略する。なお、本実施形態では、レジスタ302〜304は、順に、第1のレジスタR1、第3のレジスタR3、および第2のレジスタR2と呼ばれる。
【0056】
ハッシュ関数処理装置30は、第1の実施形態に係るハッシュ関数処理装置10と同様に、入力データに対して、まずハッシュ前処理を行い、次にラウンド処理を行い、最後にハッシュ後処理を行う。これら3つの処理の内容は、ハッシュ関数処理装置10と同じである。図6は、これら3つの処理によって、レジスタ302〜307および311〜314の値が変化する様子を示す図である。以下、図6を適宜参照しながら、ハッシュ関数処理装置30の動作を説明する。
【0057】
(1)ハッシュ前処理
ハッシュ前処理は、レジスタ311〜314にMD5アルゴリズムで定められた初期値(図6ではAsおよびDs〜Bs)が格納された状態で、2クロックサイクルをかけて行われる。第1のクロックサイクルでは、レジスタ302は、第1の実施形態とは異なり、レジスタ311の値(図6ではAs)を取り込む。同時に、レジスタ303および304は、それぞれ、レジスタ313および314の値(図6ではCsおよびBs)を取り込む。同時に、レジスタ306および307は、それぞれ、外部から与えられた第0ラウンドで使用される入力データおよび定数値(図6ではX0およびT0)を取り込む。
【0058】
次に、第2のクロックサイクルでは、レジスタ305は、加算器326の出力(図6では(As+X0+T0))を取り込む。同時に、レジスタ302は、第1の実施形態とは異なり、レジスタ312の値(図6ではDs)を取り込む。同時に、レジスタ306および307は、それぞれ、外部から与えられた第1ラウンドで使用される入力データおよび定数値(図6ではX1およびT1)を取り込む。
【0059】
(2)ラウンド処理
第0〜第62ラウンドの処理は、1ラウンドあたり1クロックサイクルをかけて(すなわち、各ブロックデータに対して63クロックサイクルをかけて)行われる。ハッシュ関数処理装置30による第0〜第62ラウンドの処理は、レジスタ101に対応したレジスタが存在しない点を除き、第1の実施形態に係るハッシュ関数処理装置10による処理と同じである。すなわち、各クロックサイクルにおいて、レジスタ302は、レジスタ303の値を取り込む。同時に、レジスタ303は、レジスタ304の値を取り込む。同時に、レジスタ304は、加算器328の出力を取り込む。同時に、レジスタ305は、加算器326の出力を取り込む。同時に、レジスタ306および307は、それぞれ、外部から与えられた、次の入力データおよび定数値を取り込む。ただし、第62ラウンドの処理では、レジスタ306および307は、任意の値を取り込んでもよい。
【0060】
一方、ラウンド終端処理は、各ブロックデータに対して4クロックサイクルをかけて行われる。第1のクロックサイクルでは、レジスタ311は、加算器321の出力(図6ではAm)を取り込む。同時に、レジスタ302および303は、それぞれ、レジスタ303および304の値(図6ではD15およびC15)を取り込む。同時に、レジスタ304は、加算器328の出力(図6ではB15)を取り込む。
【0061】
次に、第2のクロックサイクルでは、レジスタ312〜314は、それぞれ、加算器322〜324の出力(図6ではDm〜Bm)を取り込む。なお、レジスタ302〜304は、任意の値を取り込んでもよく、ここでは1つ前のクロックサイクルの値を保持するものとする。
【0062】
次に、第3のクロックサイクルでは、レジスタ302は、レジスタ311の値(図6ではAm)を取り込む。同時に、レジスタ303および304は、それぞれ、レジスタ313および314の値(図6ではCmおよびBm)を取り込む。同時に、レジスタ306および307は、それぞれ、外部から与えられた第0ラウンドで使用される入力データおよび定数値(図6ではX0およびT0)を取り込む。
【0063】
次に、第4のクロックサイクルでは、レジスタ305は、加算器326の出力(図6では(Am+X0+T0))を取り込む。同時に、レジスタ302は、レジスタ312の値(図6ではDm)を取り込む。同時に、レジスタ306および307は、それぞれ、外部から与えられた第1ラウンドで使用される入力データおよび定数値(図6ではX1およびT1)を取り込む。なお、第3および第4のクロックサイクルでレジスタ306に取り込まれる入力データは、次のブロックデータに含まれるデータである。
【0064】
(3)ハッシュ後処理
ハッシュ後処理は、2クロックサイクルをかけて行われる。第1のクロックサイクルでは、レジスタ311は、加算器321の出力(図6ではAe)を取り込む。同時に、レジスタ302および303は、それぞれ、レジスタ303および304の値(図6ではD15およびC15)を取り込む。同時に、レジスタ304は、加算器328の出力(図6ではB15)を取り込む。
【0065】
次に、第2のクロックサイクルでは、レジスタ312〜314は、それぞれ、加算器322〜324の出力(図6ではDe〜Be)を取り込む。なお、レジスタ302〜304は、任意の値を取り込んでもよく、ここでは1つ前のクロックサイクルの値を保持するものとする。
【0066】
第2のクロックサイクルが完了した時点でレジスタ311〜314に格納されている値(図6ではAeおよびDe〜Be)が、求めるべきハッシュ値となる。したがって、図示しない手段を用いてレジスタ311〜314の値を読み出すことにより(あるいは、外部に設けたレジスタがハッシュ後処理の第2のクロックサイクルにおける出力信号HVの値を取り込むことにより)、入力データ全体に対するハッシュ値を得ることができる。
【0067】
このようにハッシュ関数処理装置30は、上述した3つの点で第1の実施形態に係るハッシュ関数処理装置10と異なるにも関わらず、MD5アルゴリズムにおけるラウンド処理を正しく実行することができる。また、ハッシュ関数処理装置30からは、レジスタ101に対応するレジスタが除去されている。
【0068】
以上のことから、本実施形態に係るハッシュ関数処理装置によれば、第1の実施形態に係るハッシュ関数処理装置が奏する効果に加えて、回路規模を削減できるという効果がある。
【0069】
(第4の実施形態)
図7は、本発明の第4の実施形態に係るハッシュ関数処理装置の論理回路図である。図7に示すハッシュ関数処理装置40は、第3の実施形態に係るハッシュ関数処理装置30に含まれる回路の一部を変更したものである。ハッシュ関数処理装置40は、レジスタ402〜407および411〜414、加算器421〜428、セレクタ431〜434および436〜439、巡回シフト演算ブロック441、並びに論理演算ブロック451〜454を備えている。このうち、加算器425および426は、第1の演算処理部461を構成している。また、加算器427および428、セレクタ439、巡回シフト演算ブロック441、並びに、論理演算ブロック451〜454は、第2の演算処理部462を構成している。
【0070】
ハッシュ関数処理装置40の回路構成は、第3の実施形態に係るハッシュ関数処理装置30の回路構成と、次の3つの点で相違する。第1に、セレクタ436は、レジスタ411の値と、レジスタ412の値と、レジスタ403の値と、加算器421の出力とから、適切な値を選択して出力する。第2に、セレクタ437は、レジスタ413の値と、レジスタ404の値と、加算器423の出力とから、適切な値を選択して出力する。第3に、セレクタ438は、レジスタ414の値と、加算器428の出力と、加算器424の出力とから、適切な値を選択して出力する。ハッシュ関数処理装置40の上記以外の構成要素は、ハッシュ関数処理装置30と同じであるので、ここでは説明を省略する。
【0071】
ハッシュ関数処理装置40は、第3の実施形態に係るハッシュ関数処理装置30と同様に、入力データに対して、まずハッシュ前処理を行い、次にラウンド処理を行い、最後にハッシュ後処理を行う。これら3つの処理の内容は、ハッシュ関数処理装置30と同じである。図8は、これら3つの処理によって、レジスタ402〜407および411〜414の値が変化する様子を示す図である。以下、図8を適宜参照しながら、ハッシュ関数処理装置40の動作を説明する。
【0072】
(1)ハッシュ前処理
ハッシュ関数処理装置40におけるハッシュ前処理は、第3の実施形態に係るハッシュ関数処理装置30における処理と同じである。
【0073】
(2)ラウンド処理
ハッシュ関数処理装置40における第0〜第62ラウンドの処理は、第3の実施形態に係るハッシュ関数処理装置30における処理と同じである。第0〜第62ラウンドの処理は、1ラウンドあたり1クロックサイクルをかけて(すなわち、各ブロックデータに対して63クロックサイクルをかけて)行われる。
【0074】
一方、ラウンド終端処理は、各ブロックデータに対して2クロックサイクルをかけて行われる。第1のクロックサイクルでは、レジスタ402および411は、いずれも、加算器421の出力(図8ではAm)を取り込む。同時に、レジスタ412は、加算器422の出力(図8ではDm)を取り込む。同時に、レジスタ403は、レジスタ404の値(図8ではC15)を取り込む。同時に、レジスタ404は、加算器428の出力(図8ではB15)を取り込む。同時に、レジスタ406および407は、それぞれ、外部から与えられた第0ラウンドで使用される入力データおよび定数値(図8ではX0およびT0)を取り込む。
【0075】
次に、第2のクロックサイクルでは、レジスタ402は、レジスタ412の値(図4ではDm)を取り込む。同時に、レジスタ403および413は、いずれも、加算器423の出力(図8ではCm)を取り込む。同時に、レジスタ404および414は、いずれも、加算器424の出力(図8ではBm)を取り込む。同時に、レジスタ405は、加算器426の出力(図8では(Am+X0+T0))を取り込む。同時に、レジスタ406および407は、それぞれ、外部から与えられた第1ラウンドで使用される入力データおよび定数値(図8ではX1およびT1)を取り込む。なお、第1および第2のクロックサイクルでレジスタ406に取り込まれる入力データは、次のブロックデータに含まれるデータである。
【0076】
(3)ハッシュ後処理
ハッシュ後処理は、2クロックサイクルをかけて行われる。第1のクロックサイクルでは、レジスタ411および412は、それぞれ、加算器421および422の出力(図8ではAeおよびDe)を取り込む。同時に、レジスタ403は、レジスタ404の値(図8ではC15)を取り込む。同時に、レジスタ404は、加算器428の出力(図8ではB15)を取り込む。レジスタ402は、任意の値を取り込んでもよく、ここでは加算器421の出力を取り込むものとする。
【0077】
次に、第2のクロックサイクルでは、レジスタ413および414は、それぞれ、加算器423および424の出力(図8ではCeおよびBe)を取り込む。レジスタ402〜404は、任意の値を取り込んでもよく、ここではレジスタ402は、レジスタ412の値を取り込み、レジスタ403および404は、それぞれ、加算器423および424の出力を取り込むものとする。
【0078】
第2のクロックサイクルが完了した時点でレジスタ411〜414に格納されている値(図8ではAeおよびDe〜Be)が、求めるべきハッシュ値となる。したがって、図示しない手段を用いてレジスタ411〜414の値を読み出すことにより(あるいは、外部に設けたレジスタがハッシュ後処理の第2のクロックサイクルにおける出力信号HVの値を取り込むことにより)、入力データ全体に対するハッシュ値を得ることができる。
【0079】
このようにハッシュ関数処理装置40は、上述した4つの点で第3の実施形態に係るハッシュ関数処理装置30と異なるにも関わらず、MD5アルゴリズムにおけるラウンド処理を正しく実行することができる。また、第3の実施形態に係るハッシュ関数処理装置30は、4クロックサイクルをかけてラウンド終端処理を行うのに対して、ハッシュ関数処理装置40は、2クロックサイクルをかけてラウンド終端処理を行う。
【0080】
以上のことから、本実施形態に係るハッシュ関数処理装置によれば、第3の実施形態に係るハッシュ関数処理装置が奏する効果に加えて、ラウンド終端処理にかかるクロックサイクル数を減らし、ラウンド処理をより高速に実行できるという効果がある。すなわち、第1の実施形態に係るハッシュ関数処理装置が奏する効果に加えて、回路規模を削減し、かつ、ラウンド処理をより高速に実行できるという効果がある。
【0081】
なお、本発明のハッシュ関数処理装置は、上述したパイプライン処理によって第0〜第62ラウンドの処理を行うものであればよく、上記各実施形態で示した装置以外の変形例を構成することができる。例えば、第1の実施形態に係るハッシュ関数処理装置10について言えば、初期値As〜Dsをレジスタ111〜114に設定するタイミング、ハッシュ前処理、ラウンド終端処理、およびハッシュ後処理におけるレジスタ101〜104の更新タイミング、レジスタ111〜114の更新タイミング、任意の値を取り込んでもよいレジスタに設定される値等については、種々の設計が可能である。第2ないし第4の実施形態に係るハッシュ関数処理装置についても、これと同様である。
【0082】
また、上記各実施形態では、ハッシュ関数としてMD5アルゴリズムを使用することとしたが、ハッシュ関数として他のアルゴリズムを使用してもよいことは言うまでもない。
【図面の簡単な説明】
【図1】本発明の第1の実施形態に係るハッシュ関数処理装置の論理回路図である。
【図2】本発明の第1の実施形態に係るハッシュ関数処理装置に含まれるレジスタの値が変化する様子を示す図である。
【図3】本発明の第2の実施形態に係るハッシュ関数処理装置の論理回路図である。
【図4】本発明の第2の実施形態に係るハッシュ関数処理装置に含まれるレジスタの値が変化する様子を示す図である。
【図5】本発明の第3の実施形態に係るハッシュ関数処理装置の論理回路図である。
【図6】本発明の第3の実施形態に係るハッシュ関数処理装置に含まれるレジスタの値が変化する様子を示す図である。
【図7】本発明の第4の実施形態に係るハッシュ関数処理装置の論理回路図である。
【図8】本発明の第4の実施形態に係るハッシュ関数処理装置に含まれるレジスタの値が変化する様子を示す図である。
【符号の説明】
10、20、30、40…ハッシュ関数処理装置
101〜107、111〜114、201〜207、211〜214、302〜307、311〜314、402〜407、411〜414…レジスタ
121〜128、221〜228、321〜328、421〜428…加算器
131〜139、231〜239、331〜334、336〜339、431〜434、436〜439…セレクタ
141、241、341、441…巡回シフト演算ブロック
151〜154、251〜254、351〜354、451〜454…論理演算ブロック
161、261、361、461…第1の演算処理部
162、262、362、462…第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 processing device for a hash function, for example, a processing device described in Patent Literature 1 is known. In this processing device, a circuit unit divided into a plurality of stages is configured by interposing a register in a flow direction of processing data processed by a plurality of stages of arithmetic units. In addition, this processing apparatus performs at least the following steps while performing a calculation process in the calculator using the output data from the rotation processing unit and the feedback data of one cycle before using the bit replacement process for the input data by the rotation processing unit. The present invention is characterized in that arithmetic processing on input data of a cycle and output data from a set number of parts are performed in an overlapping manner.
[0004]
[Patent Document 1]
JP-A-2002-72879
[0005]
[Problems to be solved by the invention]
However, in the above-described conventional processing apparatus, two clock cycles are required per round at the highest speed in order to perform the repetition processing (hereinafter, round processing) in the hash function. For this reason, the conventional processing apparatus is not suitable for applications requiring high-speed processing. Further, in order to realize the overlap processing, it is necessary to divide the pipeline processing into a plurality of stages, and a large number of hardware resources such as registers are required. As described above, the above-described conventional processing apparatus also has a problem that the circuit scale is increased and the cost is increased.
[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 with one clock cycle per round. Another 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 a small amount of 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 the hash function, a value of the first 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 second 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 An operation of taking in the operation result by the control unit, an operation of the second register taking in the operation result of the second operation processing unit, an operation of taking in the value of the second register by the third register, and the first and fourth registers. Of the third register, the operation of the input data supply unit to acquire the next input data, and the operation of the constant value supply unit to acquire the next constant value within one clock cycle. Are performed in parallel.
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.
[0008]
A second invention is a hash function processing device that performs iterative processing defined by a hash function on input data, the first to third registers storing feedback data, and a predetermined length of input data. An input data supply unit for supplying, a constant value supply unit for supplying a constant value determined by the hash function, a value of the first 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 third 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 second register takes in the operation result of the second operation processing unit, the third register takes in the value of the second register, and the first register takes the value of the second register. The operation of capturing the value of the third register, the operation of the input data supply unit acquiring the next input data, and the operation of the constant value supply unit acquiring the next constant value are performed in parallel within one clock cycle. It is characterized by being performed.
According to the second 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 intermediate. 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 a small amount of hardware resources.
[0009]
In a third aspect based on the first or second aspect, the first arithmetic processing unit is configured to receive the value of the first register, the input data supplied from the input data supply unit, and the input data supplied from the constant value supply unit. And a constant value.
[0010]
In a fourth 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 stores the arithmetic result and the value of the intermediate value storage register. Is cyclically shifted by a predetermined number of bits and then added to the value of the second register.
[0011]
In a fifth aspect based on the second aspect, the second arithmetic processing unit performs a predetermined logical operation on the values of the first to third registers, and calculates a result of the arithmetic operation with the value of the intermediate value storage register. Is cyclically shifted by a predetermined number of bits and then added to the value of the second register.
[0012]
According to a sixth aspect, in any one of the first to fifth aspects, the hash function is MD5 (Message Digest 5).
According to the third to sixth aspects, the repetitive processing in the MD5 algorithm can be executed at a high speed with one clock cycle per round in appearance.
[0013]
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 Message Digest 5 (hereinafter, referred to as MD5), which is a type of hash function. MD5 is a function for obtaining a 128-bit hash value from input data of an arbitrary length. In the MD5 algorithm, input data is divided into 512 bits at a time from the beginning. Then, the following processing (hereinafter, referred to as 64 round processing) is sequentially performed on each divided input data (hereinafter, referred to as block data).
[0014]
In the 64-round process, variables A, B, C, and D of 32 bits are used. Before performing the 64-round processing on each block data, the variables A to D have predetermined initial values As to Ds (when the block data is the first block data) or the variables A to D in the 64-round processing on the block data so far. One of the obtained values of the variables A to D (when the data is not the first block data) is set. Then, the operation shown in the following equation (1) is performed 64 times while the variable i is sequentially increased from 0 to 63 in steps of one.
α = β + ((α + Fi (β, γ, Δ) + Xi + Ti) <<<< Si) (1)
Here, in the equation (1), <<<< indicates a left cyclic shift, and Fi, Xi, Ti, and Si represent a logical operation, a 32-bit input data, a 32-bit constant value, and a logical operation in the i-th operation, respectively. Indicates the shift number. Α to Δ are A, B, C, and D in order when the remainder j obtained by dividing i by 4 is 0, and D, A, B, and in order when j is 1. If it is C and j is 2, then it is C, D, A, B in order, and if j is 3, it is B, C, D, A in order.
[0015]
Hereinafter, the i-th operation using Expression (1) is referred to as an i-th round process. After the 63rd round of processing is completed for each block data, the values of the variables A to D are added to the values of the variables A to D obtained by the 64 round processing on the block data so far. When 64 rounds of processing are performed on all block data included in the input data, the result obtained by the final addition becomes the hash value to be obtained. The details of the MD5 algorithm are described in, for example, R. Rivest, "The MD5 Message Digest Algorithm", IETF RFC 1321, 1992. It is described in.
[0016]
The hash function processing device 10 shown in FIG. 1 includes registers 101 to 107 and 111 to 114, adders 121 to 128, selectors 131 to 139, a cyclic shift operation block 141, and logical operation blocks 151 to 154. Among them, the adders 125 and 126 constitute the first arithmetic processing unit 161. Further, the adders 127 and 128, the selector 139, the cyclic shift operation block 141, and the logical operation blocks 151 to 154 constitute a second operation processing unit 162.
[0017]
The data width of each of the signal lines shown in FIG. 1 is 32 bits except for the output signal HV of 128 bits. In FIG. 1, control signals and control circuits for controlling round processing in the MD5 algorithm are omitted for simplification of the drawing. This notation is also applied to FIGS. 3, 5, and 7 described below.
[0018]
In FIG. 1, registers 101 to 104 store feedback data used in round processing in the MD5 algorithm. The registers 101 to 104 are also referred to as a first register R1, a fourth register R4, a third register R3, and a second register R2, respectively. The register 105 stores intermediate data when performing round processing in the MD5 algorithm. The register 106 stores the input data Xi divided into 32 bits each, which is processed by the round processing in the MD5 algorithm. The register 107 stores a predetermined constant value Ti for each round in the round processing in the MD5 algorithm. Each of the registers 111 to 114 stores a value obtained by 64-round processing on the block data so far in the MD5 algorithm.
[0019]
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 106 and the value of the register 107. The adder 126 adds the value of the register 101 and the output of the adder 125. The adder 127 adds the value of the register 105 and the output of the selector 139. The adder 128 adds the value of the register 104 and the output of the cyclic shift operation block 141.
[0020]
The selector 131 selects and outputs an appropriate value from the initial value As before the round process in the MD5 algorithm and the output of the adder 121. The selector 132 selects and outputs an appropriate value from the initial value Ds before the start of the round process in the MD5 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 process in the MD5 algorithm and the output of the adder 123. The selector 134 selects and outputs an appropriate value from the initial value Bs before the start of the round processing in the MD5 algorithm and the output of the adder 124.
[0021]
The selector 135 selects and outputs an appropriate value from the value of the register 111, the value of the register 102, and the value of the register 103. The selector 136 selects and outputs an appropriate value from the value of the register 112 and the value of the register 103. The selector 137 selects and outputs an appropriate value from the value of the register 113 and the value of the register 104. The selector 138 selects and outputs an appropriate value from the value of the register 114 and the output of the adder 128. The selector 139 selects and outputs an appropriate value from the outputs of the logical operation blocks 151 to 154. The selectors 131 to 139 select and output appropriate values so that round processing and the like described later can be performed correctly.
[0022]
The cyclic shift operation block 141 performs a cyclic shift operation according to the MD5 algorithm. More specifically, the cyclic shift operation block 141 cyclically shifts the input to the left by a value designated for each round in the round processing in the MD5 algorithm. Note that the shift direction in the cyclic shift operation block 141 is the left direction when the bits included in the input are arranged such that the left side is higher.
[0023]
The logical operation blocks 151 to 154 perform any one of four types of predetermined logical operations in the round processing in the MD5 algorithm. Specifically, the logical operation block 151 performs a logical operation in the 0th to 15th rounds. The logical operation block 152 performs a logical operation in the 16th to 31st rounds. The logical operation block 153 performs a logical operation in the 32nd to 47th rounds. The logical operation block 154 performs a logical operation in the 48th to 63rd rounds. More specifically, the value of the register 104 is X, the value of the register 103 is Y, the value of the register 102 is Z, and the logical operations of logical sum, logical product, negation, and exclusive logical sum are respectively, and, or , Not and xor, the logical operation block 151 performs a logical operation of “(XandY) or ((notX) andZ)”. The logical operation block 152 performs a logical operation of “(XandZ) or (Yand (notZ))”. The logical operation block 153 performs a logical operation “XxorYxorZ”. The logical operation block 154 performs a logical operation of “Yxor (Xor (notZ))”.
[0024]
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, the processing of the 0th to 62nd rounds in the MD5 algorithm and the round end processing are performed on each block data. In the round end processing, (a) processing of the 63rd round in the MD5 algorithm, (b) processing of adding the value obtained this time to 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.
[0025]
FIG. 2 is a diagram illustrating how the values of the registers 101 to 107 and 111 to 114 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 FIGS. 4, 6 and 8 described later.
[0026]
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.
[0027]
(1) Hash preprocessing
The hash preprocessing is performed in two clock cycles in a state where the registers 111 to 114 store initial values (As and Ds to Bs in FIG. 2) determined by the MD5 algorithm. In the first clock cycle, the registers 101 to 104 take in the values of the registers 111 to 114 (As and Ds to Bs in FIG. 2), respectively. At the same time, registers 106 and 107 fetch input data and constant values (X0 and T0 in FIG. 2) used in the 0th round provided from the outside, respectively.
[0028]
Next, in the second clock cycle, the register 105 takes in the output of the adder 126 ((As + X0 + T0) in FIG. 2). At the same time, the register 101 takes in the value of the register 102 (Ds in FIG. 2). At the same time, registers 106 and 107 take in input data and constant values (X1 and T1 in FIG. 2) used in the first round, respectively, provided from the outside.
[0029]
(2) Round processing
The processing of the 0th to 62nd rounds is performed by taking one clock cycle per round (that is, by taking 63 clock cycles for each block data). In the processing of the 0th to 62nd rounds, each of the registers 101 and 102 takes in the value of the register 103 in each clock cycle. At the same time, the register 103 captures the value of the register 104. At the same time, the register 104 captures the output of the adder 128. At the same time, the register 105 captures the output of the adder 126. At the same time, registers 106 and 107 take in the next input data and constant value respectively given from outside. However, in the processing of the 62nd round, the registers 106 and 107 may take in arbitrary values.
[0030]
As an example, the processing of the fourth round shown in FIG. 2 will be described. When the values obtained in the processing of the 0th to third rounds are A0, D0, C0, and B0 in order, the value of the registers 101 and 102 is D0 and the value of the register 103 when the processing of the third round is completed. Is C0, the value of the register 104 is B0, the value of the register 105 is (A0 + X4 + T4), the value of the register 106 is X5, and the value of the register 107 is T5. Therefore, in the processing of the fourth round, both the registers 101 and 102 take in the value C0 of the register 103. At the same time, the register 103 takes in the value B0 of the register 104. At the same time, the register 104 takes in the output A1 of the adder 128. Here, A1 is a value obtained by substituting A0 to D0 for α to Δ, X4 for Xi, and T4 for Ti in equation (1). At the same time, the register 105 takes in the output (D0 + X5 + T5) of the adder 126. At the same time, the registers 106 and 107 take in the next input data X6 and the next constant value T6, respectively.
[0031]
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 111 takes in the output of the adder 121 (Am in FIG. 2). At the same time, registers 102 and 103 take in the values of registers 103 and 104, respectively (D15 and C15 in FIG. 2). At the same time, the register 104 takes in the output of the adder 128 (B15 in FIG. 2). Note that the register 101 may take in an arbitrary value. Here, it is assumed that the value of the register 103 is taken in.
[0032]
Next, in the second clock cycle, the registers 112 to 114 take in the outputs (Dm to Bm in FIG. 2) of the adders 122 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.
[0033]
Next, in the third clock cycle, the registers 101 to 104 take in the values (Am and Dm to Bm in FIG. 2) of the registers 111 to 114, respectively. At the same time, registers 106 and 107 fetch input data and constant values (X0 and T0 in FIG. 2) used in the 0th round provided from the outside, respectively.
[0034]
Next, in the fourth clock cycle, the register 105 takes in the output of the adder 126 ((Am + X0 + T0) in FIG. 2). At the same time, the register 101 takes in the value of the register 102 (Dm in FIG. 2). At the same time, registers 106 and 107 take in input data and constant values (X1 and T1 in FIG. 2) used in the first round, respectively, provided 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.
[0035]
(3) Hash post-processing
Post-hash processing is performed over two clock cycles. In the first clock cycle, the register 111 takes in the output of the adder 121 (Ae in FIG. 2). At the same time, registers 102 and 103 take in the values of registers 103 and 104, respectively (D15 and C15 in FIG. 2). At the same time, the register 104 takes in the output of the adder 128 (B15 in FIG. 2). Note that the register 101 may take in an arbitrary value. Here, it is assumed that the value of the register 103 is taken in.
[0036]
Next, in the second clock cycle, the registers 112 to 114 take in the outputs (De to Be in FIG. 2) of the adders 122 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.
[0037]
At the time when the second clock cycle is completed, the values (Ae and De to Be in FIG. 2) stored in the registers 111 to 114 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 114 using means (not shown).
[0038]
Before the second clock cycle is completed, the outputs of the register 111 and the adders 122 to 124 (the output signal HV shown in FIG. 1) match the hash value to be obtained. Therefore, a 128-bit register is provided outside the hash function processing device 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.
[0039]
Hereinafter, the effects provided by the hash function processing device 10 will be described. As shown in Expression (1), in round processing in the MD5 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 = α + Xi + Ti (2)
α = β + ((Q + Fi (β, γ, Δ)) <<<< Si) (3)
[0040]
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. Further, the first arithmetic processing unit 161 and the second arithmetic processing unit 162 operate in parallel, and the input of the second arithmetic processing unit 162 is supplied from the register 105. Thus, the first arithmetic processing unit 161, the second arithmetic processing unit 162, and the register 105 perform two-stage pipeline processing. Also, in order to supply data to the pipeline at an appropriate timing, the input data Xi and the constant value Ti used in each round are read one clock cycle before the timing at which they should be read. Furthermore, the hash function processing device 10 also has a path for directly writing the value of the register 103 to the register 101 without passing through the register 102 so that data is correctly supplied during the round processing.
[0041]
As described above, according to the hash function processing device according to the present embodiment, the round processing of the MD5 algorithm can be executed at a high speed in one clock cycle per apparently by performing two-stage pipeline processing. Can be.
[0042]
(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 includes registers 201 to 207 and 211 to 214, adders 221 to 228, selectors 231 to 239, a cyclic shift operation block 241, and logical operation blocks 251 to 254. Among them, the adders 225 and 226 constitute the first arithmetic processing unit 261. The adders 227 and 228, the selector 239, the cyclic shift operation block 241, and the logical operation blocks 251 to 254 constitute a second operation processing unit 262.
[0043]
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 235 selects and outputs an appropriate value from the value of the register 211, the value of the register 202, the value of the register 203, the output of the adder 221, and the output of the adder 222. . Second, the selector 236 selects and outputs an appropriate value from the value of the register 212, the value of the register 203, and the output of the adder 222. Third, the selector 237 selects and outputs an appropriate value from the value of the register 213, the value of the register 204, and the output of the adder 223. Fourth, the selector 238 selects and outputs an appropriate value from the value of the register 214, the output of the adder 228, and the output of the adder 224. The other components of the hash function processing device 20 are the same as those of the hash function processing device 10, and a description thereof will be omitted.
[0044]
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 214 are changed by these three processes. Hereinafter, the operation of the hash function processing device 20 will be described with reference to FIG.
[0045]
(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.
[0046]
(2) Round processing
The processes in the 0th to 62nd 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 62nd rounds is performed by taking one clock cycle per round (that is, by taking 63 clock cycles for each block data).
[0047]
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 the registers 201 and 211 take in the output of the adder 221 (Am in FIG. 4). At the same time, the registers 202 and 203 take in the values (D15 and C15 in FIG. 4) of the registers 203 and 204, respectively. At the same time, the register 204 takes in the output of the adder 228 (B15 in FIG. 4). At the same time, the registers 206 and 207 respectively take in the input data and the constant values (X0 and T0 in FIG. 4) used in the 0th round given from the outside.
[0048]
Next, in the second clock cycle, the registers 201, 202, and 212 all take in the output (Dm in FIG. 4) of the adder 222. 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, both registers 204 and 214 take in the output of adder 224 (Bm in FIG. 4). At the same time, the register 205 takes in the output of the adder 226 ((Am + X0 + T0) in FIG. 4). At the same time, the registers 206 and 207 fetch input data and constant values (X1 and T1 in FIG. 4) used in the first 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.
[0049]
(3) Hash post-processing
Post-hash processing is performed over two clock cycles. In the first clock cycle, the register 211 takes in the output of the adder 221 (Ae in FIG. 4). At the same time, the registers 202 and 203 take in the values (D15 and C15 in FIG. 4) of the registers 203 and 204, respectively. At the same time, the register 204 takes in the output of the adder 228 (B15 in FIG. 4). Note that the register 201 may take in an arbitrary value. Here, it is assumed that the register 201 takes in the output of the adder 221.
[0050]
Next, in the second clock cycle, the registers 212 to 214 take in the outputs (De to Be in FIG. 4) of the adders 222 to 224, respectively. The registers 201 to 204 may take in arbitrary values. Here, the register 201 takes in the output of the adder 222, and the registers 202 to 204 take in the outputs of the adders 222 to 224, respectively. I do.
[0051]
When the second clock cycle is completed, the values (Ae to De in FIG. 4) stored in the registers 211 to 214 are hash values to be obtained. Therefore, by reading the values of the registers 211 to 214 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.
[0052]
As described above, the hash function processing device 20 can correctly execute the round process in the MD5 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. .
[0053]
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.
[0054]
(Third embodiment)
FIG. 5 is a logic circuit diagram of the hash function processing device according to the third embodiment of the present invention. The hash function processing device 30 shown in FIG. 5 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 30 includes registers 302 to 307 and 311 to 314, adders 321 to 328, selectors 331 to 334 and 336 to 339, a cyclic shift operation block 341, and logical operation blocks 351 to 354. Among them, the adders 325 and 326 constitute a first arithmetic processing unit 361. The adders 327 and 328, the selector 339, the cyclic shift operation block 341, and the logical operation blocks 351 to 354 constitute a second operation processing unit 362.
[0055]
The circuit configuration of the hash function processing device 30 is different from the circuit configuration of the hash function processing device 10 according to the first embodiment in the following three points. First, the register 101 and the selector 135 of the hash function processing device 10 are deleted in the hash function processing device 20. Second, the selector 336 selects and outputs an appropriate value from the value of the register 311, the value of the register 312, and the value of the register 303. Third, the adder 321 adds the value of the register 302 and the value of the register 311. The other components of the hash function processing device 30 are the same as those of the hash function processing device 10, and the description thereof is omitted here. Note that, in the present embodiment, the registers 302 to 304 are referred to as a first register R1, a third register R3, and a second register R2, respectively.
[0056]
The hash function processing device 30 performs a pre-hash process on input data, then performs a round process, and finally performs a post-hash process on the 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. 6 is a diagram showing how the values of the registers 302 to 307 and 311 to 314 are changed by these three processes. Hereinafter, the operation of the hash function processing device 30 will be described with reference to FIG.
[0057]
(1) Hash preprocessing
The hash preprocessing is performed over two clock cycles in a state where the registers 311 to 314 store the initial values (As and Ds to Bs in FIG. 6) determined by the MD5 algorithm. In the first clock cycle, unlike the first embodiment, the register 302 takes in the value of the register 311 (As in FIG. 6). At the same time, registers 303 and 304 take in the values (Cs and Bs in FIG. 6) of registers 313 and 314, respectively. At the same time, the registers 306 and 307 respectively take in the input data and the constant values (X0 and T0 in FIG. 6) used from the outside in the 0th round.
[0058]
Next, in the second clock cycle, the register 305 takes in the output of the adder 326 ((As + X0 + T0) in FIG. 6). At the same time, unlike the first embodiment, the register 302 takes in the value of the register 312 (Ds in FIG. 6). At the same time, registers 306 and 307 take in input data and constant values (X1 and T1 in FIG. 6) used in the first round, respectively, provided from the outside.
[0059]
(2) Round processing
The processing of the 0th to 62nd rounds is performed by taking one clock cycle per round (that is, by taking 63 clock cycles for each block data). The processes of the 0th to 62nd rounds by the hash function processing device 30 are the same as the processes by the hash function processing device 10 according to the first embodiment, except that the register corresponding to the register 101 does not exist. That is, in each clock cycle, the register 302 takes in the value of the register 303. At the same time, the register 303 captures the value of the register 304. At the same time, the register 304 captures the output of the adder 328. At the same time, the register 305 takes in the output of the adder 326. At the same time, registers 306 and 307 respectively take in the next input data and constant value given from outside. However, in the process of the 62nd round, the registers 306 and 307 may take in arbitrary values.
[0060]
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 311 takes in the output of the adder 321 (Am in FIG. 6). At the same time, registers 302 and 303 take in the values (D15 and C15 in FIG. 6) of registers 303 and 304, respectively. At the same time, the register 304 takes in the output of the adder 328 (B15 in FIG. 6).
[0061]
Next, in the second clock cycle, the registers 312 to 314 take in the outputs (Dm to Bm in FIG. 6) of the adders 322 to 324, respectively. Note that the registers 302 to 304 may take in an arbitrary value, and here it is assumed that the register holds the value of the immediately preceding clock cycle.
[0062]
Next, in the third clock cycle, the register 302 takes in the value of the register 311 (Am in FIG. 6). At the same time, registers 303 and 304 take in the values (Cm and Bm in FIG. 6) of registers 313 and 314, respectively. At the same time, the registers 306 and 307 respectively take in the input data and the constant values (X0 and T0 in FIG. 6) used from the outside in the 0th round.
[0063]
Next, in the fourth clock cycle, the register 305 takes in the output of the adder 326 ((Am + X0 + T0) in FIG. 6). At the same time, the register 302 takes in the value of the register 312 (Dm in FIG. 6). At the same time, registers 306 and 307 take in input data and constant values (X1 and T1 in FIG. 6) used in the first round, respectively, provided from the outside. Note that the input data taken into the register 306 in the third and fourth clock cycles is data included in the next block data.
[0064]
(3) Hash post-processing
Post-hash processing is performed over two clock cycles. In the first clock cycle, the register 311 takes in the output of the adder 321 (Ae in FIG. 6). At the same time, registers 302 and 303 take in the values (D15 and C15 in FIG. 6) of registers 303 and 304, respectively. At the same time, the register 304 takes in the output of the adder 328 (B15 in FIG. 6).
[0065]
Next, in the second clock cycle, the registers 312 to 314 take in the outputs (De to Be in FIG. 6) of the adders 322 to 324, respectively. Note that the registers 302 to 304 may take in an arbitrary value, and here it is assumed that the register holds the value of the immediately preceding clock cycle.
[0066]
At the time when the second clock cycle is completed, the values (Ae and De to Be in FIG. 6) stored in the registers 311 to 314 are hash values to be obtained. Therefore, by reading the values of the registers 311 to 314 using means (not shown) (or by an external register taking in the value of the output signal HV in the second clock cycle of the post-hash processing), A hash value for the whole can be obtained.
[0067]
As described above, the hash function processing device 30 can correctly execute the round process in the MD5 algorithm, despite being different from the hash function processing device 10 according to the first embodiment in the above-described three points. In addition, the register corresponding to the register 101 is removed from the hash function processing device 30.
[0068]
As described above, according to the hash function processing device according to the present embodiment, in addition to the effect provided by the hash function processing device according to the first embodiment, there is an effect that the circuit scale can be reduced.
[0069]
(Fourth embodiment)
FIG. 7 is a logic circuit diagram of the hash function processing device according to the fourth embodiment of the present invention. A hash function processing device 40 shown in FIG. 7 is obtained by changing a part of a circuit included in a hash function processing device 30 according to the third embodiment. The hash function processing device 40 includes registers 402 to 407 and 411 to 414, adders 421 to 428, selectors 431 to 434 and 436 to 439, a cyclic shift operation block 441, and logical operation blocks 451 to 454. Among them, the adders 425 and 426 constitute a first arithmetic processing unit 461. The adders 427 and 428, the selector 439, the cyclic shift operation block 441, and the logical operation blocks 451 to 454 form a second operation processing unit 462.
[0070]
The circuit configuration of the hash function processing device 40 is different from the circuit configuration of the hash function processing device 30 according to the third embodiment in the following three points. First, the selector 436 selects and outputs an appropriate value from the value of the register 411, the value of the register 412, the value of the register 403, and the output of the adder 421. Second, the selector 437 selects and outputs an appropriate value from the value of the register 413, the value of the register 404, and the output of the adder 423. Third, the selector 438 selects and outputs an appropriate value from the value of the register 414, the output of the adder 428, and the output of the adder 424. The other components of the hash function processing device 40 are the same as those of the hash function processing device 30, and a description thereof will not be repeated.
[0071]
The hash function processing device 40 performs a pre-hash process on input data, then performs a round process, and finally performs a post-hash process on the input data, similarly to the hash function processing device 30 according to the third embodiment. . The contents of these three processes are the same as those of the hash function processing device 30. FIG. 8 is a diagram showing how the values of the registers 402 to 407 and 411 to 414 change by these three processes. Hereinafter, the operation of the hash function processing device 40 will be described with reference to FIG.
[0072]
(1) Hash preprocessing
The pre-hash processing in the hash function processing device 40 is the same as the process in the hash function processing device 30 according to the third embodiment.
[0073]
(2) Round processing
The processes in the 0th to 62nd rounds in the hash function processing device 40 are the same as those in the hash function processing device 30 according to the third embodiment. The processing of the 0th to 62nd rounds is performed by taking one clock cycle per round (that is, by taking 63 clock cycles for each block data).
[0074]
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 402 and 411 take in the output of adder 421 (Am in FIG. 8). At the same time, the register 412 takes in the output of the adder 422 (Dm in FIG. 8). At the same time, the register 403 takes in the value of the register 404 (C15 in FIG. 8). At the same time, the register 404 takes in the output of the adder 428 (B15 in FIG. 8). At the same time, registers 406 and 407 fetch input data and constant values (X0 and T0 in FIG. 8) used in the 0th round provided from the outside, respectively.
[0075]
Next, in the second clock cycle, the register 402 takes in the value of the register 412 (Dm in FIG. 4). At the same time, the registers 403 and 413 both take in the output of the adder 423 (Cm in FIG. 8). At the same time, the registers 404 and 414 both take in the output of the adder 424 (Bm in FIG. 8). At the same time, the register 405 takes in the output of the adder 426 ((Am + X0 + T0) in FIG. 8). At the same time, registers 406 and 407 fetch input data and constant values (X1 and T1 in FIG. 8) used in the first round, respectively, provided from outside. Note that the input data taken into the register 406 in the first and second clock cycles is data included in the next block data.
[0076]
(3) Hash post-processing
Post-hash processing is performed over two clock cycles. In the first clock cycle, registers 411 and 412 take in the outputs (Ae and De in FIG. 8) of adders 421 and 422, respectively. At the same time, the register 403 takes in the value of the register 404 (C15 in FIG. 8). At the same time, the register 404 takes in the output of the adder 428 (B15 in FIG. 8). The register 402 may take in an arbitrary value. Here, it is assumed that the register 402 takes in the output of the adder 421.
[0077]
Next, in the second clock cycle, the registers 413 and 414 take in the outputs of the adders 423 and 424 (Ce and Be in FIG. 8), respectively. Registers 402 to 404 may capture any value, where register 402 captures the value of register 412 and registers 403 and 404 capture the output of adders 423 and 424, respectively.
[0078]
At the time when the second clock cycle is completed, the values (Ae and De to Be in FIG. 8) stored in the registers 411 to 414 are the hash values to be obtained. Therefore, by reading the values of the registers 411 to 414 using means (not shown) (or by an external register taking in the value of the output signal HV in the second clock cycle of the post-hash processing), A hash value for the whole can be obtained.
[0079]
As described above, the hash function processing device 40 can correctly execute the round process in the MD5 algorithm, despite being different from the hash function processing device 30 according to the third embodiment in the above-described four points. The hash function processing device 30 according to the third embodiment performs the round termination process over four clock cycles, whereas the hash function processing device 40 performs the round termination process over two clock cycles. .
[0080]
From the above, according to the hash function processing device according to the present embodiment, in addition to the effect provided by the hash function processing device according to the third 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. That is, in addition to the effects provided by the hash function processing device according to the first embodiment, there is an effect that the circuit scale can be reduced and round processing can be executed at higher speed.
[0081]
The hash function processing device of the present invention may be any device that performs the processes of the 0th to 62nd 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 Ds in the registers 111 to 114, the registers 101 to 104 in the pre-hash processing, the round end processing, and the post-hash processing , The timing of updating the registers 111 to 114, the value set in the register that may take in an arbitrary value, and the like can be variously designed. The same applies to the hash function processing devices according to the second to fourth embodiments.
[0082]
Further, in each of the above embodiments, the MD5 algorithm 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.
FIG. 5 is a logic circuit diagram of a hash function processing device according to a third embodiment of the present invention.
FIG. 6 is a diagram illustrating a state in which the value of a register included in a hash function processing device according to a third embodiment of the present invention changes.
FIG. 7 is a logic circuit diagram of a hash function processing device according to a fourth embodiment of the present invention.
FIG. 8 is a diagram illustrating a state in which a value of a register included in a hash function processing device according to a fourth embodiment of the present invention changes.
[Explanation of symbols]
10, 20, 30, 40 ... hash function processing device
101-107, 111-114, 201-207, 211-214, 302-307, 311-314, 402-407, 411-414 ... registers
121-128, 221-228, 321-328, 421-428 ... adders
131-139, 231-239, 331-334, 336-339, 431-434, 436-439 ... selector
141, 241, 341, 441... Cyclic shift operation block
151-154, 251-254, 351-354, 451-454 ... Logic operation block
161, 261, 361, 461: first arithmetic processing unit
162, 262, 362, 462: second arithmetic processing unit

Claims (6)

入力データに対して、ハッシュ関数で定められた繰り返し処理を行うハッシュ関数処理装置であって、
フィードバックデータを格納する第1から第4のレジスタと、
所定長の入力データを供給する入力データ供給部と、
ハッシュ関数で定められた定数値を供給する定数値供給部と、
前記第1のレジスタの値と、前記入力データ供給部から供給される入力データと、前記定数値供給部から供給される定数値とに対して、所定の演算処理を行う第1の演算処理部と、
前記第1の演算処理部による演算結果を格納する中間値格納レジスタと、
前記第2から第4のレジスタの値と、前記中間値格納レジスタの値とに対して、所定の演算処理を行う第2の演算処理部とを備え、
前記第1および第2の演算処理部は並列に動作し、かつ、前記中間値格納レジスタが前記第1の演算処理部による演算結果を取り込む動作と、前記第2のレジスタが前記第2の演算処理部による演算結果を取り込む動作と、前記第3のレジスタが前記第2のレジスタの値を取り込む動作と、前記第1および第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 first register, the input data supplied from the input data supply unit, and the 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 second 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 second register performs the second arithmetic operation. An operation of capturing a calculation result by the processing unit, an operation of capturing the value of the second register by the third register, an operation of capturing the value of the third register by the first and fourth registers, A hash function, wherein the operation of the input data supply unit to obtain the next input data and the operation of the constant value supply unit to obtain the next constant value are performed in parallel within one clock cycle. Processing equipment.
入力データに対して、ハッシュ関数で定められた繰り返し処理を行うハッシュ関数処理装置であって、
フィードバックデータを格納する第1から第3のレジスタと、
所定長の入力データを供給する入力データ供給部と、
ハッシュ関数で定められた定数値を供給する定数値供給部と、
前記第1のレジスタの値と、前記入力データ供給部から供給される入力データと、前記定数値供給部から供給される定数値とに対して、所定の演算処理を行う第1の演算処理部と、
前記第1の演算処理部による演算結果を格納する中間値格納レジスタと、
前記第1から第3のレジスタの値と、前記中間値格納レジスタの値とに対して、所定の演算処理を行う第2の演算処理部とを備え、
前記第1および第2の演算処理部は並列に動作し、かつ、前記中間値格納レジスタが前記第1の演算処理部による演算結果を取り込む動作と、前記第2のレジスタが前記第2の演算処理部による演算結果を取り込む動作と、前記第3のレジスタが前記第2のレジスタの値を取り込む動作と、前記第1のレジスタが前記第3のレジスタの値を取り込む動作と、前記入力データ供給部が次の入力データを取得する動作と、前記定数値供給部が次の定数値を取得する動作とが、1つのクロックサイクル内で並列に行われることを特徴とする、ハッシュ関数処理装置。
A hash function processing device that performs iterative processing defined by a hash function on input data,
First to third 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 first register, the input data supplied from the input data supply unit, and the 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 third 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 second register performs the second arithmetic operation. An operation of taking in the operation result by the processing unit, an operation of taking in the value of the second register by the third register, an operation of taking in the value of the third register by the first register, A hash function processing device, wherein the operation of the unit to obtain the next input data and the operation of the constant value supply unit to obtain the next constant value are performed in parallel within one clock cycle.
前記第1の演算処理部は、前記第1のレジスタの値と、前記入力データ供給部から供給される入力データと、前記定数値供給部から供給される定数値とを加算することを特徴とする、請求項1または2に記載のハッシュ関数処理装置。The first arithmetic processing unit adds a value of the first 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 or 2, wherein 前記第2の演算処理部は、前記第2から第4のレジスタの値に対して所定の論理演算を行い、当該演算結果と前記中間値格納レジスタの値との加算結果を所定のビット数だけ巡回シフトした上で、前記第2のレジスタの値と加算することを特徴とする、請求項1に記載のハッシュ関数処理装置。The second arithmetic processing unit performs a predetermined logical operation on the values of the second to fourth registers, and calculates a result of adding the operation result and the value of the intermediate value storage register by a predetermined number of bits. 2. The hash function processing device according to claim 1, wherein the value of the second register is added after the cyclic shift. 前記第2の演算処理部は、前記第1から第3のレジスタの値に対して所定の論理演算を行い、当該演算結果と前記中間値格納レジスタの値との加算結果を所定のビット数だけ巡回シフトした上で、前記第2のレジスタの値と加算することを特徴とする、請求項2に記載のハッシュ関数処理装置。The second arithmetic processing unit performs a predetermined logical operation on the values of the first to third registers, and calculates an addition result of the operation result and the value of the intermediate value storage register by a predetermined number of bits. 3. The hash function processing device according to claim 2, wherein after cyclically shifting, the value is added to the value of the second register. 前記ハッシュ関数がMD5(Message Digest 5)であることを特徴とする、請求項1〜5のいずれかに記載のハッシュ関数処理装置。The hash function processing device according to claim 1, wherein the hash function is MD5 (Message Digest 5).
JP2003031043A 2003-02-07 2003-02-07 Hash function processor Pending JP2004240298A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2003031043A JP2004240298A (en) 2003-02-07 2003-02-07 Hash function processor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2003031043A JP2004240298A (en) 2003-02-07 2003-02-07 Hash function processor

Publications (1)

Publication Number Publication Date
JP2004240298A true JP2004240298A (en) 2004-08-26

Family

ID=32957757

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2003031043A Pending JP2004240298A (en) 2003-02-07 2003-02-07 Hash function processor

Country Status (1)

Country Link
JP (1) JP2004240298A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007166279A (en) * 2005-12-14 2007-06-28 Nippon Telegr & Teleph Corp <Ntt> IPsec CIRCUIT AND IPsec PROCESSING METHOD
US7962753B2 (en) 2006-11-08 2011-06-14 Oki Semiconductor Co., Ltd. Method and a circuit for SHA operation with power saved

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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
US7962753B2 (en) 2006-11-08 2011-06-14 Oki Semiconductor Co., Ltd. Method and a circuit for SHA operation with power saved

Similar Documents

Publication Publication Date Title
CN102096609B (en) Instruction-set architecture for programmable cyclic redundancy check (CRC) computations
Abdulrahman et al. Faster kyber and dilithium on the cortex-m4
KR100377172B1 (en) Key Scheduller of encryption device using data encryption standard algorithm
US11716076B2 (en) Circuits and methods for performing hash algorithm
CN114615069A (en) Quartet lightweight encryption algorithm implementation device and method
JP3940714B2 (en) Arithmetic device and encryption / decryption arithmetic device
JP2502836B2 (en) Preprocessing device for division circuit
JP2004240298A (en) Hash function processor
JP4567753B2 (en) Parity generation circuit, counting circuit, and counting method
JP2004240299A (en) Hash function processor
CN113741972B (en) SM3 algorithm parallel processing method and electronic equipment
JP3709760B2 (en) Hash device
JP2002358010A (en) Exponentiation remainder computing element
CN112988235B (en) Hardware implementation circuit and method of high-efficiency third-generation secure hash algorithm
JPH11224183A (en) Pseudo-random number generating device
JP4057876B2 (en) Control method of Galois field multiplier
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
Ali Efficient implementation of linearisation attacks on F-FCSR-16 type key-stream generators
KR100377173B1 (en) Encryption device using data encryption standard algorithm
KR100761132B1 (en) Apparatus and method for computing SHA-1
CN113723035A (en) Modulo operation method with variable bit width and modulo operation circuit
Gazzoni Filho et al. Efficient isochronous fixed-weight sampling with applications to NTRU
CN112861154A (en) SHA algorithm execution method, storage medium and electronic device for data flow architecture
WO2013051139A1 (en) Multiplication method for finite fields, calculator, and program