25#ifndef JOIN_CRYPTO_DIGEST_HPP
26#define JOIN_CRYPTO_DIGEST_HPP
54 virtual const char*
name ()
const noexcept;
61 virtual std::string
message (
int code)
const;
142 virtual int_type
overflow (int_type c = traits_type::eof ())
override;
248 static std::string
md5hex (
const char* data, std::streamsize size);
262 static std::string
md5hex (
const std::string& data);
292 static std::string
sha1hex (
const char* data, std::streamsize size);
306 static std::string
sha1hex (
const std::string& data);
336 static std::string
sha224hex (
const char* data, std::streamsize size);
350 static std::string
sha224hex (
const std::string& data);
380 static std::string
sha256hex (
const char* data, std::streamsize size);
394 static std::string
sha256hex (
const std::string& data);
424 static std::string
sha384hex (
const char* data, std::streamsize size);
438 static std::string
sha384hex (
const std::string& data);
468 static std::string
sha512hex (
const char* data, std::streamsize size);
482 static std::string
sha512hex (
const std::string& data);
512 static std::string
sm3hex (
const char* data, std::streamsize size);
526 static std::string
sm3hex (
const std::string& data);
551 struct is_error_condition_enum<
join::DigestErrc> :
public true_type
digest error category.
Definition digest.hpp:48
virtual std::string message(int code) const
translate digest error code to human readable error string.
Definition digest.cpp:50
virtual const char * name() const noexcept
get digest error category name.
Definition digest.cpp:41
digest stream.
Definition digest.hpp:161
Digest & operator=(const Digest &other)=delete
copy assignment operator.
Digest(const Digest &other)=delete
copy constructor.
static const char * algorithm(Algorithm algo)
get algorithm name.
Definition digest.cpp:642
Algorithm
algorithm.
Definition digest.hpp:167
@ SM3
Definition digest.hpp:174
@ SHA1
Definition digest.hpp:169
@ SHA384
Definition digest.hpp:172
@ SHA512
Definition digest.hpp:173
@ SHA224
Definition digest.hpp:170
@ SHA256
Definition digest.hpp:171
@ MD5
Definition digest.hpp:168
Digest(Algorithm algo)
default constructor.
Definition digest.cpp:204
BytesArray finalize()
get message digest.
Definition digest.cpp:236
Digestbuf _digestbuf
associated digest stream buffer.
Definition digest.hpp:537
virtual ~Digest()=default
destroy digest stream instance.
digest stream buffer.
Definition digest.hpp:91
Digestbuf(const Digestbuf &other)=delete
copy constructor.
Digestbuf(const std::string &algo)
create digest stream buffer instance.
Definition digest.cpp:97
std::unique_ptr< char[]> _buf
internal buffer.
Definition digest.hpp:148
Digestbuf & operator=(const Digestbuf &other)=delete
copy assignment operator.
static const std::streamsize _bufsize
internal buffer size.
Definition digest.hpp:145
EvpMdCtxPtr _ctx
message digest context.
Definition digest.hpp:154
virtual ~Digestbuf()=default
destroy digest stream buffer instance.
BytesArray finalize()
get message digest.
Definition digest.cpp:141
const EVP_MD * _md
message digest.
Definition digest.hpp:151
virtual int_type overflow(int_type c=traits_type::eof()) override
writes characters to the associated output sequence from the put area.
Definition digest.cpp:160
HMAC stream.
Definition hmac.hpp:125
class used to manage signature.
Definition signature.hpp:100
BytesArray sha256bin
Definition digest_test.cpp:48
BytesArray sha384bin
Definition digest_test.cpp:50
const std::string sha512hex
Definition digest_test.cpp:67
const std::string sha1hex
Definition digest_test.cpp:62
BytesArray sm3bin
Definition digest_test.cpp:57
BytesArray md5bin
message digest in binary format.
Definition digest_test.cpp:43
BytesArray sha224bin
Definition digest_test.cpp:46
const std::string sha384hex
Definition digest_test.cpp:65
const std::string sha224hex
Definition digest_test.cpp:63
const std::string sha256hex
Definition digest_test.cpp:64
BytesArray sha512bin
Definition digest_test.cpp:53
BytesArray sha1bin
Definition digest_test.cpp:44
const std::string sm3hex
Definition digest_test.cpp:70
const std::string md5hex
message digest in hexadecimal format.
Definition digest_test.cpp:61
Definition acceptor.hpp:32
std::unique_ptr< EVP_MD_CTX, EvpMdCtxDelete > EvpMdCtxPtr
Definition openssl.hpp:133
const std::error_category & getDigestCategory()
get error category.
Definition digest.cpp:69
DigestErrc
digest error codes.
Definition digest.hpp:38
std::error_code make_error_code(join::Errc code) noexcept
Create an std::error_code object.
Definition error.cpp:150
std::error_condition make_error_condition(join::Errc code) noexcept
Create an std::error_condition object.
Definition error.cpp:159
std::vector< uint8_t > BytesArray
bytes array.
Definition base64.hpp:39