[Boost.Filesystem] unique_path uses a random number generator from the OS, correct?
The reference docs for unique_path state: Remarks: Implementations are encouraged to obtain the required randomness via a cryptographically secure pseudo-random number generator, such as one provided by the operating system. I'm confused by the "implementations are encouraged to" text. Isn't Boost.Filesystem the implementation of unique_path? Specifically, it *looks like* this is provided in unique_path.cpp which will use either CryptGenRandom from the Windows API; or /dev/urandom or /dev/random on POSIX systems. This means the random number comes from system/OS utilities, and not Boost itself, correct? -- Ben Fritz
Hi Ben, The filesystem library has been proposed to the C++14 standard as a TS library. This means that it's documentation is written in "standard-speak". Throughout the standard, when it says things like "implementations are encouraged to", the "implementation" is the compiler-vendor or implementer of the standard library being used (which may or may not be the same people). So, in the case of Boost.Filesystem, you could see it as a Boost-provided version of the standard filesystem library (or closely matching the final form it takes for the standard TS). So, the "implementation" refers to the Boost implementation itself. This can be a bit confusing, but once to understand that it is written in the same language (and perspective) as it would be if it appeared in the C++ standard, this all makes sense. Most likely, the boost implementation uses the Boost.Random or standard <random> library with the "random_device" generator (which is probably implemented in terms of something like CryptGenRandom or the /dev/urandom device). Mikael.
participants (2)
-
Ben Fritz
-
Mikael Persson