Botan
3.7.1
Crypto and TLS for C&
Toggle main menu visibility
Main Page
Related Pages
Topics
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
z
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
z
Variables
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
Enumerations
a
c
d
e
f
g
h
k
l
m
n
o
p
r
s
t
u
v
w
Enumerator
c
d
f
i
m
n
r
s
t
Concepts
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
f
h
i
m
n
o
p
r
s
t
u
v
w
Enumerations
b
c
d
e
k
m
n
o
p
s
t
x
Enumerator
_
a
b
c
d
e
f
h
k
l
m
n
p
q
r
s
t
u
w
x
Related Symbols
b
c
d
e
f
k
o
p
s
t
x
Files
File List
File Members
All
_
a
b
c
d
e
f
i
k
m
n
o
p
q
s
t
u
w
x
y
z
Functions
b
c
Variables
Typedefs
b
c
e
p
t
Enumerations
Enumerator
b
c
d
e
k
n
Macros
_
a
b
c
f
m
n
q
s
t
w
src
lib
pubkey
xmss
xmss_tools.h
Go to the documentation of this file.
1
/*
2
* XMSS Tools
3
* (C) 2016,2017 Matthias Gierlings
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
**/
7
8
#ifndef BOTAN_XMSS_TOOLS_H_
9
#define BOTAN_XMSS_TOOLS_H_
10
11
#include <botan/secmem.h>
12
#include <botan/internal/cpuid.h>
13
#include <iterator>
14
#include <type_traits>
15
16
namespace
Botan
{
17
18
/**
19
* Helper tools for low level byte operations required
20
* for the XMSS implementation.
21
**/
22
class
XMSS_Tools
final
{
23
public
:
24
XMSS_Tools
() =
delete
;
25
XMSS_Tools
(
const
XMSS_Tools
&) =
delete
;
26
void
operator=
(
const
XMSS_Tools
&) =
delete
;
27
28
/**
29
* Concatenates the byte representation in big-endian order of any
30
* integral value to a secure_vector.
31
*
32
* @param target Vector to concatenate the byte representation of the
33
* integral value to.
34
* @param src integral value to concatenate.
35
**/
36
template <typename T, typename U = typename std::enable_if<std::is_integral<T>::value,
void
>::type>
37
static
void
concat
(
secure_vector<uint8_t>
& target,
const
T
& src);
38
39
/**
40
* Concatenates the last n bytes of the byte representation in big-endian
41
* order of any integral value to a to a secure_vector.
42
*
43
* @param target Vector to concatenate the byte representation of the
44
* integral value to.
45
* @param src Integral value to concatenate.
46
* @param len number of bytes to concatenate. This value must be smaller
47
* or equal to the size of type T.
48
**/
49
template <typename T, typename U = typename std::enable_if<std::is_integral<T>::value,
void
>::type>
50
static
void
concat
(
secure_vector<uint8_t>
& target,
const
T
& src,
size_t
len);
51
};
22
class
XMSS_Tools
final
{
…
};
52
53
template
<
typename
T,
typename
U>
54
void
XMSS_Tools::concat
(
secure_vector<uint8_t>
& target,
const
T
& src) {
55
const
uint8_t* src_bytes =
reinterpret_cast<
const
uint8_t*
>
(&src);
56
if
(
CPUID::is_little_endian
()) {
57
std::reverse_copy(src_bytes, src_bytes +
sizeof
(src), std::back_inserter(target));
58
}
else
{
59
std::copy(src_bytes, src_bytes +
sizeof
(src), std::back_inserter(target));
60
}
61
}
54
void
XMSS_Tools::concat
(
secure_vector<uint8_t>
& target,
const
T
& src) {
…
}
62
63
template
<
typename
T,
typename
U>
64
void
XMSS_Tools::concat
(
secure_vector<uint8_t>
& target,
const
T
& src,
size_t
len) {
65
size_t
c =
static_cast<
size_t
>
(std::min(len,
sizeof
(src)));
66
if
(len >
sizeof
(src)) {
67
target.resize(target.size() + len -
sizeof
(src), 0);
68
}
69
70
const
uint8_t* src_bytes =
reinterpret_cast<
const
uint8_t*
>
(&src);
71
if
(
CPUID::is_little_endian
()) {
72
std::reverse_copy(src_bytes, src_bytes + c, std::back_inserter(target));
73
}
else
{
74
std::copy(src_bytes +
sizeof
(src) - c, src_bytes +
sizeof
(src), std::back_inserter(target));
75
}
76
}
64
void
XMSS_Tools::concat
(
secure_vector<uint8_t>
& target,
const
T
& src,
size_t
len) {
…
}
77
}
// namespace Botan
78
79
#endif
Botan::CPUID::is_little_endian
static bool is_little_endian()
Definition
cpuid.h:60
Botan::XMSS_Tools
Definition
xmss_tools.h:22
Botan::XMSS_Tools::XMSS_Tools
XMSS_Tools()=delete
Botan::XMSS_Tools::operator=
void operator=(const XMSS_Tools &)=delete
Botan::XMSS_Tools::XMSS_Tools
XMSS_Tools(const XMSS_Tools &)=delete
Botan::XMSS_Tools::concat
static void concat(secure_vector< uint8_t > &target, const T &src)
Definition
xmss_tools.h:54
final
int(* final)(unsigned char *, CTX *)
Definition
commoncrypto_hash.cpp:29
T
FE_25519 T
Definition
ge.cpp:34
Botan
Definition
alg_id.cpp:13
Botan::secure_vector
std::vector< T, secure_allocator< T > > secure_vector
Definition
secmem.h:61
Generated by
1.12.0