37 if (other.
md_ !=
nullptr) {
40 1, EVP_MD_CTX_copy_ex(
ctx_.get(), other.
ctx_.get()));
46 return *
new (
this)
Digest(other);
55 1, EVP_DigestUpdate(
ctx_.get(), data.
data(), data.
size()));
63 const auto size = EVP_MD_size(
md_);
72 const EVP_MD*
md_ =
nullptr;
89 hash(out, EVP_sha1(), data);
92 hash(out, EVP_sha1(), data);
95 hash(out, EVP_sha256(), data);
98 hash(out, EVP_sha256(), data);
115 for (
auto r : data) {
120 const auto size = EVP_MD_size(
md_);
122 unsigned int len = 0;
129 const EVP_MD*
md_ =
nullptr;
151 hmac(out, EVP_sha1(), key, data);
155 hmac(out, EVP_sha1(), key, data);
158 hmac(out, EVP_sha256(), key, data);
162 hmac(out, EVP_sha256(), key, data);
177 if (
LIKELY(result == expected)) {
180 throw_exception<std::runtime_error>(
"openssl crypto function failed");
static void hmac(MutableByteRange out, const EVP_MD *md, ByteRange key, ByteRange data)
static void check_out_size_throw(size_t size, MutableByteRange out)
std::unique_ptr< HMAC_CTX, HmacCtxDeleter > HmacCtxUniquePtr
void hash_init(const EVP_MD *md)
constexpr size_type size() const
void hash_update(const IOBuf &data)
—— Concurrent Priority Queue Implementation ——
static void sha256(MutableByteRange out, ByteRange data)
Digest(const Digest &other)
constexpr auto size(C const &c) -> decltype(c.size())
HMAC_CTX * HMAC_CTX_new()
void hash_final(MutableByteRange out)
static void check_libssl_result(int expected, int result)
void hash_update(ByteRange data)
void hash_update(ByteRange data)
Digest & operator=(const Digest &other)
constexpr Iter data() const
constexpr auto data(C &c) -> decltype(c.data())
static void hmac(MutableByteRange out, const EVP_MD *md, ByteRange key, const IOBuf &data)
static void hmac_sha256(MutableByteRange out, ByteRange key, const IOBuf &data)
static void hash(MutableByteRange out, const EVP_MD *md, const IOBuf &data)
static void hmac_sha256(MutableByteRange out, ByteRange key, ByteRange data)
void hash_init(const EVP_MD *md, ByteRange key)
static void sha1(MutableByteRange out, const IOBuf &data)
static void hmac_sha1(MutableByteRange out, ByteRange key, const IOBuf &data)
static void hmac_sha1(MutableByteRange out, ByteRange key, ByteRange data)
EVP_MD_CTX * EVP_MD_CTX_new()
void hash_update(const IOBuf &data)
void hash_final(MutableByteRange out)
static void hash(MutableByteRange out, const EVP_MD *md, ByteRange data)
static void sha256(MutableByteRange out, const IOBuf &data)
std::unique_ptr< EVP_MD_CTX, EvpMdCtxDeleter > EvpMdCtxUniquePtr
static void sha1(MutableByteRange out, ByteRange data)
static void check_out_size(size_t size, MutableByteRange out)