#ifndef _WIN32 #include "CryptoInit.h" #include #include #include namespace openssl { #include #include #include #include #include } // namespace openssl namespace bts { namespace crypto { static const char rnd_seed[] = "string to make the random number generator think it has entropy"; bool CryptoInit::init = false; tbb::spin_mutex _lock; void CryptoInit::initialize() { if (!init) { tbb::spin_mutex::scoped_lock lock(_lock); if (!init) { openssl::OpenSSL_add_all_algorithms(); openssl::OpenSSL_add_all_ciphers(); openssl::OpenSSL_add_all_digests(); openssl::RAND_seed(rnd_seed, sizeof rnd_seed); init = true; } } } void CryptoInit::cleanup() { if (init) { tbb::spin_mutex::scoped_lock lock(_lock); if (init) { init = false; } } } } // namespace crypto } // namespace bts #endif