/dev/random 由 SecurityServer 的熵提供。SecurityServer 从内核事件跟踪 (kdebug) 收集熵。该方法在“Mac OS X Internals. A Systems Approach”一书中进行了描述。您可以在线阅读它,例如http://flylib.com/books/en/3.126.1.73/1/
熵收集的源代码在这里:http ://www.opensource.apple.com/source/securityd/securityd-40600/src/entropy.cpp
在 xnu-1504.9.37(截至写作时 OS X 的最新版本)中,内核熵缓冲区被填充kernel_debug_internal()
,仅使用时间信息。这是熵缓冲区写入的唯一位置。
if (entropy_flag && (kdebug_enable & KDEBUG_ENABLE_ENTROPY)) {
if (kd_entropy_indx < kd_entropy_count) {
kd_entropy_buffer [ kd_entropy_indx] = mach_absolute_time();
kd_entropy_indx++;
}
if (kd_entropy_indx == kd_entropy_count) {
/*
* Disable entropy collection
*/
kdebug_enable &= ~KDEBUG_ENABLE_ENTROPY;
kdebug_slowcheck &= ~SLOW_ENTROPY;
}
}