- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是一个关于/dev/urandom
的Linux内核实现的问题.如果用户要求读取大量数据(千兆字节)并且熵没有添加到池中,是否可以根据当前数据预测从 urandom 生成的下一个数据?
通常的情况是当熵经常被添加到池中时,但在我的情况下我们可以考虑,没有额外的熵(例如,添加它被内核补丁禁用)。所以在我的情况下,问题是关于 urandom 算法本身。
来源是/drivers/char/random.c 或 http://www.google.com/codesearch#KMCRKdMbI4g/drivers/char/random.c&q=urandom%20linux&type=cs&l=116
或 http://lxr.linux.no/linux+v3.3.3/drivers/char/random.c
// data copying loop
while (nbytes) {
extract_buf(r, tmp);
memcpy(buf, tmp, i);
nbytes -= i;
buf += i;
ret += i;
}
static void extract_buf(struct entropy_store *r, __u8 *out)
{
int i;
__u32 hash[5], workspace[SHA_WORKSPACE_WORDS];
__u8 extract[64];
/* Generate a hash across the pool, 16 words (512 bits) at a time */
sha_init(hash);
for (i = 0; i < r->poolinfo->poolwords; i += 16)
sha_transform(hash, (__u8 *)(r->pool + i), workspace);
/*
* We mix the hash back into the pool to prevent backtracking
* attacks (where the attacker knows the state of the pool
* plus the current outputs, and attempts to find previous
* ouputs), unless the hash function can be inverted. By
* mixing at least a SHA1 worth of hash data back, we make
* brute-forcing the feedback as hard as brute-forcing the
* hash.
*/
mix_pool_bytes_extract(r, hash, sizeof(hash), extract);
/*
* To avoid duplicates, we atomically extract a portion of the
* pool while mixing, and hash one final time.
*/
sha_transform(hash, extract, workspace);
memset(extract, 0, sizeof(extract));
memset(workspace, 0, sizeof(workspace));
/*
* In case the hash function has some recognizable output
* pattern, we fold it in half. Thus, we always feed back
* twice as much data as we output.
*/
hash[0] ^= hash[3];
hash[1] ^= hash[4];
hash[2] ^= rol32(hash[2], 16);
memcpy(out, hash, EXTRACT_SIZE);
memset(hash, 0, sizeof(hash));
}
最佳答案
原则上,是的,您可以预测。当没有可用的熵时,dev/urandom 变为 PRNG,一旦知道其内部状态,原则上就可以预测其输出。实际上并不是那么简单,因为内部状态相当大,散列函数阻止我们从输出向后工作。它可以通过反复试验来确定,但这可能需要很长时间。
关于random - linux/dev/urandom 前向预测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6929320/
在 Linux 中,/dev/urandom/ 的随机性到底有多大?它被认为是安全的吗? 还有可能获得 1 的流吗? 最佳答案 注意 4.5 年后:这是个糟糕的建议。参见 these 之一links了
如果您想从/dev/urandom 保证读取 N 个字节,执行单个读取调用是否安全并保证您获得 N 个字节 - 或者是否有一些操作系统不提供这种保证,并且可能从/dev/urandom 产生一个简短的
我正在进行随机数生成领域的研究,我需要演示著名的“P 和 Q”论文 (here) 中的“启动时熵洞”。我们将同时假脱机处理同一个最小 Linux 虚拟机的两个副本,我们期望它们的/dev/urando
我们在 Linux、Solaris 和 AIX 平台上使用 tomcat、weblogic、websphere、apache(主要是 java)。对于加密,我们使用 SSL。要生成私钥/公钥对,我们使
我需要生成一些只能接受一定范围字符的 token ,[a-zA-Z0-9_] 我正在尝试使用 binascii.b2a_base64(os.urandom(64)),它具有其他字符(例如 +)并导致问
在哪里可以找到有关 os.urandom 的完整教程或文档?我需要获取一个随机 int 以从 80 个字符的字符串中选择一个 char。 最佳答案 如果你只需要一个随机整数,你可以使用random.r
似乎在类 unix 系统中使用纯 C,/dev/urandom 中的 fread 是提取高质量随机字节的最简单方法。我需要运行一个模拟,每秒需要大约 10k 个 32 位随机数,它可能会运行几天。 /
这是一个关于/dev/urandom的Linux内核实现的问题.如果用户要求读取大量数据(千兆字节)并且熵没有添加到池中,是否可以根据当前数据预测从 urandom 生成的下一个数据? 通常的情况是当
我有这段 C 代码,我想知道是否可能如何绕过此检查? int fd, password, input; fd = open("/dev/urandom", 0); read(fd, &password
我正在循环中读取 dev/urandom 来为模拟创建随机数。它不起作用,我最终将问题追溯到以下代码示例 int myFile = open("/dev/urandom", O_RDONLY); be
我需要许多加密安全数字,所以我考虑从 /dev/urandom 中提取随机性,然后将其“转换”为(比如)unsigned long long int .我想它应该是非常有效的,而且它似乎是加密安全的,
不知何故我的 python 坏了并发出错误: jseidel@EDP15:/etc/default$ python -c 'import random' Traceback (most recent
想研究学习python 3.7的os.urandom()函数的代码。我查看了相应标准库的 os.py,但既没有在那里定义,也没有在那里导入。我还尝试 grep 获取定义: /usr/lib/pytho
我正在编写一个读取标准输入的程序。我有一个这样的循环: while(read(0, buffer, sizeof(buffer)) > 0) 它工作正常,但是当我执行 cat/dev/urandom
我正在尝试生成随机数以供我的 Perl 代码中的某些特定用途。 我能够弄清楚 Linux 的命令并且它工作正常。 cat /dev/urandom | tr -dc 'a-zA-Z0-9-_!@#$%
我有一个需要的应用程序 numpy.random.normal但来自神秘的 PRNG 源。 Numpy 似乎没有提供这个选项。 我能找到的最好的是numpy.random.entropy.random
我看到的所有地方都说 linux 上的 /dev/urandom 是“随机的”,但我找不到任何来源引用什么样的随机“随机”。我希望它在 0x01 到 0xff 字节上接近统一。如果我想对此进行测试,那
我需要获取由硬件设备生成的高速随机数流,并将其拆分为不同的子流。出于测试目的,我考虑将/dev/urandom 作为数据源。有没有它的linux工具?如果没有 - 请帮助使用 bash 脚本来完成它。
我正在使用函数: private function random($len) { if (@is_readable('/dev/urandom')) { $f=
我正在用 php 5.4 开发一个站点,我想知道使用哪个来生成随机盐以确保密码安全性更好? $salt = sha1(openssl_random_pseudo_bytes(23)); 或 $seed
我是一名优秀的程序员,十分优秀!