25#ifndef MYSQLROUTER_DIGEST_INCLUDED
26#define MYSQLROUTER_DIGEST_INCLUDED
35#include <openssl/evp.h>
63#
if defined(OPENSSL_VERSION_NUMBER) && \
65 EVP_MD_CTX_new(), &EVP_MD_CTX_free
67 EVP_MD_CTX_create(), &EVP_MD_CTX_destroy
78#if defined(OPENSSL_VERSION_NUMBER) && \
79 (OPENSSL_VERSION_NUMBER >= ROUTER_OPENSSL_VERSION(1, 1, 0))
80 EVP_MD_CTX_reset(
ctx_.get());
82 EVP_MD_CTX_cleanup(
ctx_.get());
92 void update(
const std::string &data) {
93 EVP_DigestUpdate(
ctx_.get(), data.data(), data.size());
101 void update(
const std::vector<uint8_t> &data) {
102 EVP_DigestUpdate(
ctx_.get(), data.data(), data.size());
127 return EVP_MD_size(dg);
130 throw std::invalid_argument(
"type wasn't part of Type");
135 template <
typename Container>
139 unsigned int out_len{
static_cast<unsigned int>(std::min(
141 static_cast<size_t>(std::numeric_limits<unsigned int>::max())))};
143 EVP_DigestFinal_ex(
ctx_.get(),
reinterpret_cast<uint8_t *
>(&out[0]),
168#if defined(OPENSSL_VERSION_NUMBER) && \
169 (OPENSSL_VERSION_NUMBER >= ROUTER_OPENSSL_VERSION(1, 1, 0))
message digest.
Definition: digest.h:53
void finalize(std::vector< uint8_t > &out)
finalize the digest and get digest value.
Definition: digest.h:110
static size_t digest_size(Type type)
get size of the digest value.
Definition: digest.h:125
Type type_
Definition: digest.h:166
void finalize(std::string &out)
finalize the digest and get digest value.
Definition: digest.h:117
void update(const std::vector< uint8_t > &data)
update Digest.
Definition: digest.h:101
void update(const std::string &data)
update Digest.
Definition: digest.h:92
static const EVP_MD * get_evp_md(Type type) noexcept
Definition: digest.h:148
void finalize_impl(Container &out)
Definition: digest.h:136
Type
Definition: digest.h:55
void reinit()
initialize or reinitialize the message digest functions.
Definition: digest.h:77
std::unique_ptr< EVP_MD_CTX, decltype(&EVP_MD_CTX_destroy)> ctx_
Definition: digest.h:175
Digest(Type type)
constructor.
Definition: digest.h:62
if(!(yy_init))
Definition: lexyy.cc:1144
std::conditional_t< !std::is_array< T >::value, std::unique_ptr< T, detail::Deleter< T > >, std::conditional_t< detail::is_unbounded_array_v< T >, std::unique_ptr< T, detail::Array_deleter< std::remove_extent_t< T > > >, void > > unique_ptr
The following is a common type that is returned by all the ut::make_unique (non-aligned) specializati...
Definition: ut0new.h:2439
#define ROUTER_OPENSSL_VERSION(MAJOR, MINOR, FIX)
build openssl version (pre-releases and stable).
Definition: openssl_version.h:60
required string type
Definition: replication_group_member_actions.proto:34