Botan
3.12.0
Crypto and TLS for C&
src
lib
pubkey
xmss
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
21
namespace
Botan
{
22
23
XMSS_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
32
XMSS_WOTS_Parameters
XMSS_WOTS_Parameters::from_id
(
ots_algorithm_t
id
) {
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
49
case
WOTSP_SHAKE_256_256
:
50
return
XMSS_WOTS_Parameters::from_hash_len(
WOTSP_SHAKE_256_256
, 32);
51
52
case
WOTSP_SHAKE_256_192
:
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
BOTAN_ASSERT_NOMSG
#define BOTAN_ASSERT_NOMSG(expr)
Definition
assert.h:75
Botan::Not_Implemented
Definition
exceptn.h:335
Botan::XMSS_WOTS_Parameters
Definition
xmss_parameters.h:35
Botan::XMSS_WOTS_Parameters::XMSS_WOTS_Parameters
XMSS_WOTS_Parameters(const XMSS_WOTS_Parameters &other)=default
Botan::XMSS_WOTS_Parameters::ots_algorithm_t
ots_algorithm_t
Definition
xmss_parameters.h:37
Botan::XMSS_WOTS_Parameters::WOTSP_SHA2_192
@ WOTSP_SHA2_192
Definition
xmss_parameters.h:48
Botan::XMSS_WOTS_Parameters::WOTSP_SHAKE_256
@ WOTSP_SHAKE_256
Definition
xmss_parameters.h:44
Botan::XMSS_WOTS_Parameters::WOTSP_SHAKE_256_192
@ WOTSP_SHAKE_256_192
Definition
xmss_parameters.h:50
Botan::XMSS_WOTS_Parameters::WOTSP_SHAKE_512
@ WOTSP_SHAKE_512
Definition
xmss_parameters.h:45
Botan::XMSS_WOTS_Parameters::WOTSP_SHAKE_256_256
@ WOTSP_SHAKE_256_256
Definition
xmss_parameters.h:49
Botan::XMSS_WOTS_Parameters::WOTSP_SHA2_256
@ WOTSP_SHA2_256
Definition
xmss_parameters.h:39
Botan::XMSS_WOTS_Parameters::WOTSP_SHA2_512
@ WOTSP_SHA2_512
Definition
xmss_parameters.h:43
Botan::XMSS_WOTS_Parameters::from_id
static XMSS_WOTS_Parameters from_id(ots_algorithm_t id)
Definition
xmss_wots_parameters.cpp:32
Botan
Definition
alg_id.cpp:13
Generated by
1.16.1