9#include <botan/internal/streebog.h>
11#include <botan/exceptn.h>
12#include <botan/internal/fmt.h>
13#include <botan/internal/loadstor.h>
14#include <botan/internal/stl_util.h>
22 return std::make_unique<Streebog>(*
this);
26 if(output_bits != 256 && output_bits != 512) {
34 return fmt(
"Streebog-{}", m_output_bits);
45 const uint64_t fill = (m_output_bits == 512) ? 0 : 0x0101010101010101;
46 std::fill(m_h.begin(), m_h.end(), fill);
76 const uint8_t padding = 0x01;
77 m_buffer.
append({&padding, 1});
95inline uint64_t force_le(uint64_t x) {
96#if defined(BOTAN_TARGET_CPU_IS_LITTLE_ENDIAN)
98#elif defined(BOTAN_TARGET_CPU_IS_BIG_ENDIAN)
101 store_le(x,
reinterpret_cast<uint8_t*
>(&x));
106inline void lps(uint64_t block[8]) {
109 std::memcpy(r, block, 64);
111 for(
int i = 0; i < 8; ++i) {
123 std::memcpy(M, input, 64);
129 const uint64_t N = last_block ? 0 : force_le(m_count);
140 for(
size_t i = 0; i != 8; ++i) {
144 for(
size_t i = 0; i < 12; ++i) {
145 for(
size_t j = 0; j != 8; ++j) {
151 for(
size_t j = 0; j != 8; ++j) {
156 for(
size_t i = 0; i != 8; ++i) {
157 m_h[i] ^= hN[i] ^ M[i];
162 for(
int i = 0; i < 8; i++) {
163 const uint64_t m = force_le(M[i]);
164 const uint64_t hi = force_le(m_S[i]);
165 const uint64_t t = hi + m +
carry;
167 m_S[i] = force_le(t);
std::span< T > directly_modify_first(size_t elements)
size_t elements_in_buffer() const
std::optional< std::span< const uint8_t > > next_aligned_block_to_process(BufferSlicer &slicer) const
void append(std::span< const T > elements)
std::optional< std::span< const T > > handle_unaligned_data(BufferSlicer &slicer)
std::span< const T > consume()
void fill_up_with_zeros()
bool in_alignment() const
void compress(const uint8_t input[], bool lastblock=false)
void add_data(std::span< const uint8_t > input) override
size_t output_length() const override
void compress_64(const uint64_t input[], bool lastblock=false)
std::unique_ptr< HashFunction > copy_state() const override
void final_result(std::span< uint8_t > out) override
Streebog(size_t output_bits)
std::string name() const override
void zeroise(std::vector< T, Alloc > &vec)
std::string fmt(std::string_view format, const T &... args)
const uint64_t STREEBOG_C[12][8]
constexpr void store_le(T in, OutR &&out_range)
constexpr uint16_t reverse_bytes(uint16_t x)
void carry(int64_t &h0, int64_t &h1)
const uint64_t STREEBOG_Ax[8][256]
constexpr void copy_mem(T *out, const T *in, size_t n)