8#include <botan/internal/par_hash.h>
10#include <botan/exceptn.h>
11#include <botan/internal/buffer_stuffer.h>
17void Parallel::add_data(std::span<const uint8_t> input) {
18 for(
auto&& hash : m_hashes) {
23void Parallel::final_result(std::span<uint8_t> output) {
24 BufferStuffer out(output);
25 for(
auto&& hash : m_hashes) {
26 hash->final(out.next(hash->output_length()));
33 for(
auto&& hash : m_hashes) {
34 sum += hash->output_length();
43 for(
auto&& hash : m_hashes) {
44 level = std::max(level, hash->security_level());
50 std::ostringstream
name;
54 for(
size_t i = 0; i != m_hashes.size(); ++i) {
58 name << m_hashes[i]->name();
67 std::vector<std::unique_ptr<HashFunction>> hash_copies;
68 hash_copies.reserve(m_hashes.size());
70 for(
auto&& hash : m_hashes) {
71 hash_copies.push_back(std::unique_ptr<HashFunction>(hash->new_object()));
74 return std::make_unique<Parallel>(hash_copies);
78 std::vector<std::unique_ptr<HashFunction>> hash_new_objects;
79 hash_new_objects.reserve(m_hashes.size());
81 for(
const auto& hash : m_hashes) {
82 hash_new_objects.push_back(hash->copy_state());
85 return std::make_unique<Parallel>(hash_new_objects);
89 for(
auto&& hash : m_hashes) {
95 if(hashes.size() < 2) {
96 throw Invalid_Argument(
"Parallel hash requires at least two hashes be specified");
98 m_hashes.reserve(hashes.size());
99 for(
auto&& hash : hashes) {
100 m_hashes.push_back(std::move(hash));
std::unique_ptr< HashFunction > new_object() const override
std::string name() const override
std::unique_ptr< HashFunction > copy_state() const override
Parallel(std::vector< std::unique_ptr< HashFunction > > &hashes)
size_t security_level() const override
size_t output_length() const override