17 std::span<uint8_t> output,
18 std::span<const uint8_t> input,
19 std::span<const uint8_t> domain_sep) {
20 if(domain_sep.size() > 0xFF) {
22 throw Not_Implemented(
"XMD does not currently implement oversize DST handling");
25 const uint8_t domain_sep_len =
static_cast<uint8_t
>(domain_sep.size());
28 const size_t block_size = hash->hash_block_size();
33 const size_t hash_output_size = hash->output_length();
34 if(output.size() > 255 * hash_output_size || output.size() > 0xFFFF) {
35 throw Invalid_Argument(
"expand_message_xmd requested output length too long");
40 hash->update(std::vector<uint8_t>(block_size));
42 hash->update_be(
static_cast<uint16_t
>(output.size()));
44 hash->update(domain_sep);
45 hash->update(domain_sep_len);
53 hash->update(domain_sep);
54 hash->update(domain_sep_len);
60 const size_t produced = std::min(output.size(), hash_output_size);
62 copy_mem(&output[0], b_i.data(), produced);
63 output = output.subspan(produced);
74 hash->update(domain_sep);
75 hash->update(domain_sep_len);