JP2004109420A - Method and apparatus for generating random number - Google Patents

Method and apparatus for generating random number Download PDF

Info

Publication number
JP2004109420A
JP2004109420A JP2002271214A JP2002271214A JP2004109420A JP 2004109420 A JP2004109420 A JP 2004109420A JP 2002271214 A JP2002271214 A JP 2002271214A JP 2002271214 A JP2002271214 A JP 2002271214A JP 2004109420 A JP2004109420 A JP 2004109420A
Authority
JP
Japan
Prior art keywords
random number
number generation
data
area
hash
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP2002271214A
Other languages
Japanese (ja)
Inventor
Takashi Suzuki
鈴木 孝
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sony Corp
Original Assignee
Sony Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Sony Corp filed Critical Sony Corp
Priority to JP2002271214A priority Critical patent/JP2004109420A/en
Publication of JP2004109420A publication Critical patent/JP2004109420A/en
Pending legal-status Critical Current

Links

Images

Abstract

<P>PROBLEM TO BE SOLVED: To provide a method by which safe having multiple bits are generated at high speed by using a simple apparatus constitution and an initial value having a small number of bits, and to provide an apparatus for generating random numbers. <P>SOLUTION: An input buffer 8 of a hash operation is reserved in a non-initialized region of a RAM, for example, a stack area 11, and data generated at an execution of a program are temporally stored into a region 11b of the stack area 11. Thus, values of memory region which becomes an input buffer are updated as needed and input data of the hash operation are different each time. Thus, the safe random numbers which are unpredictable from the initial value are generated and the period of available pseudo random numbers is large. <P>COPYRIGHT: (C)2004,JPO

Description

【0001】
【発明の属する技術分野】
本発明は、乱数を生成する乱数生成装置、及び乱数生成方法に関する。
【0002】
【従来の技術】
近年、デジタル通信技術の発展につれて、データ通信の安全性を高めるセキュリティ技術が注目され、そのため、暗号化技術が一般的に知られるようになってきた。
コンピュータネットワークを利用したデータ通信における代表的な暗号化方式として、共通鍵暗号方式と公開鍵暗号方式とがある。共通鍵暗号方式は、暗号化と復号化とで同じ暗号鍵を使う方法である。これは、「秘密鍵暗号」、「対称鍵暗号」、「慣用暗号」とも呼ばれる。一方、公開鍵暗号方式は、暗号化と復号化とで違う暗号鍵を使う方法である。公開鍵暗号方式では、一方の暗号鍵で暗号化したデータは、もう一方の鍵を使わないと復号できない。このため一方の鍵を公開し、他方の鍵を秘密にしておく。
【0003】
共通鍵暗号方式は、暗号化、復号化の処理速度が速いが、暗号化と復号の鍵が同一であるので、通信相手に安全な方法で暗号鍵を渡すことが難しく、鍵を共有するための手段が必要になる。
一方、公開鍵暗号方式は、暗号化および復号化の処理速度が低いが、暗号化の鍵と復号のための鍵が異なるので、暗号化の鍵を片方の鍵は公開する、例えば、安全性が保証されない通信網で配送することが可能であり、相手に暗号鍵を渡すことは非常に楽である。公開鍵暗号方式として、RSA方式が代表的であり、よく知られている。しかし、RSA方式は、暗号化、復号化とも共通鍵方式に比べ、1000倍程度処理速度が遅い。
【0004】
このため、コンピュータネットワークを利用したデータ通信において、高速な暗号システムを構成する場合、一般に、暗号化および復号は共通鍵暗号を用い、その鍵を公開鍵暗号によって暗号化し、配送するという方法を用いている。この方式を採用しているものには、PGP、PEM等がある。
RSA方式は、このような共通鍵の受け渡し、あるいは、比較的少量のデータ伝送等に使われている。
【0005】
以上の暗号化技術を利用すれば、電子マネーや、ネット上の音楽配信や、携帯電話とIDカードを用いた個人向けのサービス等において、データの暗号化、および、本人認証に必要なデジタル署名の生成を行なうことができる。
このような通信システムにおいて、安全なデータ通信を保証するために、乱数生成技術は不可欠なものである。乱数の主な用途として、パスワードの作成、暗号化に使用する鍵値の作成、暗号文の生成、電子署名情報の生成等がある。このような応用において、セキュリティを確保するために、乱数生成方式の実用性と生成した乱数の安全性が特に重要になってくる。即ち、外部から推測できない安全な乱数が必要である。
【0006】
乱数の生成方法としては、物理手段を利用して乱数列を発生させる方式と、数学的な演算処理を行ない、長い周期の乱数列を生成する擬似乱数生成方式がある。
物理手段を利用して乱数列を発生させる方式が多数知られている。例えば、抵抗体の熱雑音により乱数を生成する方式があげられる。抵抗体の熱雑音は多数の電子により発生する微少電流を合成したものであり、それぞれの電子の衝突と散乱は無関係に発生するため、雑音は一様に発生する。高抵抗の両端に発生する微少な雑音電圧を、ハイインピーダンス、低雑音のアンプで増幅して雑音電圧を取得し、その電圧をA/Dコンバータでデジタルデータに変換してパーソナルコンピュータに入力し、棄却法や括り合せ法などの処理を行なうことによって、乱数の性質の改善を行なうことができ、適切な乱数が得られる。
【0007】
この方式は、物理的な性質を利用するので、0と1の発生確率がおのおの約1/2になり、各ビットが他の部分と独立であるので、生成される乱数列の推測は困難であり、セキュリティの用途に適した乱数列が得られる。しかし、特別なハード・ウェアを必要とし、また、乱数を生成するのに時間がかかり、デジタル署名時のセッションキーなどを生成する際に、セキュリティ度を高めるためにデータ長を長くとった場合には、処理速度の低下等の不具合が懸念される。
【0008】
擬似乱数生成方式も多数知られている。例えば、M系列等の線形回路を複数組み合わせて生成する擬似乱数生成方法や、DES(Data Encryption Standard)等の共通鍵暗号を用いて生成する方法などは知られている。特許文献1〜3は、擬似乱数の生成方法と生成装置、または、擬似乱数を用いた暗号認証システムに関する。
例えば、擬似乱数生成法では、乱数演算を行なう関数をFとすれば、初期値R(0)より順番に乱数列R(1)、R(2)、R(3)、・・・を生成し、乱数R(1)、R(2)、R(3)、を結合して所望の乱数を生成する。ここでR(i+1)=F(R(i))。
擬似乱数生成法では、特別なハード・ウェアを必要とせず、ソフト・ウエアによる実現が可能であり、マイクロコンピュータ上で利用できるが、以上に示すように、初期値により乱数列が生成されるために、使った関数および初期値が決まると、全ての乱数列が決定され、そのため、関数および初期値を判明すれば、同様の乱数列を容易に生成し得ることが欠点である。
【0009】
次に、1つの具体例を用いて述べる。DESやトリプルDESのCBCモードを利用して乱数を生成する場合、例えばある手段により得られた64ビットの値をD、DESに使われる鍵情報をKr、乱数発生用のシードをSとするとき、乱数Rは以下のように計算される。
【0010】
I=DES(Kr,D)                     (1)
R=DES(Kr、S xor I)               (2)
S=DES(Kr、R xor I)               (3)
【0011】
ここで、関数DES(X,Y)において、第1引数Xを暗号鍵情報として、第2引数Yの値をDESで暗号化する関数とする。また、ここで、演算“xor”は64ビット単位の排他的論理和演算である。最終的に出てきた値Sは新規のシードとして更新されていく。ビット数の多い乱数を生成する場合には、式2と式3を繰り返す。次に乱数を生成する時に備えて、シードSは、例えば集積化回路化された乱数生成LSIの不揮発性メモリ内に格納されていることが多い。この場合、生成された擬似乱数列に関わる入力パラメータ変数は、ある手段(例えば時刻や日付などから生成)によって乱数生成時に生成するDと、不揮発性メモリ等に保存させておいたシード、つまり前回の乱数値Sである。
【0012】
このような乱数生成方法及び乱数生成回路において、生成された擬似乱数列は、基本的に入力D、Sに対して一定であり、不揮発性メモリ等の記録媒体を持たず、前回の乱数値Sは記憶されないシステムにおいては、生成された擬似乱数列はDのみに依存してしまい、Dの選び方の論理によっては、容易に短周期性が生じてしまい、乱数の安全性(秘匿性)強度に不安がある。また得られる擬似乱数の周期性も264以下に固定されてしまう。
【0013】
また、FIPS186におけるSHA−1(Secure Hash Algorithm)を用いた擬似乱数生成方法においては、長さが160ビットのビット列tと、長さがbビット(160≦b≦512)のビット列cをSHA−1演算器にかけて160ビットの乱数を生成する方法が知られているが、乱数生成に必要なシードの量が多く、かつ、512ビットの入力バッファにビット列cを格納した後に、入力バッファの残りのビットに(512−b)個の0を埋めるので、ビット列cが決まると、ビット列cの入力に対し、SHA−1演算器の出力は常に一定となってしまう。
【0014】
【特許文献1】
特開2000−242470号公報
【特許文献2】
特開2001−75476号公報
【特許文献3】
特開2000−4223号公報
【0015】
【発明が解決しようとする課題】
上記のように、従来の擬似乱数生成法は、初期値を用いて乱数列が生成されるために、使った関数および初期値が決まると、全ての乱数列が決定される。従って、関数および初期値を判明すれば、同様の乱数列を容易に生成し得ることが欠点であり、安全性上には問題がある。
【0016】
本発明は、以上の実情に鑑みてなされ、その目的は、簡単な装置構成で、少ないビット数の初期値を用い、多ビット数の安全な乱数を高速度に生成する方法と、乱数生成装置を提供することにある。
【0017】
【課題を解決するための手段】
本発明による乱数生成装置は、第1の乱数を入力し、第2の乱数を生成する乱数生成手段と、記憶部とを有し、前記乱数生成手段は、前記第1の乱数の少なくとも一部として、前記記憶部における初期化されない領域である非初期化領域の一部のデータを入力する。
好ましくは、前記記憶部に、実行可能な処理プログラムが格納されており、実行中の前記処理プログラムから出力された一時データが、前記記憶部の非初期化領域に保存された時に、前記第1の乱数の値は変更される。
【0018】
また、好ましくは、外部装置と通信するインタフェースを有し、前記インタフェースを介して、前記外部装置からのデータが前記記憶部に格納され、前記記憶部の非初期化領域に保存される一時データは、前記外部装置からのデータを含む。
【0019】
また、好ましくは、前記乱数生成手段は、前記第1の乱数を入力し、乱数関数の演算を行ない、第2の乱数を生成する乱数演算部を有し、前記乱数関数は、少なくともSHA−1からなるハッシュ関数、または、MD5からなるハッシュ関数のいずれかを含む。或は、前記乱数関数は、少なくとも、DES共通鍵暗号関数を含む。
好ましくは、前記第1の乱数は、前記乱数演算部が出力した乱数を含む。
【0020】
好ましくは、前記乱数生成手段は、初期値を生成する乱数発生器を有し、前記第1の乱数は、前記乱数発生器が生成した初期値を含む。
前記乱数発生器は、真性乱数発生回路を含む。
【0021】
本発明による乱数生成方法は、乱数関数の演算を行なう乱数演算部と、実行可能な処理プログラムを格納した記憶部とを有する乱数生成装置により乱数を生成する方法であって、前記記憶部の非初期化領域の一部のデータを、第1の乱数の少なくとも一部として前記乱数演算部に入力する工程と、前記入力された第1の乱数を用い、第2の乱数を生成する工程とを有する。
好ましくは、前記記憶部に実行可能な処理プログラムが格納されており、前記記憶部の非初期化領域には、実行中の前記処理プログラムの一時データを保存した時に、前記第1の乱数の値は変更される。
好ましくは、前記記憶部の非初期化領域に保存される一時データは、外部から入力されたデータを含む。
好ましくは、前記第1の乱数は、前記乱数演算部が出力した乱数を含む。
【0022】
また、好ましくは、前記乱数生成装置は、初期値を生成する乱数発生器を含み、前記第1の乱数は、前記乱数発生器が生成した初期値を含む。
また、好ましくは、前記乱数関数は、少なくともSHA−1からなるハッシュ関数、または、MD5からなるハッシュ関数のいずれかを含む、或は、前記乱数関数は、少なくとも、DES共通鍵暗号関数を含む。
【0023】
以上の本発明の乱数生成装置によれば、乱数生成手段は第1の乱数を入力して第2の乱数を生成する時に、第1の乱数の一部または全部として、記憶部における非初期化領域からデータを読み込む。記憶部の非初期化領域は、初期化(ゼロにリセットする)されず、かつ、その領域に随時上書きされるので、この非初期化領域のデータの値は常に変化している。この領域のデータを乱数生成手段に入力すると、入力データが毎回異なっているので、乱数生成手段から出力された乱数列は、外部から推測が困難な安全な乱数となる。
以上の本発明の乱数生成方法によれば、乱数演算部の入力データの一部または全部として、記憶部の非初期化領域からデータを読み込む。読み込んだデータが毎回の演算で異なっているので、出力された乱数列は、推測が困難な安全な乱数となる。
【0024】
【発明の実施の形態】
次に、本発明にかかる乱数生成方法と乱数生成装置の実施形態について、添付の図面を参照して詳細に説明する。
第1の実施形態
図1は、本実施形態にかかる乱数演算装置の概略構成を示す図である。
図1において、乱数演算装置10は、例えば、CPU1、ランダム・アクセス・メモリ(Random Access Memory: RAM)2、書き換え可能な不揮発性メモリEEPROM3、ハッシュ演算器4を備えている。
【0025】
CPU1は、乱数生成装置10が起動された時に、EEPROM3に記憶されているオペレーティング・システム(operating system:OS)、システム用アプリケーション・プログラムなど、または、実行しようとするユーザ用アプリケーション・プログラムをRAM2に読込む。また、乱数生成装置10が通常に動作する時に、CPU1において、実行しようとするアプリケーション・プログラムに記述された手続き、及び指示されたコマンドを逐次解釈し、実行させる。例えば、デジタル署名のルーチンにおいて、乱数生成のコマンドを実行させると、デジタル署名の時の乱数生成を行なう。
なお、CPU1においてプログラムを実行させる際に一時的に発生するデータをRAM2の所定の領域に随時書き込む。
【0026】
RAM2、EEPROM3、及び不図示の読み出し専用メモリ(ROM)が乱数生成装置10のメモリシステムを構成する。通常、ROMには、OSまたはOSのカーネル部が記憶されており、OS上に動作するシステム用プログラムや、サービスを提供するアプリケーション・プログラムなどがEEPROM3に配置されている。
RAM2はCPU1に直接にアクセスされる記憶装置である。乱数生成装置10は起動された時に、EEPROM3に記憶されているOS、システム用アプリケーション・プログラムなどがCPU1によってRAM2の所定のアドレス領域に読み込まれ、また、乱数生成装置10が通常に動作する時に、実行しようとするユーザ用アプリケーション・プログラムもCPU1によってRAM2の所定のアドレスに読込まれる。さらに、CPU1において各種アプリケーション・プログラムを実行する際に一時的に発生するデータをRAM2の所定の領域に随時書き込む。
なお、パーソナルコンピュータのようにCPU1とRAM2が別々に実装されていても差し支えない。
以上の乱数生成装置10のメモリシステムは、本発明の請求項においての「記憶部」に対応する。
【0027】
ハッシュ演算器4は、入力されたデータに対してハッシュ演算を行ない、入力されたデータから推測することが困難であるデータを出力し、擬似乱数として使う。ハッシュ関数は一方向性があるので、入力されたデータから演算の結果を求める事は出来ず、無相関性の良い擬似乱数を生成できる。
図1において、ハッシュ演算を行なう手段は、ハード・ウェアで実装されて、ハッシュ演算器4となっているが、ハッシュ演算のソフト・ウエアを実装されても問題はない。
ハッシュ演算器4は、本発明の請求項での「乱数演算部」に対応する。
バスライン5は、乱数生成装置10において、CPU1,RAM2、EEPROM3、ハッシュ演算器4と接続し、これらの間にデータを伝送する。
【0028】
図2は、乱数演算装置10において、ハッシュ演算器4における処理の概略を示す図である。ハッシュ関数として、例えば、SHA−1、MD5、或は、DES関数を用いることができるが、ここで、1具体例として、SHA−1のハッシュ関数Hを用いた場合の演算処理を例として述べる。
SHA−1のハッシュ関数Hを用いた場合は、ハッシュ演算器4に入力するデータXは、264ビット未満の長さのビット列である。ここで、例えば、入力データのビット長を512ビットにする。図2に示すように、ハッシュ演算器4は、512ビットの入力バファ8を有する。
【0029】
擬似乱数生成方式を利用して乱数を生成する時は、乱数を生成するごとに初期値を設定する必要がある。初期値を生成する方法が色々あるが、本実施形態では、システムが保有している現在時刻を用いて、乱数を生成するための32ビットの初期値を生成し、図2のように、入力バッファ8に書き込む。入力バッファ8にシードエリアが書き込まれた領域をシードエリア7と呼ぶ。
本実施形態において、本発明の請求項における「乱数生成手段」は、ハッシュ演算器4及び初期値となる現在時刻を生成する部分に対応する。
入力バッファ8の残りの領域に所定のデータを埋め込んで、入力データとなる。例えば、従来は、ゼロを埋め込むようにしていた。本実施形態では、後述する方法で入力バッファ8の残りの領域を埋め込む。
【0030】
ハッシュ演算器4が入力データに対してハッシュ演算を行なう。ハッシュ関数として、例えば、SHA−1を用いる。ハッシュ演算が終了したら、例えばSHA−1の場合は、160ビット長の乱数(ビット列)Yを出力する。演算が行なっている間に、出力された160ビットの乱数は、例えば、RAM2の出力データ領域9に記憶される。ビット長が長い乱数を生成する場合は、目標となる乱数のビット数で決められる回数nでハッシュ関数の演算を行なう。得られた160ビットの乱数(ビット列)Y1、Y2…Ynをビット結合し、即ち、Y1‖Y2‖…‖Yn、n×160ビットのビット列に変換する。このn×160ビット列から目標の乱数を抽出する。
ここで、演算子“x‖y”は、ビット列xとビット列yの結合を表わし、例えば、(0110)‖(101)=0110101。
例えば、RSA方式の公開鍵暗号方式において2048ビット長の公開鍵を作る場合は、1024ビット長の乱数を2つ生成する。そのため、ハッシュ演算器4が7回演算をし、1120ビット長のビット列を生成し、そのビット列から1024ビットを抽出し、1つ目の乱数が生成される。同じように、2つ目の1024ビットの乱数を生成する。
【0031】
既に述べたように、ハッシュ演算のパターンが決まると、同じ入力データに対して、ハッシュ演算器4の出力は一定になってしまう。乱数Y1、Y2…Ynが同じにならないように、毎回のハッシュ演算において、異なる入力データをハッシュ演算器に入力する必要がある。
従来は、演算で得られた160ビットの乱数(例えば、Y1)を入力バッファ8へ入力し、次のハッシュ値を演算し、次の160ビットの乱数(例えば、Y2)を得る。このように必要な回数で繰り返し、目標の乱数を生成する。
しかし、前述のように、こうして生成した乱数列は、演算パターンと初期値に依存し、使った関数および初期値が決まると、乱数列の全体が決定されてしまい、同様の乱数列を容易に生成し得る。また、初期値は32ビットの場合は、擬似乱数の周期は最大でも232であり、周期は小さく、安全性上に問題がある。
本実施形態では、後述する方法で毎回のハッシュ演算において、ハッシュ演算器4に推測の困難なデータを入力し、乱数の安全性を高める。
【0032】
図3は、乱数演算装置10において、RAM2の記憶領域の配置を示す図である。
図3に示すように、例えば、RAM2の記憶領域には、スタック・エリア11、ヒープ・エリア13、スタティック・データ・エリア14、コード・エリア15が少なくとも割り当てられており、また、例えば、スタック・エリア11とヒープ・エリア13の間に未使用領域12が存在する。
【0033】
スタック・エリア11は、CPU1がプログラムの実行を行なう際に、一時的なデータを格納する領域として使われているデータ構造、いわゆるスタック・データ構造は、使用しているメモリ領域である。例えば、プログラムで関数や、サブルーチンを呼び出した場合は、引数やリターンアドレスなどがスタック・エリア11に一時的に保存される。
スタック・データ構造は、First In Last Out(FILO)のデータ構造であり、一番最後に入れたデータを、一番最初に取り出す。
【0034】
ヒープ・エリア13は、OSが管理、利用するメモリ領域であり、OSはプログラムを実行する際に利用する。OSは、ヒープ・エリア13からメモリを取得してアプリケーションに提供したり、この領域に新しいプログラム、または、システム・プログラムをロードし、アロケーションしたりする。OSはメモリを管理する時、アプリケーション用とシステム用のヒープ領域に区別し、システム用はシステムヒープと呼ばれ、機能拡張ファイルなどをこちらに読込み、アプリケーション用ヒープ領域に一時的なデータを格納する。
【0035】
スタティック・データ・エリア14は、プログラムが実行する際に発生するスタティック・データを保存するメモリ領域である。スタティック・データは、プログラムが実行する際に、実行開始から終了まで値は変化しないと宣言された変数である。例えば、実行中のプログラムは関数やサブルーチンを呼び出した場合に、これらの変数を変化させないために、スタティック・データ・エリア14に一時保存する。
コード・エリア15は、RAM2に読み込まれ、実行するプログラムのコード本体を保存するメモリ領域である。
【0036】
スタック・エリア11とヒープ・エリア13は、通常CPU1のワークRAM領域であり、様々なアプリケーションがこれらの領域を一時的に使用している。
使用プロセスが終了すると開放をするが、ゼロ初期化はされず、随時上書きされている領域であるので、この領域のデータの値は随時変化している。以降、これらの領域をRAM2の「非初期化領域」と呼ぶ。
本実施形態では、図2に示された入力バッファ8をRAM2の上記の非初期化領域に指定する。
【0037】
図4は、本実施形態にかかる乱数演算装置10において、ハッシュ演算器4の入力バッファをRAM2の非初期化領域に設ける例を示す図である。
図4に示すように、例えば、スタック・エリア11において、点線で示された512ビットの領域をハッシュ演算器4の入力バッファ8として確保する。符号11bで示された領域は、実行中のプログラムが出力した一時データを保存した領域であり、これによって、入力バッファ8となる512ビットのメモリ領域の値は書き換えられる。
図2と同じように、最初のハッシュ演算の際に、別途で生成された例えば32ビットの初期値を入力バッファ8におけるシードエリア7に書き込む。
【0038】
前述のように、非初期化領域に確保された入力バッファ8は、様々なアプリケーションに一時的に使用され、随時上書きされており、しかもゼロ初期化されないので、一定の初期値でハッシュ演算を開始しても、ハッシュ演算器4に入力される値は、初回を含めて、毎回全く異なっている。このようにして、32ビットの初期値を用いても、入力バッファ8に予測できないデータが埋め込まれているため、入力データの変化範囲は実質上に512ビットに拡大され、初期値のビット長(32ビット)をはるか越えている。これによって、得られる擬似乱数の周期は232より大きくなり、外部からの推測が困難な安全な乱数となる。
また、ハッシュ演算器4以外に専用の回路を必要とせず、容易に実現することが可能となる。
【0039】
図5は、本実施形態の乱数演算装置10において、乱数を生成する処理を示すフローチャートである。
ステップS1:
RAM2上の非初期化領域、即ち、図4に示すように、スタック・エリア11、或は、ヒープ領域13に、ハッシュ演算器4への入力用の512ビットの入力バッファ8を確保する。即ち、この領域からデータを読込むことを宣言する。
ステップS2:
乱数を生成するための32ビットの初期値を生成する。本実施形態において、例えば、システムが保有している現在時刻を用いて初期値を生成し、入力バッファ8におけるシードエリア7にこの32ビットの初期値を書き込む。
【0040】
ステップS3:
続いて、ハッシュ演算器4は、512ビットの入力バッファ8から入力データを読み込んで、ハッシュ演算を実行する。
乱数生成装置10の電源がリセットされた時のみに、スタック・エリア11や、ヒープ領域13などの非初期化領域に、ゼロ初期化されるので、初期値を入力しなければ、入力バッファ8の全領域はゼロとなり、第1回目のハッシュ演算結果は初期値に依存する。このようなことを避けるために、最初は、別途に生成された初期値を用いてハッシュ演算を行なうこととする。
ハッシュ演算の詳細は、後程詳細に説明する。
【0041】
ステップS4:
ハッシュ演算を行なった結果、例えば、SHA−1の場合に、ハッシュ値から160ビットのビット列を乱数として取り出す。
ステップS5:
これまで生成された複数の乱数を結合し、目標の乱数のビット長になっているか否かを判断する。
結合されたビット列のビット長は、目標の乱数のビット長以上である場合は、ステップS7に進む。
結合されたビット列のビット長は、目標の乱数のビット長以下である場合は、ステップS6に進む。
【0042】
ステップS6:
ステップS3で説明した理由で、ここで、従来と同じように、得られた160ビットの乱数値を入力バッファ8へ入力し、ステップS3に戻り、ステップS3〜6を経て、ハッシュ演算と、次の160ビットの乱数値の抽出と、今まで得られた全部の160ビット乱数の結合と、結合された乱数は必要なビット長に達したかどうかの判断を繰り返す。
ステップS3に戻った時に、乱数生成装置10で実行しているプログラムが発生したデータを一時にRAM2の非初期化領域に記憶しているので、入力バッファ8は既に書き換えられた。即ち、ステップS3に戻って、次のハッシュ演算を行なう時には、入力バッファ8の値は、前回の入力バッファ8の値と全く異なり、前回の160ビットの乱数から予測できない次の160ビットの乱数を生成できる。
ステップS7:
結合されたビット列のビット長は、目標の乱数のビット長以上になった場合は、結合されたビット列のビット長から目標の乱数を抽出し、これで目標となる乱数が取得され、乱数生成処理を終了する。
【0043】
次に、図6〜図11を用い、ハッシュ演算回路4において、ハッシュ演算の詳細を説明する。なお、次の説明には、SHA−1ハッシュ関数を一例として述べる。
図6(a)は、ハッシュ演算回路4の入力バッファ8のデータ構造を示している。図6(b)は、ハッシュ演算回路4において、ハッシュ演算を実行する各バッファを示している。
図6(a)に示す入力バッファ8は、16個のロングワード(32ビット)W0、W1、…W15から構成され、即ち、入力バッファ8のバッファサイズは、512ビットとなる。この入力バッファ8は、RAM2上の非初期化領域、即ち、図4に示されたように、スタック・エリア11、或は、ヒープ領域13に設けられている。別途に生成された32ビットの初期値は、例えば、入力バッファ8のロングワードW10に入力されている。
【0044】
ハッシュ演算回路4には、演算を実行する5ワードのバッファが2つある。図6(b)に示すように、1番目のバッファが、5個の32ビットのレジスタA、B、C、D、Eからなり、2番目のバッファが、5個の32ビットのレジスタH0、H1、H2、H3、H4からなる。また、レジスタTEMPからなる1ワードのバッファには、演算を実行する際に、データを一時的に保存する。
演算をスタートする前に、図6(b)に示すように、レジスタH0、H1、H2、H3、H4は予め初期化する。初期化後に、レジスタH0、H1、H2、H3、H4の値は、16進数で次のようになる。
H0=67452301h、
H1=EFCDAB89h、
H2=98BADCFEh、
H3=10325476h、
H4=C3D2E1F0h。
【0045】
図6(a)に示すように、初期値を入力バッファ8のW10に入力して、ハッシュ演算をスタートする。入力バッファ8から一回で読込んだ入力データに対して、一回のハッシュ演算を実行する。この一回のハッシュ演算は80ステップに分けて行なう。
図7(a)と(b)は、ハッシュ演算におけるステップ1の演算の内容を示す。
図7(a)に示すように、ハッシュ演算のステップ1において、まずは、予め与えられたレジスタH0、H1、H2、H3、H4での各初期値を、レジスタA、B、C、D、Eに転送する(STEP1−1と記す)。
図7(b)に示すように、各演算ステップにおいての値が定められている変数Wと、レジスタAの値を5ビット左向きにローテーションさせた値A≪5と、レジスタEの値、加算定数K値、関数fの値とをビット単位で加算し、232で剰余をとった値を、レジスタTEMPに転送し、TEMPの値とする(STEP1−2と記す)。
変数Sに対して、ビット・ローテーション演算「S≪n」は、変数Sを左側にnビットをシフトして、あふれた上位のnビットを最下位ビットからの下位nビットに割り当てる演算を表す。8bitの数値を例にとると、S=1001 1011bとして、S≪2を求めると、S≪2=0110 1110bのようになる。
従って、A≪5は、Aを左側に5ビットをシフトして、あふれた上位5ビットが下位5ビットに割り当てられた値となる。
【0046】
図8(a)〜(c)は、STEP1−2における変数W、加算定数K、関数fの定義を示す図である。
図8(a)に示すように、ハッシュ演算の各ステップにおいて、変数Wの値が入力バッファ8の入力データW0〜W15を用いて定められている。
具体的に、ハッシュ演算のステップ1からステップ15までは、Wの値はそれぞれ入力バッファ8の入力データW0〜W15そのままである。
ステップ16から、Wの値は、図8(a)に示された定義のように、W0〜W15を用いて演算で定められている。
即ち、ステップ16では、Wの値は、W0、W2、W8、W13のビット単位の排他的論理和演算(xor)の後に、左側に1ビットローテーションしてなる。
ステップ17では、W1、W3、W9、W14について同様な演算を行なってWの値を決める。
ステップ18では、W2、W4、W10、W15について同様な演算を行なってWの値を決める。
このように類似した方法でステップ19からステップ80においてのWを定義する。例えば、ステップ80では、Wの値は、W63、W65、W71、W76のビット単位の排他的論理和演算(xor)の後に、左側に1ビットローテーションしてなる。
【0047】
図8(b)に示すように、加算定数Kの各ステップにおいての値が予め定められている。具体的に、Kの値は16進数で次のようになる。
ステップ1 〜ステップ20に、K=5A827999h、
ステップ21〜ステップ40に、K=6ED9EBA1h、
ステップ41〜ステップ60に、K=8F1BBCDCh、
ステップ61〜ステップ80に、K=CA62C1D6h。
【0048】
図8(c)に示すように、ハッシュ演算の各ステップにおいて、関数fの値がレジスタB、C、Dの値を用いて定められている。
ステップ1 〜ステップ20に、
f=(B and C) or ((not B) and D)、
ステップ21〜ステップ40に、
f=B xor C xor D、
ステップ41〜ステップ60に、
f=(B and C) or (B and D) or (C and D)、
ステップ61〜ステップ80に、
f=B xor C xor D.
ここで、“and”、“or”、“not”は、それぞれビット単位の論理積、論理和、反転演算を表わす。
【0049】
図9(a)と(b)は、図7に続き、ハッシュ演算におけるステップ1の演算の内容を示す。
図9(a)に示すように、図7(b)に続いて、レジスタEにレジスタDの値を転送し、レジスタDにレジスタCの値を転送し、レジスタCにはレジスタBの値を左方向へ30ビットローテーションした値を転送し、レジスタBにはレジスタAの値を転送、レジスタAにはTEMP値を転送して、レジスタA〜Eの値を更新する(STEP1−3と記す)。
【0050】
続いて、図9(b)に示すように、レジスタH0にレジスタAの値を加算してH0とし、レジスタH1にレジスタBの値を加算してH1とし、レジスタH2にレジスタCの値を加算してH2とし、レジスタH3にレジスタDの値を加算してH3とし、レジスタH4にレジスタEの値を加算してH4とし、レジスタH1、H2、H3、H4、H5の値を更新する(STEP1−4と記す)。
【0051】
上記STEP1−1〜STEP1−4を1つのステップとして各レジスタを次々と更新し、これを80ステップ繰り返す。
例として、図10(a)と(b)は、ステップ2の一部(STEP2−1)とステップ80の一部(STEP80−4)を示している。
図10(a)に示すように、ステップ2−1において、STEP1−1と同じように、ステップ1で更新されたレジスタH0、H1、H2、H3、H4の各値を初期値として、レジスタA、B、C、D、Eに転送する。
そして、STEP1−2〜STEP1−4と同じような演算内容を、STEP2−2〜STEP2−4として実行され、レジスタH1、H2、H3、H4、H5の値をさらに更新する。
このように、ステップ3〜ステップ80まで、STEP1−2〜STEP1−4と同じような演算内容を繰り返し、各レジスタを次々と更新する。
最後に、図10(b)に示すように、ステップ80−4において、STEP1−4と同じように、ステップ79で更新されたレジスタH0、H1、H2、H3、H4の各値にレジスタA、B、C、D、Eの値をそれぞれ加算して、レジスタH1、H2,H3、H4、H5の値を更新する。
【0052】
図11(a)と(b)は、図10に続いて、ハッシュ演算の内容を示す。
ステップ80−4において、最終的に5つの32ビット長のビット列H0〜H4が得られた。図11(a)に示すように、ビット列H0〜H4を結合して、即ち、H0‖H1‖H2‖H3‖H4、得られた5×32ビット=160ビットのビット列をハッシュ演算の結果(ハッシュ値)として取り出す。
このように得られたハッシュ値は、入力バッファ8のワードW0〜W15の値が1ビットでも変化すると、全く異なる結果が得られるアルゴリズムとなっており、乱数値となる。
【0053】
以上のように得られた160ビットの乱数値を、図11(b)に示すように、例えば、入力バッファ8の例えばW0〜W4に入力し、再びハッシュ演算を行ない、次の160ビットの乱数値が得られる。これを、必要な桁数の乱数値が得られるまで繰り返して擬似乱数を生成する。
前述のように、入力バッファ8は、RAM2上のスタック・エリア11、或は、ヒープ領域13などの非初期化領域に設けられているので、以上のハッシュ演算を行なっている間に、乱数生成装置10に実行している全てのプログラムが入力バッファ8を含む非初期化領域に上書きをする。これによって、80ステップの演算を終了した時点で、入力バッファ8の16のワードW0〜W15の値はすでに更新された可能性が高い。
前述したように、電源のリセットによってW0〜W15は全部ゼロになる。また、入力バッファ8の16ワードW0〜W15の更新が少ないこともあり得る。
このようなことを避けるために、以上のように、毎回得られた160ビットの乱数値を再び入力バッファ8に入力し、ハッシュ演算を繰り返すようにしている。
【0054】
以上の本実施の形態によれば、入力バッファのデータからハッシュ演算によって乱数を生成する時に、入力バッファをRAMのスタック・エリアや、ヒープ・エリアなどの初期化されない、かつ、随時上書きされる非初期化領域に設置することによって、ハッシュ演算の入力データが毎回異なっているので、外部から初期値からハッシュ演算の結果を推測することが困難となる。
また、初期値はビット長が短くても、入力バッファ8には、ゼロではなく、全く予測できない値を埋めこむので、入力データの変化範囲は実質上に512ビットに拡大し、得られる擬似乱数の周期は232より大きくなり、外部からの推測が困難な安全な乱数となる。EEPROM等の不揮発性メモリにシード値を保存しておく必要も不要となる。
また、専用の回路を必要とせず、容易に実現することが可能となる。
【0055】
第2の実施形態
本実施形態において、本発明にかかる乱数生成装置の他の実施形態について述べる。
図12は、本実施形態にかかる乱数演算装置の概略構成を示す図である。なお、図12において、第1の実施形態と同じ構成に同じ符号を用い、重複する説明を適宜に省略する。
図12において、乱数演算装置30は、例えば、CPU1、ランダム・アクセス・メモリ(RAM)2、書き換え可能な不揮発性メモリEEPROM3、ハッシュ演算器4、真性乱数発生回路31を備えている。
本実施形態において、第1の実施形態と同じように、ハッシュ演算器4の入力バッファ8をRAM2のスタック・エリア11、または、ヒープ・エリア13に指定する。これによって、ハッシュ演算器4の入力データが毎回異なっているようになり、外部からの推測が困難となる。
【0056】
真性乱数とは、物理手段を利用して発生した乱数を言う。例えば、抵抗体の熱雑音により乱数を生成する方式を用いる。抵抗体の熱雑音は多数の電子により発生する微少電流を合成したものであり、それぞれの電子の衝突と散乱は無関係に発生するため、雑音は一様に発生する。高抵抗の両端に発生する微少な雑音電圧を、ハイインピーダンス、低雑音のアンプで増幅して雑音電圧を取得し、その電圧をA/Dコンバータでデジタルデータに変換してパーソナルコンピュータに入力し、棄却法や括り合せ法などの処理を行なうことによって、乱数の性質の改善を行なうことができ、適切な乱数が得られる。
この方式は、物理的な性質を利用するので、0と1の発生確率がおのおの約1/2になり、各ビットが他の部分と独立であるので、生成される乱数列の推測は困難であり、セキュリティの用途に適した乱数列が得られる。しかし、乱数を生成するのに時間が掛かるので、特に、セキュリティ度を高めるためにデータ長を長くとった場合には、処理速度が十分ではない。
【0057】
第1の実施形態では、乱数を生成するための32ビットの初期値として、システムが保有している現在時刻を用いていた。
本実施形態では、ハッシュ演算の入力バッファ8はRAM2の非初期化領域に設けたことによって、初期値は少ないビット数でよいので、例えば、32ビットで十分である。従って、例えば、図12に示された真性乱数発生回路31を乱数生成装置30に搭載した場合は、ハッシュ演算の初期値を真性乱数とする。
また、動作の遅い真性乱数発生回路31を乱数生成装置30に搭載し、真性乱数が生成されるたびにハッシュ値の演算入力として使用し、未生成時は、第1の実施形態のようにハッシュ値の演算結果を使用するようにすれば、周期性の長い擬似乱数が高速に得られることになる。
本実施形態において、請求項における「乱数生成手段」は、ハッシュ演算器4及び真性乱数発生回路31に対応する。
【0058】
図13は、本実施形態の乱数演算装置30において、乱数を生成する処理を示すフローチャートである。
ステップS11:
RAM2上の非初期化領域、即ち、図4に示すように、スタック・エリア11、或は、ヒープ領域13に、ハッシュ演算器4への入力用の512ビットの入力バッファ8を確保する。
ステップS12:
乱数を生成するための32ビットの初期値を生成する。本実施形態において、真性乱数発生回路31によって、ハッシュ演算の初期値となる乱数を生成し、入力バッファ8におけるシードエリア7に書き込む。
例えば、一様に発生する抵抗体の熱雑音により乱数を生成する方式を用いる。
高抵抗の両端に発生する微少な雑音電圧を、ハイインピーダンス、低雑音のアンプで増幅して雑音電圧を取得し、その電圧をA/Dコンバータでデジタルデータに変換してパーソナルコンピュータに入力し、例えば、32ビットの乱数を抽出する。
【0059】
ステップS13:
続いて、ハッシュ演算器4は、512ビットの入力バッファ8から入力データを読み込んで、図6〜図11に示されたようにハッシュ演算を実行する。
乱数生成装置10の電源がリセットされた時のみに、スタック・エリア11や、ヒープ領域13などの非初期化領域に、ゼロ初期化されるので、最初は、真性乱数発生回路31で生成された初期値を用いてハッシュ演算を行なうこととする。
【0060】
ステップS14:
ハッシュ演算の結果、例えば、SHA−1の場合に、ハッシュ値から160ビットのビット列を乱数として取り出す。
ステップS15:
これまでのハッシュ演算で生成された複数の160ビットの乱数を結合し、目標の乱数のビット長になっているか否かを判断する。
結合されたビット列のビット長は、目標の乱数のビット長以上である場合は、ステップS18に進む。
結合されたビット列のビット長は、目標の乱数のビット長以下である場合は、ステップS16に進む。
【0061】
ステップS16:
真性乱数発生回路31は真性乱数シードを生成したか否かを判断し、
真性乱数発生回路31は真性乱数シードを生成済みであれば、例えば、その32ビットの乱数値を入力バッファ8へ入力し、ステップS13に戻り、ステップS13〜15を経て、ハッシュ演算と、次の160ビットの乱数値の抽出と、今まで得られた全部の160ビット乱数の結合と、結合された乱数は必要なビット長に達したかどうかの判断を繰り返す。
ステップS13に戻った時に、乱数生成装置30で実行しているプログラムが発生したデータを一時にRAM2の非初期化領域に記憶しているので、入力バッファ8は既に書き換えられた。即ち、ステップS13に戻って、次のハッシュ演算を行なう時には、入力バッファ8の値は、前回の入力バッファ8の値と全く異なり、前回の160ビットの乱数から予測できない次の160ビットの乱数を生成できる。
真性乱数シードは生成されていない場合は、ステップS17に進む。
【0062】
ステップS17:
真性乱数シードは生成されていない場合は、前回のハッシュ演算で得られた160ビットの乱数値を入力バッファ8へ入力する。そして、ステップS13に戻り、ステップS13〜15を経て、ハッシュ演算と、次の160ビットの乱数値の抽出と、今まで得られた全部の160ビット乱数の結合と、結合された乱数は必要なビット長に達したかどうかの判断を繰り返す。
同じように、ステップS13に戻った時に、入力バッファ8は書き換えられたので、次のハッシュ演算の時に、入力バッファ8の値は、前回の入力バッファ8の値と全く異なり、前回の160ビットの乱数から予測できない乱数を生成できる。
ステップS18:
結合されたビット列のビット長は、目標の乱数のビット長以上になった場合は、結合されたビット列のビット長から目標の乱数を抽出し、これで目標となる乱数が取得され、乱数生成処理を終了する。
【0063】
以上の本実施の形態によれば、入力バッファのデータからハッシュ演算によって乱数を生成する時に、入力バッファをRAMのスタック・エリアや、ヒープ・エリアなどの非初期化領域に設置することによって、ハッシュ演算の入力データが毎回異なっているので、外部から初期値からハッシュ演算の結果を推測することが困難となる。
また、初期値はビット長が短くても、入力バッファ8には、ゼロではなく、全く予測できない値を埋めこむので、入力データの変化範囲は実質上に512ビットに拡大し、得られる擬似乱数の周期は232より大きくなり、外部からの推測が困難な安全な乱数となる。また、EEPROM等の不揮発性メモリにシード値を保存しておく必要も不要となる。
また、動作の遅い真性乱数発生回路を乱数生成装置に搭載し、真性乱数が生成されるたびにハッシュ値の演算入力として使用し、未生成時は、ハッシュ値の演算結果を使用することによって、安全性がさらに高く、周期性の長い擬似乱数が高速に得られる。
【0064】
第3の実施形態
本実施形態において、本発明にかかる乱数生成装置の他の実施形態について述べる。
図14は、本実施形態にかかる乱数演算装置の概略構成を示す図である。なお、図14において、第1の実施形態と同じ構成に同じ符号を用い、重複する説明を適宜に省略する。
図14において、乱数演算装置40は、例えば、CPU1、ランダム・アクセス・メモリ(RAM)2、書き換え可能な不揮発性メモリEEPROM3、ハッシュ演算器4、インタフェース(I/F)41、外部コンピュータ42とを備えている。
本実施形態において、第1の実施形態と同じように、ハッシュ演算器4の入力バッファ8をRAM2のスタック・エリア11、または、ヒープ・エリア13に指定する。これによって、ハッシュ演算器4の入力データが毎回異なっているようになり、生成された乱数列を初期値から推測することが困難となる。
本実施形態では、乱数を生成するための初期値として、システムが保有している現在時刻を用いる。
本実施形態において、請求項における「乱数生成手段」は、ハッシュ演算器4及び初期値となる現在時刻を生成する部分に対応する。
【0065】
外部コンピュータ42は、例えば、公開鍵暗号、共通鍵暗号を用いて、電子マネーや、ネット上の音楽配信や、携帯電話とIDカードを用いた個人向けのサービス等を行なう通信システムにおけるホストコンピュータである。外部コンピュータ42は、乱数生成装置40で生成した乱数を用いて、パスワードの作成、暗号化に使用する鍵値の作成、暗号文の生成、電子署名情報の生成等を行なう。
I/F41は、乱数生成装置40と外部コンピュータ42との間に送受信し、外部コンピュータ42から受信した指令をCPU1に出力し、また、CPU1から入力された信号を外部コンピュータ42に送信する。例えば、I/F41は、外部コンピュータ42からの指示やデータなどを乱数生成装置40に送信し、または、乱数生成装置40からの演算結果を外部コンピュータ42に送信する。
CPU1は、外部コンピュータ42からのコマンド、あるいは、予め乱数生成装置40に設定されたコマンドに基づいて、EEPROM3に記憶されているプログラムをRAM2に読込み、逐次解読して実行し、乱数を生成する。
【0066】
乱数生成装置40が外部コンピュータ42とデータの送受信を行ない、受信したデータを、EEPROM3に記憶されているプログラムが実行する際に、そのプログラムにより、RAM2の非初期化領域に配置する。これにより乱数生成装置40において、ハッシュ演算器4の入力バッファ8に入力されるデータの範囲は広くなり、ハッシュ演算器4が生成した乱数の周期はさらに拡大され、32ビットの初期値を用い、2160の周期に近づくことになる。
【0067】
図15は、本実施形態の乱数演算装置40において、乱数を生成する処理を示すフローチャートである。
ステップS21:
乱数生成装置40は、外部コンピュータ42と通信し、データを送受信し、乱数生成装置40は、乱数の演算を開始する。特に、乱数生成装置40は、外部コンピュータ42から受信したデータは、実行しているプログラムによって、RAM2の非初期化領域に書き込まれる。
【0068】
ステップS22:
RAM2上の非初期化領域、即ち、図4に示すように、スタック・エリア11、或は、ヒープ領域13に、ハッシュ演算器4への入力用の512ビットの入力バッファ8を確保する。
ステップS23:
乱数を生成するための32ビットの初期値を生成する。本実施形態において、システムが保有している現在時刻を用いて初期値を生成し、入力バッファ8におけるシードエリア7にこの32ビットの初期値を書き込む。
【0069】
ステップS24:
続いて、ハッシュ演算器4は、512ビットの入力バッファ8から入力データを読み込んで、図6〜図11に示されたようにハッシュ演算を実行する。
ステップS25:
ハッシュ演算の結果、例えば、SHA−1の場合に、ハッシュ値から160ビットのビット列を乱数として取り出す。
ステップS26:
これまでのハッシュ演算で生成された複数の160ビットの乱数を結合し、目標の乱数のビット長になっているか否かを判断する。
結合されたビット列のビット長は、目標の乱数のビット長以上である場合は、ステップS28に進む。
結合されたビット列のビット長は、目標の乱数のビット長以下である場合は、ステップS27に進む。
【0070】
ステップS27:
前回のハッシュ演算で得られた160ビットの乱数値を入力バッファ8へ入力する。そして、ステップS24に戻り、ステップS24〜26を経て、ハッシュ演算と、次の160ビットの乱数値の抽出と、今まで得られた全部の160ビット乱数の結合と、結合された乱数は必要なビット長に達したかどうかの判断を繰り返す。
ステップS24に戻った時に、乱数生成装置40で実行しているプログラムが発生したデータを一時にRAM2の非初期化領域に記憶しているので、入力バッファ8は既に書き換えられた。即ち、ステップS24に戻って、次のハッシュ演算を行なう時には、入力バッファ8の値は、前回の入力バッファ8の値と全く異なり、前回の160ビットの乱数から予測できない次の160ビットの乱数を生成できる。
特に、本実施形態では、乱数生成装置40が外部コンピュータ42から受信したデータも、実行しているプログラムよりRAM2の非初期化領域に書き込むので、入力バッファ8に入力されるデータの範囲はさらに広くなる。これによって、生成された乱数の周期は拡大される。
【0071】
ステップS28:
結合されたビット列のビット長は、目標の乱数のビット長以上になった場合は、結合されたビット列のビット長から目標の乱数を抽出し、これで目標となる乱数が取得され、乱数生成処理を終了する。
ステップS29:
乱数を取得した後に、乱数生成装置40は得られた乱数を外部コンピュータ42に送信する。そして、乱数生成装置40と外部コンピュータ42との通信が終了する。
【0072】
以上の本実施の形態によれば、入力バッファのデータからハッシュ演算によって乱数を生成する時に、入力バッファをRAMのスタック・エリアや、ヒープ・エリアなどの非初期化領域に設置することによって、ハッシュ演算の入力データが毎回異なっているので、外部から初期値からハッシュ演算の結果を推測することが困難となる。
また、初期値はビット長が短くても、入力バッファには、ゼロではなく、全く予測できない値を埋めこむので、入力データの変化範囲は実質上に512ビットに拡大し、得られる擬似乱数の周期は232より大きくなり、外部からの推測が困難な安全な乱数となる。EEPROM等の不揮発性メモリにシード値を保存しておく必要も不要となる。
さらに、乱数生成装置が外部コンピュータから受信したデータもRAMの非初期化領域に配置するので、入力バッファに入力されるデータの範囲は広くなり、生成された乱数の周期はさらに拡大され、32ビットの初期値を用い、2160の周期に近づくことができる。
これによって、安全性がさらに高く、周期性の長い擬似乱数が高速に得られる。
【0073】
以上、本発明を好ましい実施の形態に基づき説明したが、本発明は以上に説明した実施の形態に限られるものではなく、本発明の要旨を逸脱しない範囲で、種々の改変が可能である。
例えば、上記の実施形態での乱数生成装置の構成は一例であり、本発明の効果を得られれば、他の構成を用いても良い。
また、上記の実施形態でハッシュ関数としては、主にSHA−1を例として用いていたが、他のハッシュ関数を用いた場合も本発明を適用できることが明らかである。
また、RAMの非初期化領域としては、スタック・エリアとヒープ・エリアを例として用いていたが、他のプログラムの実行に妨げず、随時変化するメモリ領域であれば、他のメモリ領域でも良い。
【0074】
【発明の効果】
以上説明した本発明の乱数生成方法及び乱数生成装置によれば、ハッシュ演算の入力バッファを記憶部の非初期化領域に配置することによって、ハッシュ演算の入力データが随時変化し、毎回の演算に異なっている値となるので、外部から初期値からハッシュ演算の結果を推測することが困難となる。
これによって、初期値はビット長が短くても、入力バッファ8には、予測できない値を埋めこむので、入力データの変化範囲は実質上に拡大され、得られる乱数の周期は大きくなり、推測が一層困難となり、安全な乱数を生成できる。
さらに、専用の回路を必要とせず、容易に実現することが可能となる。
また、真性乱数発生回路を搭載した場合は、真性乱数が生成されるたびにハッシュ値の演算入力として使用し、未生成時は、ハッシュ値の演算結果を使用することによって、安全性がさらに高く、周期性の長い擬似乱数が高速に得られる。
また、乱数生成装置が外部コンピュータから受信したデータもRAMの非初期化領域に配置すれば、入力バッファに入力されるデータの範囲は広くなり、生成された乱数の周期はさらに拡大される。
従って、本発明によれば、デジタル署名生成時や各種公開鍵、共通鍵生成時に必要となる、安全性の高い長周期の擬似乱数を容易にかつ高速に得られることになる。
【図面の簡単な説明】
【図1】本発明の第1の実施形態にかかる乱数演算装置の概略構成を示す図である。
【図2】本発明の第1の実施形態にかかる乱数演算装置において、ハッシュ演算器における処理の概略を示す図である。
【図3】本発明の第1の実施形態にかかる乱数演算装置において、メモリの記憶領域の配置を示す図である。
【図4】本発明の第1の実施形態にかかる乱数演算装置において、ハッシュ演算器の入力バッファをメモリに設ける例を示す図である。
【図5】本発明の第1の実施形態にかかる乱数演算装置において、乱数を生成する処理を示すフローチャートである。
【図6】本発明の第1の実施形態にかかる乱数演算装置において、ハッシュ演算器における演算処理を示す図である。
【図7】図6に続いて、本発明の第1の実施形態にかかる乱数演算装置において、ハッシュ演算器における演算処理を示す図である。
【図8】図7に続いて、本発明の第1の実施形態にかかる乱数演算装置において、ハッシュ演算器における演算処理を示す図である。
【図9】図8に続いて、本発明の第1の実施形態にかかる乱数演算装置において、ハッシュ演算器における演算処理を示す図である。
【図10】図9に続いて、本発明の第1の実施形態にかかる乱数演算装置において、ハッシュ演算器における演算処理を示す図である。
【図11】図10に続いて、本発明の第1の実施形態にかかる乱数演算装置において、ハッシュ演算器における演算処理を示す図である。
【図12】本発明の第2の実施形態にかかる乱数演算装置の概略構成を示す図である。
【図13】本発明の第2の実施形態にかかる乱数演算装置において、乱数を生成する処理を示すフローチャートである。
【図14】本発明の第3の実施形態にかかる乱数演算装置の概略構成を示す図である。
【図15】本発明の第3の実施形態にかかる乱数演算装置において、乱数を生成する処理を示すフローチャートである。
【符号の説明】
1…CPU、2…RAM、3…EEPROM、4…ハッシュ演算器、5…バスライン、7…シードエリア、8…入力バッファ、9…出力バッファ、10…乱数生成装置、11…スタック・エリア、11b…一時データ保存エリア、12…未使用エリア、13…ヒープ・エリア、14…スタティック・データ・エリア、15…コード・エリア、30…乱数生成装置、31…真性乱数発生回路、40…乱数生成装置、41…インタフェース、42…外部コンピュータ。
[0001]
TECHNICAL FIELD OF THE INVENTION
The present invention relates to a random number generation device that generates random numbers and a random number generation method.
[0002]
[Prior art]
2. Description of the Related Art In recent years, with the development of digital communication technology, a security technology that enhances the security of data communication has attracted attention, and therefore, an encryption technology has become generally known.
Representative encryption methods in data communication using a computer network include a common key encryption method and a public key encryption method. The common key encryption method uses the same encryption key for encryption and decryption. This is also called "secret key encryption", "symmetric key encryption", or "conventional encryption". On the other hand, the public key cryptosystem uses different encryption keys for encryption and decryption. In public key cryptography, data encrypted with one encryption key cannot be decrypted without using the other key. For this reason, one key is made public and the other key is kept secret.
[0003]
The common key encryption method has a high encryption and decryption processing speed, but since the encryption and decryption keys are the same, it is difficult to pass the encryption key to the communication partner in a secure manner, and the key is shared. Means is required.
On the other hand, in the public key cryptosystem, the processing speed of encryption and decryption is low, but since the key for encryption and the key for decryption are different, one of the encryption keys is made public. Can be delivered over a communication network that is not guaranteed, and passing the encryption key to the other party is very easy. As the public key cryptosystem, the RSA system is typical and well known. However, the processing speed of the RSA scheme is about 1000 times slower than that of the common key scheme for both encryption and decryption.
[0004]
For this reason, when configuring a high-speed encryption system in data communication using a computer network, generally, a method is used in which encryption and decryption use a common key encryption, the key is encrypted by a public key encryption, and then delivered. ing. There are PGP, PEM, etc. adopting this method.
The RSA method is used for the transfer of such a common key or the transmission of a relatively small amount of data.
[0005]
If the above encryption technology is used, the digital signature required for data encryption and personal authentication in electronic money, music distribution on the Internet, services for individuals using mobile phones and ID cards, etc. Can be generated.
In such a communication system, a random number generation technique is indispensable in order to guarantee secure data communication. The main uses of the random number include creation of a password, creation of a key value used for encryption, creation of a ciphertext, creation of electronic signature information, and the like. In such applications, in order to ensure security, the practicality of the random number generation method and the security of the generated random numbers become particularly important. That is, a secure random number that cannot be estimated from the outside is required.
[0006]
As a method of generating random numbers, there are a method of generating a random number sequence using physical means and a pseudo-random number generation method of performing a mathematical operation to generate a long-period random number sequence.
Many methods for generating a random number sequence using physical means are known. For example, there is a method of generating a random number using thermal noise of a resistor. The thermal noise of the resistor is obtained by synthesizing a minute current generated by a large number of electrons. Since the collision and scattering of each electron are generated independently, the noise is generated uniformly. A small noise voltage generated at both ends of the high resistance is amplified by a high impedance, low noise amplifier to obtain a noise voltage, and the voltage is converted into digital data by an A / D converter and input to a personal computer. By performing processes such as the rejection method and the combining method, the properties of random numbers can be improved, and appropriate random numbers can be obtained.
[0007]
Since this method uses physical properties, the probability of occurrence of 0s and 1s is about half each, and since each bit is independent of other parts, it is difficult to estimate the generated random number sequence. Yes, a random number sequence suitable for security use can be obtained. However, when special hardware is required, it takes time to generate random numbers, and when generating a session key for digital signature, if the data length is increased to increase the degree of security, In this case, there is a concern that a problem such as a reduction in processing speed may occur.
[0008]
Many pseudorandom number generation systems are also known. For example, a method of generating a pseudo-random number by combining a plurality of linear circuits such as an M-sequence and a method of generating the same using a common key cryptosystem such as DES (Data \ Encryption \ Standard) are known. Patent Documents 1 to 3 relate to a method and a device for generating a pseudo-random number, or an encryption authentication system using a pseudo-random number.
For example, in the pseudo random number generation method, if a function for performing a random number operation is F, random number sequences R (1), R (2), R (3),... Are generated in order from an initial value R (0). Then, a desired random number is generated by combining the random numbers R (1), R (2), and R (3). Here, R (i + 1) = F (R (i)).
The pseudo-random number generation method does not require special hardware, can be realized by software, and can be used on a microcomputer.However, as described above, since a random number sequence is generated by initial values, In addition, when the used function and the initial value are determined, all the random number sequences are determined. Therefore, if the function and the initial value are known, a similar random number sequence can be easily generated.
[0009]
Next, a description will be given using one specific example. When generating a random number using the DES or triple DES CBC mode, for example, when a 64-bit value obtained by a certain means is D, key information used for DES is Kr, and a seed for generating a random number is S , R are calculated as follows.
[0010]
I = DES (Kr, D) (1)
R = DES (Kr, S xor I) (2)
S = DES (Kr, R xor I) (3)
[0011]
Here, in the function DES (X, Y), the first argument X is used as encryption key information, and the value of the second argument Y is encrypted by DES. Here, the operation “xor” is an exclusive OR operation in 64-bit units. The value S that finally comes out is updated as a new seed. When generating a random number having a large number of bits, Equations 2 and 3 are repeated. The seed S is often stored in, for example, a nonvolatile memory of a random number generation LSI integrated into an integrated circuit in preparation for the next time a random number is generated. In this case, the input parameter variables related to the generated pseudo-random number sequence are D generated at the time of random number generation by a certain means (for example, generated from time or date) and a seed stored in a nonvolatile memory or the like, that is, Is a random value S of
[0012]
In such a random number generation method and a random number generation circuit, the generated pseudo-random number sequence is basically constant with respect to the inputs D and S, does not have a recording medium such as a nonvolatile memory, In a system where is not stored, the generated pseudo-random number sequence depends only on D, and depending on the logic of how to select D, short-periodicity easily occurs, and the security (confidentiality) strength of the random number is reduced. I have anxiety. The periodicity of the obtained pseudo-random numbers is also 264Fixed below.
[0013]
Also, in the pseudo random number generation method using SHA-1 (Secure @ Hash @ Algorithm) in FIPS 186, a bit sequence t having a length of 160 bits and a bit sequence c having a length of b bits (160 ≦ b ≦ 512) are formed by SHA- A method of generating a 160-bit random number by using one arithmetic unit is known. However, after a large amount of seeds are required for generating a random number and the bit string c is stored in a 512-bit input buffer, the remaining amount of the input buffer is reduced. Since (512-b) zeros are filled in the bits, when the bit sequence c is determined, the output of the SHA-1 arithmetic unit is always constant with respect to the input of the bit sequence c.
[0014]
[Patent Document 1]
JP 2000-242470 A
[Patent Document 2]
JP 2001-75476 A
[Patent Document 3]
JP 2000-4223 A
[0015]
[Problems to be solved by the invention]
As described above, in the conventional pseudo-random number generation method, since a random number sequence is generated using the initial value, when the function used and the initial value are determined, all the random number sequences are determined. Therefore, if a function and an initial value are known, a similar random number sequence can be easily generated, which is a disadvantage, and has a problem in security.
[0016]
SUMMARY OF THE INVENTION The present invention has been made in view of the above circumstances, and has as its object a method of generating a secure random number of a large number of bits at a high speed with a simple device configuration, using an initial value of a small number of bits, and a random number generation device. Is to provide.
[0017]
[Means for Solving the Problems]
A random number generation device according to the present invention includes a random number generation unit that receives a first random number and generates a second random number, and a storage unit, wherein the random number generation unit includes at least a part of the first random number. As a part of the data, a part of the data in the non-initialized area which is the area not initialized in the storage unit is input.
Preferably, an executable processing program is stored in the storage unit, and when the temporary data output from the processing program being executed is stored in a non-initialized area of the storage unit, the first processing is performed. Is changed.
[0018]
Also preferably, it has an interface for communicating with an external device, via the interface, data from the external device is stored in the storage unit, temporary data stored in a non-initialized area of the storage unit is , And data from the external device.
[0019]
Also, preferably, the random number generation means has a random number calculation unit that receives the first random number, performs a calculation of a random number function, and generates a second random number, and the random number function includes at least SHA-1. Or a hash function consisting of MD5. Alternatively, the random number function includes at least a DES common key encryption function.
Preferably, the first random number includes a random number output by the random number calculation unit.
[0020]
Preferably, the random number generation means has a random number generator for generating an initial value, and the first random number includes an initial value generated by the random number generator.
The random number generator includes a true random number generation circuit.
[0021]
A random number generation method according to the present invention is a method of generating a random number by a random number generation device having a random number calculation unit that performs a calculation of a random number function and a storage unit that stores an executable processing program. A step of inputting a part of the data of the initialization area as at least a part of a first random number to the random number calculation unit, and a step of generating a second random number using the input first random number. Have.
Preferably, an executable processing program is stored in the storage unit, and a value of the first random number is stored in a non-initialized area of the storage unit when temporary data of the processing program being executed is stored. Is changed.
Preferably, the temporary data stored in the uninitialized area of the storage unit includes data input from outside.
Preferably, the first random number includes a random number output by the random number calculation unit.
[0022]
Preferably, the random number generation device includes a random number generator for generating an initial value, and the first random number includes an initial value generated by the random number generator.
Preferably, the random number function includes at least one of a hash function including SHA-1 and a hash function including MD5. Alternatively, the random number function includes at least a DES common key encryption function.
[0023]
According to the random number generation device of the present invention described above, when the first random number is input and the second random number is generated, the random number generation unit performs the non-initialization in the storage unit as part or all of the first random number. Read data from the area. Since the uninitialized area of the storage unit is not initialized (reset to zero) and is overwritten as needed, the data value of the uninitialized area is constantly changing. When the data in this area is input to the random number generation means, the input data is different each time, so that the random number sequence output from the random number generation means is a safe random number which is difficult to guess from the outside.
According to the random number generation method of the present invention described above, data is read from the non-initialized area of the storage unit as part or all of the input data of the random number calculation unit. Since the read data differs in each operation, the output random number sequence is a safe random number that is difficult to guess.
[0024]
BEST MODE FOR CARRYING OUT THE INVENTION
Next, an embodiment of a random number generation method and a random number generation device according to the present invention will be described in detail with reference to the accompanying drawings.
First embodiment
FIG. 1 is a diagram illustrating a schematic configuration of a random number calculation device according to the present embodiment.
In FIG. 1, a random number calculation device 10 includes, for example, a CPU 1, a random access memory (Random Access Memory: RAM) 2, a rewritable nonvolatile memory EEPROM 3, and a hash calculator 4.
[0025]
When the random number generation device 10 is started, the CPU 1 stores an operating system (operating @ system: OS) stored in the EEPROM 3, a system application program, or a user application program to be executed in the RAM 2. Read. When the random number generation device 10 operates normally, the CPU 1 sequentially interprets and executes a procedure described in an application program to be executed and a designated command. For example, when a command for generating a random number is executed in a digital signature routine, a random number is generated for a digital signature.
The data temporarily generated when the CPU 1 executes the program is written to a predetermined area of the RAM 2 as needed.
[0026]
The RAM 2, the EEPROM 3, and a read-only memory (ROM) (not shown) constitute a memory system of the random number generation device 10. Normally, the ROM stores an OS or a kernel section of the OS, and a system program operating on the OS, an application program for providing a service, and the like are arranged in the EEPROM 3.
The RAM 2 is a storage device directly accessed by the CPU 1. When the random number generation device 10 is started, the OS, system application programs, and the like stored in the EEPROM 3 are read into a predetermined address area of the RAM 2 by the CPU 1, and when the random number generation device 10 operates normally, The user application program to be executed is also read into a predetermined address of the RAM 2 by the CPU 1. Further, data temporarily generated when the CPU 1 executes various application programs is written into a predetermined area of the RAM 2 as needed.
Note that the CPU 1 and the RAM 2 may be separately mounted as in a personal computer.
The memory system of the random number generation device 10 described above corresponds to the “storage unit” in the claims of the present invention.
[0027]
The hash calculator 4 performs a hash operation on the input data, outputs data that is difficult to guess from the input data, and uses the data as a pseudo-random number. Since the hash function has one-way property, the result of the operation cannot be obtained from the input data, and a pseudo-random number having good decorrelation can be generated.
In FIG. 1, the means for performing the hash operation is implemented by hardware and constitutes the hash operation unit 4, but there is no problem if the software for the hash operation is implemented.
The hash calculator 4 corresponds to a “random number calculator” in the claims of the present invention.
The bus line 5 is connected to the CPU 1, the RAM 2, the EEPROM 3, and the hash calculator 4 in the random number generation device 10, and transmits data therebetween.
[0028]
FIG. 2 is a diagram showing an outline of the processing in the hash calculator 4 in the random number calculation device 10. As the hash function, for example, SHA-1, MD5, or DES function can be used. Here, as one specific example, an arithmetic process when the hash function H of SHA-1 is used will be described as an example. .
When the hash function H of SHA-1 is used, the data X input to the hash calculator 4 is 264This is a bit string having a length of less than a bit. Here, for example, the bit length of the input data is set to 512 bits. As shown in FIG. 2, the hash calculator 4 has a 512-bit input buffer 8.
[0029]
When generating a random number using the pseudo random number generation method, it is necessary to set an initial value each time a random number is generated. There are various methods for generating an initial value. In the present embodiment, a 32-bit initial value for generating a random number is generated using the current time held by the system, and an input value is generated as shown in FIG. Write to buffer 8. The area where the seed area is written in the input buffer 8 is called the seed area 7.
In the present embodiment, the “random number generating means” in the claims of the present invention corresponds to the hash calculator 4 and a part that generates the current time as an initial value.
Predetermined data is embedded in the remaining area of the input buffer 8 to become input data. For example, in the past, zero was embedded. In the present embodiment, the remaining area of the input buffer 8 is embedded by a method described later.
[0030]
The hash calculator 4 performs a hash calculation on the input data. For example, SHA-1 is used as the hash function. When the hash calculation is completed, for example, in the case of SHA-1, a 160-bit random number (bit string) Y is output. During the operation, the output random number of 160 bits is stored in the output data area 9 of the RAM 2, for example. When a random number having a long bit length is generated, the hash function is calculated by the number n determined by the number of bits of the target random number. The resulting 160-bit random numbers (bit strings) Y1, Y2... Yn are bit-connected, that is, converted into a bit string of Y1‖Y2‖. A target random number is extracted from the n × 160 bit string.
Here, the operator “x‖y” represents a combination of the bit string x and the bit string y, for example, (0110) ‖ (101) = 011010101.
For example, when a public key having a length of 2048 bits is generated in the public key cryptosystem of the RSA system, two random numbers having a length of 1024 bits are generated. Therefore, the hash calculator 4 performs the calculation seven times, generates a bit string having a length of 1120 bits, extracts 1024 bits from the bit string, and generates a first random number. Similarly, a second 1024-bit random number is generated.
[0031]
As described above, when the pattern of the hash calculation is determined, the output of the hash calculator 4 becomes constant for the same input data. In each hash calculation, different input data must be input to the hash calculator so that the random numbers Y1, Y2,... Yn do not become the same.
Conventionally, a 160-bit random number (for example, Y1) obtained by calculation is input to the input buffer 8, and the next hash value is calculated to obtain the next 160-bit random number (for example, Y2). In this manner, the target random number is generated by repeating the necessary number of times.
However, as described above, the random number sequence generated in this way depends on the operation pattern and the initial value. When the function used and the initial value are determined, the entire random number sequence is determined. Can be generated. When the initial value is 32 bits, the period of the pseudo random number is 2 at the maximum.32, The cycle is small, and there is a problem in safety.
In the present embodiment, in each hash calculation by a method described later, data that is difficult to guess is input to the hash calculator 4 to improve the security of random numbers.
[0032]
FIG. 3 is a diagram showing an arrangement of the storage area of the RAM 2 in the random number calculation device 10.
As shown in FIG. 3, for example, at least a stack area 11, a heap area 13, a static data area 14, and a code area 15 are allocated to a storage area of the RAM 2. An unused area 12 exists between the area 11 and the heap area 13.
[0033]
The stack area 11 is a memory area used as a data structure used as an area for temporarily storing data when the CPU 1 executes a program, that is, a so-called stack data structure. For example, when a function or a subroutine is called by a program, arguments, return addresses, and the like are temporarily stored in the stack area 11.
The stack data structure is a data structure of First \ In \ Last \ Out (FILO), and the data inserted last is taken out first.
[0034]
The heap area 13 is a memory area managed and used by the OS, and is used when the OS executes a program. The OS acquires the memory from the heap area 13 and provides it to the application, or loads and allocates a new program or a system program in this area. When managing the memory, the OS distinguishes between the heap area for the application and the heap area for the system, and the system heap is called the system heap. The function extension file is read here and the temporary data is stored in the heap area for the application. .
[0035]
The static data area 14 is a memory area for storing static data generated when a program is executed. Static data is a variable declared to have a value that does not change from the start to the end of execution when a program is executed. For example, when a program being executed calls a function or subroutine, the variables are temporarily stored in the static data area 14 so as not to change these variables.
The code area 15 is a memory area that stores the code body of a program that is read into the RAM 2 and executed.
[0036]
The stack area 11 and the heap area 13 are usually work RAM areas of the CPU 1, and various applications temporarily use these areas.
When the use process is completed, the area is released. However, since the area is not initialized and overwritten as needed, the value of the data in this area changes as needed. Hereinafter, these areas are referred to as “non-initialized areas” of the RAM 2.
In the present embodiment, the input buffer 8 shown in FIG.
[0037]
FIG. 4 is a diagram illustrating an example in which the input buffer of the hash calculator 4 is provided in a non-initialized area of the RAM 2 in the random number calculation device 10 according to the present embodiment.
As shown in FIG. 4, for example, a 512-bit area indicated by a dotted line in the stack area 11 is secured as the input buffer 8 of the hash calculator 4. The area indicated by reference numeral 11b is an area in which temporary data output by the program being executed is stored, and thereby the value of the 512-bit memory area serving as the input buffer 8 is rewritten.
As in FIG. 2, at the time of the first hash calculation, for example, a 32-bit initial value separately generated is written to the seed area 7 in the input buffer 8.
[0038]
As described above, the input buffer 8 secured in the non-initialized area is temporarily used by various applications, is overwritten as needed, and is not initialized to zero, so that the hash operation is started with a constant initial value. However, the value input to the hash calculator 4 is completely different every time including the first time. In this way, even if the initial value of 32 bits is used, since unpredictable data is embedded in the input buffer 8, the change range of the input data is substantially expanded to 512 bits, and the bit length of the initial value ( 32 bits). Thus, the period of the obtained pseudo-random number is 232It is a larger random number that is difficult to guess from outside.
In addition, a dedicated circuit other than the hash calculator 4 is not required, and it can be easily realized.
[0039]
FIG. 5 is a flowchart illustrating a process of generating random numbers in the random number calculation device 10 of the present embodiment.
Step S1:
A 512-bit input buffer 8 for input to the hash calculator 4 is secured in the uninitialized area on the RAM 2, that is, in the stack area 11 or the heap area 13, as shown in FIG. That is, it is declared that data is read from this area.
Step S2:
A 32-bit initial value for generating a random number is generated. In the present embodiment, for example, an initial value is generated using the current time held by the system, and the 32-bit initial value is written in the seed area 7 in the input buffer 8.
[0040]
Step S3:
Subsequently, the hash calculator 4 reads the input data from the 512-bit input buffer 8 and performs a hash calculation.
Only when the power of the random number generation device 10 is reset, the non-initialization area such as the stack area 11 and the heap area 13 is initialized to zero. The entire area becomes zero, and the first hash calculation result depends on the initial value. In order to avoid such a situation, first, a hash operation is performed using a separately generated initial value.
The details of the hash calculation will be described later in detail.
[0041]
Step S4:
As a result of performing the hash operation, for example, in the case of SHA-1, a bit string of 160 bits is extracted as a random number from the hash value.
Step S5:
A plurality of random numbers generated so far are combined to determine whether or not the bit length of the target random number is reached.
If the bit length of the combined bit string is greater than or equal to the bit length of the target random number, the process proceeds to step S7.
If the bit length of the combined bit string is equal to or less than the bit length of the target random number, the process proceeds to step S6.
[0042]
Step S6:
For the reason described in step S3, the obtained 160-bit random number value is input to the input buffer 8 as in the related art, the process returns to step S3, and the hash calculation and the next , Extraction of the 160-bit random number value, combination of all the 160-bit random numbers obtained so far, and determination as to whether the combined random number has reached a required bit length.
When returning to step S3, since the data generated by the program executed by the random number generation device 10 is temporarily stored in the uninitialized area of the RAM 2, the input buffer 8 has already been rewritten. That is, returning to step S3, when performing the next hash operation, the value of the input buffer 8 is completely different from the value of the previous input buffer 8, and the next 160-bit random number that cannot be predicted from the previous 160-bit random number is calculated. Can be generated.
Step S7:
If the bit length of the combined bit string is greater than or equal to the bit length of the target random number, the target random number is extracted from the bit length of the combined bit string, and the target random number is obtained, and the random number generation processing is performed. To end.
[0043]
Next, details of the hash calculation in the hash calculation circuit 4 will be described with reference to FIGS. In the following description, the SHA-1 hash function will be described as an example.
FIG. 6A shows the data structure of the input buffer 8 of the hash calculation circuit 4. FIG. 6B illustrates each buffer that executes a hash operation in the hash operation circuit 4.
The input buffer 8 shown in FIG. 6A is composed of 16 long words (32 bits) W0, W1,... W15, that is, the buffer size of the input buffer 8 is 512 bits. The input buffer 8 is provided in a non-initialized area on the RAM 2, that is, in the stack area 11 or the heap area 13 as shown in FIG. The 32-bit initial value generated separately is input to, for example, the long word W10 of the input buffer 8.
[0044]
The hash operation circuit 4 has two 5-word buffers for executing the operation. As shown in FIG. 6B, the first buffer includes five 32-bit registers A, B, C, D, and E, and the second buffer includes five 32-bit registers H0, H1, H2, H3 and H4. In addition, data is temporarily stored in a one-word buffer including the register TEMP when an operation is performed.
Before starting the operation, the registers H0, H1, H2, H3, H4 are initialized in advance, as shown in FIG. After initialization, the values of the registers H0, H1, H2, H3, H4 are as follows in hexadecimal:
H0 = 67452301h,
H1 = EFCDAB89h,
H2 = 98BADCFEh,
H3 = 10325476h,
H4 = C3D2E1F0h.
[0045]
As shown in FIG. 6A, an initial value is input to W10 of the input buffer 8, and a hash operation is started. A single hash operation is performed on input data read from the input buffer 8 at one time. This one hash operation is performed in 80 steps.
FIGS. 7A and 7B show the contents of the operation in step 1 in the hash operation.
As shown in FIG. 7A, in step 1 of the hash calculation, first, the initial values in the registers H0, H1, H2, H3, and H4 given in advance are stored in the registers A, B, C, D, and E. (Referred to as STEP 1-1).
As shown in FIG. 7B, a variable W having a value determined in each operation step, a value A 値 5 obtained by rotating the value of the register A left by 5 bits, a value of the register E, an addition constant The K value and the value of the function f are added in bit units, and 232Is transferred to the register TEMP and set as the value of TEMP (denoted as STEP1-2).
The bit rotation operation “S≪n” for the variable S represents an operation of shifting the variable S by n bits to the left and assigning the overflowing upper n bits to the lower n bits from the least significant bit. Taking an 8-bit numerical value as an example, assuming that S = 1001 1011b and calculating S≪2, S≪2 = 0110 1110b.
Therefore, A≪5 is a value in which A is shifted to the left by 5 bits, and the overflowing upper 5 bits are assigned to the lower 5 bits.
[0046]
FIGS. 8A to 8C are diagrams showing definitions of the variable W, the addition constant K, and the function f in STEP1-2.
As shown in FIG. 8A, in each step of the hash calculation, the value of the variable W is determined using the input data W0 to W15 of the input buffer 8.
Specifically, in steps 1 to 15 of the hash operation, the values of W are the input data W0 to W15 of the input buffer 8 as they are.
From step 16, the value of W is determined by calculation using W0 to W15 as in the definition shown in FIG.
That is, in step 16, the value of W is obtained by rotating one bit to the left after the exclusive OR operation (xor) in bit units of W0, W2, W8, and W13.
In step 17, the same operation is performed on W1, W3, W9, and W14 to determine the value of W.
In step 18, the same operation is performed on W2, W4, W10, and W15 to determine the value of W.
W is defined in steps 19 to 80 in a similar manner. For example, in step 80, the value of W is obtained by performing a bitwise exclusive OR operation (xor) of W63, W65, W71, and W76, followed by one bit rotation to the left.
[0047]
As shown in FIG. 8B, the value of each step of the addition constant K is predetermined. Specifically, the value of K is as follows in hexadecimal.
In step 1 to step 20, K = 5A829999h,
In steps 21 to 40, K = 6ED9EBA1h,
In steps 41 to 60, K = 8F1BCDCh,
In steps 61 to 80, K = CA62C1D6h.
[0048]
As shown in FIG. 8C, in each step of the hash calculation, the value of the function f is determined using the values of the registers B, C, and D.
Step 1 to Step 20
f = (B and C) or ((not B) and D),
In steps 21 to 40,
f = B xor C xor D,
In steps 41 to 60,
f = (B and C) or (B and D) or (C and D),
In steps 61 to 80,
f = B xor C xor D.
Here, “and”, “or”, and “not” represent bit-wise logical product, logical sum, and inversion operation, respectively.
[0049]
FIGS. 9A and 9B show the content of the operation of step 1 in the hash operation, following FIG.
As shown in FIG. 9A, following FIG. 7B, the value of the register D is transferred to the register E, the value of the register C is transferred to the register D, and the value of the register B is transferred to the register C. The value rotated 30 bits to the left is transferred, the value of register A is transferred to register B, the value of TEMP is transferred to register A, and the values of registers A to E are updated (described as STEP1-3). .
[0050]
Subsequently, as shown in FIG. 9B, the value of the register A is added to the register H0 to obtain H0, the value of the register B is added to the register H1 to obtain H1, and the value of the register C is added to the register H2. Then, the value of the register D is added to the register H3 to obtain H3, the value of the register E is added to the register H4 to obtain H4, and the values of the registers H1, H2, H3, H4, and H5 are updated (STEP 1). -4).
[0051]
Each register is updated one after another with the above-mentioned STEP1-1 to STEP1 as one step, and this is repeated for 80 steps.
As an example, FIGS. 10A and 10B show a part of Step 2 (STEP 2-1) and a part of Step 80 (STEP 80-4).
As shown in FIG. 10A, in step 2-1 similarly to STEP 1-1, each of the registers H0, H1, H2, H3, and H4 updated in step 1 is set as an initial value and the register A , B, C, D, and E.
Then, the same operation contents as STEP1-2 to STEP1-4 are executed as STEP2-2 to STEP2-4, and the values of the registers H1, H2, H3, H4, and H5 are further updated.
As described above, the contents of the operation similar to STEP1-2 to STEP1-4 are repeated from step 3 to step 80, and each register is updated one after another.
Finally, as shown in FIG. 10 (b), in step 80-4, similarly to STEP1-4, each value of the registers H0, H1, H2, H3, H4 updated in step 79 is added to the register A, The values of the registers H1, H2, H3, H4, and H5 are updated by adding the values of B, C, D, and E, respectively.
[0052]
FIGS. 11A and 11B show the content of the hash operation following FIG.
In step 80-4, five 32-bit bit strings H0 to H4 are finally obtained. As shown in FIG. 11A, the bit strings H0 to H4 are combined, that is, H0‖H1‖H2‖H3‖H4, and the obtained bit string of 5 × 32 bits = 160 bits is subjected to a hash operation result (hash operation). Value).
The hash value thus obtained is an algorithm that can obtain a completely different result if the value of the word W0 to W15 in the input buffer 8 changes even by one bit, and is a random number value.
[0053]
As shown in FIG. 11B, the 160-bit random value obtained as described above is input to, for example, W0 to W4 of the input buffer 8, and a hash operation is performed again, and the next 160-bit random number is output. A numerical value is obtained. This is repeated until a random number with the required number of digits is obtained, to generate a pseudo random number.
As described above, the input buffer 8 is provided in the stack area 11 on the RAM 2 or in the uninitialized area such as the heap area 13, so that the random number generation is performed during the above-described hash calculation. All programs running on the device 10 overwrite the uninitialized area including the input buffer 8. As a result, it is highly likely that the values of the 16 words W0 to W15 of the input buffer 8 have already been updated at the time when the calculation of 80 steps is completed.
As described above, W0 to W15 all become zero by resetting the power supply. Further, the update of the 16 words W0 to W15 of the input buffer 8 may be small.
In order to avoid such a situation, the 160-bit random value obtained each time is input to the input buffer 8 again, and the hash calculation is repeated.
[0054]
According to the above-described embodiment, when a random number is generated by hash calculation from the data in the input buffer, the input buffer is not initialized, such as the stack area or the heap area of the RAM, and is not overwritten as needed. Since the input data of the hash operation is different every time by being set in the initialization area, it is difficult to externally estimate the result of the hash operation from the initial value.
Even if the initial value has a short bit length, the input buffer 8 embeds a value which is not at all predictable, not zero, so that the change range of the input data is substantially expanded to 512 bits, and the obtained pseudo random number is obtained. Cycle is 232It is a larger random number that is difficult to guess from outside. It is not necessary to store the seed value in a nonvolatile memory such as an EEPROM.
In addition, it is possible to easily realize this without requiring a dedicated circuit.
[0055]
Second embodiment
In the present embodiment, another embodiment of the random number generation device according to the present invention will be described.
FIG. 12 is a diagram illustrating a schematic configuration of a random number calculation device according to the present embodiment. In FIG. 12, the same components as those of the first embodiment are denoted by the same reference numerals, and duplicate description will be appropriately omitted.
In FIG. 12, the random number calculation device 30 includes, for example, a CPU 1, a random access memory (RAM) 2, a rewritable nonvolatile memory EEPROM 3, a hash calculator 4, and a true random number generation circuit 31.
In the present embodiment, the input buffer 8 of the hash calculator 4 is designated to the stack area 11 or the heap area 13 of the RAM 2 as in the first embodiment. As a result, the input data of the hash calculator 4 becomes different every time, and it is difficult to estimate from outside.
[0056]
Intrinsic random numbers are random numbers generated using physical means. For example, a method of generating a random number using thermal noise of a resistor is used. The thermal noise of the resistor is obtained by synthesizing a minute current generated by a large number of electrons. Since the collision and scattering of each electron are generated independently, the noise is generated uniformly. A small noise voltage generated at both ends of the high resistance is amplified by a high impedance, low noise amplifier to obtain a noise voltage, and the voltage is converted into digital data by an A / D converter and input to a personal computer. By performing processes such as the rejection method and the combining method, the properties of random numbers can be improved, and appropriate random numbers can be obtained.
Since this method uses physical properties, the probability of occurrence of 0s and 1s is about half each, and since each bit is independent of other parts, it is difficult to estimate the generated random number sequence. Yes, a random number sequence suitable for security use can be obtained. However, since it takes time to generate random numbers, the processing speed is not sufficient, especially when the data length is increased to increase the degree of security.
[0057]
In the first embodiment, the current time held by the system is used as a 32-bit initial value for generating a random number.
In the present embodiment, since the input buffer 8 for the hash calculation is provided in the non-initialized area of the RAM 2, the initial value can be a small number of bits. For example, 32 bits is sufficient. Therefore, for example, when the true random number generation circuit 31 shown in FIG. 12 is mounted on the random number generation device 30, the initial value of the hash operation is set to the true random number.
In addition, a true random number generation circuit 31 having a slow operation is mounted on the random number generation device 30 and is used as a hash value calculation input every time a true random number is generated. If the calculation result of the value is used, a pseudorandom number having a long periodicity can be obtained at high speed.
In the present embodiment, the “random number generation means” in the claims corresponds to the hash calculator 4 and the true random number generation circuit 31.
[0058]
FIG. 13 is a flowchart illustrating a process of generating a random number in the random number calculation device 30 of the present embodiment.
Step S11:
A 512-bit input buffer 8 for input to the hash calculator 4 is secured in the uninitialized area on the RAM 2, that is, in the stack area 11 or the heap area 13 as shown in FIG.
Step S12:
A 32-bit initial value for generating a random number is generated. In the present embodiment, a random number, which is an initial value of the hash calculation, is generated by the true random number generation circuit 31 and written into the seed area 7 in the input buffer 8.
For example, a method of generating a random number by uniformly generating thermal noise of a resistor is used.
A small noise voltage generated at both ends of the high resistance is amplified by a high impedance, low noise amplifier to obtain a noise voltage, which is converted into digital data by an A / D converter and input to a personal computer, For example, a 32-bit random number is extracted.
[0059]
Step S13:
Subsequently, the hash calculator 4 reads the input data from the 512-bit input buffer 8 and executes the hash calculation as shown in FIGS.
Only when the power of the random number generation device 10 is reset, the non-initialization area such as the stack area 11 or the heap area 13 is initialized to zero. A hash operation is performed using the initial value.
[0060]
Step S14:
As a result of the hash operation, for example, in the case of SHA-1, a bit string of 160 bits is extracted as a random number from the hash value.
Step S15:
A plurality of 160-bit random numbers generated by the previous hash calculation are combined, and it is determined whether or not the target random number has the bit length.
If the bit length of the combined bit string is equal to or greater than the bit length of the target random number, the process proceeds to step S18.
If the bit length of the combined bit string is equal to or less than the bit length of the target random number, the process proceeds to step S16.
[0061]
Step S16:
The true random number generation circuit 31 determines whether a true random number seed has been generated,
If the true random number generation circuit 31 has already generated the true random number seed, for example, the 32-bit random number value is input to the input buffer 8, the process returns to step S13, and through steps S13 to S15, the hash calculation and the next The extraction of the 160-bit random number value, the combination of all 160-bit random numbers obtained so far, and the determination as to whether the combined random number has reached the required bit length are repeated.
When returning to step S13, since the data generated by the program executed by the random number generation device 30 is temporarily stored in the uninitialized area of the RAM 2, the input buffer 8 has already been rewritten. That is, returning to step S13, when performing the next hash operation, the value of the input buffer 8 is completely different from the value of the previous input buffer 8, and the next 160-bit random number that cannot be predicted from the previous 160-bit random number is calculated. Can be generated.
If the true random number seed has not been generated, the process proceeds to step S17.
[0062]
Step S17:
If a true random number seed has not been generated, the 160-bit random number value obtained in the previous hash calculation is input to the input buffer 8. Then, returning to step S13, through steps S13 to S15, the hash calculation, the extraction of the next 160-bit random number value, the combination of all the 160-bit random numbers obtained so far, and the combined random number are necessary. The determination as to whether the bit length has been reached is repeated.
Similarly, when the process returns to step S13, the input buffer 8 is rewritten, so that at the time of the next hash operation, the value of the input buffer 8 is completely different from the value of the previous input buffer 8, and Unpredictable random numbers can be generated from random numbers.
Step S18:
If the bit length of the combined bit string is greater than or equal to the bit length of the target random number, the target random number is extracted from the bit length of the combined bit string, and the target random number is obtained, and the random number generation processing is performed. To end.
[0063]
According to the above-described embodiment, when a random number is generated by hash calculation from the data in the input buffer, the input buffer is placed in a non-initialized area such as a stack area or a heap area of the RAM, so that Since the input data of the calculation is different each time, it is difficult to externally estimate the result of the hash calculation from the initial value.
Even if the initial value has a short bit length, the input buffer 8 embeds a value which is not at all predictable, not zero, so that the change range of the input data is substantially expanded to 512 bits, and the obtained pseudo random number is obtained. Cycle is 232It is a larger random number that is difficult to guess from outside. Further, it is not necessary to store the seed value in a nonvolatile memory such as an EEPROM.
In addition, by installing a slow-acting true random number generation circuit in the random number generation device and using it as a hash value calculation input every time a true random number is generated, and using a hash value calculation result when not generated, Pseudo random numbers with higher security and long periodicity can be obtained at high speed.
[0064]
Third embodiment
In the present embodiment, another embodiment of the random number generation device according to the present invention will be described.
FIG. 14 is a diagram illustrating a schematic configuration of a random number calculation device according to the present embodiment. In FIG. 14, the same components as those in the first embodiment are denoted by the same reference numerals, and duplicate description will be appropriately omitted.
14, a random number calculation device 40 includes, for example, a CPU 1, a random access memory (RAM) 2, a rewritable nonvolatile memory EEPROM 3, a hash calculator 4, an interface (I / F) 41, and an external computer 42. Have.
In the present embodiment, the input buffer 8 of the hash calculator 4 is designated to the stack area 11 or the heap area 13 of the RAM 2 as in the first embodiment. This makes the input data of the hash calculator 4 different every time, making it difficult to estimate the generated random number sequence from the initial value.
In the present embodiment, the current time held by the system is used as an initial value for generating a random number.
In the present embodiment, the “random number generating means” in the claims corresponds to the hash calculator 4 and a part that generates the current time as an initial value.
[0065]
The external computer 42 is, for example, a host computer in a communication system that performs electronic money, music distribution over the Internet, personal services using a mobile phone and an ID card, using public key encryption and common key encryption. is there. The external computer 42 uses the random numbers generated by the random number generation device 40 to create a password, create a key value used for encryption, generate a ciphertext, generate digital signature information, and the like.
The I / F 41 transmits and receives between the random number generation device 40 and the external computer 42, outputs a command received from the external computer 42 to the CPU 1, and transmits a signal input from the CPU 1 to the external computer 42. For example, the I / F 41 transmits an instruction, data, and the like from the external computer 42 to the random number generation device 40, or transmits a calculation result from the random number generation device 40 to the external computer 42.
The CPU 1 reads a program stored in the EEPROM 3 into the RAM 2 based on a command from the external computer 42 or a command previously set in the random number generation device 40, sequentially decodes and executes the program, and generates a random number.
[0066]
When the random number generation device 40 transmits and receives data to and from the external computer 42, and the received data is executed by a program stored in the EEPROM 3, the random number generation device 40 arranges the received data in a non-initialized area of the RAM 2 by the program. As a result, in the random number generation device 40, the range of data input to the input buffer 8 of the hash calculator 4 is widened, the cycle of the random numbers generated by the hash calculator 4 is further expanded, and a 32-bit initial value is used. 2160Cycle.
[0067]
FIG. 15 is a flowchart illustrating a process of generating a random number in the random number calculation device 40 of the present embodiment.
Step S21:
The random number generation device 40 communicates with the external computer 42 to transmit and receive data, and the random number generation device 40 starts calculating a random number. In particular, in the random number generation device 40, data received from the external computer 42 is written into a non-initialized area of the RAM 2 by an executing program.
[0068]
Step S22:
A 512-bit input buffer 8 for input to the hash calculator 4 is secured in the uninitialized area on the RAM 2, that is, in the stack area 11 or the heap area 13 as shown in FIG.
Step S23:
A 32-bit initial value for generating a random number is generated. In the present embodiment, an initial value is generated using the current time held by the system, and the 32-bit initial value is written in the seed area 7 in the input buffer 8.
[0069]
Step S24:
Subsequently, the hash calculator 4 reads the input data from the 512-bit input buffer 8 and executes the hash calculation as shown in FIGS.
Step S25:
As a result of the hash operation, for example, in the case of SHA-1, a bit string of 160 bits is extracted as a random number from the hash value.
Step S26:
A plurality of 160-bit random numbers generated by the previous hash calculation are combined, and it is determined whether or not the target random number has the bit length.
If the bit length of the combined bit string is equal to or greater than the bit length of the target random number, the process proceeds to step S28.
If the bit length of the combined bit string is equal to or less than the bit length of the target random number, the process proceeds to step S27.
[0070]
Step S27:
The 160-bit random value obtained in the previous hash calculation is input to the input buffer 8. Then, returning to step S24, through steps S24 to S26, the hash calculation, the extraction of the next 160-bit random number value, the combination of all the 160-bit random numbers obtained so far, and the combined random number are necessary. The determination as to whether the bit length has been reached is repeated.
When the process returns to step S24, since the data generated by the program executed by the random number generation device 40 is temporarily stored in the uninitialized area of the RAM 2, the input buffer 8 has already been rewritten. That is, returning to step S24, when performing the next hash operation, the value of the input buffer 8 is completely different from the value of the previous input buffer 8, and the next 160-bit random number that cannot be predicted from the previous 160-bit random number is calculated. Can be generated.
In particular, in the present embodiment, the data received by the random number generation device 40 from the external computer 42 is also written into the non-initialized area of the RAM 2 by the program being executed, so that the range of data input to the input buffer 8 is even wider. Become. Thereby, the cycle of the generated random numbers is expanded.
[0071]
Step S28:
If the bit length of the combined bit string is greater than or equal to the bit length of the target random number, the target random number is extracted from the bit length of the combined bit string, and the target random number is obtained, and the random number generation processing is performed. To end.
Step S29:
After obtaining the random number, the random number generation device 40 transmits the obtained random number to the external computer 42. Then, the communication between the random number generation device 40 and the external computer 42 ends.
[0072]
According to the above-described embodiment, when a random number is generated by hash calculation from the data in the input buffer, the input buffer is placed in a non-initialized area such as a stack area or a heap area of the RAM, so that Since the input data of the calculation is different each time, it is difficult to externally estimate the result of the hash calculation from the initial value.
Even if the initial value has a short bit length, the input buffer embeds a completely unpredictable value, not zero, in the input buffer. Therefore, the change range of the input data is substantially expanded to 512 bits, and the obtained pseudo random number Period is 232It is a larger random number that is difficult to guess from outside. It is not necessary to store the seed value in a nonvolatile memory such as an EEPROM.
Further, since the data received from the external computer by the random number generation device is also arranged in the uninitialized area of the RAM, the range of the data input to the input buffer is widened, and the cycle of the generated random number is further expanded to 32 bits. Using the initial value of160Cycle can be approached.
Thus, pseudorandom numbers with higher security and long periodicity can be obtained at high speed.
[0073]
As described above, the present invention has been described based on the preferred embodiments. However, the present invention is not limited to the above-described embodiments, and various modifications can be made without departing from the gist of the present invention.
For example, the configuration of the random number generation device in the above embodiment is an example, and other configurations may be used as long as the effects of the present invention can be obtained.
In addition, although SHA-1 is mainly used as an example of the hash function in the above embodiment, it is apparent that the present invention can be applied to a case where another hash function is used.
Although the stack area and the heap area are used as an example of the uninitialized area of the RAM, other memory areas may be used as long as they do not hinder the execution of other programs and change as needed. .
[0074]
【The invention's effect】
According to the random number generation method and the random number generation device of the present invention described above, by arranging the input buffer of the hash calculation in the non-initialized area of the storage unit, the input data of the hash calculation changes as needed, and the Since the values are different, it is difficult to externally estimate the result of the hash operation from the initial value.
As a result, even if the initial value has a short bit length, an unpredictable value is embedded in the input buffer 8, so that the range of change of the input data is substantially expanded, the period of the obtained random number is increased, and the estimation is made. It becomes more difficult and secure random numbers can be generated.
Furthermore, it can be easily realized without requiring a dedicated circuit.
When a true random number generation circuit is mounted, each time a true random number is generated, it is used as a hash value calculation input, and when it is not generated, the hash value calculation result is used to further enhance security. Thus, pseudorandom numbers having a long periodicity can be obtained at high speed.
Also, if the data received from the external computer by the random number generation device is also arranged in the uninitialized area of the RAM, the range of the data input to the input buffer is widened, and the cycle of the generated random numbers is further expanded.
Therefore, according to the present invention, a highly secure long-period pseudo-random number required for generating a digital signature, various public keys, and a common key can be obtained easily and at high speed.
[Brief description of the drawings]
FIG. 1 is a diagram illustrating a schematic configuration of a random number calculation device according to a first embodiment of the present invention.
FIG. 2 is a diagram illustrating an outline of processing in a hash calculator in the random number calculation device according to the first embodiment of the present invention.
FIG. 3 is a diagram showing an arrangement of storage areas of a memory in the random number calculation device according to the first embodiment of the present invention.
FIG. 4 is a diagram illustrating an example in which an input buffer of a hash calculator is provided in a memory in the random number calculation device according to the first embodiment of the present invention.
FIG. 5 is a flowchart illustrating a process of generating a random number in the random number calculation device according to the first embodiment of the present invention.
FIG. 6 is a diagram illustrating a calculation process in a hash calculator in the random number calculation device according to the first embodiment of the present invention.
FIG. 7 is a diagram showing a calculation process in the hash calculator in the random number calculation device according to the first embodiment of the present invention, following FIG. 6;
FIG. 8 is a diagram showing a calculation process in the hash calculator in the random number calculation device according to the first embodiment of the present invention, following FIG. 7;
FIG. 9 is a diagram illustrating a calculation process in the hash calculator in the random number calculation device according to the first embodiment of the present invention, following FIG. 8;
FIG. 10 is a diagram showing a calculation process in the hash calculator in the random number calculation device according to the first embodiment of the present invention, following FIG. 9;
FIG. 11 is a diagram showing a calculation process in the hash calculator in the random number calculation device according to the first embodiment of the present invention, following FIG. 10;
FIG. 12 is a diagram illustrating a schematic configuration of a random number calculation device according to a second embodiment of the present invention.
FIG. 13 is a flowchart illustrating a process of generating a random number in the random number calculation device according to the second embodiment of the present invention.
FIG. 14 is a diagram illustrating a schematic configuration of a random number calculation device according to a third embodiment of the present invention.
FIG. 15 is a flowchart illustrating a process of generating a random number in the random number calculation device according to the third embodiment of the present invention.
[Explanation of symbols]
DESCRIPTION OF SYMBOLS 1 ... CPU, 2 ... RAM, 3 ... EEPROM, 4 ... Hash arithmetic unit, 5 ... Bus line, 7 ... Seed area, 8 ... Input buffer, 9 ... Output buffer, 10 ... Random number generator, 11 ... Stack area, 11b: temporary data storage area, 12: unused area, 13: heap area, 14: static data area, 15: code area, 30: random number generator, 31: true random number generation circuit, 40: random number generation Device, 41 interface, 42 external computer.

Claims (16)

第1の乱数を入力し、第2の乱数を生成する乱数生成手段と、
記憶部と
を有し、
前記乱数生成手段は、前記第1の乱数の少なくとも一部として、前記記憶部における初期化されない領域である非初期化領域の一部のデータを入力する
乱数生成装置。
Random number generation means for inputting a first random number and generating a second random number;
A storage unit,
The random number generation device, wherein the random number generation unit inputs, as at least a part of the first random number, data of a part of a non-initialized area that is an uninitialized area in the storage unit.
前記記憶部に、実行可能な処理プログラムが格納されており、
実行中の前記処理プログラムから出力された一時データが、前記記憶部の非初期化領域に保存された時に、前記第1の乱数の値は変更される
請求項1に記載の乱数生成装置。
An executable processing program is stored in the storage unit,
The random number generation device according to claim 1, wherein the value of the first random number is changed when temporary data output from the processing program being executed is stored in a non-initialized area of the storage unit.
外部装置と通信するインタフェースを有し、
前記インタフェースを介して、前記外部装置からのデータが前記記憶部に格納され、
前記記憶部の非初期化領域に保存される一時データは、前記外部装置からのデータを含む
請求項2に記載の乱数生成装置。
Has an interface to communicate with external devices,
Via the interface, data from the external device is stored in the storage unit,
3. The random number generation device according to claim 2, wherein the temporary data stored in the non-initialized area of the storage unit includes data from the external device.
前記乱数生成手段は、前記第1の乱数を入力し、乱数関数の演算を行ない、第2の乱数を生成する乱数演算部を有する
請求項1に記載の乱数生成装置。
The random number generation device according to claim 1, wherein the random number generation unit includes a random number calculation unit that receives the first random number, performs a calculation of a random number function, and generates a second random number.
前記乱数関数は、少なくともSHA−1からなるハッシュ関数、または、MD5からなるハッシュ関数のいずれかを含む
請求項4に記載の乱数生成装置。
The random number generation device according to claim 4, wherein the random number function includes at least one of a hash function composed of SHA-1 and a hash function composed of MD5.
前記乱数関数は、少なくとも、DES共通鍵暗号関数を含む
請求項4に記載の乱数生成装置。
The random number generation device according to claim 4, wherein the random number function includes at least a DES common key encryption function.
前記第1の乱数は、前記乱数演算部が出力した乱数を含む
請求項4に記載の乱数生成装置。
The random number generation device according to claim 4, wherein the first random number includes a random number output by the random number calculation unit.
前記乱数生成手段は、初期値を生成する乱数発生器を有し、
前記第1の乱数は、前記乱数発生器が生成した初期値を含む
請求項1に記載の乱数生成装置。
The random number generation means has a random number generator for generating an initial value,
The random number generation device according to claim 1, wherein the first random number includes an initial value generated by the random number generator.
前記乱数発生器は、真性乱数発生回路を含む
請求項8に記載の乱数生成装置。
9. The random number generation device according to claim 8, wherein the random number generator includes a true random number generation circuit.
乱数関数の演算を行なう乱数演算部と、記憶部とを有する乱数生成装置により乱数を生成する方法であって、
前記記憶部の非初期化領域の一部のデータを、第1の乱数の少なくとも一部として前記乱数演算部に入力する工程と、
前記入力された第1の乱数を用い、第2の乱数を生成する工程と
を有する
乱数生成方法。
A method of generating a random number by a random number generation unit having a random number calculation unit that performs a calculation of a random number function and a storage unit,
Inputting a part of the data of the uninitialized area of the storage unit to the random number calculation unit as at least a part of a first random number;
Generating a second random number using the input first random number.
前記記憶部に実行可能な処理プログラムが格納されており、
前記記憶部の非初期化領域には、実行中の前記処理プログラムの一時データを保存した時に、前記第1の乱数の値は変更される
請求項10に記載の乱数生成方法。
An executable processing program is stored in the storage unit,
The random number generation method according to claim 10, wherein the value of the first random number is changed when temporary data of the processing program being executed is stored in a non-initialized area of the storage unit.
前記記憶部の非初期化領域に保存される一時データは、外部から入力されたデータを含む
請求項10に記載の乱数生成方法。
The random number generation method according to claim 10, wherein the temporary data stored in the uninitialized area of the storage unit includes data input from outside.
前記第1の乱数は、前記乱数演算部が出力した乱数を含む
請求項10に記載の乱数生成方法。
The random number generation method according to claim 10, wherein the first random number includes a random number output by the random number calculation unit.
前記乱数生成装置は、初期値を生成する乱数発生器を含み、
前記第1の乱数は、前記乱数発生器が生成した初期値を含む
請求項10に記載の乱数生成方法。
The random number generation device includes a random number generator that generates an initial value,
The random number generation method according to claim 10, wherein the first random number includes an initial value generated by the random number generator.
前記乱数関数は、少なくともSHA−1からなるハッシュ関数、または、MD5からなるハッシュ関数のいずれかを含む
請求項10に記載の乱数生成方法。
The random number generation method according to claim 10, wherein the random number function includes at least one of a hash function composed of SHA-1 and a hash function composed of MD5.
前記乱数関数は、少なくとも、DES共通鍵暗号関数を含む
請求項10に記載の乱数生成方法。
The random number generation method according to claim 10, wherein the random number function includes at least a DES common key encryption function.
JP2002271214A 2002-09-18 2002-09-18 Method and apparatus for generating random number Pending JP2004109420A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2002271214A JP2004109420A (en) 2002-09-18 2002-09-18 Method and apparatus for generating random number

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2002271214A JP2004109420A (en) 2002-09-18 2002-09-18 Method and apparatus for generating random number

Publications (1)

Publication Number Publication Date
JP2004109420A true JP2004109420A (en) 2004-04-08

Family

ID=32268598

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2002271214A Pending JP2004109420A (en) 2002-09-18 2002-09-18 Method and apparatus for generating random number

Country Status (1)

Country Link
JP (1) JP2004109420A (en)

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007011579A (en) * 2005-06-29 2007-01-18 Canon Inc Random number generation device and random number generation method
WO2009064002A1 (en) * 2007-11-12 2009-05-22 Osamu Kameda System for safely transmitting and/or managing file
JP2015212804A (en) * 2014-03-27 2015-11-26 インテル・コーポレーション Method and apparatus for efficiently executing hash operations
US10038550B2 (en) 2013-08-08 2018-07-31 Intel Corporation Instruction and logic to provide a secure cipher hash round functionality
US10148428B2 (en) 2012-12-29 2018-12-04 Intel Corporation Instruction and logic to provide SIMD secure hashing round slice functionality
JP2019054466A (en) * 2017-09-15 2019-04-04 株式会社 エヌティーアイ Communication system, first communication device, second communication device, method, and computer program
US10503510B2 (en) 2013-12-27 2019-12-10 Intel Corporation SM3 hash function message expansion processors, methods, systems, and instructions
US10592245B2 (en) 2014-09-26 2020-03-17 Intel Corporation Instructions and logic to provide SIMD SM3 cryptographic hashing functionality
US10623175B2 (en) 2014-09-04 2020-04-14 Intel Corporation SM3 hash algorithm acceleration processors, methods, systems, and instructions
KR20200044685A (en) 2018-10-19 2020-04-29 가부시키가이샤 코쿠사이 엘렉트릭 Substrate processing apparatus and method of manufacturing semiconductor device
CN111708513A (en) * 2020-05-15 2020-09-25 深圳和而泰智能家电控制器有限公司 Pseudo-random number seed generation method and related product
CN115051798A (en) * 2022-06-10 2022-09-13 北京海泰方圆科技股份有限公司 Random number generation method and device, electronic equipment and storage medium
KR102649847B1 (en) * 2023-10-06 2024-03-21 위더맥스(주) Apparatus and method for generating random numbers using stack/heap area of mcu

Cited By (21)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4546339B2 (en) * 2005-06-29 2010-09-15 キヤノン株式会社 Random number generation apparatus and random number generation method
JP2007011579A (en) * 2005-06-29 2007-01-18 Canon Inc Random number generation device and random number generation method
WO2009064002A1 (en) * 2007-11-12 2009-05-22 Osamu Kameda System for safely transmitting and/or managing file
US10148428B2 (en) 2012-12-29 2018-12-04 Intel Corporation Instruction and logic to provide SIMD secure hashing round slice functionality
US10686591B2 (en) 2012-12-29 2020-06-16 Intel Corporation Instruction and logic to provide SIMD secure hashing round slice functionality
US10038550B2 (en) 2013-08-08 2018-07-31 Intel Corporation Instruction and logic to provide a secure cipher hash round functionality
US10503510B2 (en) 2013-12-27 2019-12-10 Intel Corporation SM3 hash function message expansion processors, methods, systems, and instructions
JP2015212804A (en) * 2014-03-27 2015-11-26 インテル・コーポレーション Method and apparatus for efficiently executing hash operations
US9912481B2 (en) 2014-03-27 2018-03-06 Intel Corporation Method and apparatus for efficiently executing hash operations
US11075746B2 (en) 2014-09-04 2021-07-27 Intel Corporation SM3 hash algorithm acceleration processors, methods, systems, and instructions
US10623175B2 (en) 2014-09-04 2020-04-14 Intel Corporation SM3 hash algorithm acceleration processors, methods, systems, and instructions
US11128443B2 (en) 2014-09-04 2021-09-21 Intel Corporation SM3 hash algorithm acceleration processors, methods, systems, and instructions
US10592245B2 (en) 2014-09-26 2020-03-17 Intel Corporation Instructions and logic to provide SIMD SM3 cryptographic hashing functionality
WO2019054518A3 (en) * 2017-09-15 2019-05-16 株式会社エヌティーアイ Communication system, first communication device, second communication device, method, and computer program
JP2019054466A (en) * 2017-09-15 2019-04-04 株式会社 エヌティーアイ Communication system, first communication device, second communication device, method, and computer program
US11356253B2 (en) 2017-09-15 2022-06-07 Nti, Inc. Communication system, first communication device, second communication device, method, and computer program
KR20200044685A (en) 2018-10-19 2020-04-29 가부시키가이샤 코쿠사이 엘렉트릭 Substrate processing apparatus and method of manufacturing semiconductor device
CN111708513A (en) * 2020-05-15 2020-09-25 深圳和而泰智能家电控制器有限公司 Pseudo-random number seed generation method and related product
CN111708513B (en) * 2020-05-15 2023-12-08 深圳和而泰智能家电控制器有限公司 Pseudo-random number seed generation method and related product
CN115051798A (en) * 2022-06-10 2022-09-13 北京海泰方圆科技股份有限公司 Random number generation method and device, electronic equipment and storage medium
KR102649847B1 (en) * 2023-10-06 2024-03-21 위더맥스(주) Apparatus and method for generating random numbers using stack/heap area of mcu

Similar Documents

Publication Publication Date Title
JP4669046B2 (en) Cryptographically secure pseudorandom number generator
KR101237104B1 (en) Initial seed management for pseudorandom number generator
EP2695052B1 (en) Random number generating system based on memory start-up noise
TW201812638A (en) Storage design method of blockchain encrypted radio frequency chip
US8781117B2 (en) Generating pseudo random bits from polynomials
US10313128B2 (en) Address-dependent key generator by XOR tree
US20060104443A1 (en) Method, apparatus and system for resistance to side channel attacks on random number generators
US8681976B2 (en) System and method for device dependent and rate limited key generation
JPH10511778A (en) Method of executing a communication protocol between two processing devices using a secret key
KR20020091059A (en) Method of authenticating anonymous users while reducing potential for “middleman” fraud
JP2004109420A (en) Method and apparatus for generating random number
US10146701B2 (en) Address-dependent key generation with a substitution-permutation network
JP6884284B2 (en) White box calculation of keyed message authentication code
JP2010528511A (en) Software encryption method, software decryption method, software encryption device, and software decryption device
JP2008233683A (en) Encryption processing apparatus and program
CN110851112A (en) Random bit generation method and device, electronic equipment and storage medium
JP2004361969A (en) Ciphering method
TWI439101B (en) Apparatus and method for generating an authentication code
JP2011123356A (en) Prime number generating device, prime number generating method, and prime number generating program
CN111967026A (en) Method and device for encrypting and decrypting redemption code and computer equipment
US20210240861A1 (en) Data processing device and method for processing secret data
JP2006024140A (en) Random-number generator
JP3526504B2 (en) Random number generator
JP4664514B2 (en) Prime number generating apparatus and program
CN111602367A (en) Method for protecting entropy sources used in countermeasures securing white-box cryptographic algorithms