25#ifndef MYSQLROUTER_DIGEST_INCLUDED
26#define MYSQLROUTER_DIGEST_INCLUDED
37#include <openssl/evp.h>
65#
if defined(OPENSSL_VERSION_NUMBER) && \
67 EVP_MD_CTX_new(), &EVP_MD_CTX_free
69 EVP_MD_CTX_create(), &EVP_MD_CTX_destroy
80#if defined(OPENSSL_VERSION_NUMBER) && \
81 (OPENSSL_VERSION_NUMBER >= ROUTER_OPENSSL_VERSION(1, 1, 0))
82 EVP_MD_CTX_reset(
ctx_.get());
84 EVP_MD_CTX_cleanup(
ctx_.get());
94 void update(
const std::span<const uint8_t> &data) {
95 EVP_DigestUpdate(
ctx_.get(), data.data(), data.size());
98 void update(
const std::string_view &data) {
99 EVP_DigestUpdate(
ctx_.get(), data.data(), data.length());
124 return EVP_MD_size(dg);
127 throw std::invalid_argument(
"type wasn't part of Type");
132 template <
typename Container>
136 unsigned int out_len{
static_cast<unsigned int>(std::min(
138 static_cast<size_t>(std::numeric_limits<unsigned int>::max())))};
140 EVP_DigestFinal_ex(
ctx_.get(),
reinterpret_cast<uint8_t *
>(&out[0]),
165#if defined(OPENSSL_VERSION_NUMBER) && \
166 (OPENSSL_VERSION_NUMBER >= ROUTER_OPENSSL_VERSION(1, 1, 0))
message digest.
Definition: digest.h:55
void finalize(std::vector< uint8_t > &out)
finalize the digest and get digest value.
Definition: digest.h:107
static size_t digest_size(Type type)
get size of the digest value.
Definition: digest.h:122
Type type_
Definition: digest.h:163
void finalize(std::string &out)
finalize the digest and get digest value.
Definition: digest.h:114
void update(const std::span< const uint8_t > &data)
update Digest.
Definition: digest.h:94
static const EVP_MD * get_evp_md(Type type) noexcept
Definition: digest.h:145
void finalize_impl(Container &out)
Definition: digest.h:133
Type
Definition: digest.h:57
void reinit()
initialize or reinitialize the message digest functions.
Definition: digest.h:79
std::unique_ptr< EVP_MD_CTX, decltype(&EVP_MD_CTX_destroy)> ctx_
Definition: digest.h:172
void update(const std::string_view &data)
Definition: digest.h:98
Digest(Type type)
constructor.
Definition: digest.h:64
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:2440
#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