8#include <botan/internal/emsa_raw.h>
10#include <botan/exceptn.h>
11#include <botan/mem_ops.h>
12#include <botan/internal/ct_utils.h>
13#include <botan/internal/fmt.h>
18 if(m_expected_size > 0) {
19 return fmt(
"Raw({})", m_expected_size);
27void EMSA_Raw::update(
const uint8_t input[],
size_t length) {
28 m_message += std::make_pair(input, length);
34std::vector<uint8_t> EMSA_Raw::raw_data() {
35 if(m_expected_size && m_message.size() != m_expected_size) {
36 throw Invalid_Argument(
37 fmt(
"EMSA_Raw was configured to use a {} byte hash but instead was used for a {} byte hash",
42 std::vector<uint8_t> output;
43 std::swap(m_message, output);
50std::vector<uint8_t> EMSA_Raw::encoding_of(std::span<const uint8_t> msg,
53 if(m_expected_size && msg.size() != m_expected_size) {
54 throw Invalid_Argument(
55 fmt(
"EMSA_Raw was configured to use a {} byte hash but instead was used for a {} byte hash",
60 return std::vector<uint8_t>(msg.begin(), msg.end());
66bool EMSA_Raw::verify(std::span<const uint8_t> coded, std::span<const uint8_t> raw,
size_t ) {
67 if(m_expected_size && raw.size() != m_expected_size) {
71 if(raw.size() > coded.size()) {
73 const size_t expected_lz = raw.size() - coded.size();
75 auto contents_ok =
CT::is_equal(coded.data(), raw.data() + expected_lz, coded.size());
76 return (zeros_ok & contents_ok).as_bool();
std::string name() const override
constexpr CT::Mask< T > is_equal(const T x[], const T y[], size_t len)
constexpr CT::Mask< T > all_zeros(const T elem[], size_t len)
std::string fmt(std::string_view format, const T &... args)
bool constant_time_compare(std::span< const uint8_t > x, std::span< const uint8_t > y)