Name
random, urandom - kernel
random number source devices
Description
<!--
google_ad_client = "pub-5823754184406795";
google_ad_slot = "5992934909";
google_ad_width = 300;
google_ad_height = 250;
//-->
<iframe name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-5823754184406795&dt=1205818900718&lmt=1205818900&output=html&slotname=5992934909&correlator=1205818900500&url=http%3A%2F%2Flinux.die.net%2Fman%2F4%2Frandom&ref=http%3A%2F%2Fwww.google.cn%2Fsearch%3Fcomplete%3D1%26hl%3Dzh-CN%26newwindow%3D1%26rlz%3D1T4SHCN_zh-CNCN264CN266%26q%3Dmknod%2B%252Fdev%252Frandom%26meta%3D%26aq%3Df&frm=0&cc=302&ga_vid=1466898322.1205818901&ga_sid=1205818901&ga_hid=1407481144&flash=9.0.115.0&u_h=768&u_w=1024&u_ah=738&u_aw=1024&u_cd=32&u_tz=480&u_java=true" frameborder="0" width="300" scrolling="no" height="250" allowtransparency="allowtransparency"></iframe>
The character special files
/dev/random and
/dev/urandom (present since Linux 1.3.30) provide an interface to the kernel's
random number generator. File
/dev/random has major device number 1 and minor device number 8. File
/dev/urandom has major device number 1 and minor device number 9.
The random number generator gathers environmental noise from device drivers and other sources into an entropy pool. The generator also keeps an estimate of the number of bits of noise in the entropy pool. From this entropy pool random numbers are created.
When read, the /dev/random device will only return random bytes within the estimated number of bits of noise in the entropy pool. /dev/random should be suitable for uses that need very high quality randomness such as one-time pad or key generation. When the entropy pool is empty, reads from /dev/random will block until additional environmental noise is gathered.
A read from the /dev/urandom device will not block waiting for more entropy. As a result, if there is not sufficient entropy in the entropy pool, the returned values are theoretically vulnerable to a cryptographic attack on the algorithms used by the driver. Knowledge of how to do this is not available in the current non-classified literature, but it is theoretically possible that such an attack may exist. If this is a concern in your application, use /dev/random instead.
Configuring
If your system does not have
/dev/random and
/dev/urandom created already, they can be created with the following commands:
mknod -m 644 /dev/random c 1 8
mknod -m 644 /dev/urandom c 1 9
chown root:root /dev/random /dev/urandom
When a Linux system starts up without much operator interaction, the entropy pool may be in a fairly predictable state. This reduces the actual amount of noise in the entropy pool below the estimate. In order to counteract this effect, it helps to carry entropy pool information across shut-downs and start-ups. To do this, add the following lines to an appropriate script which is run during the Linux system start-up sequence:
echo "Initializing random number generator..."
random_seed=/var/run/random-seed
# Carry a random seed from start-up to start-up
# Load and then save the whole entropy pool
if [ -f $random_seed ]; then
cat $random_seed >/dev/urandom
else
touch $random_seed
fi
chmod 600 $random_seed
poolfile=/proc/sys/kernel/random/poolsize
[ -r $poolfile ] && bytes='cat $poolfile' || bytes=512
dd if=/dev/urandom of=$random_seed count=1 bs=$bytes
Also, add the following lines in an appropriate script which is run during the Linux system shutdown:
# Carry a random seed from shut-down to start-up
# Save the whole entropy pool
echo "Saving random seed..."
random_seed=/var/run/random-seed
touch $random_seed
chmod 600 $random_seed
poolfile=/proc/sys/kernel/random/poolsize
[ -r $poolfile ] && bytes='cat $poolfile' || bytes=512
dd if=/dev/urandom of=$random_seed count=1 bs=$bytes
Proc Interface
The files in the directory
/proc/sys/kernel/random (present since 2.3.16) provide an additional interface to the
/dev/random device.
The read-only file entropy_avail gives the available entropy. Normally, this will be 4096 (bits), a full entropy pool.
The file poolsize gives the size of the entropy pool. Normally, this will be 512 (bytes). It can be changed to any value for which an algorithm is available. Currently the choices are 32, 64, 128, 256, 512, 1024, 2048.
The file read_wakeup_threshold contains the number of bits of entropy required for waking up processes that sleep waiting for entropy from /dev/random. The default is 64. The file write_wakeup_threshold contains the number of bits of entropy below which we wake up processes that do a select() or poll() for write access to /dev/random. These values can be changed by writing to the files.
The read-only files uuid and boot_id contain random strings like 6fd5a44b-35f4-4ad4-a9b9-6b9be13e1fe9. The former is generated afresh for each read, the latter was generated once.
Files
/
dev/
random/
dev/urandom
Author
The kernel's
random number generator was written by Theodore Ts'o (
tytso@athena.mit.edu).
分享到:
相关推荐
linux /dev/random也是一个特殊文件,是用于产生随机数据流的.zip
[2023-06-21 14:30:31] # random: Got 5/5 bytes from /dev/random
/dev/random 即服务 大WaSP /dev/random作为服务。 入门 ... curl "http://dev-random-as-a-service.appspot.com/proc/sys/kernel/random/entropy_avail" 新增内容:对于我们的实验性/dev/full 、 /de
主要介绍了linux dev 常见特殊设备介绍与应用(loop,null,zero,full,random),需要的朋友可以参考下
$ sudo docker run --rm --net= " host " -v /dev/urandom:/dev/urandom -v /dev/random:/dev/random -p 50500:50500 chimeracoder/mediatomb 当然,您将需要挂载包含您要共享的媒体的目录。 例如: $ sudo docker ...
3.使用/dev/random 或 /dev/urandom /dev/random存储着系统当前运行环境的实时数据,是阻塞的随机数发生器,读取有时需要等待,尽量避免使用。 /dev/urandom非阻塞随机数发生器,读取操作不会产生阻塞。 > cat /...
开源项目-ammario-frandom.zip,frandom - Fast random. ~40x faster than /dev/urandom
刚刚使用因为您应该只使用/dev/... 您也可以使用它来替换/dev/random 。 用法: $ make$ sudo insmod justuse.ko$ DEVICE_NUMBER= $( grep " justuse " /proc/devices | awk ' {print $1} ' )$ sudo mknod /dev/u
创建随机数的方法: 代码如下: 1~~~~ /dev/urandom 在Linux中有一个设备/dev/urandom是用来产生随机数序列的。利用该设备我们可以根据在需要生成随机字符串。 比如我们要产生一个8位的字母和数字混合的随机密码,...
建造libshamir 需要 C99 编译器、工具链和类 Unix 公开/dev/urandom 、 /dev/arandom或dev/random 。 git clone ...
资源来自pypi官网。 资源全名:randomdata-0.1a.dev4.tar.gz
种子工具这是用于创建和操作BitTorrent v2 torrent文件的... 首先,创建两个文件进行测试: $ dd count=16000 if=/dev/random of=file-number-1$ dd count=32000 if=/dev/random of=file-number-2创建一个种子我们可
frandom 是一个 Linux 内核模块,它实现了快速随机数生成器 (RNG)。 它是 /dev/frandom 的字符驱动程序,像 /dev/urandom 一样工作,仅快 10-50 倍(取决于平台)
支持 /dev/random, /dev/urandom 以及 Win32 CSP RNG Fortuna SOBER-128 公钥算法 RSA (using PKCS #1 v2.1) ECC (EC-DSA X9.62 数字签名标准, X9.63 EC-DH,密钥交换标准) Rinick添加了一个ECC加密和解密的...
/dev/random > keyxor my-private-file key > encrypted-filexor encrypted-file key > decrypted-file创建密钥的一种可能更快的替代方法是:(在 bash 中) head --bytes=$(stat -c%s my-private-file) /dev/...
centos7 tomcat8.0启动慢的解决办法: 主要原因是生成随机数的时候卡住了,导致tomcat启动不了。 经过检查,发现原因是...securerandom.source=file:/dev/random 改为 securerandom.source=file:/dev/urandom 2.yum ins
npm i --save-dev @nordicsemiconductor/random-words 用法 npm i --save @nordicsemiconductor/random-words const { randomWords } = require ( "@nordicsemiconductor/random-words" ) ; randomWords ( ) . then ...
选项: -v 显示版本号-h 显示帮助文本-a 将密码限制为字母数字字符-n 指定密码的字符数-r 强制使用 rand() 调用,而不是使用 /dev/random 或 /dev/urandom。 主要用于测试。 -m 生成随机 MAC 地址,例如 d2:85:e6:...
unix 系统上的 /dev/random 和 /dev/urandom。 熵源是模块化的,非常欢迎支持其他硬件随机生成器的贡献。 默认安全 通过让随机生成器始终可用的熵池,我们可以安全地且不必给用户带来安全细节的负担,在需要时随时...
C:\Documents and Settings\Administrator>dd --list rawwrite dd for ... /dev/random (pseudo-random data) - (standard input) Virtual output devices - (standard output) /dev/null (discard the data)