OSDN Git Service

39ed8a5c48532f68c3f5bb74ccd2af0434686dd8
[linuxjm/LDP_man-pages.git] / draft / man4 / random.4
1 .\" Copyright (c) 1997 John S. Kallal (kallal@voicenet.com)
2 .\"
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.
7 .\"
8 .\" Some changes by tytso and aeb.
9 .\"
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.
16 .\"
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
28 .\"
29 .\"WORD:        random generator        乱数ジェネレータ
30 .\"
31 .TH RANDOM 4 2010-08-29 "Linux" "Linux Programmer's Manual"
32 .\"O .SH NAME
33 .SH 名前
34 .\"O random, urandom \- kernel random number source devices
35 random, urandom \- カーネル乱数ソースデバイス
36 .\"O .SH DESCRIPTION
37 .SH 説明
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
48 マイナーデバイス番号 8 である。
49 \fI/dev/urandom\fP はメジャーデバイス番号 1
50 マイナーデバイス番号 9 である。
51 .LP
52 .\"O The random number generator gathers environmental noise
53 .\"O from device drivers and other sources into an entropy pool.
54 乱数ジェネレータはデバイスドライバやその他の源からの環境ノイズを
55 エントロピー・プールへ集める。
56 .\"O The generator also keeps an estimate of the
57 .\"O number of bits of noise in the entropy pool.
58 また、ジェネレータはエントロピー・プール内のノイズのビット数の推定値を
59 保持する。
60 .\"O From this entropy pool random numbers are created.
61 このエントロピー・プールから乱数が生成される。
62 .LP
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
65 .\"O pool.
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.
68 読み込みが行われると、
69 \fI/dev/random\fP
70 デバイスはエントロピー・プールのノイズビットの数の推定値のうち、
71 ランダムバイトのみを返す。
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 更なる環境ノイズが得られるまで、ブロックされる。
78 .LP
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
86 .\"O exist.
87 .\"O If this is a concern in your application, use \fI/dev/random\fP
88 .\"O instead.
89 \fI/dev/urandom\fP デバイスから読み出しでは、
90 エントロピーがより高くなるのを待つためのブロックは行われない。
91 その結果、もしエントロピー・プールに十分なエントロピーが存在しない場合、
92 返り値はこのドライバで使われているアルゴリズムに基づく暗号攻撃に対して、
93 論理的には弱くなることになる。
94 この攻撃をどのように行うかという事については、現在研究論文などの
95 形で入手できる資料はない、しかし、そのような攻撃は論理的に存在可能である。
96 もし、この事が心配なら、(\fI/dev/urandom\fP ではなく)
97 \fI/dev/random\fP を利用すればいい。
98 .\"O .SS Usage
99 .SS 使い方
100 .\"O If you are unsure about whether you should use
101 .\"O .IR /dev/random
102 .\"O or
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.
108 .I /dev/random
109
110 .I /dev/urandom
111 のどちらを使うべきか迷った場合、たいていは
112 .I /dev/urandom
113 の方を使いたいと思っているはずだろう。
114 一般に、長期に渡って使われる GPG/SSL/SSH のキー以外の全てのものに
115 .I /dev/urandom
116 を使用すべきである。
117
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
124 .\"O .I /dev/random
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 攻撃者に対して暗号的に安全なものとなり、ネットワーク暗号化のセッションキー
134 として使うには完全に最適なものとなる。
135 .I /dev/random
136 からの読み出しは停止 (block) する可能性があるので、ユーザは普通
137 このファイルを非停止 (nonblocking) モードで開こうとし
138 (もしくはタイムアウトを指定して読み出しを実行し)、希望するレベルの
139 エントロピーはすぐには利用できない場合には、何らかの通知を行うことだろう。
140
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
149 .\"O (and
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 ランダムなデータを大量に生成するのには全くもって適していない。
158 ユーザは
159 .I /dev/urandom
160 (と
161 .IR /dev/random )
162 から読み出す乱数種の材料の量をできるだけ節約すべきである。
163 このデバイスから不必要に大量のデータを読み出すと、このデバイスを使う
164 他のユーザにマイナスの影響を与えてしまうだろう。
165
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 回の操作が必要ということ) であり、
176 そのため鍵生成器が
177 .I /dev/random
178 から読み出す必要がある乱数種の材料の量は 128 ビット (16 バイト) だけである。
179
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
186 .\"O .I not
187 .\"O skilfully implemented.
188 CPRNG アルゴリズムの欠陥に対する保護として、この最小値に対していくらかの
189 安全上のマージンを取るのはもっともだが、現在利用可能な暗号プリミティブで
190 256 ビットより多くの安全な乱数を必要とするようなものはない。
191 起動する度に、もしくは乱数種を変更する妥当な間隔 (1 分より短くなることはない)
192 の度に、カーネルの乱数プールから 256 ビット (32 バイト) よりたくさん読み出す
193 ような場合には、そのプログラムの暗号処理がうまく実装されて「いない」可能性が
194 あると考えるべきであろう。
195 .\"O .SS Configuration
196 .SS 設定
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 が存在しないなら、次のようなコマンドで作成できる。
202 .nf
203
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
207 .fi
208
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 この効果を打ち消すために、シャットダウンから (次の) 起動時まで持ち越した
219 エントロピー・プールの情報が助けになる。
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:
222 エントロピー・プールを持ち越すためには、
223 Linux システムの起動時に実行される適切なスクリプトに、
224 以下の行を追加すればよい:
225 .nf
226
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
235     else
236         touch $random_seed
237     fi
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
242 .fi
243
244 .\"O Also, add the following lines in an appropriate script which is
245 .\"O run during the Linux system shutdown:
246 また、Linux システムのシャットダウン時に実行される適切なスクリプトに、
247 以下の行を追加すればよい:
248 .nf
249
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
256     touch $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
261 .fi
262 .\"O .SS "/proc Interface"
263 .SS "/proc インタフェース"
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
267 .\"O .I /dev/random
268 .\"O device.
269 ディレクトリ
270 .I /proc/sys/kernel/random
271 にあるファイル (2.3.16 から存在する) は、
272 .I /dev/random
273 デバイスへのその他のインタフェースを提供する。
274 .LP
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.
280 読み込み専用のファイル
281 .I entropy_avail
282 は使用可能なエントロピーを表す。
283 通常、これは 4096 (ビット) になり、エントロピー・プールが満杯の状態である。
284 .LP
285 .\"O The file
286 .\"O .I poolsize
287 .\"O gives the size of the entropy pool.
288 ファイル
289 .I poolsize
290 はエントロピー・プールのサイズを表す。
291 .\"O The semantics of this file vary across kernel versions:
292 このファイルの意味はカーネルバージョンにより異なる。
293 .RS
294 .TP 12
295 Linux 2.4:
296 .\"O This file gives the size of the entropy pool in
297 .\"O .IR bytes .
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 である。
305 .TP
306 Linux 2.6:
307 .\"O This file is read-only, and gives the size of the entropy pool in
308 .\"O .IR bits .
309 .\"O It contains the value 4096.
310 このファイルは読み出し専用であり、
311 エントロピー・プールのサイズを「ビット」単位で規定する。
312 値は 4096 である。
313 .RE
314 .LP
315 .\"O The file
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 .
320 ファイル
321 .I read_wakeup_threshold
322
323 .I /dev/random
324 からのエントロピーを待って休止しているプロセスを起こすのに必要な
325 エントロピーのビット数を保持している。
326 .\"O The default is 64.
327 デフォルトは 64 である。
328 .\"O The file
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
332 .\"O .BR select (2)
333 .\"O or
334 .\"O .BR poll (2)
335 .\"O for write access to
336 .\"O .IR /dev/random .
337 ファイル
338 .I write_wakeup_threshold
339 はエントロピーのビット数を保持しており、この値以下になったら
340 .I /dev/random
341 への書き込みアクセスのために
342 .BR select (2)
343 または
344 .BR poll (2)
345 を実行するプロセスを起こす。
346 .\"O These values can be changed by writing to the files.
347 この値はファイルに書き込みを行うことによって変更できる。
348 .LP
349 .\"O The read-only files
350 .\"O .I uuid
351 .\"O and
352 .\"O .I boot_id
353 .\"O contain random strings like 6fd5a44b-35f4-4ad4-a9b9-6b9be13e1fe9.
354 読み込み専用のファイル
355 .I uuid
356
357 .I boot_id
358 は 6fd5a44b-35f4-4ad4-a9b9-6b9be13e1fe9 のような
359 ランダムな文字列を保持している。
360 .\"O The former is generated afresh for each read, the latter was
361 .\"O generated once.
362 前者は読み込みの度に新たに生成され、
363 後者は 1 度だけ生成される。
364 .\"O .SH FILES
365 .SH ファイル
366 /dev/random
367 .br
368 /dev/urandom
369 .\"O .\" .SH AUTHOR
370 .\" .SH 著者
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) によって書かれた。
375 .\"O .SH "SEE ALSO"
376 .SH 関連項目
377 mknod (1)
378 .br
379 RFC\ 1750, "Randomness Recommendations for Security"
380 .\" .SH 翻訳者
381 .\" 石川 睦 <ishikawa@linux.or.jp>