BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
rand.cpp
Go to the documentation of this file.
1 #include <openssl/rand.h>
2 #include <fc/crypto/openssl.hpp>
4 #include <fc/fwd_impl.hpp>
5 
6 
7 namespace fc {
8 
9 void rand_bytes(char* buf, int count)
10 {
11  static int init = init_openssl();
12  (void)init;
13 
14  int result = RAND_bytes((unsigned char*)buf, count);
15  if (result != 1)
16  FC_THROW("Error calling OpenSSL's RAND_bytes(): ${code}", ("code", (uint32_t)ERR_get_error()));
17 }
18 
19 } // namespace fc
openssl.hpp
fc
Definition: api.hpp:15
FC_THROW
#define FC_THROW( ...)
Definition: exception.hpp:366
exception.hpp
Defines exception's used by fc.
fc::rand_bytes
void rand_bytes(char *buf, int count)
Definition: rand.cpp:9
fc::init_openssl
int init_openssl()
Definition: openssl.cpp:63
fwd_impl.hpp