25#ifndef __JOIN_DIGEST_HPP__
26#define __JOIN_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;
148 std::unique_ptr <char []>
_buf;
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);
550 template <>
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
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
std::unique_ptr< char[]> _buf
internal buffer.
Definition digest.hpp:148
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:56
BytesArray sha384bin
Definition digest_test.cpp:62
const std::string sha512hex
Definition digest_test.cpp:93
const std::string sha1hex
Definition digest_test.cpp:89
BytesArray sm3bin
Definition digest_test.cpp:80
BytesArray md5bin
message digest in binary format.
Definition digest_test.cpp:41
BytesArray sha224bin
Definition digest_test.cpp:50
const std::string sha384hex
Definition digest_test.cpp:92
const std::string sha224hex
Definition digest_test.cpp:90
const std::string sha256hex
Definition digest_test.cpp:91
BytesArray sha512bin
Definition digest_test.cpp:70
BytesArray sha1bin
Definition digest_test.cpp:45
const std::string sm3hex
Definition digest_test.cpp:94
const std::string md5hex
message digest in hexadecimal format.
Definition digest_test.cpp:88
Definition acceptor.hpp:32
std::vector< uint8_t > BytesArray
bytes array.
Definition base64.hpp:39
std::error_code make_error_code(join::Errc code)
Create an std::error_code object.
Definition error.cpp:154
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_condition make_error_condition(join::Errc code)
Create an std::error_condition object.
Definition error.cpp:163