15 #include <botan/xmss_wots_parameters.h>
16 #include <botan/exceptn.h>
24 if(param_set ==
"WOTSP-SHA2_256")
26 if(param_set ==
"WOTSP-SHA2_512")
28 if(param_set ==
"WOTSP-SHAKE_256")
30 if(param_set ==
"WOTSP-SHAKE_512")
32 throw Invalid_Argument(
"Unknown XMSS-WOTS algorithm param '" + param_set +
"'");
48 m_name =
"WOTSP-SHA2_256";
49 m_hash_name =
"SHA-256";
56 m_name =
"WOTSP-SHA2_512";
57 m_hash_name =
"SHA-512";
64 m_name =
"WOTSP-SHAKE_256";
65 m_hash_name =
"SHAKE-128(256)";
72 m_name =
"WOTSP-SHAKE_512";
73 m_hash_name =
"SHAKE-256(512)";
77 throw Not_Implemented(
"Algorithm id does not match any known XMSS WOTS algorithm id.");
81 m_lg_w = (m_w == 16) ? 4 : 2;
82 m_len_1 =
static_cast<size_t>(std::ceil((8 *
element_size()) / m_lg_w));
83 m_len_2 =
static_cast<size_t>(
85 BOTAN_ASSERT(m_len == m_len_1 + m_len_2,
"Invalid XMSS WOTS parameter "
97 for(
size_t i = 0; i < out_size; i++)
106 result.push_back(static_cast<uint8_t>((total >> bits) & (m_w - 1)));
114 value <<= (8 - ((m_len_2 * m_lg_w) % 8));
115 size_t len_2_bytes =
static_cast<size_t>(
116 std::ceil(static_cast<float>(m_len_2 * m_lg_w) / 8.f));
119 return base_w(result, m_len_2);
127 for(
size_t i = 0; i < data.size(); i++)
133 std::move(csum_bytes.begin(), csum_bytes.end(), std::back_inserter(data));
static ots_algorithm_t xmss_wots_id_from_string(const std::string ¶m_set)
size_t element_size() const
#define BOTAN_ASSERT(expr, assertion_made)
secure_vector< uint8_t > base_w(const secure_vector< uint8_t > &msg, size_t out_size) const
std::vector< T, secure_allocator< T >> secure_vector
size_t wots_parameter() const
void append_checksum(secure_vector< uint8_t > &data)
XMSS_WOTS_Parameters(const std::string &algo_name)