Botan
3.6.1
Crypto and TLS for C&
src
lib
pubkey
sphincsplus
sphincsplus_common
sp_types.h
Go to the documentation of this file.
1
/*
2
* SLH-DSA Strong Type Definitions
3
* (C) 2023 Jack Lloyd
4
* 2023 Fabian Albert, René Meusel, Amos Treiber - Rohde & Schwarz Cybersecurity
5
*
6
* Botan is released under the Simplified BSD License (see license.txt)
7
**/
8
9
#ifndef BOTAN_SP_TYPES_H_
10
#define BOTAN_SP_TYPES_H_
11
12
#include <botan/secmem.h>
13
#include <botan/strong_type.h>
14
15
namespace
Botan
{
16
17
/*
18
* The following gives an overview about the different building blocks of
19
* SLH-DSA and how they are connected. In general, we always consider sequences of bytes
20
* that are interpreted in the following manner (flattening the || operation, i.e.,
21
* mapping the byte sequence of a strong type onto the underlying byte sequence of the containing strong type).
22
* Only FORS indices are not seen as byte sequences.
23
*
24
* SLH-DSA secret key is built up like the following:
25
* [SphincsSecretSeed || SphincsSecretPRF || SphincsPublicSeed || SphincsTreeNode] (the last chunk is the root node of SLH-DSA' topmost XMSS tree)
26
*
27
* SLH-DSA public key is built up like the following:
28
* [SphincsPublicSeed || SphincsTreeNode] (the last chunk is the root node of SLH-DSA's topmost XMSS tree)]
29
*
30
* SLH-DSA signature is built up like the following:
31
* [SphincsMessageRandomness (n bytes) || ForsSignature (k(a+1)*n = fors_signature_bytes bytes) || SphincsHypertreeSignature]. SphincsHypertreeSignature contains a total of
32
* d SphincsXMSSSignatures, with (h+d*len)*n = xmss_signature_bytes bytes each.
33
*
34
* ForsSignature is built up like the following:
35
* [<Leaf Secret of FORS Subtree 1>(n bytes) || SphincsAuthenticationPath (Subtree 1, a*n bytes) || ... || <Leaf Secret of FORS Subtree k>(n bytes) || SphincsAuthenticationPath (Subtree k, a*n bytes)]
36
* We define no special type for the leaf secret. The leaf secret is the secret PRF output that is hashed to create a FORS subtree's leaf.
37
*
38
* SphincsXmssSignature is built up like the following:
39
* [WotsSignature || SphincsAuthenticationPath]
40
*
41
* WotsSignature is built up like the following:
42
* [WotsNode || ... || WotsNode] contains len WotsNodes, each of length n bytes.
43
*/
44
45
/// The prefix appended to the message in [hash_]slh_sign and slh_verify.
46
/// E.g. for SLH-DSA (pure): 0x00 || |ctx| || ctx. Empty for SPHINCS+.
47
using
SphincsMessagePrefix
=
Strong<std::vector<uint8_t>
,
struct
SphincsMessagePrefix_>;
48
// The input to [hash_]slh_sign and [hash_]slh_verify
49
using
SphincsInputMessage
=
Strong<std::vector<uint8_t>
,
struct
SphincsInputMessage_>;
50
51
/// M' representation of FIPS 205 (the input to slh_sign_internal and slh_verify_internal)
52
struct
SphincsMessageInternal
{
53
SphincsMessagePrefix
prefix
;
54
SphincsInputMessage
message
;
55
};
56
57
using
SphincsContext
=
Strong<std::vector<uint8_t>
,
struct
SphincsContext_>;
58
59
using
SphincsHashedMessage
=
Strong<std::vector<uint8_t>
,
struct
SphincsHashedMessage_>;
60
using
SphincsPublicSeed
=
Strong<std::vector<uint8_t>
,
struct
SphincsPublicSeed_>;
61
using
SphincsSecretSeed
=
Strong<secure_vector<uint8_t>
,
struct
SphincsSecretSeed_>;
62
using
SphincsSecretPRF
=
Strong<secure_vector<uint8_t>
,
struct
SphincsSecretPRF_>;
63
using
SphincsOptionalRandomness
=
Strong<secure_vector<uint8_t>
,
struct
SphincsOptionalRandomness_>;
64
using
SphincsMessageRandomness
=
Strong<secure_vector<uint8_t>
,
struct
SphincsMessageRandomness_>;
65
using
SphincsXmssSignature
=
Strong<std::vector<uint8_t>
,
struct
SphincsXmssSignature_>;
66
using
SphincsHypertreeSignature
=
Strong<std::vector<uint8_t>
,
struct
SphincsXmssSignature_>;
67
using
SphincsAuthenticationPath
=
Strong<std::vector<uint8_t>
,
struct
SphincsAuthenticationPath_>;
68
69
/// Either an XMSS or FORS tree node or leaf
70
using
SphincsTreeNode
=
Strong<std::vector<uint8_t>
,
struct
SphincsTreeNode_>;
71
using
ForsLeafSecret
=
Strong<secure_vector<uint8_t>
,
struct
ForsLeafSecret_>;
72
using
ForsSignature
=
Strong<std::vector<uint8_t>
,
struct
ForsSignature_>;
73
using
WotsPublicKey
=
Strong<std::vector<uint8_t>
,
struct
WotsPublicKey_>;
74
75
/// End node of a WOTS+ chain (part of the WOTS+ public key)
76
using
WotsPublicKeyNode
=
Strong<std::vector<uint8_t>
,
struct
WotsPublicKeyNode_>;
77
78
/// Start (or intermediate) node of a WOTS+ chain
79
using
WotsNode
=
Strong<secure_vector<uint8_t>
,
struct
WotsNode_>;
80
using
WotsSignature
=
Strong<secure_vector<uint8_t>
,
struct
WotsSignature_>;
81
82
/// Index of the layer within a FORS/XMSS tree
83
using
TreeLayerIndex
=
Strong<uint32_t, struct TreeLayerIndex_, EnableArithmeticWithPlainNumber>
;
84
85
/// Index of a layer in the XMSS hyper-tree
86
using
HypertreeLayerIndex
=
Strong<uint32_t, struct HypertreeLayerIndex_>
;
87
88
/// Index of an XMSS tree (unique for just the local hyper-tree layer)
89
using
XmssTreeIndexInLayer
=
Strong<uint64_t, struct XmssTreeIndexInLayer_, EnableArithmeticWithPlainNumber>
;
90
91
/// Index of an individual node inside an XMSS or FORS tree
92
using
TreeNodeIndex
=
Strong<uint32_t, struct TreeNodeIndex_, EnableArithmeticWithPlainNumber>
;
93
94
/// Index of a WOTS chain within a single usage of WOTS
95
using
WotsChainIndex
=
Strong<uint32_t, struct WotsChainIndex_>
;
96
97
/// Index of a hash application inside a single WOTS chain (integers in "base_w")
98
using
WotsHashIndex
=
Strong<uint8_t, struct WotsHashIndex_, EnableArithmeticWithPlainNumber>
;
99
100
}
// namespace Botan
101
102
#endif
Botan::Strong< std::vector< uint8_t >, struct SphincsMessagePrefix_ >
Botan
Definition
alg_id.cpp:13
Botan::SphincsMessageInternal
M' representation of FIPS 205 (the input to slh_sign_internal and slh_verify_internal)
Definition
sp_types.h:52
Botan::SphincsMessageInternal::message
SphincsInputMessage message
Definition
sp_types.h:54
Botan::SphincsMessageInternal::prefix
SphincsMessagePrefix prefix
Definition
sp_types.h:53
Generated by
1.12.0