8#include <botan/internal/x919_mac.h>
10#include <botan/internal/stl_util.h>
17void ANSI_X919_MAC::add_data(std::span<const uint8_t> input) {
20 BufferSlicer in(input);
22 const auto to_be_xored = in.take(std::min(8 - m_position, in.remaining()));
23 xor_buf(&m_state[m_position], to_be_xored.data(), to_be_xored.size());
24 m_position += to_be_xored.size();
30 m_des1->encrypt(m_state);
31 while(in.remaining() >= 8) {
32 xor_buf(m_state, in.take(8).data(), 8);
33 m_des1->encrypt(m_state);
36 const auto remaining = in.take(in.remaining());
37 xor_buf(m_state, remaining.data(), remaining.size());
38 m_position = remaining.size();
44void ANSI_X919_MAC::final_result(std::span<uint8_t> mac) {
46 m_des1->encrypt(m_state);
48 m_des2->decrypt(m_state.data(), mac.data());
49 m_des1->encrypt(mac.data());
55 return m_des1->has_keying_material() && m_des2->has_keying_material();
61void ANSI_X919_MAC::key_schedule(std::span<const uint8_t> key) {
64 m_des1->set_key(key.first(8));
66 if(key.size() == 16) {
70 m_des2->set_key(key.first(8));
88 return std::make_unique<ANSI_X919_MAC>();
std::unique_ptr< MessageAuthenticationCode > new_object() const override
std::string name() const override
bool has_keying_material() const override
void assert_key_material_set() const
void zeroise(std::vector< T, Alloc > &vec)
void zap(std::vector< T, Alloc > &vec)
constexpr void xor_buf(ranges::contiguous_output_range< uint8_t > auto &&out, ranges::contiguous_range< uint8_t > auto &&in)