8#include <botan/emsa_raw.h>
9#include <botan/exceptn.h>
15 if(m_expected_size > 0)
16 return "Raw(" + std::to_string(m_expected_size) +
")";
23void EMSA_Raw::update(
const uint8_t input[],
size_t length)
25 m_message += std::make_pair(input, length);
31secure_vector<uint8_t> EMSA_Raw::raw_data()
33 if(m_expected_size && m_message.size() != m_expected_size)
34 throw Invalid_Argument(
"EMSA_Raw was configured to use a " +
35 std::to_string(m_expected_size) +
36 " byte hash but instead was used for a " +
37 std::to_string(m_message.size()) +
" hash");
39 secure_vector<uint8_t> output;
40 std::swap(m_message, output);
48EMSA_Raw::encoding_of(
const secure_vector<uint8_t>& msg,
50 RandomNumberGenerator&)
52 if(m_expected_size && msg.size() != m_expected_size)
53 throw Invalid_Argument(
"EMSA_Raw was configured to use a " +
54 std::to_string(m_expected_size) +
55 " byte hash but instead was used for a " +
56 std::to_string(msg.size()) +
" hash");
64bool EMSA_Raw::verify(
const secure_vector<uint8_t>& coded,
65 const secure_vector<uint8_t>& raw,
68 if(m_expected_size && raw.size() != m_expected_size)
71 if(coded.size() == raw.size())
72 return (coded == raw);
74 if(coded.size() > raw.size())
78 const size_t leading_zeros_expected = raw.size() - coded.size();
80 bool same_modulo_leading_zeros =
true;
82 for(
size_t i = 0; i != leading_zeros_expected; ++i)
84 same_modulo_leading_zeros =
false;
87 same_modulo_leading_zeros =
false;
89 return same_modulo_leading_zeros;
std::string name() const override
bool constant_time_compare(const uint8_t x[], const uint8_t y[], size_t len)