8#ifndef BOTAN_ROUGHTIME_H_
9#define BOTAN_ROUGHTIME_H_
15#include <botan/ed25519.h>
19class RandomNumberGenerator;
35 Nonce(
const std::vector<uint8_t>& nonce);
38 Nonce(
const std::array<uint8_t, 64>& nonce) { m_nonce = nonce; }
42 const std::array<uint8_t, 64>&
get_nonce()
const {
return m_nonce; }
45 std::array<uint8_t, 64> m_nonce;
63 static Response from_bits(
const std::vector<uint8_t>& response,
const Nonce& nonce);
72 Response(
const std::array<uint8_t, 72>& dele,
73 const std::array<uint8_t, 64>& sig,
74 sys_microseconds64 utc_midp,
75 microseconds32 utc_radius) :
76 m_cert_dele(dele), m_cert_sig(sig), m_utc_midpoint{utc_midp}, m_utc_radius{utc_radius} {}
78 const std::array<uint8_t, 72> m_cert_dele;
79 const std::array<uint8_t, 64> m_cert_sig;
80 const sys_microseconds64 m_utc_midpoint;
81 const microseconds32 m_utc_radius;
87 m_response{response}, m_public_key{public_key}, m_nonce_or_blind{nonce_or_blind} {}
89 const std::vector<uint8_t>&
response()
const {
return m_response; }
98 std::vector<uint8_t> m_response;
100 Nonce m_nonce_or_blind;
106 Chain(std::string_view str);
108 const std::vector<Link>&
links()
const {
return m_links; }
110 std::vector<Response> responses()
const;
112 void append(
const Link& new_link,
size_t max_chain_size);
113 std::string to_string()
const;
116 std::vector<Link> m_links;
122Nonce
nonce_from_blind(const std::vector<uint8_t>& previous_response, const Nonce& blind);
134 std::chrono::milliseconds timeout = std::chrono::seconds(3));
140 const std::vector<std::string>& addresses) :
141 m_name{
name}, m_public_key{public_key}, m_addresses{addresses} {}
143 const std::string&
name()
const {
return m_name; }
147 const std::vector<std::string>&
addresses()
const {
return m_addresses; }
152 std::vector<std::string> m_addresses;
const std::vector< Link > & links() const
const Ed25519_PublicKey & public_key() const
const Nonce & nonce_or_blind() const
const std::vector< uint8_t > & response() const
Link(const std::vector< uint8_t > &response, const Ed25519_PublicKey &public_key, const Nonce &nonce_or_blind)
const std::array< uint8_t, 64 > & get_nonce() const
Nonce(const std::array< uint8_t, 64 > &nonce)
bool operator==(const Nonce &rhs) const
std::chrono::time_point< std::chrono::system_clock, microseconds64 > sys_microseconds64
microseconds32 utc_radius() const
sys_microseconds64 utc_midpoint() const
std::chrono::duration< uint32_t, std::micro > microseconds32
std::chrono::duration< uint64_t, std::micro > microseconds64
ErrorType error_type() const noexcept override
Roughtime_Error(std::string_view s)
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
std::vector< Server_Information > servers_from_str(std::string_view str)
std::vector< uint8_t > online_request(std::string_view uri, const Nonce &nonce, std::chrono::milliseconds timeout)
Nonce nonce_from_blind(const std::vector< uint8_t > &previous_response, const Nonce &blind)
std::array< uint8_t, request_min_size > encode_request(const Nonce &nonce)
const unsigned request_min_size