14 #include <openssl/crypto.h>
15 #include <openssl/rand.h>
18 namespace cryptolink {
21 class CryptoLinkImpl {
24 CryptoLink::~CryptoLink() {
29 class RNGImpl :
public RNG {
36 std::vector<uint8_t> random(
size_t len) {
37 std::vector<uint8_t> data;
40 if (RAND_bytes(&data[0], len) != 1) {
42 "OpenSSL RAND_bytes() failed");
51 CryptoLink& c = getCryptoLinkInternal();
54 c.impl_ =
new CryptoLinkImpl();
55 }
catch (
const std::exception &ex) {
58 "Error during OpenSSL initialization:" << ex.what());
62 "Error during OpenSSL initialization");
67 c.rng_.reset(
new RNGImpl());
68 }
catch (
const std::exception &ex) {
71 "Error during OpenSSL RNG initialization:" << ex.what());
75 "Error during OpenSSL RNG initialization");
82 return (SSLeay_version(SSLEAY_VERSION));
This exception is raised when a general error that was not specifically caught is thrown by the under...
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
static void initialize()
Initialize the library manually.
Defines the logger used by the top-level component of kea-dhcp-ddns.
static std::string getVersion()
Get version string.