1 .\" Copyright (c) 1997 John S. Kallal (kallal@voicenet.com)
3 .\" This is free documentation; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
8 .\" Some changes by tytso and aeb.
10 .\" 2004-12-16, John V. Belmonte/mtk, Updated init and quit scripts
11 .\" 2004-04-08, AEB, Improved description of read from /dev/urandom
12 .\" 2008-06-20, George Spelvin <linux@horizon.com>,
13 .\" Matt Mackall <mpm@selenic.com>
14 .\" Add a Usage subsection that recommends most users to use
15 .\" /dev/urandom, and emphasizes parsimonious usage of /dev/random.
17 .\" Japanese Version Copyright (c) 1998
18 .\" ISHIKAWA Mutsumi, all rights reserved.
19 .\" Translated into Japanese Mon Jan 12 03:20:27 JST 1998
20 .\" by ISHIKAWA Mutsumi <ishikawa@linux.or.jp>
21 .\" Japanese Version Last Modified Thu Feb 5 21:08:33 JST 1998
22 .\" by ISHIKAWA Mutsumi <ishikawa@linux.or.jp>
23 .\" Updated & Modified Sun Jun 6 14:48:03 JST 2004
24 .\" by Yuichi SATO <ysato444@yahoo.co.jp>
25 .\" Updated & Modified Tue Jan 18 04:21:16 JST 2005 by Yuichi SATO
26 .\" Updated & Modified Fri Apr 22 03:44:01 JST 2005 by Yuichi SATO
27 .\" Updated 2008-08-13, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.05
29 .\"WORD: random generator 乱数ジェネレータ
31 .TH RANDOM 4 2010-08-29 "Linux" "Linux Programmer's Manual"
34 .\"O random, urandom \- kernel random number source devices
35 random, urandom \- カーネル乱数ソースデバイス
38 .\"O The character special files \fI/dev/random\fP and
39 .\"O \fI/dev/urandom\fP (present since Linux 1.3.30)
40 .\"O provide an interface to the kernel's random number generator.
41 (Linux 1.3.30 から提供されている) \fI/dev/random\fP 、
42 \fI/dev/urandom\fP キャラクタスペシャルファイルは
43 カーネル乱数ジェネレータへのインタフェースを提供する。
44 .\"O File \fI/dev/random\fP has major device number 1
45 .\"O and minor device number 8.
46 .\"O File \fI/dev/urandom\fP has major device number 1 and minor device number 9.
47 \fI/dev/random\fP ファイルはメジャーデバイス番号 1
49 \fI/dev/urandom\fP はメジャーデバイス番号 1
52 .\"O The random number generator gathers environmental noise
53 .\"O from device drivers and other sources into an entropy pool.
54 乱数ジェネレータはデバイスドライバやその他の源からの環境ノイズを
56 .\"O The generator also keeps an estimate of the
57 .\"O number of bits of noise in the entropy pool.
58 また、ジェネレータはエントロピー・プール内のノイズのビット数の推定値を
60 .\"O From this entropy pool random numbers are created.
61 このエントロピー・プールから乱数が生成される。
63 .\"O When read, the \fI/dev/random\fP device will only return random bytes
64 .\"O within the estimated number of bits of noise in the entropy
66 .\"O \fI/dev/random\fP should be suitable for uses that need very
67 .\"O high quality randomness such as one-time pad or key generation.
70 デバイスはエントロピー・プールのノイズビットの数の推定値のうち、
72 \fI/dev/random\fP はワンタイムパッド (one-time pad) や鍵の生成のような
73 非常に高い品質を持った無作為性が必要になる用途に向いているだろう。
74 .\"O When the entropy pool is empty, reads from \fI/dev/random\fP will block
75 .\"O until additional environmental noise is gathered.
76 エントロピー・プールが空の時は、\fI/dev/random\fP からの読み出しは、
77 更なる環境ノイズが得られるまで、ブロックされる。
79 .\"O A read from the \fI/dev/urandom\fP device will not block
80 .\"O waiting for more entropy.
81 .\"O As a result, if there is not sufficient entropy in the
82 .\"O entropy pool, the returned values are theoretically vulnerable to a
83 .\"O cryptographic attack on the algorithms used by the driver.
84 .\"O Knowledge of how to do this is not available in the current unclassified
85 .\"O literature, but it is theoretically possible that such an attack may
87 .\"O If this is a concern in your application, use \fI/dev/random\fP
89 \fI/dev/urandom\fP デバイスから読み出しでは、
90 エントロピーがより高くなるのを待つためのブロックは行われない。
91 その結果、もしエントロピー・プールに十分なエントロピーが存在しない場合、
92 返り値はこのドライバで使われているアルゴリズムに基づく暗号攻撃に対して、
94 この攻撃をどのように行うかという事については、現在研究論文などの
95 形で入手できる資料はない、しかし、そのような攻撃は論理的に存在可能である。
96 もし、この事が心配なら、(\fI/dev/urandom\fP ではなく)
97 \fI/dev/random\fP を利用すればいい。
100 .\"O If you are unsure about whether you should use
103 .\"O .IR /dev/urandom ,
104 .\"O then probably you want to use the latter.
105 .\"O As a general rule,
106 .\"O .IR /dev/urandom
107 .\"O should be used for everything except long-lived GPG/SSL/SSH keys.
111 のどちらを使うべきか迷った場合、たいていは
114 一般に、長期に渡って使われる GPG/SSL/SSH のキー以外の全てのものに
118 .\"O If a seed file is saved across reboots as recommended below (all major
119 .\"O Linux distributions have done this since 2000 at least), the output is
120 .\"O cryptographically secure against attackers without local root access as
121 .\"O soon as it is reloaded in the boot sequence, and perfectly adequate for
122 .\"O network encryption session keys.
123 .\"O Since reads from
125 .\"O may block, users will usually want to open it in nonblocking mode
126 .\"O (or perform a read with timeout),
127 .\"O and provide some sort of user notification if the desired
128 .\"O entropy is not immediately available.
129 下記で推奨しているように再起動の前後で乱数種ファイルが保存される場合
130 (全ての主な Linux のディストリビューションは少なくとも 2000 年以降は
131 乱数種を保存するようになっている)、起動シーケンスにおいて乱数種が
132 再ロードされた直後から、その出力はローカルのルートアクセスができない
133 攻撃者に対して暗号的に安全なものとなり、ネットワーク暗号化のセッションキー
136 からの読み出しは停止 (block) する可能性があるので、ユーザは普通
137 このファイルを非停止 (nonblocking) モードで開こうとし
138 (もしくはタイムアウトを指定して読み出しを実行し)、希望するレベルの
139 エントロピーはすぐには利用できない場合には、何らかの通知を行うことだろう。
141 .\"O The kernel random-number generator is designed to produce a small
142 .\"O amount of high-quality seed material to seed a
143 .\"O cryptographic pseudo-random number generator (CPRNG).
144 .\"O It is designed for security, not speed, and is poorly
145 .\"O suited to generating large amounts of random data.
146 .\"O Users should be very economical in the amount of seed
147 .\"O material that they read from
148 .\"O .IR /dev/urandom
150 .\"O .IR /dev/random );
151 .\"O unnecessarily reading large quantities of data from this device will have
152 .\"O a negative impact on other users of the device.
153 カーネルの乱数ジェネレータは、暗号疑似乱数ジェネレータ (Cryptographic
154 pseudo-random number generator; CPRNG) の種として使用できる
155 高品質な乱数種の材料を少し生成するために設計されている。
156 これは速度ではなく安全性を重視して設計されており、
157 ランダムなデータを大量に生成するのには全くもって適していない。
162 から読み出す乱数種の材料の量をできるだけ節約すべきである。
163 このデバイスから不必要に大量のデータを読み出すと、このデバイスを使う
164 他のユーザにマイナスの影響を与えてしまうだろう。
166 .\"O The amount of seed material required to generate a cryptographic key
167 .\"O equals the effective key size of the key.
168 .\"O For example, a 3072-bit RSA
169 .\"O or Diffie-Hellman private key has an effective key size of 128 bits
170 .\"O (it requires about 2^128 operations to break) so a key generator only
171 .\"O needs 128 bits (16 bytes) of seed material from
172 .\"O .IR /dev/random .
173 暗号鍵を生成するのに必要な乱数種の材料の量は、鍵の実効サイズと同じである。
174 例えば、3072 ビットの RSA および Diffie-Hellman の秘密鍵の実効サイズは
175 128 ビット (この秘密鍵を破るには 2^128 回の操作が必要ということ) であり、
178 から読み出す必要がある乱数種の材料の量は 128 ビット (16 バイト) だけである。
180 .\"O While some safety margin above that minimum is reasonable, as a guard
181 .\"O against flaws in the CPRNG algorithm, no cryptographic primitive
182 .\"O available today can hope to promise more than 256 bits of security,
183 .\"O so if any program reads more than 256 bits (32 bytes) from the kernel
184 .\"O random pool per invocation, or per reasonable reseed interval (not less
185 .\"O than one minute), that should be taken as a sign that its cryptography is
187 .\"O skilfully implemented.
188 CPRNG アルゴリズムの欠陥に対する保護として、この最小値に対していくらかの
189 安全上のマージンを取るのはもっともだが、現在利用可能な暗号プリミティブで
190 256 ビットより多くの安全な乱数を必要とするようなものはない。
191 起動する度に、もしくは乱数種を変更する妥当な間隔 (1 分より短くなることはない)
192 の度に、カーネルの乱数プールから 256 ビット (32 バイト) よりたくさん読み出す
193 ような場合には、そのプログラムの暗号処理がうまく実装されて「いない」可能性が
195 .\"O .SS Configuration
197 .\"O If your system does not have
198 .\"O \fI/dev/random\fP and \fI/dev/urandom\fP created already, they
199 .\"O can be created with the following commands:
200 システムにあらかじめ作成された \fI/dev/random\fP と
201 \fI/dev/urandom\fP が存在しないなら、次のようなコマンドで作成できる。
204 mknod \-m 644 /dev/random c 1 8
205 mknod \-m 644 /dev/urandom c 1 9
206 chown root:root /dev/random /dev/urandom
209 .\"O When a Linux system starts up without much operator interaction,
210 .\"O the entropy pool may be in a fairly predictable state.
211 オペレータの操作なしに Linux システムが起動した直後は、
212 エントロピー・プールは意外性の乏しい均一な状態にあるだろう。
213 .\"O This reduces the actual amount of noise in the entropy pool
214 .\"O below the estimate.
215 .\"O In order to counteract this effect, it helps to carry
216 .\"O entropy pool information across shut-downs and start-ups.
217 これにより、エントロピー・プールの実際のノイズ量は評価値より少なくなる。
218 この効果を打ち消すために、シャットダウンから (次の) 起動時まで持ち越した
220 .\"O To do this, add the following lines to an appropriate script
221 .\"O which is run during the Linux system start-up sequence:
223 Linux システムの起動時に実行される適切なスクリプトに、
227 echo "Initializing random number generator..."
228 random_seed=/var/run/random-seed
229 .\"O # Carry a random seed from start-up to start-up
230 .\"O # Load and then save the whole entropy pool
231 # 乱数種を今回のスタートアップから次回のスタートアップまで持ち越す。
232 # ロードを行い、その後、全てのエントロピー・プールを保存する。
233 if [ \-f $random_seed ]; then
234 cat $random_seed >/dev/urandom
238 chmod 600 $random_seed
239 poolfile=/proc/sys/kernel/random/poolsize
240 [ \-r $poolfile ] && bytes=\`cat $poolfile\` || bytes=512
241 dd if=/dev/urandom of=$random_seed count=1 bs=$bytes
244 .\"O Also, add the following lines in an appropriate script which is
245 .\"O run during the Linux system shutdown:
246 また、Linux システムのシャットダウン時に実行される適切なスクリプトに、
250 .\"O # Carry a random seed from shut-down to start-up
251 .\"O # Save the whole entropy pool
252 # 乱数種を今回のシャットダウンから次回のスタートアップまで持ち越す。
253 # 全てのエントロピー・プールを保存する。
254 echo "Saving random seed..."
255 random_seed=/var/run/random-seed
257 chmod 600 $random_seed
258 poolfile=/proc/sys/kernel/random/poolsize
259 [ \-r $poolfile ] && bytes=\`cat $poolfile\` || bytes=512
260 dd if=/dev/urandom of=$random_seed count=1 bs=$bytes
262 .\"O .SS "/proc Interface"
264 .\"O The files in the directory
265 .\"O .I /proc/sys/kernel/random
266 .\"O (present since 2.3.16) provide an additional interface to the
270 .I /proc/sys/kernel/random
271 にあるファイル (2.3.16 から存在する) は、
273 デバイスへのその他のインタフェースを提供する。
275 .\"O The read-only file
276 .\"O .I entropy_avail
277 .\"O gives the available entropy.
278 .\"O Normally, this will be 4096 (bits),
279 .\"O a full entropy pool.
283 通常、これは 4096 (ビット) になり、エントロピー・プールが満杯の状態である。
287 .\"O gives the size of the entropy pool.
291 .\"O The semantics of this file vary across kernel versions:
292 このファイルの意味はカーネルバージョンにより異なる。
296 .\"O This file gives the size of the entropy pool in
298 .\"O Normally, this file will have the value 512, but it is writable,
299 .\"O and can be changed to any value for which an algorithm is available.
300 .\"O The choices are 32, 64, 128, 256, 512, 1024, or 2048.
301 このファイルはエントロピー・プールのサイズを「バイト」単位で規定する。
302 通常、このファイルの値は 512 になるが、書き込み可能であり、
303 アルゴリズムで利用可能な任意の値に変更できる。
304 選択可能な値は 32, 64, 128, 256, 512, 1024, 2048 である。
307 .\"O This file is read-only, and gives the size of the entropy pool in
309 .\"O It contains the value 4096.
311 エントロピー・プールのサイズを「ビット」単位で規定する。
316 .\"O .I read_wakeup_threshold
317 .\"O contains the number of bits of entropy required for waking up processes
318 .\"O that sleep waiting for entropy from
319 .\"O .IR /dev/random .
321 .I read_wakeup_threshold
324 からのエントロピーを待って休止しているプロセスを起こすのに必要な
326 .\"O The default is 64.
329 .\"O .I write_wakeup_threshold
330 .\"O contains the number of bits of entropy below which we wake up
331 .\"O processes that do a
335 .\"O for write access to
336 .\"O .IR /dev/random .
338 .I write_wakeup_threshold
339 はエントロピーのビット数を保持しており、この値以下になったら
346 .\"O These values can be changed by writing to the files.
347 この値はファイルに書き込みを行うことによって変更できる。
349 .\"O The read-only files
353 .\"O contain random strings like 6fd5a44b-35f4-4ad4-a9b9-6b9be13e1fe9.
358 は 6fd5a44b-35f4-4ad4-a9b9-6b9be13e1fe9 のような
360 .\"O The former is generated afresh for each read, the latter was
371 .\"O .\" The kernel's random number generator was written by
372 .\"O .\" Theodore Ts'o (tytso@athena.mit.edu).
373 .\" カーネル・ランダムナンバー・ジェネレータは Theodora Ts'o
374 .\" (tytso@athena.mit.edu) によって書かれた。
379 RFC\ 1750, "Randomness Recommendations for Security"
381 .\" 石川 睦 <ishikawa@linux.or.jp>