- 'bloom_test_1': infinite loop if file not exists - 'websocket_test': uncatched exceptions - 'fc_crypto*' test_stream<>: uninitialized variable (hash) - 'blowfish_chain_test': using memory after allocated heap - memcmp: passing nullptr, when non-null expected - undefined behavior: return value from function - static_variant: member alignment - performance issue on 64-bit arch - memory leak: fc::thread cleanup in asio thread - warning: signed-unsigned comparison - warning: unused variables
29 lines
719 B
C++
29 lines
719 B
C++
#include <openssl/rand.h>
|
|
#include <fc/crypto/openssl.hpp>
|
|
#include <fc/exception/exception.hpp>
|
|
#include <fc/fwd_impl.hpp>
|
|
|
|
|
|
namespace fc {
|
|
|
|
void rand_bytes(char* buf, int count)
|
|
{
|
|
static int init = init_openssl();
|
|
(void)init;
|
|
|
|
int result = RAND_bytes((unsigned char*)buf, count);
|
|
if (result != 1)
|
|
FC_THROW("Error calling OpenSSL's RAND_bytes(): ${code}", ("code", (uint32_t)ERR_get_error()));
|
|
}
|
|
|
|
void rand_pseudo_bytes(char* buf, int count)
|
|
{
|
|
static int init = init_openssl();
|
|
(void)init;
|
|
|
|
int result = RAND_pseudo_bytes((unsigned char*)buf, count);
|
|
if (result == -1)
|
|
FC_THROW("Error calling OpenSSL's RAND_pseudo_bytes(): ${code}", ("code", (uint32_t)ERR_get_error()));
|
|
}
|
|
|
|
} // namespace fc
|