Botan 3.9.0
Crypto and TLS for C&
buf_comp.cpp
Go to the documentation of this file.
1/*
2* (C) 2019 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#include <botan/buf_comp.h>
8
9#include <botan/internal/loadstor.h>
10#include <botan/internal/mem_utils.h>
11
12namespace Botan {
13
14void Buffered_Computation::update(std::string_view str) {
15 add_data(as_span_of_bytes(str));
16}
17
19 uint8_t inb[sizeof(val)];
20 store_be(val, inb);
21 add_data({inb, sizeof(inb)});
22}
23
25 uint8_t inb[sizeof(val)];
26 store_be(val, inb);
27 add_data({inb, sizeof(inb)});
28}
29
31 uint8_t inb[sizeof(val)];
32 store_be(val, inb);
33 add_data({inb, sizeof(inb)});
34}
35
37 uint8_t inb[sizeof(val)];
38 store_le(val, inb);
39 add_data({inb, sizeof(inb)});
40}
41
43 uint8_t inb[sizeof(val)];
44 store_le(val, inb);
45 add_data({inb, sizeof(inb)});
46}
47
49 uint8_t inb[sizeof(val)];
50 store_le(val, inb);
51 add_data({inb, sizeof(inb)});
52}
53
54void Buffered_Computation::final(std::span<uint8_t> out) {
55 BOTAN_ARG_CHECK(out.size() >= output_length(), "provided output buffer has insufficient capacity");
56 final_result(out);
57}
58
59} // namespace Botan
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:33
void update_le(uint16_t val)
Definition buf_comp.cpp:36
void update(const uint8_t in[], size_t length)
Definition buf_comp.h:34
virtual size_t output_length() const =0
void update_be(uint16_t val)
Definition buf_comp.cpp:18
std::span< const uint8_t > as_span_of_bytes(const char *s, size_t len)
Definition mem_utils.h:28
constexpr auto store_le(ParamTs &&... params)
Definition loadstor.h:736
constexpr auto store_be(ParamTs &&... params)
Definition loadstor.h:745