18 #include <hicn/transport/errors/runtime_exception.h>
19 #include <hicn/transport/utils/membuf.h>
24 #include <openssl/evp.h>
30 typedef const EVP_MD *(*CryptoHashEVP)(void);
32 enum class CryptoHashType : uint8_t {
47 CryptoHash(
const uint8_t *hash, std::size_t size, CryptoHashType hash_type);
48 CryptoHash(
const std::vector<uint8_t> &hash, CryptoHashType hash_type);
55 bool operator==(
const CryptoHash &other)
const;
58 void computeDigest(
const uint8_t *buffer, std::size_t len);
59 void computeDigest(
const std::vector<uint8_t> &buffer);
65 std::vector<uint8_t> getDigest()
const;
68 std::string getStringDigest()
const;
71 CryptoHashType getType()
const;
74 std::size_t getSize()
const;
77 void setType(CryptoHashType hash_type);
86 static CryptoHashEVP getEVP(CryptoHashType hash_type);
89 static std::size_t getSize(CryptoHashType hash_type);
92 static bool compareDigest(
const uint8_t *h1,
const uint8_t *h2,
93 CryptoHashType hash_type);
96 CryptoHashType digest_type_;
97 std::vector<uint8_t> digest_;
98 std::size_t digest_size_;