10#define FMT_HEADER_ONLY
11#include <fmt/format.h>
18 static constexpr size_t SIZE = 256 / 8;
30 explicit Sha256Hash(
const std::vector<uint8_t>& vec);
49 [[nodiscard]] std::string
hex_str()
const;
56 void to_json(nlohmann::json& j,
const Sha256Hash& hash);
58 void from_json(
const nlohmann::json& j, Sha256Hash& hash);
64 bool operator==(
const Sha256Hash& lhs,
const Sha256Hash& rhs);
66 bool operator!=(
const Sha256Hash& lhs,
const Sha256Hash& rhs);
71struct formatter<
ccf::crypto::Sha256Hash>
73 template <
typename ParseContext>
74 constexpr auto parse(ParseContext& ctx)
79 template <
typename FormatContext>
82 return format_to(ctx.out(),
"<sha256 {:02x}>", fmt::join(p.
h,
""));
95 return {hex_str.begin(), hex_str.end()};
100 auto data_str = std::string{data.begin(), data.end()};
Definition sha256_hash.h:16
Representation h
Definition sha256_hash.h:20
static Sha256Hash from_representation(const Representation &r)
Definition sha256_hash.cpp:76
static Sha256Hash from_span(const std::span< const uint8_t, SIZE > &sp)
Definition sha256_hash.cpp:69
Sha256Hash(const Sha256Hash &hash)=default
Sha256Hash(Sha256Hash &&hash) noexcept
Definition sha256_hash.h:39
std::array< uint8_t, SIZE > Representation
Definition sha256_hash.h:19
Sha256Hash & operator=(Sha256Hash &&hash) noexcept
Definition sha256_hash.h:40
std::string hex_str() const
Definition sha256_hash.cpp:57
void set(const Representation &r)
Definition sha256_hash.h:24
friend std::ostream & operator<<(std::ostream &os, const ccf::crypto::Sha256Hash &h)
Definition sha256_hash.cpp:51
static constexpr size_t SIZE
Definition sha256_hash.h:18
static Sha256Hash from_hex_string(const std::string &str)
Definition sha256_hash.cpp:62
Sha256Hash & operator=(const Sha256Hash &hash)=default
bool operator!=(const Sha256Hash &lhs, const Sha256Hash &rhs)
Definition sha256_hash.cpp:134
void fill_json_schema(nlohmann::json &schema, const Pem *pem)
Definition pem.h:107
std::string schema_name(const Pem *pem)
Definition pem.h:99
void to_json(nlohmann::json &j, const Pem &p)
Definition pem.h:77
bool operator==(const Sha256Hash &lhs, const Sha256Hash &rhs)
Definition sha256_hash.cpp:122
void from_json(const nlohmann::json &j, Pem &p)
Definition pem.h:82
Definition sha256_hash.h:88
ccf::ByteVector SerialisedEntry
Definition serialised_entry.h:8
Definition app_interface.h:14
static ccf::crypto::Sha256Hash from_serialised(const SerialisedEntry &data)
Definition sha256_hash.h:98
static SerialisedEntry to_serialised(const ccf::crypto::Sha256Hash &h)
Definition sha256_hash.h:92
Definition blit_serialiser.h:14