Cryptographic security of std::random_device

Is it safe to use it for cryptography purposes say generating a salt ?
std::random_device::entropy() gives 0 on my system (g++ 4.8) as well as here(http://coliru.stacked-crooked.com/a/74d00918b7e4c381).
I want to make my application cross-platform so I can't just use /dev/urandom , also , if std::random_device is not safe (on most platforms) , could you suggest some library , I would prefer an implementation that I could include in my project.
> std::random_device::entropy() gives 0 on my system (g++ 4.8)

Entropy of zero indicates that the std::random_device implementation uses a pseudo-random number engine.

boost::random_device uses cryptographically secure platform-specific randomness sources.
Class random_device models a non-deterministic random number generator . It uses one or more implementation-defined stochastic processes to generate a sequence of uniformly distributed non-deterministic random numbers. For those environments where a non-deterministic random number generator is not available, class random_device must not be implemented.
http://www.boost.org/doc/libs/1_57_0/doc/html/boost/random/random_device.html


http://coliru.stacked-crooked.com/a/dc8f6abe3cef001f
http://rextester.com/FVMMB1160
So , Does that means if a platform could construct an object of std::random_device , I could assume that the output is non-deterministic ?
I wonder , if thats the reason cpp.sh couldn't run the same code I posted which ran on coliru.
Last edited on
> Does that means if a platform could construct an object of std::random_device , I could assume that the output is non-deterministic ?

No.
If implementation limitations prevent generating non-deterministic random numbers, the implementation may employ a random number engine. - IS


It means that if, on a particular implementation, boost::random_device is available, then its output is non-deterministic.
For those environments where a non-deterministic random number generator is not available, class random_device must not be implemented. - boost
Okay , thanks .
Topic archived. No new replies allowed.