`
xiaoer_1982
  • 浏览: 1817436 次
  • 性别: Icon_minigender_2
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

如何创建 /dev/random

阅读更多
<iframe name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-5823754184406795&amp;dt=1205818900718&amp;lmt=1205818900&amp;output=html&amp;slotname=5992934909&amp;correlator=1205818900500&amp;url=http%3A%2F%2Flinux.die.net%2Fman%2F4%2Frandom&amp;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&amp;frm=0&amp;cc=302&amp;ga_vid=1466898322.1205818901&amp;ga_sid=1205818901&amp;ga_hid=1407481144&amp;flash=9.0.115.0&amp;u_h=768&amp;u_w=1024&amp;u_ah=738&amp;u_aw=1024&amp;u_cd=32&amp;u_tz=480&amp;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).
分享到:
评论

相关推荐

    图解迪杰斯特拉(Dijkstra)最短路径算法.docx

    一、最短路径的概念及应用 在介绍最短路径之前我们首先要明白两个概念:什么是源点,什么是终点?在一条路径中,起始的第 一个节点叫做源点;终点:在一条路径中,最后一个的节点叫做终点;注意!源点和终点都只是相对 于一条路径而言,每一条路径都会有相同或者不相同的源点和终点。 而最短路径这个词不用过多解释,就是其字面意思: 在图中,对于非带权无向图而言, 从源点到终点 边最少的路径(也就是 BFS 广度优先的方法); 而对于带权图而言, 从源点到终点权值之和最少的 路径叫最短路径; 最短路径应用:道路规划; 我们最关心的就是如何用代码去实现寻找最短路径, 通过实现最短路径有两种算法:Dijkstra 迪杰斯 特拉算法和 Floyd 弗洛伊德算法, 接下来我会详细讲解 Dijkstra 迪杰斯特拉算法;

    基于faster-rcnn实现的行人检测算法python源码+项目说明+详细注释.zip

    基于faster-rcnn实现的行人检测算法python源码+项目说明+详细注释.zip 使用方法: 1.编译安装faster-rcnn的python接口,代码在:https://github.com/rbgirshick/py 2.下载训练好的caffe模型,百度云链接为:https://pan.baidu.com/s/1w479QUUAwLBS2AJbc-eXIA,将下载的模型文件放到faster-rcnn文件夹的data/faster_rcnn_models文件夹中 3.将本项目中的文件夹替换安装好的faster-rcnn源码中的文件夹 4.使用tools文件夹下的测试脚本运行demo:python person_detect.py

    jsp基于Web的可维护的数据库浏览器(源代码+论文+答辩PPT).zip

    jsp基于Web的可维护的数据库浏览器(源代码+论文+答辩PPT)

    node-v12.7.0-linux-ppc64le.tar.xz

    Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。

    unet + pytorch 数据科学碗2018-python源码.zip

    unet + pytorch 数据科学碗2018-python源码.zip

    1999-2020年各地级市实际利用外资数据.xlsx

    数据预览链接:https://pan.baidu.com/s/17y5tiSmC5U4d1Mben250gg 提取码:u1da 更多介绍:https://blog.csdn.net/m0_71334485/article/details/138400336

    基于Torch Hub的渐进式GAN架构-python源码.zip

    基于Torch Hub的渐进式GAN架构-python源码.zip

    JSP基于Iptables图形管理工具的设计与实现(源代码+论文).zip

    JSP基于Iptables图形管理工具的设计与实现(源代码+论文)

    使用Keras+TensorFlow+FCN分割KITTI数据集-python源码.zip

    使用Keras+TensorFlow+FCN分割KITTI数据集-python源码.zip

    基于RRT采样对六轴机械臂进行路径规划Matlab完整源码+代码注释+项目说明.zip

    基于RRT采样对六轴机械臂进行路径规划Matlab完整源码+代码注释+项目说明.zip

    深蹲姿势分析-python源码.zip

    深蹲姿势分析-python源码.zip

    基于python实现的交通网络中的流量调控使用复杂网络中的级联失效模型.rar

    基于python实现的交通网络中的流量调控使用复杂网络中的级联失效模型.rar

    node-v4.4.1.tar.xz

    Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。

    node-v4.8.7.tar.xz

    Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。

    深度残差网络ResNet-python源码.zip

    深度残差网络ResNet-python源码.zip

    基于oecms内核蓝色经典大方手机wap企业网站源码.zip

    触屏版自适应手机wap软件网站模板 触屏版自适应手机wap软件网站模板

    2007-2022商业银行绿色信贷数据绿色信贷余额贷款总额绿色信贷比率不良贷款率

    2007-2022商业银行绿色信贷数据绿色信贷余额贷款总额绿色信贷比率不良贷款率 在一定的客观缺失。 1、数据来源:公司年报、可持续发展报告、社会责任报告 2、数 据范围: 36家上市银行 北京银行、常熟银行、成都银行、工商银行、光大银行、贵阳 银行、杭州银行、华夏银行、建设银行、江苏银行、江阴银行、交通银行、民生银行、南京 银行、宁波银行、农业银行、平安银行、浦发银行、青岛银行、青农商行、上海银行、苏农 银行、苏州银行、无锡农村商业银行、西安银行、兴业银行、邮储银行、渝农商行、张家港 行、长沙银行、招商银行、浙商银行、郑州银行、中国银行、中信银行、紫金银行

    基于优化设计的储油罐变位识别与罐容表标定的研究.doc

    本文档是课题研究的研究报告内含调研以及源码设计以及结果分析

    更新全球夜间灯光数据大全(包含各省、地级市及县区)1992-2022年

    全球夜间灯光数据 参考文献 [1]徐康宁, 陈丰龙, and 刘修岩. "中国经 济增长的真实性:基于全球夜间灯光数据的检验." 经济研究 (2015). [2] 王贤彬等. "中国地区经济差距动态趋势重估——基于卫星灯光数据的考察." 经济学 (季刊) 16.2(2017):20. 基于美国国家海洋与大气管理局(NOAA) 的DMSP/OLS影像数据和VIIRS/DNB影像数据开发而成的,目前主要反映中 国各省、地级市及县区夜间灯光数据和一带一路沿线国家的夜间灯光数据情况。DMSP/ OLS影像灯光数据目前已经应用于经济类研究,并且已有较多文献发表在诸多高水平杂志 上,因此逐渐受到学者关注。VIIRS/DNB影像灯光数据在国内文献中还未被广泛应 用,但基于其具有许多优点因此逐渐受到学者关注。由于学者通常只能获得NOAA上面的 原始图片资料,将这些图像资料转化为可用数据需要用到较为复杂的计算机和编程技术。 数据包含 核心指标:[DN均值]-计算所得的DN总值/栅格数 项目 字段内容 数 据起始时间 DMSP中国各省份灯光数据(校正后) 省份名称、年度、DN均值 1992~20

    Dijkstra算法Java实现示例

    Dijkstra算法是一种用于在加权图中找到单个源点到所有其他顶点的最短路径的算法。以下是Java语言实现Dijkstra算法的一个简单示例,这个示例假设你有一个图的邻接矩阵表示,并且所有边的权重都是正数。 代码定义了一个DijkstraExample类,其中包含了Dijkstra算法的实现。dijkstra方法接受一个图的邻接矩阵和源顶点作为输入,计算从源顶点到图中所有其他顶点的最短路径。minDistance方法用于找到未被考虑的顶点中距离最小的顶点。printSolution方法用于打印最终的最短路径结果。 在main方法中,我们创建了一个图的邻接矩阵,并调用dijkstra方法来计算从顶点0到其他所有顶点的最短路径。 请注意,这个示例仅适用于没有负权边的图,因为Dijkstra算法不能处理负权边。如果你的图有负权边,你可能需要使用Bellman-Ford算法。

Global site tag (gtag.js) - Google Analytics