18#include <openssl/opensslv.h>
25#if OPENSSL_VERSION_NUMBER < 0x30000000L
42 explicit DH(
const std::string &dh_txt)
53 DH(
DH &&other) noexcept
81 return dh_ !=
nullptr;
83 ::EVP_PKEY *
obj()
const
93 ::EVP_PKEY *obj_release()
100 void parse_pem(
const std::string &dh_txt)
102 BIO *bio = ::BIO_new_mem_buf(
const_cast<char *
>(dh_txt.c_str()), numeric_cast<int>(dh_txt.length()));
104 throw OpenSSLException();
106 ::EVP_PKEY *dh = ::PEM_read_bio_Parameters_ex(bio,
nullptr,
nullptr,
nullptr);
109 throw OpenSSLException(
"DH::parse_pem");
119 BIO *bio = ::BIO_new(BIO_s_mem());
120 const int ret = ::PEM_write_bio_Parameters(bio,
dh_);
124 throw OpenSSLException(
"DH::render_pem");
129 const size_t buf_len = ::BIO_get_mem_data(bio, &temp);
130 std::string
ret = std::string(temp, buf_len);
148 ::EVP_PKEY_free(
dh_);
151 void dup(const ::EVP_PKEY *dh)
154 dh_ = EVP_PKEY_dup(
const_cast<EVP_PKEY *
>(dh));
void parse_pem(const std::string &dh_txt)
void operator=(const DH &other)
std::string render_pem() const