#include "blocxx/BLOCXX_config.h"#include "blocxx/Array.hpp"#include "blocxx/Assertion.hpp"#include "blocxx/Exec.hpp"#include "blocxx/FileSystem.hpp"#include "blocxx/Mutex.hpp"#include "blocxx/MutexLock.hpp"#include "blocxx/GlobalMutex.hpp"#include "blocxx/Secure.hpp"#include "blocxx/SecureRand.hpp"#include "blocxx/SSLCtxMgr.hpp"#include "blocxx/String.hpp"#include "blocxx/Thread.hpp"#include "blocxx/ThreadOnce.hpp"#include "blocxx/UnnamedPipe.hpp"#include "blocxx/UserUtils.hpp"#include "blocxx/Process.hpp"#include <cmath>#include <csignal>#include <cstring>#include <limits>#include <unistd.h>#include <fcntl.h>#include <openssl/rand.h>#include <openssl/err.h>#include <sys/resource.h>#include <sys/time.h>Go to the source code of this file.
Namespaces | |
| namespace | BLOCXX_NAMESPACE |
| namespace | BLOCXX_NAMESPACE::Secure |
| namespace | BLOCXX_NAMESPACE::Secure::Impl |
Classes | |
| struct | BLOCXX_NAMESPACE::Secure::Impl::log2< N > |
| struct | BLOCXX_NAMESPACE::Secure::Impl::log2< 1 > |
| struct | BLOCXX_NAMESPACE::Secure::Impl::bits_precision< Number > |
Functions | |
| void | rand_init_impl () |
| void | BLOCXX_NAMESPACE::Secure::rand_init () |
| Initializes and seeds the cryptographic PRNG, if this has not been done already. | |
| unsigned char * | BLOCXX_NAMESPACE::Secure::rand (unsigned char *buf, std::size_t n) |
| Generates n cryptographically secure pseudo-random bytes and stores them in buf. | |
| ::pid_t | BLOCXX_NAMESPACE::Secure::fork_reseed () |
| Forks and reseeds the PRNG so that a compromise of the child cannot compromise the parent's PRNG state, and a compromise of the parent cannot compromise the child's PRNG state. | |
| template<typename UnsignedInt> | |
| UnsignedInt | BLOCXX_NAMESPACE::Secure::Impl::rand_uint_lt (UnsignedInt n) |
| template unsigned char | BLOCXX_NAMESPACE::Secure::Impl::rand_uint_lt< unsigned char > (unsigned char) |
| template unsigned short | BLOCXX_NAMESPACE::Secure::Impl::rand_uint_lt< unsigned short > (unsigned short) |
| template unsigned int | BLOCXX_NAMESPACE::Secure::Impl::rand_uint_lt< unsigned int > (unsigned int) |
| template unsigned long | BLOCXX_NAMESPACE::Secure::Impl::rand_uint_lt< unsigned long > (unsigned long) |
| template unsigned long long | BLOCXX_NAMESPACE::Secure::Impl::rand_uint_lt< unsigned long long > (unsigned long long) |
| template<typename Integer> | |
| Integer | BLOCXX_NAMESPACE::Secure::Impl::rand_range (Integer min_value, Integer max_value) |
| template char | BLOCXX_NAMESPACE::Secure::Impl::rand_range (char, char) |
| template signed char | BLOCXX_NAMESPACE::Secure::Impl::rand_range (signed char, signed char) |
| template unsigned char | BLOCXX_NAMESPACE::Secure::Impl::rand_range (unsigned char, unsigned char) |
| template short | BLOCXX_NAMESPACE::Secure::Impl::rand_range (short, short) |
| template int | BLOCXX_NAMESPACE::Secure::Impl::rand_range (int, int) |
| template long | BLOCXX_NAMESPACE::Secure::Impl::rand_range (long, long) |
| template unsigned long long | BLOCXX_NAMESPACE::Secure::Impl::rand_range (unsigned long long, unsigned long long) |
| template<typename Real> | |
| Real | BLOCXX_NAMESPACE::Secure::Impl::rand_unit_interval () |
| template float | BLOCXX_NAMESPACE::Secure::Impl::rand_unit_interval< float > () |
| template double | BLOCXX_NAMESPACE::Secure::Impl::rand_unit_interval< double > () |
| template long double | BLOCXX_NAMESPACE::Secure::Impl::rand_unit_interval< long double > () |
| void | BLOCXX_NAMESPACE::Secure::rand_save_state () |
| static void | randomALRMHandler (int sig) |
| void | generateRandomTimerData (unsigned char *data, int size, int *iterations) |
| void | generateRandomDataFromFile (const char *name, int len) |
| void | generateRandomDataFromTime (double entropy) |
| String | locateInPath (const String &cmd, const String &path) |
| void | rand_init_impl () |
Variables | |
| unsigned const | RESEED_BYTES = 16 |
| unsigned const | SEED_BYTES = 16 |
| blocxx::OnceFlag | guard = {0, PTHREAD_MUTEX_INITIALIZER} |
| volatile sig_atomic_t | g_counter |
| volatile unsigned char * | g_data |
| volatile sig_atomic_t | g_dataIdx |
| int | g_dataSize |
| GlobalMutex | g_randomTimerGuard = { 0 , 0, {0, PTHREAD_MUTEX_INITIALIZER} } |
| const cmd | randomSourceCommands [] |
| void @199::generateRandomDataFromFile | ( | const char * | name, | |
| int | len | |||
| ) | [static] |
Definition at line 438 of file SecureRand.cpp.
References BLOCXX_NAMESPACE::FileSystem::read().
Referenced by rand_init_impl().
| void @199::generateRandomDataFromTime | ( | double | entropy | ) | [static] |
| void @199::generateRandomTimerData | ( | unsigned char * | data, | |
| int | size, | |||
| int * | iterations | |||
| ) | [static] |
Definition at line 389 of file SecureRand.cpp.
References BLOCXX_ASSERT, g_counter, g_data, g_dataIdx, g_dataSize, and randomALRMHandler().
| String @199::locateInPath | ( | const String & | cmd, | |
| const String & | path | |||
| ) | [static] |
Definition at line 633 of file SecureRand.cpp.
References BLOCXX_NAMESPACE::FileSystem::exists(), and i.
Referenced by rand_init_impl().
| void @199::rand_init_impl | ( | ) | [static] |
Definition at line 667 of file SecureRand.cpp.
References command, BLOCXX_NAMESPACE::FileSystem::Path::E_SECURE_FILE, generateRandomDataFromFile(), generateRandomDataFromTime(), i, locateInPath(), MAXPATHLEN, BLOCXX_NAMESPACE::Exec::processInputOutput(), BLOCXX_NAMESPACE::FileSystem::Path::security(), and BLOCXX_NAMESPACE::Exec::spawn().
| void @199::rand_init_impl | ( | ) | [static] |
Referenced by BLOCXX_NAMESPACE::Secure::rand(), and BLOCXX_NAMESPACE::Secure::rand_init().
| static void randomALRMHandler | ( | int | sig | ) | [static] |
Definition at line 372 of file SecureRand.cpp.
References g_counter, g_data, g_dataIdx, and g_dataSize.
Referenced by generateRandomTimerData().
| const char* command |
Definition at line 476 of file SecureRand.cpp.
Referenced by BLOCXX_NAMESPACE::StackTrace::getStackTrace(), and rand_init_impl().
volatile sig_atomic_t g_counter [static] |
Definition at line 359 of file SecureRand.cpp.
Referenced by generateRandomTimerData(), and randomALRMHandler().
volatile unsigned char* g_data [static] |
Definition at line 360 of file SecureRand.cpp.
Referenced by generateRandomTimerData(), and randomALRMHandler().
volatile sig_atomic_t g_dataIdx [static] |
Definition at line 361 of file SecureRand.cpp.
Referenced by generateRandomTimerData(), and randomALRMHandler().
int g_dataSize [static] |
Definition at line 362 of file SecureRand.cpp.
Referenced by generateRandomTimerData(), and randomALRMHandler().
GlobalMutex g_randomTimerGuard = { 0 , 0, {0, PTHREAD_MUTEX_INITIALIZER} } [static] |
Definition at line 384 of file SecureRand.cpp.
blocxx::OnceFlag guard = {0, PTHREAD_MUTEX_INITIALIZER} [static] |
Definition at line 127 of file SecureRand.cpp.
const cmd randomSourceCommands[] [static] |
Definition at line 483 of file SecureRand.cpp.
unsigned const RESEED_BYTES = 16 [static] |
Definition at line 89 of file SecureRand.cpp.
Referenced by BLOCXX_NAMESPACE::Secure::fork_reseed().
unsigned const SEED_BYTES = 16 [static] |
Definition at line 90 of file SecureRand.cpp.
| double usefulness |
Definition at line 479 of file SecureRand.cpp.
1.5.6