I\'m principally interested in the implementation of SecRandomCopyBytes
on iOS, if it differs from the OS X implementation. (I would presume that i
/dev/random is fed by entropy from the SecurityServer. SecurityServer collecting entropy from the kernel event tracking (kdebug). The method is described in the book "Mac OS X Internals. A Systems Approach". You can read about it online for example at http://flylib.com/books/en/3.126.1.73/1/
the source code for the entropy collecting is here: http://www.opensource.apple.com/source/securityd/securityd-40600/src/entropy.cpp
In xnu-1504.9.37 (latest version for OS X as of writing), the kernel entropy buffer is filled in kernel_debug_internal()
, using only timing information. This is the only place that the entropy buffer is written to.
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;
}
}