JP2004157164A - Message digest generating circuit and padding circuit - Google Patents

Message digest generating circuit and padding circuit Download PDF

Info

Publication number
JP2004157164A
JP2004157164A JP2002319966A JP2002319966A JP2004157164A JP 2004157164 A JP2004157164 A JP 2004157164A JP 2002319966 A JP2002319966 A JP 2002319966A JP 2002319966 A JP2002319966 A JP 2002319966A JP 2004157164 A JP2004157164 A JP 2004157164A
Authority
JP
Japan
Prior art keywords
circuit
padding
data
message
length
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.)
Granted
Application number
JP2002319966A
Other languages
Japanese (ja)
Other versions
JP4212339B2 (en
Inventor
Machiko Mikami
真智子 三上
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.)
Fujitsu Ltd
Original Assignee
Fujitsu 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 Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP2002319966A priority Critical patent/JP4212339B2/en
Publication of JP2004157164A publication Critical patent/JP2004157164A/en
Application granted granted Critical
Publication of JP4212339B2 publication Critical patent/JP4212339B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Abstract

<P>PROBLEM TO BE SOLVED: To conduct a padding addition and a length addition without imposing a load on a CPU. <P>SOLUTION: A message is divided into data having a prescribed data length by a message input circuit 100 and the divided data are successively inputted starting from leading data. Moreover, information indicating the length of the message is inputted by the circuit 100. Then, the last data of the message is discriminated by a padding circuit 210 in accordance with the total amount and the information on the length of the data inputted by the circuit 100 and padding is outputted following the last data. Then, the completion position of the padding is discriminated by a length adding circuit 220 in accordance with the total amount of the padding outputted by the circuit 210 and the length information is outputted following the padding. <P>COPYRIGHT: (C)2004,JPO

Description

【0001】
【発明の属する技術分野】
本発明はメッセージダイジェストを生成するメッセージダイジェスト生成回路およびメッセージ認証の際のパディングを行うパディング回路に関し、特にハッシュ関数のメッセージダイジェストアルゴリズムに沿った処理を行うメッセージダイジェスト生成回路およびパディング回路に関する。
【0002】
【従来の技術】
情報通信の利用範囲が広がるのに伴い、通信データに関する高い安全性が求められている。そのため、データのセキュリティ技術の重要性が増している。
【0003】
データのセキュリティ技術の1つに、データの改竄等を防ぐための認証技術がある。認証技術では、受け取ったデータが、正しい送信元から送られたものであることや、第三者により改竄されていないことを認証するための技術である。
【0004】
データ認証技術には、ハッシュ関数を用いる技術がある。ハッシュ関数アルゴリズムとしては、MD(Message Digest algorithm)5やSHA(Secure Hash Algorithm)1などがある。MD5は、IETF(Internet Engineering Task Force)で発行されたRFC(Requests For Comment)1321に規定されている。また、SHA1は、RFC2841に規定されている。これらのハッシュ関数アルゴリズムは、ネットワークで使われるメッセージ認証、デジタル署名法などの通信暗号技術に最も使われているハッシュ関数である。
【0005】
ハッシュ関数を用いたメッセージ認証では、大きな文章にデジタル署名を施すとき、元になる長いメッセージ(文書、データファイルといった可変長のメッセージ)に対してハッシュ関数を適用し、固定長の文字列を生成する。この固定長の文字列をメッセージダイジェストという。これは、長いメッセージや文書をコンピュータ処理することによって、簡潔なダイジェストとして表すという考え方で、元の入力情報(メッセージ)の「デジタル指紋」ととらえることもできる。
【0006】
メッセージダイジェストを用いる場合には、使用する通信路の安全性やメッセージ自体の重要性を考慮して利用形態が決定される。たとえば、メッセージ自体は公になっても問題が少ないが、改竄されると問題が生じるような情報(例えば、電子商取引での発注数量など)を扱う場合、メッセージ認証のためにハッシュ関数を利用する。また、メッセージ自身も公になると問題が生じるような情報(例えば、電子商取引でのクレジットカード番号など)を扱う場合、メッセージダイジェストを付加した後に暗号化を行う。これにより、送信する情報全体が保護される。
【0007】
ところで、IP(Internet Protocol)sec(security)というIPプロトコルにセキュリティ機能を追加したプロトコルがある。IPsecは、次世代IPであるIPv6において、実装が必須とされている。そのため、IPsecは、現時点でも最も将来性を約束されたセキュリティプロトコルである。
【0008】
IPsecを用いれば、LAN(Local Area Network)、私的もしくは公共のWAN(Wide Area Network)、およびインターネット経由の通信の安全性を、IPレベルで確保することができる。IPレベルでの安全性を確保することによって、ネットワークの運営者はセキュリティ機構を備えたアプリケーションだけでなく、セキュリティに関する備えの無い多くのアプリケーションに対しても安全なネットワーク環境を提供できる。すなわち、個々のアプリケーションに対してはセキュリティ関連機能を実装せずに、安全な通信を行うことができる。
【0009】
IPレベルのセキュリティは、認証、秘密性、鍵管理の三要素を含む。認証機構は受け取ったパケットが実際にパケットヘッダに記載してある送り主から来ていることを確認する。さらにこのパケットが送信中に外部からの改竄を受けていないことも保証する。秘密性を保つ機能は通信ノードが第三者からの盗聴を防ぐため、メッセージを暗号化する。鍵管理は鍵の安全な交換に関するものである。
【0010】
このように、ハッシュ関数を用いた技術は今後益々必要度が高まる技術である。ハッシュ関数を用いたメッセージ認証技術では、一般的にパディングの付加処理と長さ情報の付加(以下、単に長さの付加という)処理とが行われる。
【0011】
例えば代表的なハッシュ関数であるSHA1メッセージダイジェストアルゴリズムでは、任意の長さのメッセージが入力されると、入力されたメッセージに対する160ビットのメッセージダイジェストを生成し、出力する。SHA1アルゴリズムは、大別して以下の5つの構成となっている。
[第1の処理]パディングビットの付加
[第2の処理]長さの付加
[第3の処理]メッセージダイジェストバッファの初期化
[第4の処理]16ワード(512ビット)長のブロックメッセージの処理
[第5の処理]出力
ここで、[第1の処理]パディングビットの付加、[第2の処理]長さの付加に着目する。以下、1ワードは32ビットを指すものとする。
【0012】
ハッシュ関数としてSHA1を使用する場合、メッセージに対するパディング処理は以下のように行われる。
メッセージは、264バイト未満の長さLであるとする。SHA1に入力される前に、メッセージは以下のようにして右側にパディングが付加される。
【0013】
まず1つの“1”が追加される。続いて0個以上の“0”が追加される([第1の処理])。“0”の数は、元のメッセージの長さに依存する。すなわち、パディング付加後のメッセージの長さ(ビット)が448modulo512に適合するように(512の倍数より448だけ長いビット長となる)、付加する“0”の個数が決定される。
【0014】
なお、たとえメッセージ長が448modulo512に適合していても、パディングは常に実行される。たとえば、メッセージの長さが448ビットであった場合、960ビットになるように512ビット分のパディングが付加される。従って、全体で最低でも1ビット、最大で512ビットのパディングが付加される。
【0015】
次に前記パディングの結果に元データの長さを示す64ビットが付加される([第2の処理])。パディング付加後のメッセージ長が448modulo512に適合しているため、長さ情報である64ビットのデータを付加すると、長さ情報を付加したメッセージのビット長が512の倍数となる。
【0016】
ここで、パディング付加、長さ付加処理の具体例を示す。たとえば、元のメッセージを、次のビット・ストリングとする。
「01100001 01100010 01100011 01100100 01100101」
[第1の処理]により、ビット・ストリングは次のようになる。
【0017】
まず、“1”が追加される。
「01100001 01100010 01100011 01100100 01100101 1」
長さL(Lは0以上の整数)が40(ビット)の時、“1”を追加後のビット数は41である。そこで、448modulo512に適合するように407個の“0”が追加され、ビット数は全部で448になる。これは、16進数表記で次のようになる。
61626364 65800000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000
[第2の処理]元のメッセージのビット数である長さLの2ワード表現(1ワードは32ビット)を得る。もし長さL<232であれば、最初のワードはすべて0になる。パディングされたメッセージにその2ワードを追加する。
【0018】
この例では、L=40である。40の2ワード表記は16進数で00000000 00000028である。その結果、最終的に当て物されたメッセージは16進数で次のようになる。
61626364 65800000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000028
この時に、結果として生じるメッセージの長さは、512ビットの正確な倍数である。512ビットは32ビットのワード16個分であるため、このメッセージの長さは16個のワードの正確な倍数でもある。
【0019】
このようなハッシュ関数を用いたメッセージ認証技術は、たとえば、非特許文献1や非特許文献2に詳しく述べられている。
また、ハッシュ関数を用いたセキュリティ技術の例としては、特許文献1がある。
【0020】
【非特許文献1】
池野信一、小山謙二著、「現代暗号理論」、電子通信学会、1986年9月1日
【非特許文献2】
Bruce Schneier,「Applied Cryptography (Second Edition)」, John Wiely & Sons, Inc 1996, P429〜P459
【特許文献1】
特表2001−527325号公報(第27頁〜第30頁)
【0021】
【発明が解決しようとする課題】
ところで、従来は、ハッシュ関数による処理全般や、ある特定のハッシュ関数を使用してHMAC(エイチ・マック:Hash−based Message Authentication Code)メッセージ認証関数を構成する処理は、処理内容がソフトウェアで定義されCPU(Central Processing Unit)が実行していた。そこで、CPUによるソフトウェア実行の効率化のため、MD5,SHA1アルゴリズムがコード化されていた。そして、そのコードは32ビットマシンでも効率良く動作するように設計されていた。
【0022】
なお、HMACは暗号ハッシュ関数を使用してメッセージ認証を行う仕組みである。HMACはMD5やSHA1などの反復暗号ハッシュ関数を秘密の共有鍵と組み合わせて使用する。
【0023】
しかし、パディング処理が効率良く動作するように設計されていても、その速度はCPU占有率とCPUのパフォーマンスに完全に依存する。そのため、十分な速度が得られないことがある上に、他のアプリケーション等の処理と組み合わせた状況下では、より一層の処理速度の低下が発生していた。しかも、IPsecのIPパケット認証のような大きなデータの処理をソフトウェア的に実行すると、膨大な時間がかかる。
【0024】
さらに、CPUにおいてパディングの付加や長さの付加を行うには、送信対象のメッセージをメモリに格納しておく必要があり、メモリの記憶領域が消費される。メモリ内の記憶容量でパディング付加等に使用されると、他のアプリケーション実行のために使用できるメモリ容量が減少し、処理効率が低下してしまう。
【0025】
このように、従来のパディング付加等の処理はCPUによるソフトウェア的な処理であったため、CPUにかかる処理負担が重く、十分な処理速度を得るのが難しかった。しかも、パディング付加の処理をCPUに実行させることで、他のアプリケーションの処理にも支障を来す場合があり、システム全体の処理能力に大きな影響を及ぼしていた。
【0026】
本発明はこのような点に鑑みてなされたものであり、CPUに対して負荷をかけずにパディング付加や長さ付加を行うことができるメッセージダイジェスト生成回路を提供することを目的とする。
【0027】
また、本発明の他の目的は、CPUに対して負荷をかけずにパディング付加を行うことができるパディング回路を提供することを目的とする。
【0028】
【課題を解決するための手段】
本発明では上記課題を解決するために、図1に示すようなメッセージダイジェスト生成回路が提供される。本発明に係るメッセージダイジェスト生成回路は、メッセージの認証処理を行うものである。メッセージダイジェスト生成回路は、メッセージ入力回路100、パディング回路210、および長さ付加回路220を有する。メッセージ入力回路100は、メッセージを所定のデータ長のデータに分割して先頭から順に入力するとともに、メッセージの長さを示す長さ情報を入力する。パディング回路210は、メッセージ入力回路100で入力されたデータの総量と長さ情報とに応じてメッセージの最後のデータを判断し、最後の前記データに続けてパディングを出力する。長さ付加回路220は、前記メッセージ入力回路で入力された前記データと前記パディング回路で出力された前記パディングとの総量に応じてパディングの終了位置を判断し、パディングに続けて前記長さ情報を出力する。
【0029】
このようなメッセージダイジェスト生成回路によれば、メッセージ入力回路100によって、メッセージが所定のデータ長のデータに分割され、先頭から順に入力される。また、メッセージ入力回路100によって、メッセージの長さを示す長さ情報が入力される。すると、パディング回路210によって、メッセージ入力回路100で入力されたデータの総量と長さ情報とに応じてメッセージの最後のデータが判断され、最後のデータに続けてパディングが出力される。その後、長さ付加回路220により、メッセージ入力回路で入力されたデータと前記パディング回路で出力されたパディングとの総量に応じてパディングの終了位置が判断され、パディングに続けて長さ情報が出力される。
【0030】
また、上記課題を解決するために本発明では、メッセージにパディングを付加するパディング回路において、前記メッセージが所定のデータ長のデータに分割され先頭から順に入力されるとともに、前記メッセージの長さを示す長さ情報が入力されると、入力された前記データの総量と前記長さ情報とに応じて前記メッセージの最後の前記データを判断する判断回路と、前記判断回路で判断された前記最後の前記データに続けてパディングを出力するパディング出力回路と、を有することを特徴とするパディング回路が提供される。
【0031】
このようなパディング回路によれば、メッセージが所定のデータ長のデータに分割され先頭から順に入力されるとともに、メッセージの長さを示す長さ情報が入力されると、判断回路により、入力されたデータの総量と長さ情報とに応じてメッセージの最後の前記データが判断される。そして、パディング出力回路により、判断回路で判断された最後のデータに続けてパディングが出力される。
【0032】
【発明の実施の形態】
以下、本発明の実施の形態を図面を参照して説明する。
図1は、本実施の形態に係るメッセージダイジェスト生成回路の概略構成を示す図である。メッセージダイジェスト生成回路は、大別してメッセージ入力回路100、情報付加回路200、およびメッセージ処理回路300で構成される。
【0033】
メッセージ入力回路100は、メッセージを所定のデータ長のデータに分割して先頭から順に入力するとともに、メッセージの長さを示す長さ情報を情報付加回路200に入力する。また、メッセージ入力回路100は、1ブロック分のデータを入力する毎にブロック切替を示す信号を出力する。
【0034】
情報付加回路200は、メッセージダイジェスト生成処理のうちの前半を実行する。具体的には、情報付加回路200は、パディングの付加および長さの付加を行う。情報付加回路200は、パディングを付加するパディング回路210と長さを付加する長さ付加回路220とを有している。
【0035】
パディング回路210は、メッセージ入力回路100で入力されたデータの総量と長さ情報とに応じてメッセージの最後のデータを判断し、最後のデータに続けてパディングを出力する。入力されたデータの総量と長さ情報とに応じた情報は、たとえば、長さ情報の数値から入力されたデータ量を減算することで数値化できる。
【0036】
具体的には、パディング回路210は、長さ情報から、メッセージ入力回路100から入力されたデータの容量を順次減算する減算器と、減算器の減算結果が1ブロック分のデータ長(たとえば、64バイト)以下になったときにパディング対象ブロックを示す信号を出力する比較器とを有する。たとえば、減算器は、ブロック切替を示す信号が出力されると、長さ情報から1ブロック分のデータ長を減算する。減算結果が1ブロック分のデータ長以下になったことで、次に入力されるブロックがパディングするべきブロックであることが分かる。
【0037】
そして、パディング回路210は、比較器からパディング対象ブロックを示す信号が出力されると、その後、1ブロックの間のデータの中から最後のデータを判断する。
【0038】
たとえば、メッセージ入力回路100が入力するデータのサイズがNバイト(Nは自然数)の場合、パディング回路210は、比較器よりパディング対象ブロックを示す信号が出力されたとき、減算器の減算結果をNで除算し、その後データが入力された回数をカウントする。カウントした値が除算による商の値に達すると、そのとき入力されたデータがメッセージの最後のデータであると判断し、パディング回路210は、最後のデータに続けて除算による剰余の値に応じたパディングを出力する。
【0039】
すなわち、パディングを付加すべきブロック内の残りのメッセージのデータ長を、入力されるデータのサイズN(1ワードであれば4)で割ることで、ブロック内の元のメッセージを含む最後尾のワードが特定される。また、Nで割ったときの剰余(残りデータ長の下位2ビット)は、パディングを開始する32ビットワード中の何バイト目からパディングが行われるのかを示している。
【0040】
なお、データ長の除算処理は、ビットシフト回路で実現可能である。メッセージ入力回路100により入力されるデータのサイズが2バイト(nは自然数)の場合、パディング回路210は、減算器の減算結果の右nビットシフトするビットシフト回路を有しており、ビットシフト回路によるシフト結果を除算結果とする。1ワード(2バイト)のデータが入力される場合、残りデータ長の値の2ビット右シフトで商を求めればよい。ビットシフト回路により除算を行うことで、効率的に回路化できる。
【0041】
また、パディングを開始する23ビットのワードに対するパディングの付加処理は、そのワードとパディング値を示すワードとの論理和演算を行うことで実現できる。すなわち、論理和演算回路を用いて実現可能である。
【0042】
このとき、論理和演算回路に入力するパディングの値は、たとえば、以下のように決定する。なお、メッセージ入力回路100により入力されるデータのサイズを2バイト(nは自然数)とする。
【0043】
すなわち、パディング回路210は、nビットで表せる数値それぞれに対応付けてパディング値を記憶装置に予め格納しておく。そして、パディング回路210は、セレクタにより、減算器の減算結果(メッセージの残りのバイト単位のデータ長)の下位nビットの値に応じて記憶装置から出力するパディング値を選択する。
【0044】
なお、減算器がブロック長(たとえば、64バイト)単位で減算を行っていれば、元のメッセージのデータ長を示す長さ情報の下位2ビットの値は、減算処理によっては変化しない。したがって、その場合、元のメッセージのデータ長を示す長さ情報の下位2ビットに基づいて、パディング値を選択することもできる。
【0045】
ここで選択されるパディング値は、メッセージの最後尾を含むデータに論理和演算で加える値である。その後、所定のデータ長(448modulo512)になるまで、“0”の値のパディングが付加される。
【0046】
長さ付加回路220は、メッセージ入力回路で入力されたデータとパディング回路で出力されたパディングとの総量に応じてパディングの終了位置を判断し、パディングに続けて長さ情報を出力する。たとえば、長さ付加回路220は、1ブロック分のデータ長の倍数から長さ情報のデータ長の分を減算したデータ量に相当するデータ(たとえば448modulo512)とパディングとが出力された後、長さ情報を出力する。
【0047】
具体的には、1ブロックのデータ長が64バイトであり、長さ情報のデータ長が8バイト(メッセージの最大長(264バイト)までの数値を表現可能なデータ長)であれば、メッセージとパディングとの合計のデータ長が、64バイトの倍数から8バイトを減算した値(8バイトを加算することで64バイトとなる)になったとき(448modulo512に適合したとき)に、パディングの終了位置と判断される。
【0048】
すなわち、長さ情報を示すワードは、1つのブロックの最後の2ワードとして追加される。従って、メッセージの最後尾のデータを含むブロックにパディングを付加後、2ワード分の領域が確保できないときは、次のブロックに長さ情報が付加される。
【0049】
たとえば、残りのデータ長が56バイト以上であった場合、メッセージの最後尾のデータを含むブロックの次のブロックの56バイトまでパディングが行われ、その後に、長さ情報を示す2ワードが付加される。残りデータ長が55バイト以下であった場合、メッセージの最後尾のデータを含むブロックの56バイトまでパディングが行われ、その後に、長さ情報を示す2ワードが付加される。
【0050】
メッセージ処理回路300は、メッセージダイジェスト生成処理のうちの後半を実行し、最終的なメッセージダイジェストを生成する。具体的には、メッセージ処理回路300は、メッセージダイジェストバッファの初期化、16ワード長のブロックメッセージの処理、メッセージダイジェストの出力を行う。なお、16ワード長のブロックメッセージの処理は、4つの「ラウンド」と呼ばれる処理からなる圧縮関数である。
【0051】
このようなメッセージダイジェスト生成回路によれば、メッセージ入力回路100が、他のCPU等からの264バイト以下のメッセージの入力を待つ。
なお、一般に、メッセージのビット長は、0以上の正の整数であり、必ずしも8の倍数(バイト単位)である必要は無い。しかし、以下の実施の形態では、メッセージダイジェストを文字コードに適応する場合を想定し、バイト単位のメッセージに基づくメッセージダイジェストの生成例を具体的に説明する。
【0052】
メッセージを受け取ったメッセージ入力回路100は、そのメッセージを先頭から順に32ビット(1ワード)ずつ情報付加回路200に入力する。
図2は、分割されたメッセージのデータ構造を示す図である。メッセージ10は、理論上、512ビット毎のブロック11単位で扱われる。すなわち、メッセージ10は、1以上のブロック11で構成されることとなる。各ブロック11は、32ビットデータで構成される16段のワード12に分けられる。そして、メッセージ入力回路100から情報付加回路200に、ワード単位でデータが入力される。
【0053】
なお、ここでは詳しく述べないが、例えば64ビット、または128ビット以上の単位で処理を行うCPUを用いる場合は、メッセージ入力回路100から入力されるデータは、それぞれ64ビットの8段、128ビットの4段となる。処理単位のデータ長が変わっても、後述するハードウェア構成に関しては、基本的には変更の必要はない。
【0054】
但し、64ビット単位のデータであれば、除算するときの右シフトが3ビットとなる(8で除算)。また、除算の剰余は、0〜7の値であるため、それぞれの値に応じたパディング値が予め用意される。そして、データ長の下位3ビットに応じたパディング値が出力される。
【0055】
同様に、128ビット単位のデータであれば、除算するときの右シフトが4ビットとなる(16で除算)。また、除算の剰余は、0〜15の値であるため、それぞれの値に応じたパディング値が予め用意される。そして、データ長の下位4ビットに応じたパディング値が出力される。
【0056】
分割されたワードが情報付加回路200に入力されると、パディング回路210において、パディングが付加される。パディングは、1つの“1”のビットと必要な数(0以上)の“0”のビットである。パディングは、1以上512以下のビット長である。パディングが付加された後、長さ付加回路220によって、メッセージ長を示す64ビットのデータ(長さ情報)が付加される。パディングと長さ情報とが付加されたメッセージの長さは512ビットの倍数に適合する。
【0057】
パディングと長さ情報とが付加されたデータは、先頭のワードから順に、メッセージ処理回路300に渡される。メッセージ処理回路300は、ワード長のブロックメッセージの処理を行い、メッセージダイジェストを出力する。
【0058】
以下、情報付加回路200の処理を詳細に説明する。
図3は、情報付加回路で行われる処理の概略フローチャートである。以下、図3に示す処理をステップ番号に沿って説明する。
【0059】
[ステップS11]情報付加回路200では、バイト単位のメッセージの入力と、メッセージのデータ長を示す情報(長さ情報)の入力とを受け付け、パディング回路210がメッセージの最後尾を検出する。すなわち、入力されたメッセージのバイト数が、メッセージのデータ長に達したことを検出する。
【0060】
[ステップS12]パディング回路210は、メッセージの最後尾に続けて、パディング(1000・・・000)を付加する。
[ステップS13]長さ付加回路220は、パディングの後に続けて、パディングが付加される前のメッセージ長を示す64ビットのデータ(長さ情報)を付加する。これにより、512ビットの倍数の長さのメッセージが生成され、メッセージ処理回路300に入力される。
【0061】
ここで、パディングの付加処理について詳細に説明する。
まず、ステップS11に示したメッセージの最後尾の検出処理について説明する。本実施の形態では、32ビットワード単位でデータが入力される。パディング回路210は、元のメッセージのバイト単位のデータの長さ情報と、比較器、減算器等を用いてパディングする位置を検出する。すなわち、パディング回路210は、入力されたワード数(1ワードは32ビット)をカウントしメッセージの最後のワードおよびワード内のパディング開始位置を判断する。
【0062】
具体的には、パディング回路210は、ハッシュ対象の元のメッセージの長さ(バイト数)を表すビット列(64ビット)によって、メッセージのワード数と、そのワード内のパディングを開始する位置を判断する。すなわち、長さを4で割り、商と剰余を求める。ビットシフト回路を用いる場合、長さを表すビット列の下位2ビットを除く上位のビット(62ビット)を、4で割ったときの商と判断し、下位2ビットが剰余と判断する。
【0063】
除算の結果得られる商が、パディングを開始するワードを示している。具体的には、商と同数のワードが入力されたとき、次に入力されるワードからパディングを行うことが分かる。
【0064】
除算の結果得られる剰余は、パディングを開始するワード中の何バイト目からパディングを行うかを示している。すなわち、パディング対象のワード内に、剰余で表されるバイト数だけメッセージのデータが残存するため、剰余と同数のバイトデータが入力されたとき、次のバイトデータからパディングを行うべきことが分かる。
【0065】
次に、ステップS12のパディング処理について詳細に説明する。パディング回路210は、パディングを開始するワードのパディング開始位置の先頭に、“1”のビットを付加する。次に、パディングの終了位置まで、“0”のビットを付加し続ける。なお、回路的には、入力されるメッセージが終了すると、その後、0の値のワードがメッセージ入力回路100から入力される。そのため、パディング開始ワードのパディング開始位置に“1”を設定し、その後はメッセージ入力回路100からの入力データの“0”を維持すればよい。
【0066】
図4は、パディング付加および長さ付加処理の例を示す図である。図の例では、40ビットのメッセージ10が入力されている。メッセージ10は、先頭から順番に32ビットワードずつパディング回路210に渡される。40ビットのメッセージ10の場合、1つのワード13,14に分割して、パディング回路210に渡される。最初のワード13は、パディング対象ではないため、パディング回路210において処理は行われない。次のワード14は、パディング対象のワードであるため、有効なメッセージのデータ(図4の例では”01100101”)の後に、パディングが付加される。その後、全体で448ビットになるまで“0”の値のワード16が付加される。
【0067】
パディング付加後のメッセージ20では、448ビットのデータ長となっている(メッセージ20は、16進表記)。
そして、長さ付加回路220が、元データ長を表す2ワード(64ビット)を、パディングされたメッセージの後に追加する。図4の例では、40ビットのデータ長であるため”00000000 00000028”の値が付加されている。
【0068】
もし、L<232であれば、パディング開始ワードが属するブロックは、最後のワードまで“0”が設定される。次のブロックの最初のワードから14番目のワードまで“0”が設定される。そして、最後の2ワードに、データ長を示す値が設定される。
【0069】
本実施の形態では、このようなパディング付加と長さ付加の処理が、CPUを経由せずに情報付加回路200内の電子回路によって行われる。
図5は、情報付加回路の内部構成を示す図である。情報付加回路200には、メッセージ入力回路100は、データ長110(メッセージのバイト数(長さ情報))、DREQ信号120、入力データ130が入力され、出力データ310がメッセージ処理回路300に対して出力される。
【0070】
なお、DREQ信号120は、メッセージ入力回路100が1ブロック(本実施の形態では64バイト)のデータを入力する毎に出力する信号である。このDREQ信号120は、次のブロックの入力開始を示している。すなわち、メッセージ入力回路100は、DREQ信号120により、メッセージをブロック単位に分割したときのブロックの切替位置を、パディング回路210に通知している。
【0071】
情報付加回路200には、パディング回路210、長さ付加回路220、および論理和演算回路201が設けられている。
パディング回路210は、データ長カウントダウンレジスタ211、減算器212、比較器213、ビットシフト回路214、カウンタ回路215、残りデータ長レジスタ216、セレクタ217およびパディング値定数ROM218で構成される。
【0072】
なお、パディング回路210は、大別して、判断回路とパディング出力回路とに分けることができる。判断回路は、入力されたデータ(ワード単位)の総量とメッセージの長さ情報とに応じて、メッセージの最後のデータを判断する回路である。図5の例では、判断回路には、データ長カウントダウンレジスタ211、減算器212、比較器213、ビットシフト回路214およびカウンタ回路215が含まれる。パディング出力回路は、メッセージの最後のデータに続けてパディングを出力する回路である。図5の例では、パディング出力回路には、残りデータ長レジスタ216、セレクタ217およびパディング値定数ROM218が含まれる。
【0073】
また、長さ付加回路220は、比較器221、比較器222、カウンタ+セレクタ回路223、データ長格納レジスタ224、およびビットシフト回路225で構成される。
【0074】
データ長110は、データ長カウントダウンレジスタ211とデータ長格納レジスタ224に入力される。DREQ信号120は、減算器212に入力される。入力データ130は、論理和演算回路201、カウンタ回路215、およびカウンタ+セレクタ回路223に入力される。
【0075】
まず、パディング回路210の内部構成を説明する。
データ長カウントダウンレジスタ211は、初期値としてデータ長(バイト数)が入力される。入力された初期値は、ビットシフト回路214に渡される。そして、減算器212で減算が行われる毎に、減算結果に更新される。これにより、データ長カウントダウンレジスタ211には、処理対象メッセージのデータ残量が保持される。
【0076】
減算器212は、データ長カウントダウンレジスタ211に接続されている。減算器212は、DREQ信号120が入力される毎に、データ長カウントダウンレジスタ211の値を取得し、入力されたデータ量(1ブロック)に相当する値(バイト数)を減算する。本実施の形態では、64(バイト)を減算する。そして、減算器212は、減算結果をデータ長カウントダウンレジスタ211に格納する。
【0077】
比較器213は、データ長カウントダウンレジスタ211とビットシフト回路214とに接続されている。比較器213は、データ長カウントダウンレジスタ211に格納されている値(処理対象メッセージのデータ残量(バイト数))と、1ブロックのバイト数M(本実施の形態では64(バイト))とを比較する。そして、比較器213は、入力データ130の1ブロックのバイト数Mの方が大きくなると、ビットシフト回路214に対してパディング対象ブロックを示す信号を出力する。
【0078】
ビットシフト回路214は、データ長カウントダウンレジスタ211、比較器213、およびカウンタ回路215に接続されている。ビットシフト回路214は、2の累乗の割り算を、右ビットシフトで実現する回路である。本実施の形態では、右2ビットシフトを行う(下位2ビットを破棄する)ことで、4で割った商を求める。
【0079】
すなわち、ビットシフト回路214は、比較器213からパディング対象ブロックを示す信号を受け取ると、そのときデータ長カウントダウンレジスタ211に格納されている処理対象メッセージのデータ残量を取得する。そして、ビットシフト回路214は、取得したデータ残量の値を右2ビットシフトし、データ残量(バイト数)を4で割った商を生成する。ビットシフト回路214は、生成した値を、カウンタ回路215に渡す。これにより、パディング対象ブロックのデータ残量が、何ワード分のデータかを示す値がカウンタ回路215に渡される。
【0080】
カウンタ回路215は、入力データ130、ビットシフト回路214、およびパディング値設定ROM218に接続されている。カウンタ回路215は、ビットシフト回路214により除算の商が入力される毎(パディング対象ブロックが検出されたとき)に“0”クリアされるカウンタ値を保持している。そして、カウンタ回路215は、入力データ130が1ワード入力される毎に、カウンタ値を1ずつカウントアップする。カウンタ回路215は、カウンタ値をカウントアップする毎に、保持しているカウンタ値とビットシフト回路214の値とを比較する。両方の値が等しくなると、カウンタ回路215は、パディング開始を示す信号を出力する。
【0081】
残りデータ長レジスタ216は、データ長カウントダウンレジスタ211とセレクタ217とに接続されている。残りデータ長レジスタ216は、データ長カウントダウンレジスタ211に格納されている残りデータ長(バイト数)を取得し、保持する。そして、残りデータ長レジスタ216は、残りデータ長の下位2ビットの値をセレクタ217に渡す。図5において、最下位のビットをLA[0]と示し、下位から2ビット目のビットをLA[1]と示している。残りデータ長の下位2ビットは、残りデータ長を4で割った剰余を示している。
【0082】
セレクタ217は、残りデータ長レジスタ216とパディング値設定ROM218に接続されている。セレクタ217は、残りデータ長レジスタ216から入力された残りデータ長の下位2ビットに応じた選択信号を、パディング値設定ROM218に出力する。
【0083】
パディング値設定ROM218は、カウンタ回路215、セレクタ217および論理和演算回路201に接続されている。パディング値設定ROM218は、残りデータ長の下位2ビットの値毎のパディング値が格納されている。パディング値設定ROM218は、カウンタ回路215からパディング開始を示す信号が入力されると、セレクタ217から入力される選択信号で選択されたパディング値を論理和演算回路201に出力する。
【0084】
次に、長さ付加回路220の内部構成を説明する。
比較器221は、データ長カウントダウンレジスタ211とカウンタ+セレクタ回路223とに接続されている。比較器221には、1ブロックのデータ長(バイト数)Wと、1ブロックのデータ長Wから、メッセージ長を示すデータのデータ長+1を減算した値(バイト数)Zとが予め設定されている。本実施の形態では、1ブロックのデータ長は64バイトであり、メッセージのデータ長は8バイト(64ビット)のデータで表現される。したがって、W=64、Z=55が設定される。
【0085】
比較器221は、データ長カウントダウンレジスタ211に格納されている処理対象メッセージのデータ残量LAが更新される毎に、LAと、W、Zそれぞれとを比較する。そして、Z<LA<Wであれば、カウンタ+セレクタ回路223に対して長さ付加位置選択信号を出力する。
【0086】
比較器222は、データ長カウントダウンレジスタ211とカウンタ+セレクタ回路223とに接続されている。また、比較器222には、データ長Zが予め設定されている。比較器222は、データ長カウントダウンレジスタ211に格納されている処理対象メッセージのデータ残量LAが更新される毎に、LAとZとを比較する。そして、LA≦Zであれば、カウンタ+セレクタ回路223に対して長さ付加位置選択信号を出力する。
【0087】
カウンタ+セレクタ回路223は、入力データ130が入力されると共に、比較器221、比較器222、およびビットシフト回路225に接続されている。カウンタ+セレクタ回路223は、比較器221もしくは比較器222から長さ付加開始信号が出力されると“0”クリアされるカウンタ値を保持している。そして、カウンタ+セレクタ回路223は、入力データ130が1ワード入力される毎に、カウンタ値を1ずつカウントアップする。
【0088】
また、カウンタ+セレクタ回路223は、2種類の長さ付加開始位置情報を有している。
一方の長さ付加開始位置指定情報は、比較器221から長さ付加位置選択信号が出力されたときに有効となる情報である。この長さ付加開始位置指定情報は、パディング対象ブロックの次のブロックの最後の2ワードの位置を指定する情報である。たとえば、1ブロックが16ワードであれば、ワード単位で31が設定される。
【0089】
他方の長さ付加開始位置指定情報は、比較器222から長さ付加位置選択信号が出力されたときに有効となる情報である。この長さ付加開始位置指定情報は、パディング対象ブロックの最後の2ワードの位置を指定する情報である。たとえば、1ブロックが16ワードであれば、ワード単位で15が設定される。
【0090】
カウンタ+セレクタ回路223は、カウンタ値がカウントアップされる毎に、有効な長さ付加位置指定情報とカウンタ値とを比較する。比較の結果、値が一致すると、カウンタ+セレクタ回路223は、ビットシフト回路225に対して長さ付加開始を示す信号を出力する。
【0091】
データ長格納レジスタ224は、データ長110が入力されると共に、ビットシフト回路225に接続されている。データ長格納レジスタ224は、入力されたデータ長110を保持し、ビットシフト回路225へ出力する。
【0092】
ビットシフト回路225は、2の累乗の掛け算を左ビットシフトで実現する回路である。本実施の形態では、バイト単位の値をビット単位に変換するために、左3ビットシフトを行う。左3ビットシフトにより、元の値が8倍される。すなわち、バイト単位の値がビット単位の値に変換される。
【0093】
具体的には、ビットシフト回路225は、カウンタ+セレクタ回路223から長さ付加開始を示す信号を受け取ると、データ長格納レジスタ224に格納されたデータを取得し、左3ビットシフトの処理を施す。これにより、バイト単位で設定されたデータ長がビット単位に変換される。ビットシフト回路225は、ビット単位のデータ長を表す2ワードのデータを、1ワードずつ2回に分けて論理和演算回路201に対して出力する。
【0094】
以上が、パディング回路210と長さ付加回路220の内部構成である。入力データ130、パディング回路210のパディング値定数ROM218からの出力値、および長さ付加回路220のビットシフト回路225からの出力値が論理和演算回路201に入力されている。論理和演算回路201は、入力されたデータの論理和を演算し、出力データ310としてメッセージ処理回路300へ出力する。
【0095】
以上のような構成の電子回路によって、パディングの付加と長さの付加とが行われる。
ここで、セレクタ217に入力される値とパディング値設定ROM218との対応関係について説明する。
【0096】
図6は、データ長の下位2ビットとパディング開始ワードの中身との対応関係を示す図である。
残りデータ長の下位2ビットが“00”の場合、余りは0(バイト)である。すなわち、パディング対象ワードの先頭がパディング開始位置となる。従って、論理和演算で加算すべきパディング値の中身は、“80000000”(16進表記)となる。これをビット表記に直すと、“10000000 00000000 00000000 00000000”となる。
【0097】
残りデータ長の下位2ビットが“01”の場合、余りは1(バイト)である。すなわち、パディング対象ワードの2バイト目がパディング開始位置となる。従って、論理和演算で加算すべきパディング値の中身は、“00800000”(16進表記)となる。これをビット表記に直すと、“00000000 10000000 00000000 00000000”となる。
【0098】
残りデータ長の下位2ビットが“10”の場合、余りは2(バイト)である。すなわち、パディング対象ワードの3バイト目がパディング開始位置となる。従って、論理和演算で加算すべきパディング値の中身は、“00008000”(16進表記)となる。これをビット表記に直すと、“00000000 00000000 10000000 00000000”となる。
【0099】
残りデータ長の下位2ビットが“11”の場合、余りは3(バイト)である。すなわち、パディング対象ワードの4バイト目がパディング開始位置となる。従って、論理和演算で加算すべきパディング値の中身は、“00000080”(16進表記)となる。これをビット表記に直すと、“00000000 00000000 00000000 10000000”となる。
【0100】
以上のような構成の情報付加回路200により、パディングの付加と長さの付加とが行われる。ここで、図4に示した40ビットのメッセージ10が入力された場合の例を用いながら、情報付加回路200の動作を説明する。
【0101】
メッセージ10が入力される場合、データ長110として、メッセージ10の長さ(40ビット)のバイト単位の値“5”が入力される。入力データ130として、メッセージ10の最初のワード13が入力される。
【0102】
まず、データ長110を示す値“5”が、データ長カウントダウンレジスタ211とデータ長格納レジスタ224とに格納される。データ長カウントダウンレジスタ211に格納された値は、比較器213で1ブロックのバイト数M“64”と比較される。この例では、Mの方が大きいため、比較器213からビットシフト回路214に対してパディング対象ブロックであることを示す信号が出力される。
【0103】
その信号を受け取ったビットシフト回路214は、メッセージ10の残りデータ長を示す値“5”をデータ長カウントダウンレジスタ211から取得し、右2ビットシフトの処理を行う。これにより、残りデータ長を“4”で除算したときの商“1”が得られる。商“1”は、カウンタ回路215に渡される。
【0104】
また、最初のワード13が入力されたときはパディング対象ブロックが検出され、カウンタ回路215の値に0が設定される。このときビットシフト回路214からは“1”が入力されているため、パディング開始を示す信号は出力されない。この結果、パディング回路210からパディング値は出力されない。
【0105】
一方、長さ付加回路220では、2つの比較器221,222において、残りのデータ長LAと所定のデータとの大小の比較が行われる。この例では、残りのデータ長LAが“5”、Zが“55”、Wが“64”である。従って、比較器221の比較結果は偽(要件(Z<LA<W)を満たさない)であるが、比較器222の比較結果は真(要件(LA≦Z)を満たす)となる。従って、比較器222からカウンタ+セレクタ回路223に対して、長さ付加位置選択信号が出力される。
【0106】
カウンタ+セレクタ回路223は、入力データ130から最初のワード13が入力されたことで、カウンタ値に“1”を設定する。そして、比較器222から長さ付加位置選択信号が出力されたことにより、カウンタ+セレクタ回路223において、比較器222に予め対応付けられていた長さ付加開始位置指定情報“15”とカウンタ値“1”とが比較される。比較の結果、値が一致しないため、長さ付加開始を示す信号は出力されない。その結果、長さ付加回路220からは、長さのデータは出力されない。
【0107】
以上のようなパディング回路210と長さ付加回路220との動作により、論理和演算回路201には、ワード13のみが入力される。その結果、ワード13がそのまま出力データ310として出力される。
【0108】
次のワード14が入力データ130として入力されると、カウンタ回路215のカウンタ値がカウントアップされ“1”となる。すると、カウンタ回路215は、パディング値設定ROM218に対してパディング開始を示す信号を出力する。
【0109】
このとき、残りデータ長レジスタ216には、データ長カウントダウンレジスタ211の値“5”が設定されている。この値をビット列で表すと”101”となる。この場合、最下位のビットLA[0]の値が“1”、下位から2番目のビットLA[1]の値が“0”である。すなわち、データ長下位2ビットは“01”となる“01”の値がセレクタ217に入力されると、その値に対応する選択信号が、セレクタ217からパディング値設定ROM218に対して出力される。
【0110】
パディング値設定ROM218は、データ長を4で割ったときの余り1(下位2ビットが“01”)に予め関連付けて格納しているパディング値“00000000 10000000 00000000 00000000”を論理和演算回路201に対して出力する。
【0111】
一方、長さ付加回路220では、ワード14の入力に応じて、カウンタ+セレクタ回路223のカウンタ値がカウントアップされ“2”となる。このカウンタ値は、所定の値“15”に達していないため、カウンタ+セレクタ回路223から長さ付加開始を示す信号は出力されない。その結果、長さ付加回路220からは、長さのデータは出力されない。
【0112】
以上のようなパディング回路210と長さ付加回路220との動作により、論理和演算回路201には、ワード14とパディング回路210から出力されたパディング値が入力される。これらの値の論理和が論理和演算回路201で算出され、“01100101 10000000 00000000 00000000”という内容の出力データ310が出力される。
【0113】
その後、メッセージ10の内容が終了したため、全てのビットに“0”が設定されたワードが、順次、入力データ130として入力される。ワード13から順番に数えて、3番目のワードから14番目のワードまでは、そのままのデータが出力データ310として出力される。この間、カウンタ+セレクタ回路223のカウンタ値が逐次カウンタとアップされる。
【0114】
ワード13から数えて15番目のワードが入力されると、カウンタ+セレクタ回路223のカウンタ値が“15”にカウントアップされる。すると、カウンタ+セレクタ回路223において比較器222に関連付けて設定されていた値“15”とカウンタ値とが一致し、カウンタ+セレクタ回路223から長さ付加開始を示す信号が出力される。
【0115】
すると、ビットシフト回路225から論理和演算回路201へ、メッセージ10のビット単位の長さを示す2ワードのデータの上位1ワード分“00000000”(16進表記)が出力される。長さを示す上位1ワードのデータと、入力データ130として入力されたワードとの論理和が論理和演算回路201で計算され、出力データ310として出力される。
【0116】
次に、ワード13から数えて16番目のワードが入力されると、ビットシフト回路225から論理和演算回路201へ、メッセージ10のビット単位の長さを示す2ワードのデータの下位1ワード分“00000028”(16進表記)が出力される。長さを示す下位1ワードのデータと、入力データ130として入力されたワードとの論理和が論理和演算回路201で計算され、出力データ310として出力される。
【0117】
このようにして、ハードウェア的な電子回路で、認証対象のメッセージに対し、パディング付加、および長さ付加を行うことができる。その結果、CPUに負担をかけずに、メッセージ認証処理を高速に行うことができる。しかも、コンピュータのメインメモリの消費量も少なくてすむ。
【0118】
本実施の形態を利用したメッセージ認証処理を行う回路は、ネットワークを介した通信を行う各種機器に実装することができる。たとえば、インターネットに接続されたコンピュータ(パーソナルコンピュータやサーバコンピュータ等)やルータ等に対して、本実施の形態を適用できる。
【0119】
以下、本実施の形態に係るメッセージ認証機能を有するコンピュータのハードウェア構成例について説明する。
図7は、本実施の形態の回路を適用したコンピュータのハードウェア構成例を示す図である。コンピュータ400は、CPU401によって装置全体が制御されている。CPU401には、バス408を介してRAM(Random Access Memory)402、ハードディスクドライブ(HDD:Hard Disk Drive)403、グラフィック処理装置404、入力インタフェース405、通信インタフェース406、およびHMAC演算回路407が接続されている。
【0120】
RAM402には、CPU401に実行させるOS(Operating System)のプログラムやアプリケーションプログラムの少なくとも一部が一時的に格納される。また、RAM402には、CPU401による処理に必要な各種データが格納される。HDD403には、OSやアプリケーションプログラムが格納される。
【0121】
グラフィック処理装置404には、モニタ11が接続されている。グラフィック処理装置404は、CPU401からの命令に従って、画像をモニタ11の画面に表示させる。入力インタフェース405には、キーボード12とマウス13とが接続されている。入力インタフェース405は、キーボード12やマウス13から送られてくる信号を、バス408を介してCPU401に送信する。
【0122】
通信インタフェース406は、ネットワーク10に接続されている。通信インタフェース406は、ネットワーク10を介して、他のコンピュータとの間でデータの送受信を行う。
【0123】
HMAC演算回路407は、入力されたメッセージに対してHMACの演算を行い、認証後のメッセージを出力する回路である。たとえば、ネットワーク10を介して送信すべきメッセージがHMAC演算回路407に入力されると、パディング付加、長さ付加後、1ワード毎の所定のメッセージ処理が行われ、メッセージダイジェストが生成される。生成されたメッセージダイジェストは、通信インタフェース406を介してネットワーク10上へ送出される。
【0124】
以上のようなハードウェア構成によって、本実施の形態の処理機能を実現することができる。たとえば、IPsec処理をハードウェア回路で実行するコンピュータが提供される。
【0125】
以下、図8、図9、図10を参照して、IPsecの認証範囲とIPパケットのサイズについて説明する。IPsecではIPパケットの改竄、なりすましを防ぐために認証機能を必須としている。IPsecはプロトコル群であり、ESP(Encapsulating Security Payload)とAH(Authentication Header)とからなる。
【0126】
図8は、トランスポートモードESPの認証範囲を示す図である。図8(A)はIPv4のパケットを示し、図8(B)はIPv6のパケットを示す。
IPv4のパケット40は、IPヘッダ41、ESPヘッダ42、TCPヘッダ43、データ44、ESPトレーラ45、ESP認証ヘッダ46で構成される。そのうち、ESPヘッダ42、TCPヘッダ43、データ44、ESPトレーラ45が認証範囲である。
【0127】
IPv6のパケット50は、IPv6ヘッダ51、経路制御ヘッダ52、ESPヘッダ53、終点オプションヘッダ54、TCPヘッダ55、データ56、ESPトレーラ57、ESP認証ヘッダ58で構成される。そのうち、ESPヘッダ53、終点オプションヘッダ54、TCPヘッダ55、データ56、ESPトレーラ57が認証範囲である。
【0128】
例えばトランスポートESPを用いる際のパケット生成時には、範囲の情報に関して、鍵付きハッシュ関数(HMAC−SHA1,HMAC−MD5)を用いた認証処理が行われる。
【0129】
図9は、AHの認証範囲を示す図である。AHのパケット60の構成は、IPv4、IPv6、共に同じである。AHのパケット60は、IPヘッダ61、AHヘッダ62、TCPヘッダ63、データ64で構成される。AHのパケット60では、全てが認証範囲となる。すなわち、パケット全体の鍵付きハッシュ関数(HMAC−SHA1,HMAC−MD5)を用いた認証処理が必要となる。
【0130】
また、最大パケットサイズはネットワークの接続媒体によって決定される。たとえば、ネットワークの接続物理媒体としてイーサネット(登録商標)と呼ばれるネットワーク(IEEE802.3)を用いた場合のIPパケットのサイズを説明する。
【0131】
なお、IEEE802.3のネットワークの一例として、1パケットの認証処理を例に発明の作用を説明する。認証処理においては、最初と最後にHMAC処理を行うため機能的には、CPUにて設定(HMAC処理かどうか、MD5/SHA1かどうかなどのモード設定)を行った後、シームレスにハードウェア処理が行われる。これにより、CPU負荷を軽減し、またハードウェアの持つパフォーマンス値を引き出すことが可能となる。また、DMAC(Direct Memory Access Controller)を用いてCPUにおいて処理を行う認証処理を独立して実行することもできる。
【0132】
図10は、IPパケットサイズを示す図である。図10に示すように、IPパケット70は、IPv6ヘッダ71、経路制御ヘッダ72、終点オプションヘッダ73、TCPヘッダ74、データ75で構成される。このような構成のIEEE802.3に従ったネットワークの最大IPパケットサイズは、約1500バイト(IPv6ヘッダ40バイト、その他1460バイト以下)である。
【0133】
認証アルゴリズムであるハッシュ関数のMD5とSHA1は、64バイト(512ビット)ブロック関数である。従って、1パケットの処理でさえ、最大約20回を超えるハッシュ処理が行われる。また、鍵管理においてもハッシュ関数が使用される。
【0134】
このようなデータ構造のIPパケットに本実施の形態を適用すれば、インターネット等のデータ通信能力を高めることができる。例えば、次世代プロトコルIPsecの認証処理はハッシュ関数を用いており、そのIPパケット生成処理で、図10に示したIPパケットの認証作業を行う。IPパケットレベルでの認証だけでなく、暗号化して送信する場合はESPヘッダを使用する。IPsecではパケットごとに暗号化がなされ、ESPと呼ばれる入れ物にパックされ送信される。なお、最新のIPsec version2.0では認証と暗号化の両方をESPで行えるように改訂されている。
【0135】
ESPはトンネリングモードとトランスポート・モードの2方式がある。トンネリングモードはIPパケットをヘッダごと暗号化する手順である。トランスポート・モードはIPパケットのデータ部だけを暗号化する手順である。
【0136】
IPsecでは、暗号化する対象部分によって、「トランスポート・モード」と「トンネル・モード」という2つの方法が提供されている。トランスポート・モードでは、IPパケットで運ぶデータ部分のみを暗号化し、これにあて先などを指定したIPヘッダを付けて送信をする。一方、トンネル・モードでは、ほかのホストからいったん受信したIPヘッダとデータ部分を合わせたものをまとめて暗号化したうえで、新たにIPヘッダを再度付け直して送信を行う。送信時にはこの暗号化の後に認証処理を施し、受信時には最初に認証処理を行う。
【0137】
基本的に、上位プロトコルのデータ・サイズは、下位プロトコルのデータ・サイズに制限される。従って、下位がイーサネット(登録商標)なら、中に入るIPパケットの最大サイズは、IPパケットがフラグメントしない場合、MACフレームのデータ部分の最大サイズ(1500バイト)になる。
【0138】
図11は、IPsecによる送信処理の手順を示すフローチャートである。以下、図11に示す処理をステップ番号に沿って説明する。
[ステップS21]CPU401は、送信メッセージを含む送信用のパケットを生成する。
【0139】
[ステップS22]CPU402は、パケットの暗号化処理を行う。暗号化されたメッセージは、HMAC演算回路407に渡される。
[ステップS23]HMAC演算回路407は、渡されたメッセージの認証処理(HMAC)を行う。これにより、CPU401で暗号化されたメッセージに、認証のためのメッセージダイジェストが付加される。暗号化されたメッセージとメッセージダイジェストとは、共に通信インタフェース406に渡される。
【0140】
[ステップS24]通信インタフェース406は、通信用のフレームを生成する。
[ステップS25]通信インタフェース406、生成したフレームをネットワーク10経由で送信する。
【0141】
図12は、IPsecによる受信処理の手順を示すフローチャートである。以下、図12に示す処理をステップ番号に沿って説明する。
[ステップS31]通信インタフェース406は、ネットワーク10経由で送られたフレームを受信する。受信したフレームは、HMAC演算回路407に渡される。
【0142】
[ステップS32]HMAC演算回路407は、受信したフレームのメッセージダイジェストに基づいて、フレーム内のメッセージを認証する。すなわち、メッセージが改竄されていないことを確認する。正しく認証されたメッセージ(暗号化されている)は、CPU401に渡される。
【0143】
[ステップS33]CPU401は、暗号化されたメッセージを復号し、元の平文のメッセージを再現する。
このように、本実施の形態に係る回路が実装されたコンピュータでは、送信時にも受信時にも、認証処理が行われる。なお、CPU401は暗号化処理や認証処理のほかに複雑なプロトコル処理も行う。
【0144】
このように、ハードウェア回路によってメッセージ認証を行うことで、メッセージ認証を高速に行うことができると共に、コンピュータ全体としての処理能力を高めることができる。
【0145】
すなわち、CPUに対してソフトウェア的な負担をかけることなく、独立したハードウェアでハッシュ関数アルゴリズムの処理を行うことができる。このような専用ハードウェア化により、CPUの占有率も低減させ、例えば上記システム全体のパフォーマンスも向上させることができる。
【0146】
具体的には、ソフトウェアで認証処理を行う場合、CPU401が認証処理を終了するまで他の処理はできず待たされたままである。一方、図7に示したHMAC演算回路407(ハッシュ関数専用ハードウェア回路)を実装することで、CPU401は認証処理を専用ハードウェアに行わせている間に、他の処理を行うことができる。その結果、コンピュータにおける他のアプリケーションの処理時間が短縮される。
【0147】
しかも、HMAC演算回路407は入力されたメッセージを逐次処理して、出力するため、CPU401による演算のようにRAM402内にデータをロードする必要がない。そのため、RAM402の記憶容量を余計に使用することも無く、システムとして安定したパフォーマンスを提供できる。
【0148】
なお、HMAC演算回路407のような認証回路は、様々な機器にも組み込み可能である。そのため、高度な演算能力を有さないCPUで制御される機器でも、IPsec通信を提供できる。たとえば、認証回路を、PDA(Personal Digital(Data) Assistants)や移動体電話機などに組み込むことができる。
【0149】
次に、パディングの付加と長さの付加とを電子回路で実行することによる処理時間の短縮効果について説明する。
以下の例では、CPUコアに32ビットRISCプロセッサを採用したマイクロコンピュータと、本実施の形態に係る「パディング付加」「長さの付加」専用ハードウェア回路を実装したPLD(Programmable Logic Device)/FPGA(Field Programmable Gate Array)を用いて実装評価を行った。
【0150】
実装評価では、テストデータを本実施の形態を適用したハードウェアに入力し、出力データを公知データ(RFC1321、FIPS180−1)と比較し、正しく動作していることを確認した。その際、従来技術(ソフトウェアでパディング付加、および長さ付加を実行)と本実施の形態(ハードウェアでパディング付加、および長さ付加を実行)とを比較した。具体的には、1280バイトのデータに対して1000回処理を行った処理速度をCPUによるソフトウェア実行とハードウェア実行とのそれぞれでの処理の所要時間を、ハードマクロへのレジスタライトも含めてトータルで比較を行ったものである。
【0151】
1.アルゴリズムMD5のとき
[ソフトウェア実行所要時間]11667(ミリ秒)
[ハードウェア実行所要時間]1178(ミリ秒)
この場合、ソフトウェア実行所要時間/ハードウェア実行所要時間=9.92である。すなわち、専用ハードウェアで実行した場合の方が9.92倍速い。
【0152】
2.アルゴリズムHMAC−MD5のとき
[ソフトウェア実行所要時間]14067(ミリ秒)
[ハードウェア実行所要時間]1206(ミリ秒)
この場合、ソフトウェア実行所要時間/ハードウェア実行所要時間=11.66である。すなわち、専用ハードウェアで実行した場合の方が11.66倍速い。
【0153】
3.アルゴリズムSHA1のとき
[ソフトウェア実行所要時間]32000(ミリ秒)
[ハードウェア実行所要時間]1473(ミリ秒)
この場合、ソフトウェア実行所要時間/ハードウェア実行所要時間は21.73である。すなわち、専用ハードウェアで実行した場合の方が21.73倍速い。
【0154】
4.アルゴリズムHMAC−SHA1のとき
[ソフトウェア実行所要時間]38643(ミリ秒)
[HMACをソフトウェア実行−SHA1をハードウェア実行の所要時間]3372(ミリ秒)
[ハードウェア実行所要時間]1500(ミリ秒)
この場合、ソフトウェア実行所要時間/ハードウェア実行所要時間は25.76である。すなわち、HMAC−SHA1の両方を専用ハードウェアで実行した場合の方が、両方ソフトウェアで実行した場合より25.76倍速い。
【0155】
本結果から、本実施の形態に関する専用ハードウェアの従来技術に対する有効性が明確に分かる。以上の結果よりIPパケット長が長いほど、IPsecの本ハード処理が効果的になるといえる。
【0156】
以上、説明したように本実施の形態によれば、ハッシュ関数、HMACを用いる処理における「パディング付加」、「長さの付加」を専用ハードウェアによって実行することができる。そのため、ハッシュ関数処理、ハッシュ関数を用いた認証処理の際に、CPUに負荷をかけることなく処理を高速化でき、CPUの処理負荷を大幅に軽減することができる。
【0157】
また、パディングや長さ付加のために必要なメモリ容量を削減することができる。
さらに、パディングや長さ付加のためのCPU占有率を軽減することから、システムとして機能させる際にも確実なパフォーマンスを保障することができる。しかも、安価なマイコンでも高速処理が可能となるため、コスト削減に効果がある。
【0158】
(付記1) メッセージダイジェストを生成するメッセージダイジェスト生成回路において、
メッセージを所定のデータ長のデータに分割して先頭から順に入力するとともに、前記メッセージの長さを示す長さ情報を入力するメッセージ入力回路と、
前記メッセージ入力回路で入力された前記データの総量と前記長さ情報とに応じて前記メッセージの最後の前記データを判断し、前記最後の前記データに続けてパディングを出力するパディング回路と、
前記メッセージ入力回路で入力された前記データと前記パディング回路で出力された前記パディングとの総量に応じて前記パディングの終了位置を判断し、前記パディングに続けて前記長さ情報を出力する長さ付加回路と、
を有することを特徴とするメッセージダイジェスト生成回路。
【0159】
(付記2) 前記パディング回路は、前記長さ情報から、前記メッセージ入力回路から入力された前記データの容量を順次減算する減算器と、前記減算器の減算結果が1ブロック分のデータ長以下になったときにパディング対象ブロックを示す信号を出力する比較器とを有することを特徴とする付記1記載のメッセージダイジェスト生成回路。
【0160】
(付記3) 前記メッセージ入力回路は、1ブロック分の前記データを入力する毎にブロック切替を示す信号を出力し、
前記減算器は、前記ブロック切替を示す信号が出力されると、前記長さ情報から前記1ブロック分のデータ長を減算することを特徴とする付記2記載のメッセージダイジェスト生成回路。
【0161】
(付記4) 前記メッセージ入力回路は、前記データのサイズをNバイト(Nは自然数)とし、
前記パディング回路は、前記比較器より前記パディング対象ブロックを示す信号が出力されたとき、前記減算器の前記減算結果をNで除算し、その後前記データが入力された回数をカウントし、カウントした値が前記除算による商の値に達すると、入力された前記データに続けて前記除算による剰余の値に応じたパディングを出力することを特徴とする付記2記載のメッセージダイジェスト生成回路。
【0162】
(付記5) 前記メッセージ入力回路は、前記データのサイズを2バイト(nは自然数)とし、
前記パディング回路は、前記減算器の前記減算結果の右nビットシフトするビットシフト回路を有しており、前記ビットシフト回路によるシフト結果を前記除算結果とすることを特徴とする付記4記載のメッセージダイジェスト生成回路。
【0163】
(付記6) 前記メッセージ入力回路は、前記データのサイズを2バイト(nは自然数)とし、
前記パディング回路は、nビットで表せる数値それぞれに対応付けて前記パディング値が格納された記憶装置と、前記減算器の前記減算結果の下位nビットの値に応じて前記記憶装置から出力するパディング値を選択するセレクタとを有することを特徴とする付記4記載のメッセージダイジェスト生成回路。
【0164】
(付記7) 前記長さ付加回路は、1ブロック分のデータ長の倍数から前記長さ情報のデータ長の分を減算したデータ量に相当する前記データおよび前記パディングが出力された後、前記長さ情報を出力することを特徴とする付記1記載のメッセージダイジェスト生成回路。
【0165】
(付記8) メッセージにパディングを付加するパディング回路において、
前記メッセージが所定のデータ長のデータに分割され先頭から順に入力されるとともに、前記メッセージの長さを示す長さ情報が入力されると、入力された前記データの総量と前記長さ情報とに応じて前記メッセージの最後の前記データを判断する判断回路と、
前記判断回路で判断された前記最後の前記データに続けてパディングを出力するパディング出力回路と、
を有することを特徴とするパディング回路。
【0166】
(付記9) 前記判断回路は、前記長さ情報から、入力された前記データの容量を順次減算する減算器と、前記減算器の減算結果が1ブロック分のデータ長以下になったときにパディング対象ブロックを示す信号を出力する比較器とを有することを特徴とする付記8記載のパディング回路。
【0167】
(付記10) 前記データは、Nバイト(Nは自然数)単位であり、
前記判断回路は、前記比較器より前記パディング対象ブロックを示す信号が出力されたとき、前記減算器の前記減算結果をNで除算し、その後前記データが入力された回数をカウントし、
前記パディング出力回路は、カウントした値が前記除算による商の値に達すると、入力された前記データに続けて前記除算による剰余の値に応じたパディングを出力することを特徴とする付記9記載のパディング回路。
【0168】
(付記11) 認証されたメッセージを送信する通信装置において、
送信すべきメッセージを生成するCPUと、
前記CPUで生成されたメッセージを所定のデータ長のデータに分割して先頭から順に入力するとともに、前記メッセージの長さを示す長さ情報を入力するメッセージ入力回路と、
前記メッセージ入力回路で入力された前記データの総量と前記長さ情報とに応じて前記メッセージの最後の前記データを判断し、前記最後の前記データに続けてパディングを出力するパディング回路と、
前記メッセージ入力回路で入力された前記データと前記パディング回路で出力された前記パディングとの総量に応じて前記パディングの終了位置を判断し、前記パディングに続けて前記長さ情報を出力する長さ付加回路と、
前記メッセージ入力回路から入力された前記メッセージ、前記パディング回路から出力されたパディング、および前記長さ付加回路から出力された長さ情報に基づいてメッセージダイジェストを生成するメッセージ処理回路と、
を有することを特徴とする通信装置。
【0169】
(付記12) メッセージの認証処理を行うためのメッセージ認証方法において、
CPUにより、送信すべきメッセージを生成し、
メッセージ入力回路により、前記CPUで生成されたメッセージを所定のデータ長のデータに分割して先頭から順にパディング回路に入力するとともに、前記メッセージの長さを示す長さ情報を前記パディング回路に入力し、
前記パディング回路により、前記メッセージ入力回路で入力された前記データの総量と前記長さ情報とに応じて前記メッセージの最後の前記データを判断し、前記最後の前記データに続けてパディングを出力し、
長さ付加回路により、前記メッセージ入力回路で入力された前記データと前記パディング回路で出力された前記パディングとの総量に応じて前記パディングの終了位置を判断し、前記パディングに続けて前記長さ情報を出力し、
メッセージ処理回路によって、前記メッセージ入力回路から入力された前記メッセージ、前記パディング回路から出力されたパディング、および前記長さ付加回路から出力された長さ情報に基づいてメッセージダイジェストを生成する、
ことを特徴とするメッセージ認証方法。
【0170】
【発明の効果】
以上説明したように本発明では、パディング回路がメッセージの最後のデータを判断し、最後のデータに続けてパディングを出力するとともに、長さ付加回路がパディングの終了位置を判断し、パディングに続けて長さ情報を出力するようにした。これにより、CPUに負荷をかけずに、入力されたメッセージに対してパディングと長さ情報とを付加することができる。
【図面の簡単な説明】
【図1】本実施の形態に係るメッセージダイジェスト生成回路の概略構成を示す図である。
【図2】分割されたメッセージのデータ構造を示す図である。
【図3】情報付加回路で行われる処理の概略フローチャートである。
【図4】パディング付加および長さ付加処理の例を示す図である。
【図5】情報付加回路の内部構成を示す図である。
【図6】データ長の下位2ビットとパディング開始ワードの中身との対応関係を示す図である。
【図7】本実施の形態の回路を適用したコンピュータのハードウェア構成例を示す図である。
【図8】トランスポートモードESPの認証範囲を示す図である。図8(A)はIPv4のパケットを示し、図8(B)はIPv6のパケットを示す。
【図9】AHの認証範囲を示す図である。
【図10】IPパケットサイズを示す図である。
【図11】IPsecによる送信処理の手順を示すフローチャートである。
【図12】IPsecによる受信処理の手順を示すフローチャートである。
【符号の説明】
100 メッセージ入力回路
200 情報付加回路
210 パディング回路
220 長さ付加回路
300 メッセージ処理回路
[0001]
TECHNICAL FIELD OF THE INVENTION
The present invention relates to a message digest generating circuit that generates a message digest and a padding circuit that performs padding at the time of message authentication, and more particularly to a message digest generating circuit and a padding circuit that perform processing according to a message digest algorithm of a hash function.
[0002]
[Prior art]
As the range of use of information communication expands, high security regarding communication data is required. Therefore, the importance of data security technology is increasing.
[0003]
As one of data security technologies, there is an authentication technology for preventing data tampering and the like. The authentication technology is a technology for authenticating that received data is transmitted from a correct source and that the data is not falsified by a third party.
[0004]
As a data authentication technique, there is a technique using a hash function. Examples of the hash function algorithm include MD (Message Digest algorithm) 5 and SHA (Secure Hash Algorithm) 1. MD5 is defined in RFCs (Requests For Comments) 1321 issued by the IETF (Internet Engineering Task Force). SHA1 is defined in RFC2841. These hash function algorithms are hash functions most used in communication encryption techniques such as message authentication and digital signature methods used in networks.
[0005]
In message authentication using a hash function, when digitally signing a large sentence, a hash function is applied to the original long message (a variable-length message such as a document or data file) to generate a fixed-length character string. I do. This fixed-length character string is called a message digest. This is a concept that a long message or document is computer-processed and represented as a simple digest, and can be regarded as a “digital fingerprint” of the original input information (message).
[0006]
When the message digest is used, the usage form is determined in consideration of the security of the communication path used and the importance of the message itself. For example, a hash function is used for message authentication when dealing with information (for example, an order quantity in e-commerce) in which the message itself has few problems even if it is made public, but is falsified if it is tampered with. . Also, when handling information that would cause a problem if the message itself becomes public (for example, a credit card number in electronic commerce), encryption is performed after adding a message digest. This protects the entire information to be transmitted.
[0007]
Meanwhile, there is a protocol called IP (Internet Protocol) sec (security) in which a security function is added to the IP protocol. Implementation of IPsec is mandatory in IPv6, the next generation IP. Therefore, IPsec is the most promising security protocol at present.
[0008]
With the use of IPsec, the security of communication via a LAN (Local Area Network), a private or public WAN (Wide Area Network), and the Internet can be secured at the IP level. By ensuring security at the IP level, a network operator can provide a secure network environment for not only applications with security mechanisms but also many applications without security provisions. That is, secure communication can be performed for each application without mounting security-related functions.
[0009]
IP-level security includes three elements: authentication, confidentiality, and key management. The authentication mechanism verifies that the received packet actually comes from the sender described in the packet header. It also guarantees that this packet has not been altered during transmission. The function of maintaining confidentiality encrypts the message so that the communication node prevents eavesdropping from a third party. Key management concerns secure exchange of keys.
[0010]
As described above, the technology using the hash function is a technology that is increasingly required in the future. In a message authentication technique using a hash function, padding addition processing and length information addition processing (hereinafter, simply referred to as length addition) processing are generally performed.
[0011]
For example, in the SHA1 message digest algorithm, which is a typical hash function, when a message of an arbitrary length is input, a 160-bit message digest for the input message is generated and output. The SHA1 algorithm has roughly the following five configurations.
[First processing] Addition of padding bit
[Second processing] Addition of length
[Third processing] Initialization of message digest buffer
[Fourth processing] Processing of 16-word (512-bit) block message
[Fifth processing] Output
Here, attention is paid to [first processing] addition of padding bits and [second processing] addition of length. Hereinafter, one word indicates 32 bits.
[0012]
When SHA1 is used as a hash function, padding processing for a message is performed as follows.
The message is 2 64 It is assumed that the length is less than the byte L. Before being input to SHA1, the message is padded on the right side as follows.
[0013]
First, one “1” is added. Subsequently, zero or more “0” s are added ([first processing]). The number of “0” depends on the length of the original message. That is, the number of “0” to be added is determined so that the length (bit) of the message after padding conforms to 448 modulo 512 (the bit length is 448 longer than a multiple of 512).
[0014]
Note that padding is always performed even if the message length conforms to 448 modulo 512. For example, if the length of the message is 448 bits, 512 bits of padding are added so that the length becomes 960 bits. Therefore, padding of at least one bit and 512 bits at the maximum is added as a whole.
[0015]
Next, 64 bits indicating the length of the original data are added to the padding result ([second processing]). Since the message length after padding conforms to 448 modulo 512, if the 64-bit data that is the length information is added, the bit length of the message to which the length information is added becomes a multiple of 512.
[0016]
Here, a specific example of padding addition and length addition processing will be described. For example, let the original message be the following bit string:
"01100001 01100010 01000011 01100100 01100101"
According to the [first processing], the bit string becomes as follows.
[0017]
First, “1” is added.
"01100001 01100010 01000011 01100100 01100101 1"
When the length L (L is an integer of 0 or more) is 40 (bits), the number of bits after adding “1” is 41. Therefore, 407 “0” s are added to conform to 448 modulo 512, and the total number of bits becomes 448. This is in hexadecimal notation:
61626364 65800000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000
[Second processing] A two-word expression (one word is 32 bits) having a length L which is the number of bits of the original message is obtained. If length L <2 32 Then the first word is all zeros. Add the two words to the padded message.
[0018]
In this example, L = 40. The two-word notation of 40 is 0000000000000002 in hexadecimal. As a result, the final assigned message is as follows in hexadecimal.
61626364 65800000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
000000000 00000000 00000000 000028
At this time, the length of the resulting message is an exact multiple of 512 bits. Since 512 bits is 16 32-bit words, the length of this message is also an exact multiple of 16 words.
[0019]
Such a message authentication technique using a hash function is described in detail in Non-Patent Documents 1 and 2, for example.
Patent Document 1 discloses an example of a security technique using a hash function.
[0020]
[Non-patent document 1]
Shinichi Ikeno and Kenji Koyama, "Modern Cryptography", IEICE, September 1, 1986.
[Non-patent document 2]
Bruce Schneier, "Applied Cryptography (Second Edition)", John Wiley & Sons, Inc. 1996, P429-P459.
[Patent Document 1]
JP-T-2001-527325 (Pages 27 to 30)
[0021]
[Problems to be solved by the invention]
By the way, conventionally, the entire processing by a hash function and the processing of configuring a HMAC (Hash-based Message Authentication Code) message authentication function using a specific hash function are defined by software. The CPU (Central Processing Unit) was executing. Therefore, the MD5 and SHA1 algorithms have been coded to increase the efficiency of software execution by the CPU. The code was designed to run efficiently on a 32-bit machine.
[0022]
HMAC is a mechanism for performing message authentication using a cryptographic hash function. HMAC uses an iterative cryptographic hash function such as MD5 or SHA1 in combination with a secret shared key.
[0023]
However, even if the padding process is designed to operate efficiently, its speed is completely dependent on CPU occupancy and CPU performance. For this reason, a sufficient speed may not be obtained, and in a situation in which the processing is combined with processing of another application or the like, the processing speed is further reduced. In addition, if processing of large data such as IP packet authentication of IPsec is executed by software, it takes an enormous amount of time.
[0024]
Furthermore, in order for the CPU to add padding and length, it is necessary to store a message to be transmitted in a memory, which consumes a storage area of the memory. If the storage capacity in the memory is used for padding or the like, the memory capacity that can be used for executing other applications decreases, and the processing efficiency decreases.
[0025]
As described above, the conventional processing such as padding addition is software processing by the CPU, so that the processing load on the CPU is heavy, and it is difficult to obtain a sufficient processing speed. Moreover, causing the CPU to execute the padding addition processing may interfere with the processing of other applications in some cases, greatly affecting the processing performance of the entire system.
[0026]
The present invention has been made in view of such a point, and an object of the present invention is to provide a message digest generation circuit capable of adding padding and length without imposing a load on a CPU.
[0027]
Another object of the present invention is to provide a padding circuit capable of adding padding without imposing a load on a CPU.
[0028]
[Means for Solving the Problems]
In the present invention, in order to solve the above problem, a message digest generation circuit as shown in FIG. 1 is provided. A message digest generation circuit according to the present invention performs message authentication processing. The message digest generation circuit includes a message input circuit 100, a padding circuit 210, and a length adding circuit 220. The message input circuit 100 divides a message into data having a predetermined data length, inputs the data sequentially from the beginning, and inputs length information indicating the length of the message. The padding circuit 210 determines the last data of the message according to the total amount of data and the length information input by the message input circuit 100, and outputs padding following the last data. The length adding circuit 220 determines a padding end position according to the total amount of the data input by the message input circuit and the padding output by the padding circuit, and transmits the length information following padding. Output.
[0029]
According to such a message digest generation circuit, the message is divided into data of a predetermined data length by the message input circuit 100 and is sequentially input from the top. Further, the message input circuit 100 inputs length information indicating the length of the message. Then, the padding circuit 210 determines the last data of the message according to the total amount of data and the length information input by the message input circuit 100, and outputs padding following the last data. Thereafter, the padding end position is determined by the length adding circuit 220 according to the total amount of the data input by the message input circuit and the padding output by the padding circuit, and the length information is output following the padding. You.
[0030]
According to another aspect of the present invention, in a padding circuit for adding padding to a message, the message is divided into data of a predetermined data length, input in order from the beginning, and indicates the length of the message. When length information is input, a determination circuit that determines the last data of the message according to the total amount of the input data and the length information, and the last data determined by the determination circuit. A padding output circuit that outputs padding following data.
[0031]
According to such a padding circuit, the message is divided into data of a predetermined data length and sequentially input from the beginning, and when length information indicating the length of the message is input, the length information is input by the determination circuit. The last data of the message is determined according to the total amount of data and the length information. Then, padding is output by the padding output circuit following the last data determined by the determination circuit.
[0032]
BEST MODE FOR CARRYING OUT THE INVENTION
Hereinafter, embodiments of the present invention will be described with reference to the drawings.
FIG. 1 is a diagram showing a schematic configuration of a message digest generation circuit according to the present embodiment. The message digest generation circuit is roughly composed of a message input circuit 100, an information addition circuit 200, and a message processing circuit 300.
[0033]
The message input circuit 100 divides the message into data of a predetermined data length and inputs the data in order from the beginning, and inputs length information indicating the length of the message to the information adding circuit 200. Further, the message input circuit 100 outputs a signal indicating block switching every time data of one block is input.
[0034]
The information adding circuit 200 executes the first half of the message digest generation processing. Specifically, the information adding circuit 200 adds padding and length. The information adding circuit 200 has a padding circuit 210 for adding padding and a length adding circuit 220 for adding length.
[0035]
The padding circuit 210 determines the last data of the message according to the total amount of data and the length information input by the message input circuit 100, and outputs padding following the last data. Information according to the total amount of input data and the length information can be converted into a numerical value by, for example, subtracting the input data amount from the numerical value of the length information.
[0036]
More specifically, the padding circuit 210 includes a subtractor for sequentially subtracting the capacity of the data input from the message input circuit 100 from the length information, and a subtraction result of the subtractor for a data length of one block (for example, 64). And a comparator that outputs a signal indicating the padding target block when the number of bytes becomes equal to or less than (byte). For example, when a signal indicating block switching is output, the subtractor subtracts the data length of one block from the length information. Since the subtraction result is equal to or less than the data length of one block, it is known that the next input block is the block to be padded.
[0037]
Then, when the signal indicating the padding target block is output from the comparator, the padding circuit 210 determines the last data from the data in one block.
[0038]
For example, when the size of the data input to the message input circuit 100 is N bytes (N is a natural number), the padding circuit 210 outputs the subtraction result of the subtractor by N when the signal indicating the padding target block is output from the comparator. And then count the number of times data has been input. When the counted value reaches the value of the quotient by division, it is determined that the data input at that time is the last data of the message, and the padding circuit 210 follows the last data and responds to the value of the remainder by division. Output padding.
[0039]
That is, the data length of the remaining message in the block to which padding is to be added is divided by the size N of the input data (4 if it is 1 word) to obtain the last word including the original message in the block. Is specified. The remainder (lower 2 bits of the remaining data length) when divided by N indicates from which byte in the 32-bit word where padding starts padding is to be performed.
[0040]
The data length division process can be realized by a bit shift circuit. The size of the data input by the message input circuit 100 is 2 n In the case of a byte (n is a natural number), the padding circuit 210 has a bit shift circuit that shifts the subtraction result of the subtractor by n bits to the right, and uses the shift result by the bit shift circuit as a division result. One word (2 2 When data of (byte) is input, the quotient may be obtained by shifting the value of the remaining data length to the right by 2 bits. By performing division by a bit shift circuit, a circuit can be efficiently formed.
[0041]
In addition, padding addition processing for a 23-bit word at which padding starts can be realized by performing a logical OR operation on the word and a word indicating a padding value. That is, it can be realized using an OR operation circuit.
[0042]
At this time, the value of the padding input to the OR operation circuit is determined as follows, for example. The size of the data input by the message input circuit 100 is 2 n It is a byte (n is a natural number).
[0043]
That is, the padding circuit 210 stores the padding value in the storage device in advance in association with each numerical value represented by n bits. Then, the padding circuit 210 selects a padding value to be output from the storage device according to the value of the lower n bits of the subtraction result (data length of the remaining bytes of the message) of the subtractor by the selector.
[0044]
If the subtractor performs the subtraction in units of a block length (for example, 64 bytes), the value of the lower two bits of the length information indicating the data length of the original message does not change by the subtraction processing. Therefore, in that case, the padding value can be selected based on the lower two bits of the length information indicating the data length of the original message.
[0045]
The padding value selected here is a value to be added to data including the end of the message by an OR operation. After that, padding with a value of “0” is added until the data length reaches a predetermined data length (448 modulo 512).
[0046]
The length adding circuit 220 determines the padding end position according to the total amount of the data input by the message input circuit and the padding output by the padding circuit, and outputs length information following the padding. For example, the length adding circuit 220 outputs data (for example, 448 modulo 512) and padding corresponding to the data amount obtained by subtracting the data length of the length information from the multiple of the data length of one block, and then outputs the length. Output information.
[0047]
Specifically, the data length of one block is 64 bytes, and the data length of the length information is 8 bytes (the maximum message length (2 64 If the data length is a data length capable of expressing a numerical value up to byte), the total data length of the message and the padding becomes 64 bytes by adding 8 bytes to a multiple of 64 bytes minus 8 bytes. ) (When conforming to 448 modulo 512) is determined as the padding end position.
[0048]
That is, the word indicating the length information is added as the last two words of one block. Therefore, after padding is added to the block including the last data of the message, if an area for two words cannot be secured, length information is added to the next block.
[0049]
For example, if the remaining data length is 56 bytes or more, padding is performed up to 56 bytes of the block next to the block containing the data at the end of the message, and then 2 words indicating length information are added. You. If the remaining data length is 55 bytes or less, padding is performed up to 56 bytes of the block including the last data of the message, and then two words indicating length information are added.
[0050]
The message processing circuit 300 executes the latter half of the message digest generation processing, and generates a final message digest. More specifically, the message processing circuit 300 initializes a message digest buffer, processes a block message having a length of 16 words, and outputs a message digest. The processing of a block message having a length of 16 words is a compression function consisting of processing called four “rounds”.
[0051]
According to such a message digest generation circuit, the message input circuit 100 is capable of receiving a message from another CPU or the like. 64 Wait for a message of bytes or less.
In general, the bit length of a message is a positive integer of 0 or more, and need not always be a multiple of 8 (byte unit). However, in the following embodiment, a case in which a message digest is adapted to a character code is assumed, and a specific example of generating a message digest based on a message in byte units will be specifically described.
[0052]
Upon receiving the message, the message input circuit 100 inputs the message to the information adding circuit 200 in order of 32 bits (one word) from the top.
FIG. 2 is a diagram illustrating a data structure of the divided message. The message 10 is theoretically handled in units of blocks 11 every 512 bits. That is, the message 10 is composed of one or more blocks 11. Each block 11 is divided into 16 words 12 composed of 32-bit data. Then, data is input from the message input circuit 100 to the information adding circuit 200 in word units.
[0053]
Although not described in detail here, for example, in the case of using a CPU that performs processing in units of 64 bits or 128 bits or more, data input from the message input circuit 100 includes 64-bit 8-stage data and 128-bit data. There are four stages. Even if the data length of the processing unit changes, there is basically no need to change the hardware configuration described later.
[0054]
However, if the data is in 64-bit units, the right shift at the time of division is 3 bits (division by 8). Since the remainder of the division is a value of 0 to 7, a padding value corresponding to each value is prepared in advance. Then, a padding value corresponding to the lower three bits of the data length is output.
[0055]
Similarly, for data in units of 128 bits, the right shift at the time of division is 4 bits (division by 16). Since the remainder of the division is a value of 0 to 15, a padding value corresponding to each value is prepared in advance. Then, a padding value corresponding to the lower 4 bits of the data length is output.
[0056]
When the divided words are input to the information adding circuit 200, the padding circuit 210 adds padding. Padding is one “1” bit and a required number (0 or more) of “0” bits. Padding has a bit length of 1 or more and 512 or less. After the padding is added, the length adding circuit 220 adds 64-bit data (length information) indicating the message length. The length of the message with padding and length information added is a multiple of 512 bits.
[0057]
Data to which padding and length information have been added is passed to the message processing circuit 300 in order from the first word. The message processing circuit 300 processes a word-length block message and outputs a message digest.
[0058]
Hereinafter, the processing of the information adding circuit 200 will be described in detail.
FIG. 3 is a schematic flowchart of a process performed by the information adding circuit. Hereinafter, the processing illustrated in FIG. 3 will be described along with step numbers.
[0059]
[Step S11] The information adding circuit 200 receives an input of a message in bytes and an input of information (length information) indicating the data length of the message, and the padding circuit 210 detects the end of the message. That is, it detects that the number of bytes of the input message has reached the data length of the message.
[0060]
[Step S12] The padding circuit 210 adds padding (1000... 000) to the end of the message.
[Step S13] After the padding, the length adding circuit 220 adds 64-bit data (length information) indicating the message length before the padding is added. As a result, a message having a length of a multiple of 512 bits is generated and input to the message processing circuit 300.
[0061]
Here, the padding addition processing will be described in detail.
First, the process of detecting the end of the message shown in step S11 will be described. In the present embodiment, data is input in 32-bit word units. The padding circuit 210 detects the padding position using the length information of the original message in bytes and the comparator, the subtractor, and the like. That is, the padding circuit 210 counts the number of input words (one word is 32 bits) and determines the last word of the message and the padding start position in the word.
[0062]
More specifically, the padding circuit 210 determines the number of words in the message and the position in the word at which padding is to be started, based on a bit string (64 bits) representing the length (number of bytes) of the original message to be hashed. . That is, the length is divided by 4, and the quotient and remainder are obtained. When a bit shift circuit is used, the upper bits (62 bits) of the bit string representing the length, excluding the lower 2 bits, are determined to be a quotient obtained by dividing by 4, and the lower 2 bits are determined to be a remainder.
[0063]
The quotient resulting from the division indicates the word at which to start padding. Specifically, when the same number of words as the quotient are input, padding is performed from the next input word.
[0064]
The remainder obtained as a result of the division indicates from which byte in the word to start padding the padding is to be performed. In other words, since the message data remains in the word to be padded by the number of bytes represented by the remainder, when the same number of byte data as the remainder is input, it is understood that padding should be performed from the next byte data.
[0065]
Next, the padding processing in step S12 will be described in detail. The padding circuit 210 adds a “1” bit to the head of the padding start position of the word to start padding. Next, “0” bits are continuously added until the padding end position. In terms of the circuit, when the input message is completed, a word having a value of 0 is input from the message input circuit 100 thereafter. Therefore, it is only necessary to set “1” at the padding start position of the padding start word, and then maintain “0” of the input data from the message input circuit 100.
[0066]
FIG. 4 is a diagram illustrating an example of padding addition and length addition processing. In the illustrated example, a 40-bit message 10 is input. The message 10 is passed to the padding circuit 210 in 32-bit words sequentially from the top. In the case of the 40-bit message 10, it is divided into one word 13 and 14 and passed to the padding circuit 210. Since the first word 13 is not a padding target, no processing is performed in the padding circuit 210. Since the next word 14 is a word to be padded, padding is added after valid message data (“01100101” in the example of FIG. 4). Thereafter, a word 16 having a value of "0" is added until the total number becomes 448 bits.
[0067]
The message 20 after padding has a data length of 448 bits (the message 20 is represented in hexadecimal).
Then, the length adding circuit 220 adds two words (64 bits) representing the original data length after the padded message. In the example of FIG. 4, since the data length is 40 bits, a value of “00000000 0000028” is added.
[0068]
If L <2 32 If so, "0" is set to the last word of the block to which the padding start word belongs. “0” is set from the first word to the fourteenth word of the next block. Then, a value indicating the data length is set in the last two words.
[0069]
In the present embodiment, such processing of padding addition and length addition is performed by an electronic circuit in the information adding circuit 200 without passing through the CPU.
FIG. 5 is a diagram showing the internal configuration of the information adding circuit. The message input circuit 100 receives the data length 110 (the number of bytes (length information) of the message), the DREQ signal 120, and the input data 130, and outputs the output data 310 to the message processing circuit 300. Is output.
[0070]
The DREQ signal 120 is a signal that is output each time the message input circuit 100 inputs data of one block (64 bytes in the present embodiment). This DREQ signal 120 indicates the start of input of the next block. That is, the message input circuit 100 notifies the padding circuit 210 of the block switching position when the message is divided into blocks by the DREQ signal 120.
[0071]
The information adding circuit 200 includes a padding circuit 210, a length adding circuit 220, and an OR operation circuit 201.
The padding circuit 210 includes a data length countdown register 211, a subtractor 212, a comparator 213, a bit shift circuit 214, a counter circuit 215, a remaining data length register 216, a selector 217, and a padding value constant ROM 218.
[0072]
The padding circuit 210 can be broadly divided into a judgment circuit and a padding output circuit. The determination circuit is a circuit that determines the last data of the message according to the total amount of the input data (word unit) and the length information of the message. In the example of FIG. 5, the determination circuit includes a data length countdown register 211, a subtractor 212, a comparator 213, a bit shift circuit 214, and a counter circuit 215. The padding output circuit is a circuit that outputs padding following the last data of the message. In the example of FIG. 5, the padding output circuit includes a remaining data length register 216, a selector 217, and a padding value constant ROM 218.
[0073]
The length addition circuit 220 includes a comparator 221, a comparator 222, a counter + selector circuit 223, a data length storage register 224, and a bit shift circuit 225.
[0074]
The data length 110 is input to the data length countdown register 211 and the data length storage register 224. The DREQ signal 120 is input to a subtractor 212. The input data 130 is input to the OR operation circuit 201, the counter circuit 215, and the counter + selector circuit 223.
[0075]
First, the internal configuration of the padding circuit 210 will be described.
The data length (byte number) is input to the data length countdown register 211 as an initial value. The input initial value is passed to the bit shift circuit 214. Then, each time the subtractor 212 performs the subtraction, it is updated to the subtraction result. As a result, the data length countdown register 211 holds the remaining data amount of the message to be processed.
[0076]
The subtracter 212 is connected to the data length countdown register 211. Each time the DREQ signal 120 is input, the subtractor 212 acquires the value of the data length countdown register 211 and subtracts a value (the number of bytes) corresponding to the input data amount (one block). In the present embodiment, 64 (bytes) is subtracted. Then, the subtractor 212 stores the subtraction result in the data length countdown register 211.
[0077]
The comparator 213 is connected to the data length countdown register 211 and the bit shift circuit 214. The comparator 213 compares the value stored in the data length countdown register 211 (remaining data amount (byte number) of the message to be processed) with the byte number M of one block (64 (byte) in the present embodiment). Compare. Then, when the number of bytes M of one block of the input data 130 becomes larger, the comparator 213 outputs a signal indicating the padding target block to the bit shift circuit 214.
[0078]
The bit shift circuit 214 is connected to the data length countdown register 211, the comparator 213, and the counter circuit 215. The bit shift circuit 214 is a circuit that realizes division by a power of two by right bit shift. In the present embodiment, a quotient divided by 4 is obtained by performing a right 2 bit shift (discarding the lower 2 bits).
[0079]
That is, when receiving the signal indicating the padding target block from the comparator 213, the bit shift circuit 214 acquires the remaining data amount of the processing target message stored in the data length countdown register 211 at that time. Then, the bit shift circuit 214 shifts the value of the obtained data remaining amount by two bits to the right, and generates a quotient obtained by dividing the data remaining amount (the number of bytes) by four. The bit shift circuit 214 passes the generated value to the counter circuit 215. As a result, a value indicating how many words the data remaining amount of the padding target block is passed to the counter circuit 215.
[0080]
The counter circuit 215 is connected to the input data 130, the bit shift circuit 214, and the pad value setting ROM 218. The counter circuit 215 holds a counter value that is cleared to “0” each time a division quotient is input by the bit shift circuit 214 (when a padding target block is detected). The counter circuit 215 counts up the counter value by one each time one word of the input data 130 is input. The counter circuit 215 compares the stored counter value with the value of the bit shift circuit 214 every time the counter value is counted up. When both values become equal, the counter circuit 215 outputs a signal indicating the start of padding.
[0081]
The remaining data length register 216 is connected to the data length countdown register 211 and the selector 217. The remaining data length register 216 acquires and holds the remaining data length (the number of bytes) stored in the data length countdown register 211. Then, the remaining data length register 216 passes the value of the lower two bits of the remaining data length to the selector 217. In FIG. 5, the least significant bit is indicated as LA [0], and the second bit from the lower order is indicated as LA [1]. The lower two bits of the remaining data length indicate a remainder obtained by dividing the remaining data length by four.
[0082]
The selector 217 is connected to the remaining data length register 216 and the padding value setting ROM 218. The selector 217 outputs a selection signal corresponding to the lower two bits of the remaining data length input from the remaining data length register 216 to the padding value setting ROM 218.
[0083]
The padding value setting ROM 218 is connected to the counter circuit 215, the selector 217, and the OR operation circuit 201. The padding value setting ROM 218 stores a padding value for each of the lower two bits of the remaining data length. When a signal indicating the start of padding is input from the counter circuit 215, the padding value setting ROM 218 outputs the padding value selected by the selection signal input from the selector 217 to the OR operation circuit 201.
[0084]
Next, the internal configuration of the length adding circuit 220 will be described.
The comparator 221 is connected to the data length countdown register 211 and the counter + selector circuit 223. In the comparator 221, a data length (number of bytes) W of one block and a value (number of bytes) Z obtained by subtracting the data length of the data indicating the message length + 1 from the data length W of one block are set in advance. I have. In the present embodiment, the data length of one block is 64 bytes, and the data length of the message is represented by data of 8 bytes (64 bits). Therefore, W = 64 and Z = 55 are set.
[0085]
Each time the data remaining amount LA of the message to be processed stored in the data length countdown register 211 is updated, the comparator 221 compares LA with W and Z, respectively. If Z <LA <W, a length addition position selection signal is output to the counter + selector circuit 223.
[0086]
The comparator 222 is connected to the data length countdown register 211 and the counter + selector circuit 223. The data length Z is set in the comparator 222 in advance. The comparator 222 compares LA and Z each time the remaining data amount LA of the message to be processed stored in the data length countdown register 211 is updated. If LA ≦ Z, a length addition position selection signal is output to the counter + selector circuit 223.
[0087]
The counter + selector circuit 223 receives the input data 130 and is connected to the comparator 221, the comparator 222, and the bit shift circuit 225. The counter + selector circuit 223 holds a counter value that is cleared to “0” when the length addition start signal is output from the comparator 221 or 222. Then, the counter + selector circuit 223 counts up the counter value by one each time one word of the input data 130 is input.
[0088]
The counter + selector circuit 223 has two types of length addition start position information.
The length addition start position designation information is information that is valid when the comparator 221 outputs a length addition position selection signal. This length addition start position designation information is information for designating the position of the last two words of the block next to the padding target block. For example, if one block is 16 words, 31 is set in word units.
[0089]
The other length addition start position designation information is information that is valid when the comparator 222 outputs a length addition position selection signal. This length addition start position designation information is information for designating the position of the last two words of the padding target block. For example, if one block has 16 words, 15 is set in word units.
[0090]
Each time the counter value is counted up, the counter + selector circuit 223 compares the valid length addition position designation information with the counter value. As a result of the comparison, when the values match, the counter + selector circuit 223 outputs a signal indicating the start of length addition to the bit shift circuit 225.
[0091]
The data length storage register 224 receives the data length 110 and is connected to the bit shift circuit 225. The data length storage register 224 holds the input data length 110 and outputs it to the bit shift circuit 225.
[0092]
The bit shift circuit 225 is a circuit that realizes multiplication by a power of two by left bit shift. In the present embodiment, a left 3 bit shift is performed in order to convert a byte unit value into a bit unit. By shifting left three bits, the original value is multiplied by eight. That is, the value in byte units is converted to a value in bit units.
[0093]
Specifically, upon receiving a signal indicating the start of length addition from the counter + selector circuit 223, the bit shift circuit 225 acquires the data stored in the data length storage register 224, and performs a left 3 bit shift process. . As a result, the data length set in byte units is converted into bit units. The bit shift circuit 225 outputs the data of two words representing the data length in bit units to the logical sum operation circuit 201 in two divided words, one word at a time.
[0094]
The above is the internal configuration of the padding circuit 210 and the length adding circuit 220. The input data 130, the output value from the padding value constant ROM 218 of the padding circuit 210, and the output value from the bit shift circuit 225 of the length adding circuit 220 are input to the OR operation circuit 201. The logical sum operation circuit 201 calculates the logical sum of the input data and outputs the result to the message processing circuit 300 as output data 310.
[0095]
The padding and the length are added by the electronic circuit configured as described above.
Here, the correspondence between the value input to the selector 217 and the padding value setting ROM 218 will be described.
[0096]
FIG. 6 is a diagram showing the correspondence between the lower two bits of the data length and the contents of the padding start word.
When the lower two bits of the remaining data length are “00”, the remainder is 0 (byte). That is, the head of the padding word is the padding start position. Therefore, the content of the padding value to be added by the OR operation is “80000000” (hexadecimal notation). If this is converted into bit notation, it becomes "10000000 00000000 00000000 00000000".
[0097]
When the lower two bits of the remaining data length are “01”, the remainder is 1 (byte). That is, the second byte of the padding word is the padding start position. Therefore, the content of the padding value to be added by the OR operation is “00800000” (hexadecimal notation). If this is converted into bit notation, it becomes “00000000 10000000 00000000 00000000”.
[0098]
When the lower 2 bits of the remaining data length are “10”, the remainder is 2 (bytes). That is, the third byte of the padding word is the padding start position. Therefore, the content of the padding value to be added by the OR operation is “00008000” (hexadecimal notation). If this is converted into a bit notation, it becomes "00000000 00000000 10000000 00000000".
[0099]
When the lower 2 bits of the remaining data length are “11”, the remainder is 3 (bytes). That is, the fourth byte of the padding word is the padding start position. Therefore, the content of the padding value to be added by the OR operation is “00000080” (hexadecimal notation). If this is converted into bit notation, it becomes "00000000 00000000 00000000 10000000".
[0100]
The addition of padding and the addition of length are performed by the information adding circuit 200 configured as described above. Here, the operation of the information adding circuit 200 will be described using an example in which the 40-bit message 10 shown in FIG. 4 is input.
[0101]
When the message 10 is input, the value “5” of the length of the message 10 (40 bits) in byte units is input as the data length 110. As the input data 130, the first word 13 of the message 10 is input.
[0102]
First, a value “5” indicating the data length 110 is stored in the data length countdown register 211 and the data length storage register 224. The value stored in the data length countdown register 211 is compared by the comparator 213 with the number of bytes M “64” of one block. In this example, since M is larger, a signal indicating that the block is a padding target is output from the comparator 213 to the bit shift circuit 214.
[0103]
The bit shift circuit 214 that has received the signal acquires the value “5” indicating the remaining data length of the message 10 from the data length countdown register 211, and performs a right two-bit shift process. As a result, a quotient “1” when the remaining data length is divided by “4” is obtained. The quotient “1” is passed to the counter circuit 215.
[0104]
When the first word 13 is input, the block to be padded is detected, and the value of the counter circuit 215 is set to 0. At this time, since “1” is input from the bit shift circuit 214, no signal indicating the start of padding is output. As a result, no padding value is output from padding circuit 210.
[0105]
On the other hand, in the length adding circuit 220, the two comparators 221 and 222 compare the remaining data length LA with predetermined data. In this example, the remaining data length LA is "5", Z is "55", and W is "64". Therefore, the comparison result of the comparator 221 is false (the requirement (Z <LA <W) is not satisfied), but the comparison result of the comparator 222 is true (the requirement (LA ≦ Z) is satisfied). Therefore, the comparator 222 outputs a length addition position selection signal to the counter + selector circuit 223.
[0106]
The counter + selector circuit 223 sets the counter value to “1” when the first word 13 is input from the input data 130. Then, when the length addition position selection signal is output from the comparator 222, the counter + selector circuit 223 causes the length addition start position designation information “15” previously associated with the comparator 222 and the counter value “ 1 "is compared. As a result of the comparison, since the values do not match, no signal indicating the start of length addition is output. As a result, the length data is not output from the length adding circuit 220.
[0107]
By the operations of the padding circuit 210 and the length adding circuit 220 as described above, only the word 13 is input to the OR circuit 201. As a result, the word 13 is output as it is as the output data 310.
[0108]
When the next word 14 is input as the input data 130, the counter value of the counter circuit 215 is counted up to "1". Then, the counter circuit 215 outputs a signal indicating the start of padding to the padding value setting ROM 218.
[0109]
At this time, the value “5” of the data length countdown register 211 is set in the remaining data length register 216. When this value is represented by a bit string, it becomes “101”. In this case, the value of the least significant bit LA [0] is “1”, and the value of the second least significant bit LA [1] is “0”. That is, when the value of “01”, in which the lower two bits of the data length is “01”, is input to the selector 217, a selection signal corresponding to the value is output from the selector 217 to the padding value setting ROM 218.
[0110]
The padding value setting ROM 218 supplies the padding value “00000000 10000000 00000000 00000000” stored in advance in association with the remainder 1 (the lower 2 bits are “01”) obtained by dividing the data length by 4 to the OR circuit 201. Output.
[0111]
On the other hand, in the length adding circuit 220, in response to the input of the word 14, the counter value of the counter + selector circuit 223 is counted up to “2”. Since this counter value has not reached the predetermined value “15”, a signal indicating the start of length addition is not output from the counter + selector circuit 223. As a result, the length data is not output from the length adding circuit 220.
[0112]
By the operations of the padding circuit 210 and the length adding circuit 220 as described above, the word 14 and the padding value output from the padding circuit 210 are input to the OR circuit 201. The logical sum of these values is calculated by the logical sum operation circuit 201, and the output data 310 having the content “01100101 10000000 00000000 00000000” is output.
[0113]
Thereafter, since the content of the message 10 has been completed, words in which all bits are set to “0” are sequentially input as input data 130. From the third word to the fourteenth word, counted in order from the word 13, the data as it is is output as output data 310. During this time, the counter value of the counter + selector circuit 223 is incremented by one sequentially.
[0114]
When the fifteenth word counted from word 13 is input, the counter value of the counter + selector circuit 223 is counted up to “15”. Then, the value “15” set in association with the comparator 222 in the counter + selector circuit 223 matches the counter value, and the counter + selector circuit 223 outputs a signal indicating the start of length addition.
[0115]
Then, “00000000” (hexadecimal notation) for the upper one word of the two-word data indicating the length of the message 10 in bit units is output from the bit shift circuit 225 to the logical sum operation circuit 201. The logical sum of the data of the upper one word indicating the length and the word input as the input data 130 is calculated by the logical sum operation circuit 201 and output as the output data 310.
[0116]
Next, when the 16th word counted from the word 13 is input, the bit shift circuit 225 supplies the OR operation circuit 201 with the lower one word of the two-word data indicating the length of the message 10 in bit units. 0000028 "(hexadecimal notation) is output. The logical sum of the data of the lower one word indicating the length and the word input as the input data 130 is calculated by the logical sum operation circuit 201 and output as the output data 310.
[0117]
In this manner, the padding and the length can be added to the message to be authenticated by the hardware electronic circuit. As a result, the message authentication process can be performed at high speed without imposing a burden on the CPU. Moreover, the consumption of the main memory of the computer is small.
[0118]
A circuit that performs the message authentication process using the present embodiment can be implemented in various devices that perform communication via a network. For example, the present embodiment can be applied to a computer (a personal computer, a server computer, or the like) or a router connected to the Internet.
[0119]
Hereinafter, a hardware configuration example of a computer having a message authentication function according to the present embodiment will be described.
FIG. 7 is a diagram illustrating a hardware configuration example of a computer to which the circuit of the present embodiment is applied. The entire device of the computer 400 is controlled by the CPU 401. A RAM (Random Access Memory) 402, a hard disk drive (HDD: Hard Disk Drive) 403, a graphic processing device 404, an input interface 405, a communication interface 406, and an HMAC operation circuit 407 are connected to the CPU 401 via a bus 408. I have.
[0120]
The RAM 402 temporarily stores at least a part of an OS (Operating System) program and application programs to be executed by the CPU 401. Further, the RAM 402 stores various data necessary for processing by the CPU 401. The HDD 403 stores an OS and application programs.
[0121]
The monitor 11 is connected to the graphic processing device 404. The graphic processing device 404 displays an image on the screen of the monitor 11 according to a command from the CPU 401. The keyboard 12 and the mouse 13 are connected to the input interface 405. The input interface 405 transmits a signal transmitted from the keyboard 12 or the mouse 13 to the CPU 401 via the bus 408.
[0122]
The communication interface 406 is connected to the network 10. The communication interface 406 sends and receives data to and from another computer via the network 10.
[0123]
The HMAC operation circuit 407 is a circuit that performs an HMAC operation on an input message and outputs a message after authentication. For example, when a message to be transmitted via the network 10 is input to the HMAC operation circuit 407, predetermined message processing is performed for each word after padding and length are added, and a message digest is generated. The generated message digest is sent out onto the network 10 via the communication interface 406.
[0124]
With the above hardware configuration, the processing functions of the present embodiment can be realized. For example, a computer that executes IPsec processing by a hardware circuit is provided.
[0125]
Hereinafter, the authentication range of IPsec and the size of the IP packet will be described with reference to FIG. 8, FIG. 9, and FIG. IPsec requires an authentication function to prevent tampering and spoofing of IP packets. IPsec is a group of protocols and is composed of ESP (Encapsulating Security Payload) and AH (Authentication Header).
[0126]
FIG. 8 is a diagram showing an authentication range of the transport mode ESP. FIG. 8A shows an IPv4 packet, and FIG. 8B shows an IPv6 packet.
The IPv4 packet 40 includes an IP header 41, an ESP header 42, a TCP header 43, data 44, an ESP trailer 45, and an ESP authentication header 46. Among them, the ESP header 42, the TCP header 43, the data 44, and the ESP trailer 45 are the authentication range.
[0127]
The IPv6 packet 50 includes an IPv6 header 51, a route control header 52, an ESP header 53, an end point option header 54, a TCP header 55, data 56, an ESP trailer 57, and an ESP authentication header 58. Among them, the ESP header 53, the end point option header 54, the TCP header 55, the data 56, and the ESP trailer 57 are the authentication range.
[0128]
For example, at the time of generating a packet when using the transport ESP, authentication processing using a hash function with a key (HMAC-SHA1, HMAC-MD5) is performed on range information.
[0129]
FIG. 9 is a diagram showing the AH authentication range. The configuration of the AH packet 60 is the same for both IPv4 and IPv6. The AH packet 60 includes an IP header 61, an AH header 62, a TCP header 63, and data 64. All of the AH packets 60 fall within the authentication range. That is, an authentication process using a hash function with a key (HMAC-SHA1, HMAC-MD5) for the entire packet is required.
[0130]
The maximum packet size is determined by the connection medium of the network. For example, the size of an IP packet when a network (IEEE 802.3) called Ethernet (registered trademark) is used as a network connection physical medium will be described.
[0131]
The operation of the present invention will be described using an example of an authentication process of one packet as an example of an IEEE802.3 network. In the authentication processing, the HMAC processing is performed first and last, so that functionally, the hardware processing is performed seamlessly after setting (mode setting such as HMAC processing, MD5 / SHA1 or the like) by the CPU. Done. As a result, it is possible to reduce the CPU load and extract the performance value of the hardware. In addition, authentication processing in which processing is performed in a CPU using a DMAC (Direct Memory Access Controller) can be independently executed.
[0132]
FIG. 10 is a diagram illustrating the IP packet size. As shown in FIG. 10, the IP packet 70 includes an IPv6 header 71, a route control header 72, an end point option header 73, a TCP header 74, and data 75. The maximum IP packet size of a network according to IEEE802.3 having such a configuration is about 1500 bytes (IPv6 header 40 bytes, other 1460 bytes or less).
[0133]
The hash functions MD5 and SHA1, which are authentication algorithms, are 64-byte (512-bit) block functions. Therefore, even for processing of one packet, hash processing is performed more than about 20 times at the maximum. A hash function is also used in key management.
[0134]
If this embodiment is applied to an IP packet having such a data structure, the data communication capability of the Internet or the like can be improved. For example, the hash value function is used in the authentication process of the next-generation protocol IPsec, and the IP packet generation process performs the IP packet authentication operation shown in FIG. The ESP header is used not only for authentication at the IP packet level but also for transmission after encryption. In IPsec, encryption is performed for each packet, and the packet is packed and transmitted in a container called ESP. Note that the latest IPsec version 2.0 has been revised so that both authentication and encryption can be performed by ESP.
[0135]
ESP has two modes, a tunneling mode and a transport mode. The tunneling mode is a procedure for encrypting an IP packet together with a header. The transport mode is a procedure for encrypting only the data portion of an IP packet.
[0136]
In IPsec, two methods, a "transport mode" and a "tunnel mode", are provided depending on a portion to be encrypted. In the transport mode, only the data portion carried by the IP packet is encrypted, and the packet is transmitted with an IP header specifying a destination or the like. On the other hand, in the tunnel mode, a combination of the IP header and the data portion once received from another host is collectively encrypted, and then the IP header is re-attached and transmitted. At the time of transmission, authentication processing is performed after this encryption, and at the time of reception, authentication processing is performed first.
[0137]
Basically, the data size of the upper protocol is limited to the data size of the lower protocol. Therefore, if the lower order is Ethernet (registered trademark), the maximum size of the IP packet to enter is the maximum size (1500 bytes) of the data portion of the MAC frame when the IP packet is not fragmented.
[0138]
FIG. 11 is a flowchart illustrating a procedure of a transmission process based on IPsec. Hereinafter, the processing illustrated in FIG. 11 will be described along with step numbers.
[Step S21] The CPU 401 generates a transmission packet including a transmission message.
[0139]
[Step S22] The CPU 402 performs a packet encryption process. The encrypted message is passed to the HMAC operation circuit 407.
[Step S23] The HMAC operation circuit 407 performs authentication processing (HMAC) of the passed message. As a result, a message digest for authentication is added to the message encrypted by the CPU 401. The encrypted message and the message digest are both passed to the communication interface 406.
[0140]
[Step S24] The communication interface 406 generates a communication frame.
[Step S25] The communication interface 406 transmits the generated frame via the network 10.
[0141]
FIG. 12 is a flowchart showing the procedure of the receiving process by IPsec. Hereinafter, the processing illustrated in FIG. 12 will be described along with step numbers.
[Step S31] The communication interface 406 receives the frame transmitted via the network 10. The received frame is passed to the HMAC operation circuit 407.
[0142]
[Step S32] The HMAC operation circuit 407 authenticates a message in the frame based on the message digest of the received frame. That is, it is confirmed that the message has not been falsified. The correctly authenticated message (encrypted) is passed to the CPU 401.
[0143]
[Step S33] The CPU 401 decrypts the encrypted message and reproduces the original plaintext message.
As described above, in the computer in which the circuit according to the present embodiment is mounted, the authentication processing is performed both at the time of transmission and at the time of reception. Note that the CPU 401 performs complicated protocol processing in addition to encryption processing and authentication processing.
[0144]
As described above, by performing message authentication using a hardware circuit, message authentication can be performed at high speed, and the processing capability of the entire computer can be increased.
[0145]
That is, the processing of the hash function algorithm can be performed by independent hardware without imposing a software load on the CPU. With such dedicated hardware, the occupancy of the CPU can be reduced, and for example, the performance of the entire system can be improved.
[0146]
Specifically, when the authentication process is performed by software, other processes cannot be performed until the CPU 401 completes the authentication process, and the process is kept waiting. On the other hand, by mounting the HMAC operation circuit 407 (hardware circuit dedicated to the hash function) illustrated in FIG. 7, the CPU 401 can perform other processing while the dedicated hardware performs the authentication processing. As a result, the processing time of another application on the computer is reduced.
[0147]
Moreover, the HMAC operation circuit 407 sequentially processes and outputs the input message, so that there is no need to load data into the RAM 402 unlike the operation by the CPU 401. Therefore, the system can provide stable performance without using the storage capacity of the RAM 402 unnecessarily.
[0148]
Note that an authentication circuit such as the HMAC operation circuit 407 can be incorporated in various devices. Therefore, even a device controlled by a CPU that does not have a high degree of arithmetic capability can provide IPsec communication. For example, the authentication circuit can be incorporated in a PDA (Personal Digital (Data) Assistants), a mobile phone, or the like.
[0149]
Next, the effect of shortening the processing time by executing the addition of padding and the addition of length by an electronic circuit will be described.
In the following example, a microcomputer that employs a 32-bit RISC processor for the CPU core and a PLD (Programmable Logic Device) / FPGA that implements a hardware circuit dedicated to “add padding” and “add length” according to the present embodiment. (Field Programmable Gate Array) was used to evaluate the mounting.
[0150]
In the mounting evaluation, test data was input to hardware to which the present embodiment was applied, and output data was compared with known data (RFC1321, FIPS180-1) to confirm that the operation was correct. At that time, a comparison was made between a conventional technique (addition of padding and length addition by software) and the present embodiment (execution of padding and addition of length by hardware). Specifically, the processing speed of processing 1280 bytes of data 1000 times is represented by the total time required for software execution and hardware execution by the CPU, including the register write to the hardware macro. This is a comparison.
[0151]
1. For algorithm MD5
[Software execution time] 11667 (milliseconds)
[Hardware execution time] 1178 (milliseconds)
In this case, software execution time / hardware execution time = 9.92. In other words, execution on dedicated hardware is 9.92 times faster.
[0152]
2. For algorithm HMAC-MD5
[Software execution time] 14067 (milliseconds)
[Hardware execution time] 1206 (millisecond)
In this case, software execution time / hardware execution time = 11.66. In other words, execution on dedicated hardware is 11.66 times faster.
[0153]
3. For algorithm SHA1
[Software execution time] 32000 (milliseconds)
[Hardware execution time] 1473 (milliseconds)
In this case, the software execution time / hardware execution time is 21.73. In other words, execution with dedicated hardware is 21.73 times faster.
[0154]
4. Algorithm HMAC-SHA1
[Software execution time] 38643 (milliseconds)
[Time required for software execution of HMAC-hardware execution of SHA1] 3372 (milliseconds)
[Hardware execution time] 1500 (milliseconds)
In this case, the software execution time / hardware execution time is 25.76. That is, it is 25.76 times faster when both HMAC-SHA1 are executed by dedicated hardware than when both are executed by software.
[0155]
From this result, the effectiveness of the dedicated hardware according to the present embodiment with respect to the related art is clearly understood. From the above results, it can be said that the longer the IP packet length is, the more effective this IPsec hardware processing is.
[0156]
As described above, according to the present embodiment, “addition of padding” and “addition of length” in processing using a hash function and HMAC can be executed by dedicated hardware. Therefore, in the hash function processing and the authentication processing using the hash function, the processing can be speeded up without imposing a load on the CPU, and the processing load on the CPU can be greatly reduced.
[0157]
Further, the memory capacity required for padding and adding a length can be reduced.
Furthermore, since the CPU occupancy for padding and adding a length is reduced, reliable performance can be guaranteed even when functioning as a system. In addition, high-speed processing can be performed even with an inexpensive microcomputer, which is effective in reducing costs.
[0158]
(Supplementary Note 1) In a message digest generation circuit that generates a message digest,
A message input circuit that divides a message into data of a predetermined data length and sequentially inputs the data from the beginning, and inputs length information indicating the length of the message,
A padding circuit that determines the last data of the message in accordance with the total amount of the data and the length information input in the message input circuit, and outputs padding following the last data.
Determining the end position of the padding according to the total amount of the data input by the message input circuit and the padding output by the padding circuit, and adding a length to output the length information following the padding Circuit and
A message digest generation circuit comprising:
[0159]
(Supplementary Note 2) The padding circuit subtracts the capacity of the data input from the message input circuit from the length information sequentially, and a subtraction result of the subtractor is set to a data length of one block or less. The message digest generation circuit according to claim 1, further comprising: a comparator that outputs a signal indicating the padding target block when the message digest is generated.
[0160]
(Supplementary Note 3) The message input circuit outputs a signal indicating block switching each time the data for one block is input,
3. The message digest generation circuit according to claim 2, wherein the subtractor subtracts the data length of the one block from the length information when the signal indicating the block switching is output.
[0161]
(Supplementary Note 4) The message input circuit sets the size of the data to N bytes (N is a natural number),
The padding circuit, when a signal indicating the padding target block is output from the comparator, divides the subtraction result of the subtractor by N, then counts the number of times the data is input, and counts the value. 3. The message digest generation circuit according to claim 2, wherein when the value of the quotient by the division reaches the value, the padding corresponding to the value of the remainder by the division is output following the input data.
[0162]
(Supplementary Note 5) The message input circuit sets the size of the data to 2 n Bytes (n is a natural number)
5. The message according to claim 4, wherein the padding circuit has a bit shift circuit that shifts the subtraction result of the subtractor to the right by n bits, and uses a shift result by the bit shift circuit as the division result. Digest generation circuit.
[0163]
(Supplementary Note 6) The message input circuit sets the size of the data to 2 n Bytes (n is a natural number)
The padding circuit includes a storage device in which the padding value is stored in association with each of numerical values represented by n bits, and a padding value output from the storage device according to a value of lower n bits of the subtraction result of the subtractor. 5. The message digest generation circuit according to claim 4, further comprising: a selector for selecting the message digest.
[0164]
(Supplementary Note 7) The length adding circuit outputs the data corresponding to a data amount obtained by subtracting a data length of the length information from a multiple of a data length of one block and the padding, and then outputs the length. 3. The message digest generating circuit according to claim 1, wherein the message digest generating circuit outputs the information.
[0165]
(Supplementary note 8) In a padding circuit for adding padding to a message,
When the message is divided into data of a predetermined data length and sequentially input from the beginning, and when length information indicating the length of the message is input, the total amount of the input data and the length information become A determining circuit for determining the last data of the message accordingly;
A padding output circuit that outputs padding following the last data determined by the determination circuit;
A padding circuit comprising:
[0166]
(Supplementary Note 9) The judgment circuit is configured to sequentially subtract the capacity of the input data from the length information, and to perform padding when the subtraction result of the subtractor becomes equal to or less than the data length of one block. The padding circuit according to claim 8, further comprising: a comparator that outputs a signal indicating the target block.
[0167]
(Supplementary Note 10) The data is in units of N bytes (N is a natural number),
The determination circuit, when a signal indicating the padding target block is output from the comparator, divides the subtraction result of the subtractor by N, and then counts the number of times the data is input,
The padding output circuit according to claim 9, wherein the padding output circuit outputs padding according to the value of the remainder after the division following the input data when the counted value reaches the value of the quotient by the division. Padding circuit.
[0168]
(Supplementary Note 11) In a communication device that transmits an authenticated message,
A CPU for generating a message to be transmitted;
A message input circuit for dividing the message generated by the CPU into data of a predetermined data length and inputting the data in order from the beginning, and inputting length information indicating the length of the message;
A padding circuit that determines the last data of the message in accordance with the total amount of the data and the length information input in the message input circuit, and outputs padding following the last data.
Determining the end position of the padding according to the total amount of the data input by the message input circuit and the padding output by the padding circuit, and adding a length to output the length information following the padding Circuit and
A message processing circuit that generates a message digest based on the message input from the message input circuit, padding output from the padding circuit, and length information output from the length adding circuit;
A communication device comprising:
[0169]
(Supplementary Note 12) In a message authentication method for performing message authentication processing,
Generating a message to be transmitted by the CPU,
The message input circuit divides the message generated by the CPU into data of a predetermined data length and inputs the data to the padding circuit sequentially from the beginning, and inputs length information indicating the length of the message to the padding circuit. ,
The padding circuit determines the last data of the message according to the total amount of the data and the length information input by the message input circuit, and outputs padding following the last data.
A length adding circuit determines an end position of the padding according to a total amount of the data input by the message input circuit and the padding output by the padding circuit, and determines the length information following the padding. And output
The message processing circuit generates a message digest based on the message input from the message input circuit, the padding output from the padding circuit, and the length information output from the length adding circuit.
A message authentication method, comprising:
[0170]
【The invention's effect】
As described above, in the present invention, the padding circuit determines the last data of the message, outputs padding following the last data, and the length addition circuit determines the end position of the padding, and continues the padding. Output length information. As a result, padding and length information can be added to the input message without imposing a load on the CPU.
[Brief description of the drawings]
FIG. 1 is a diagram showing a schematic configuration of a message digest generation circuit according to the present embodiment.
FIG. 2 is a diagram showing a data structure of a divided message.
FIG. 3 is a schematic flowchart of a process performed by an information adding circuit.
FIG. 4 is a diagram illustrating an example of padding addition and length addition processing.
FIG. 5 is a diagram showing an internal configuration of an information adding circuit.
FIG. 6 is a diagram showing a correspondence relationship between lower two bits of a data length and the contents of a padding start word.
FIG. 7 is a diagram illustrating an example of a hardware configuration of a computer to which the circuit of this embodiment is applied.
FIG. 8 is a diagram showing an authentication range of a transport mode ESP. FIG. 8A shows an IPv4 packet, and FIG. 8B shows an IPv6 packet.
FIG. 9 is a diagram showing an AH authentication range.
FIG. 10 is a diagram showing an IP packet size.
FIG. 11 is a flowchart showing a procedure of transmission processing by IPsec.
FIG. 12 is a flowchart illustrating a procedure of a reception process by IPsec.
[Explanation of symbols]
100 Message input circuit
200 Information addition circuit
210 padding circuit
220 Length addition circuit
300 Message processing circuit

Claims (10)

メッセージダイジェストを生成するメッセージダイジェスト生成回路において、
メッセージを所定のデータ長のデータに分割して先頭から順に入力するとともに、前記メッセージの長さを示す長さ情報を入力するメッセージ入力回路と、
前記メッセージ入力回路で入力された前記データの総量と前記長さ情報とに応じて前記メッセージの最後の前記データを判断し、前記最後の前記データに続けてパディングを出力するパディング回路と、
前記メッセージ入力回路で入力された前記データと前記パディング回路で出力された前記パディングとの総量に応じて前記パディングの終了位置を判断し、前記パディングに続けて前記長さ情報を出力する長さ付加回路と、
を有することを特徴とするメッセージダイジェスト生成回路。
In a message digest generation circuit for generating a message digest,
A message input circuit that divides a message into data of a predetermined data length and sequentially inputs the data from the beginning, and inputs length information indicating the length of the message,
A padding circuit that determines the last data of the message in accordance with the total amount of the data and the length information input in the message input circuit, and outputs padding following the last data.
Determining the end position of the padding according to the total amount of the data input by the message input circuit and the padding output by the padding circuit, and adding a length to output the length information following the padding Circuit and
A message digest generation circuit comprising:
前記パディング回路は、前記長さ情報から、前記メッセージ入力回路から入力された前記データの容量を順次減算する減算器と、前記減算器の減算結果が1ブロック分のデータ長以下になったときにパディング対象ブロックを示す信号を出力する比較器とを有することを特徴とする請求項1記載のメッセージダイジェスト生成回路。The padding circuit includes a subtracter for sequentially subtracting the data capacity input from the message input circuit from the length information, and a subtractor that reduces a data length of one block or less. 2. The message digest generation circuit according to claim 1, further comprising: a comparator that outputs a signal indicating the padding target block. 前記メッセージ入力回路は、1ブロック分の前記データを入力する毎にブロック切替を示す信号を出力し、
前記減算器は、前記ブロック切替を示す信号が出力されると、前記長さ情報から前記1ブロック分のデータ長を減算することを特徴とする請求項2記載のメッセージダイジェスト生成回路。
The message input circuit outputs a signal indicating block switching each time the data for one block is input,
3. The message digest generation circuit according to claim 2, wherein the subtractor subtracts the data length of the one block from the length information when the signal indicating the block switching is output.
前記メッセージ入力回路は、前記データのサイズをNバイト(Nは自然数)とし、
前記パディング回路は、前記比較器より前記パディング対象ブロックを示す信号が出力されたとき、前記減算器の前記減算結果をNで除算し、その後前記データが入力された回数をカウントし、カウントした値が前記除算による商の値に達すると、入力された前記データに続けて前記除算による剰余の値に応じたパディングを出力することを特徴とする請求項2記載のメッセージダイジェスト生成回路。
The message input circuit sets the size of the data to N bytes (N is a natural number),
The padding circuit, when a signal indicating the padding target block is output from the comparator, divides the subtraction result of the subtractor by N, then counts the number of times the data is input, and counts the counted value. 3. The message digest generating circuit according to claim 2, wherein when the value of the quotient by the division reaches the value, the padding corresponding to the value of the remainder by the division is output following the input data.
前記メッセージ入力回路は、前記データのサイズを2バイト(nは自然数)とし、
前記パディング回路は、前記減算器の前記減算結果の右nビットシフトするビットシフト回路を有しており、前記ビットシフト回路によるシフト結果を前記除算結果とすることを特徴とする請求項4記載のメッセージダイジェスト生成回路。
The message input circuit sets the size of the data to 2 n bytes (n is a natural number),
5. The padding circuit according to claim 4, wherein the padding circuit includes a bit shift circuit that shifts the subtraction result of the subtractor to the right by n bits, and sets a shift result by the bit shift circuit as the division result. 6. Message digest generation circuit.
前記メッセージ入力回路は、前記データのサイズを2バイト(nは自然数)とし、
前記パディング回路は、nビットで表せる数値それぞれに対応付けて前記パディング値が格納された記憶装置と、前記減算器の前記減算結果の下位nビットの値に応じて前記記憶装置から出力するパディング値を選択するセレクタとを有することを特徴とする請求項4記載のメッセージダイジェスト生成回路。
The message input circuit sets the size of the data to 2 n bytes (n is a natural number),
The padding circuit includes a storage device in which the padding value is stored in association with each of numerical values represented by n bits, and a padding value output from the storage device according to a value of lower n bits of the subtraction result of the subtractor. 5. The message digest generation circuit according to claim 4, further comprising: a selector for selecting the message digest.
前記長さ付加回路は、1ブロック分のデータ長の倍数から前記長さ情報のデータ長の分を減算したデータ量に相当する前記データおよび前記パディングが出力された後、前記長さ情報を出力することを特徴とする請求項1記載のメッセージダイジェスト生成回路。The length adding circuit outputs the length information after outputting the data and the padding corresponding to the data amount obtained by subtracting the data length of the length information from a multiple of the data length of one block. 2. The message digest generation circuit according to claim 1, wherein: メッセージにパディングを付加するパディング回路において、
前記メッセージが所定のデータ長のデータに分割され先頭から順に入力されるとともに、前記メッセージの長さを示す長さ情報が入力されると、入力された前記データの総量と前記長さ情報とに応じて前記メッセージの最後の前記データを判断する判断回路と、
前記判断回路で判断された前記最後の前記データに続けてパディングを出力するパディング出力回路と、
を有することを特徴とするパディング回路。
In a padding circuit that adds padding to a message,
When the message is divided into data of a predetermined data length and sequentially input from the beginning, and when length information indicating the length of the message is input, the total amount of the input data and the length information become A determining circuit for determining the last data of the message accordingly;
A padding output circuit that outputs padding following the last data determined by the determination circuit;
A padding circuit comprising:
前記判断回路は、前記長さ情報から、入力された前記データの容量を順次減算する減算器と、前記減算器の減算結果が1ブロック分のデータ長以下になったときにパディング対象ブロックを示す信号を出力する比較器とを有することを特徴とする請求項8記載のパディング回路。The determination circuit indicates a subtractor for sequentially subtracting the capacity of the input data from the length information, and indicates a padding target block when the subtraction result of the subtractor becomes equal to or less than the data length of one block. The padding circuit according to claim 8, further comprising a comparator that outputs a signal. 前記データは、Nバイト(Nは自然数)単位であり、
前記判断回路は、前記比較器より前記パディング対象ブロックを示す信号が出力されたとき、前記減算器の前記減算結果をNで除算し、その後前記データが入力された回数をカウントし、
前記パディング出力回路は、カウントした値が前記除算による商の値に達すると、入力された前記データに続けて前記除算による剰余の値に応じたパディングを出力することを特徴とする請求項9記載のパディング回路。
The data is in units of N bytes (N is a natural number),
The determination circuit, when a signal indicating the padding target block is output from the comparator, divides the subtraction result of the subtractor by N, and then counts the number of times the data is input,
10. The padding output circuit according to claim 9, wherein when the counted value reaches the value of the quotient by the division, the padding output circuit outputs padding according to the value of the remainder by the division following the input data. Padding circuit.
JP2002319966A 2002-11-01 2002-11-01 Message digest generation circuit and padding circuit Expired - Fee Related JP4212339B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2002319966A JP4212339B2 (en) 2002-11-01 2002-11-01 Message digest generation circuit and padding circuit

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2002319966A JP4212339B2 (en) 2002-11-01 2002-11-01 Message digest generation circuit and padding circuit

Publications (2)

Publication Number Publication Date
JP2004157164A true JP2004157164A (en) 2004-06-03
JP4212339B2 JP4212339B2 (en) 2009-01-21

Family

ID=32801040

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2002319966A Expired - Fee Related JP4212339B2 (en) 2002-11-01 2002-11-01 Message digest generation circuit and padding circuit

Country Status (1)

Country Link
JP (1) JP4212339B2 (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2006191509A (en) * 2005-01-07 2006-07-20 N-Crypt Inc Communication system, and communication method
JP2010152468A (en) * 2008-12-24 2010-07-08 Mitsubishi Electric Corp Hash value arithmetic device, hash value arithmetic method and hash value arithmetic program
JP2011259446A (en) * 2011-06-29 2011-12-22 Nti Corp Communication system and communication method
JP2014112870A (en) * 2014-01-06 2014-06-19 Nti Corp Communication system and communication method

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2006191509A (en) * 2005-01-07 2006-07-20 N-Crypt Inc Communication system, and communication method
JP2010152468A (en) * 2008-12-24 2010-07-08 Mitsubishi Electric Corp Hash value arithmetic device, hash value arithmetic method and hash value arithmetic program
JP2011259446A (en) * 2011-06-29 2011-12-22 Nti Corp Communication system and communication method
JP2014112870A (en) * 2014-01-06 2014-06-19 Nti Corp Communication system and communication method

Also Published As

Publication number Publication date
JP4212339B2 (en) 2009-01-21

Similar Documents

Publication Publication Date Title
EP1580958B1 (en) Internet protocol tunnelling using templates
US8458461B2 (en) Methods and apparatus for performing authentication and decryption
US7941662B2 (en) Data transfer efficiency in a cryptography accelerator system
JP5131187B2 (en) Information processing system, information processing method, and information processing program
US11658803B2 (en) Method and apparatus for decrypting and authenticating a data record
JP4782343B2 (en) How to authenticate anonymous users while reducing the possibility of “middleman” fraud
US20060041938A1 (en) Method of supporting SSL/TLS protocols in a resource-constrained device
US20090279697A1 (en) Ciphertext key chaining
KR20050027254A (en) Efficient encryption and authentication for data processing systems
US20200228311A1 (en) Lightweight encryption, authentication, and verification of data moving to and from intelligent devices
US20100306540A1 (en) Encryption processing method and encryption processing device
US8281122B2 (en) Generation and/or reception, at least in part, of packet including encrypted payload
WO2021129470A1 (en) Polynomial-based system and method for fully homomorphic encryption of binary data
Liu et al. Design of password encryption model based on AES algorithm
JP4212339B2 (en) Message digest generation circuit and padding circuit
JP5500923B2 (en) Information processing device
CN114095259A (en) Authentication encryption and decryption device and method
JP5149863B2 (en) Communication device and communication processing method
JP2004004784A (en) System and method for mounting hash algorithm
Joaquim et al. Vulnerability-tolerant transport layer security
JP2004247810A (en) Encrypting apparatus, communication apparatus, decoder, encrypting method, decoding method, encryption program, and decoding program
JP2003333036A (en) Message authentication device, message authenticating method, message authenticating program, and computer- readable recording medium with the program stored thereon
Xiao Implementation Analysis of Encryption and Decryption Algorithm Based on python Language
MANAA et al. A PROACTIVE DATA SECURITY SCHEME OF FILES USING MINHASH TECHNIQUE
Khosa et al. Improved Encryption Algorithm for Public Wireless Network

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20051007

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20080729

A711 Notification of change in applicant

Free format text: JAPANESE INTERMEDIATE CODE: A712

Effective date: 20080730

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20080805

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20081002

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20081028

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20081028

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20111107

Year of fee payment: 3

R150 Certificate of patent or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20111107

Year of fee payment: 3

S531 Written request for registration of change of domicile

Free format text: JAPANESE INTERMEDIATE CODE: R313531

S533 Written request for registration of change of name

Free format text: JAPANESE INTERMEDIATE CODE: R313533

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20111107

Year of fee payment: 3

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20111107

Year of fee payment: 3

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20121107

Year of fee payment: 4

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20121107

Year of fee payment: 4

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20131107

Year of fee payment: 5

S111 Request for change of ownership or part of ownership

Free format text: JAPANESE INTERMEDIATE CODE: R313111

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

LAPS Cancellation because of no payment of annual fees