在查看英特尔数字随机数发生器(DRNG)软件实施指南之后,我对RDRAND调用时生成器的内部状态会发生什么问题提出了一些问题.不幸的是,答案似乎不在指南中.
根据该指南,在DRNG内部有四个128位缓冲器,用于提供随机位以RDRAND进行漏极.RDRAND本身将提供16位,32位或64位随机数据,具体取决于目标寄存器的宽度:
rdrand ax ; put 16 random bits in ax
rdrand eax ; put 32 random bits in eax
rdrand rax ; put 64 random bits in rax
Run Code Online (Sandbox Code Playgroud)
使用更大的目标寄存器会更快地清空这些128位缓冲区吗?例如,如果我只需要2位随机性,那么我是否应该经历在64位寄存器上使用16位寄存器的麻烦?这会对DRNG的吞吐量产生任何影响吗?我想避免消耗比必要更多的随机性.
指南说执行后将设置进位标志RDRAND:
CF = 1 Destination register valid. Non-zero random value
available at time of execution. Result placed in register.
CF = 0 Destination register all zeros. Random value not available
at time of execution. May be retried.
Run Code Online (Sandbox Code Playgroud)
"不可用"是什么意思?随机数据是否可用,因为RDRAND调用过快地耗尽了这些128位缓冲区?或者不可用意味着DRNG未通过健康检查而无法生成任何新数据?基本上,我试图理解CF …
我正在尝试找到一种简单的方法来将 a 映射URI到 a Path,而无需编写特定于任何特定文件系统的代码。以下似乎可行,但需要一种有问题的技术:
public void process(URI uri) throws IOException {
try {
// First try getting a path via existing file systems. (default fs)
Path path = Paths.get(uri);
doSomething(uri, path);
}
catch (FileSystemNotFoundException e) {
// No existing file system, so try creating one. (jars, zips, etc.)
Map<String, ?> env = Collections.emptyMap();
try (FileSystem fs = FileSystems.newFileSystem(uri, env)) {
Path path = fs.provider().getPath(uri); // yuck :(
// assert path.getFileSystem() == fs;
doSomething(uri, path);
}
} …Run Code Online (Sandbox Code Playgroud)