26#ifndef MYSQLROUTER_ROUTING_OPENSSL_DIGEST_H
27#define MYSQLROUTER_ROUTING_OPENSSL_DIGEST_H
33#include <openssl/evp.h>
34#include <openssl/opensslv.h>
54#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
57 EVP_MD_CTX_destroy(ctx);
69 bool init(
const EVP_MD *digest_func) {
70 if (digest_func ==
nullptr)
return false;
72 auto res = EVP_DigestInit_ex(
ctx_.get(), digest_func,
nullptr);
82 return EVP_DigestUpdate(
ctx_.get(), data.data(), data.size());
89 return EVP_DigestFinal_ex(
90 ctx_.get(),
reinterpret_cast<unsigned char *
>(out.data()), &written);
96 std::unique_ptr<EVP_MD_CTX, Deleter>
ctx_ {
97#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
Definition: openssl_digest.h:51
void operator()(EVP_MD_CTX *ctx)
Definition: openssl_digest.h:53
Definition: openssl_digest.h:49
std::unique_ptr< EVP_MD_CTX, Deleter > ctx_
Definition: openssl_digest.h:96
bool update(const T &data)
Definition: openssl_digest.h:81
bool init(DigestFunc func)
Definition: openssl_digest.h:78
const EVP_MD * digest_func_
Definition: openssl_digest.h:94
bool init(const EVP_MD *digest_func)
Definition: openssl_digest.h:69
DigestCtx(const DigestFunc &func)
Definition: openssl_digest.h:63
bool init()
Definition: openssl_digest.h:66
bool finalize(T &out)
Definition: openssl_digest.h:86
DigestCtx(const EVP_MD *func)
Definition: openssl_digest.h:62
Definition: openssl_digest.h:37
const EVP_MD * func_
Definition: openssl_digest.h:46
DigestFunc(const EVP_MD *func)
Definition: openssl_digest.h:39
int size() const
Definition: openssl_digest.h:41
const EVP_MD * native_func() const
Definition: openssl_digest.h:43
Definition: openssl_digest.h:36