7#include <botan/internal/x931_sig_padding.h> 
    9#include <botan/exceptn.h> 
   10#include <botan/hash.h> 
   11#include <botan/mem_ops.h> 
   12#include <botan/internal/fmt.h> 
   13#include <botan/internal/hash_id.h> 
   14#include <botan/internal/stl_util.h> 
   20std::vector<uint8_t> x931_encoding(std::span<const uint8_t> msg,
 
   22                                   std::span<const uint8_t> empty_hash,
 
   24   const size_t HASH_SIZE = empty_hash.size();
 
   26   const size_t output_length = (output_bits + 1) / 8;
 
   28   if(msg.size() != HASH_SIZE) {
 
   29      throw Encoding_Error(
"X931_SignaturePadding::encoding_of: Bad input length");
 
   31   if(output_length < HASH_SIZE + 4) {
 
   32      throw Encoding_Error(
"X931_SignaturePadding::encoding_of: Output length is too small");
 
   37   std::vector<uint8_t> output(output_length);
 
   40   stuffer.append(empty_input ? 0x4B : 0x6B);
 
   41   stuffer.append(0xBB, stuffer.remaining_capacity() - (1 + msg.size() + 2));
 
   44   stuffer.append(hash_id);
 
   54   return m_hash->name();
 
 
   58   return fmt(
"X9.31({})", m_hash->name());
 
 
   61void X931_SignaturePadding::update(
const uint8_t input[], 
size_t length) {
 
   62   m_hash->update(input, length);
 
   66   return m_hash->final_stdvec();
 
   72std::vector<uint8_t> X931_SignaturePadding::encoding_of(std::span<const uint8_t> msg,
 
   75   return x931_encoding(msg, output_bits, m_empty_hash, m_hash_id);
 
   81bool X931_SignaturePadding::verify(std::span<const uint8_t> coded, std::span<const uint8_t> raw, 
size_t key_bits) {
 
   83      const auto x931 = x931_encoding(raw, key_bits, m_empty_hash, m_hash_id);
 
   94   m_empty_hash = m_hash->final_stdvec();
 
   99      throw Encoding_Error(
"X931_SignaturePadding no hash identifier for " + m_hash->name());
 
 
#define BOTAN_ASSERT_NOMSG(expr)
 
Helper class to ease in-place marshalling of concatenated fixed-length values.
 
virtual std::vector< uint8_t > raw_data()=0
 
std::string name() const override
 
std::string hash_function() const override
 
X931_SignaturePadding(std::unique_ptr< HashFunction > hash)
 
std::string fmt(std::string_view format, const T &... args)
 
uint8_t ieee1363_hash_id(std::string_view name)
 
bool constant_time_compare(std::span< const uint8_t > x, std::span< const uint8_t > y)