9#include <botan/internal/streebog.h>
11#include <botan/exceptn.h>
12#include <botan/internal/bswap.h>
13#include <botan/internal/fmt.h>
14#include <botan/internal/loadstor.h>
15#include <botan/internal/stl_util.h>
23 return std::make_unique<Streebog>(*
this);
27 if(output_bits != 256 && output_bits != 512) {
35 return fmt(
"Streebog-{}", m_output_bits);
46 const uint64_t fill = (m_output_bits == 512) ? 0 : 0x0101010101010101;
47 std::fill(m_h.begin(), m_h.end(), fill);
77 const uint8_t padding = 0x01;
78 m_buffer.
append({&padding, 1});
96inline uint64_t force_le(uint64_t x) {
97#if defined(BOTAN_TARGET_CPU_IS_LITTLE_ENDIAN)
99#elif defined(BOTAN_TARGET_CPU_IS_BIG_ENDIAN)
102 store_le(x,
reinterpret_cast<uint8_t*
>(&x));
107inline void lps(uint64_t block[8]) {
110 std::memcpy(r, block, 64);
112 for(
int i = 0; i < 8; ++i) {
124 std::memcpy(M, input, 64);
130 const uint64_t N = last_block ? 0 : force_le(m_count);
141 for(
size_t i = 0; i != 8; ++i) {
145 for(
size_t i = 0; i < 12; ++i) {
146 for(
size_t j = 0; j != 8; ++j) {
152 for(
size_t j = 0; j != 8; ++j) {
157 for(
size_t i = 0; i != 8; ++i) {
158 m_h[i] ^= hN[i] ^ M[i];
163 for(
int i = 0; i < 8; i++) {
164 const uint64_t m = force_le(M[i]);
165 const uint64_t hi = force_le(m_S[i]);
166 const uint64_t t = hi + m +
carry;
168 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 T reverse_bytes(T x)
constexpr auto store_le(ParamTs &&... params)
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)