Botan 3.12.0
Crypto and TLS for C&
xmss_wots_parameters.cpp
Go to the documentation of this file.
1/*
2 * XMSS WOTS Parameters
3 * Describes a signature method for XMSS Winternitz One Time Signatures,
4 * as defined in:
5 * [1] XMSS: Extended Hash-Based Signatures,
6 * Request for Comments: 8391
7 * Release: May 2018.
8 * https://datatracker.ietf.org/doc/rfc8391/
9 *
10 * (C) 2016,2017,2018 Matthias Gierlings
11 * 2026 Jack Lloyd
12 *
13 * Botan is released under the Simplified BSD License (see license.txt)
14 **/
15
16#include <botan/xmss_parameters.h>
17
18#include <botan/assert.h>
19#include <botan/exceptn.h>
20
21namespace Botan {
22
23XMSS_WOTS_Parameters XMSS_WOTS_Parameters::from_hash_len(ots_algorithm_t id, size_t hash_len) {
24 BOTAN_ASSERT_NOMSG(hash_len == 24 || hash_len == 32 || hash_len == 64);
25 const size_t len1 = 2 * hash_len;
26 // Theoretically this is a computed parameter based on the hash length and the Winternitz parameter
27 // We always use W=16, so len2 = 3 is correct for all hash lengths between 18 and 270 bytes.
28 const size_t len2 = 3;
29 return XMSS_WOTS_Parameters(id, hash_len, len1 + len2, len1, len2);
30}
31
33 switch(id) {
34 case WOTSP_SHA2_256:
35 return XMSS_WOTS_Parameters::from_hash_len(WOTSP_SHA2_256, 32);
36
37 case WOTSP_SHA2_512:
38 return XMSS_WOTS_Parameters::from_hash_len(WOTSP_SHA2_512, 64);
39
40 case WOTSP_SHAKE_256:
41 return XMSS_WOTS_Parameters::from_hash_len(WOTSP_SHAKE_256, 32);
42
43 case WOTSP_SHAKE_512:
44 return XMSS_WOTS_Parameters::from_hash_len(WOTSP_SHAKE_512, 64);
45
46 case WOTSP_SHA2_192:
47 return XMSS_WOTS_Parameters::from_hash_len(WOTSP_SHA2_192, 24);
48
50 return XMSS_WOTS_Parameters::from_hash_len(WOTSP_SHAKE_256_256, 32);
51
53 return XMSS_WOTS_Parameters::from_hash_len(WOTSP_SHAKE_256_192, 24);
54
55 default:
56 throw Not_Implemented("Algorithm id does not match any known XMSS WOTS algorithm id.");
57 }
58}
59
60} // namespace Botan
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:75
XMSS_WOTS_Parameters(const XMSS_WOTS_Parameters &other)=default
static XMSS_WOTS_Parameters from_id(ots_algorithm_t id)