9#include <botan/internal/keccak_helpers.h>
11#include <botan/internal/bit_ops.h>
12#include <botan/internal/loadstor.h>
20size_t int_encoding_size(uint64_t x) {
25uint8_t
encode(std::span<uint8_t> out, uint64_t x) {
26 const auto bytes_needed = int_encoding_size(x);
29 std::array<uint8_t,
sizeof(x)> bigendian_x;
32 auto begin = bigendian_x.begin();
33 std::advance(begin,
sizeof(x) - bytes_needed);
34 std::copy(begin, bigendian_x.end(), out.begin());
36 return static_cast<uint8_t
>(bytes_needed);
43 out[0] = encode(out.last(out.size() - 1), x);
44 return out.first(out[0] + 1 );
48 const auto bytes_needed = encode(out, x);
50 out[bytes_needed] = bytes_needed;
51 return out.first(bytes_needed + 1 );
55 return int_encoding_size(x) + 1 ;
#define BOTAN_ASSERT_NOMSG(expr)
std::string encode(const uint8_t der[], size_t length, std::string_view label, size_t width)
std::span< const uint8_t > keccak_int_left_encode(std::span< uint8_t > out, size_t x)
std::span< const uint8_t > keccak_int_right_encode(std::span< uint8_t > out, size_t x)
constexpr T ceil_tobytes(T bits)
size_t keccak_int_encoding_size(size_t x)
constexpr auto store_be(ParamTs &&... params)
constexpr uint8_t ceil_log2(T x)