Coverage Report

Created: 2019-09-11 14:12

/src/botan/build/include/botan/xmss_parameters.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * XMSS Parameters
3
 * (C) 2016,2018 Matthias Gierlings
4
 *
5
 * Botan is released under the Simplified BSD License (see license.txt)
6
 **/
7
8
#ifndef BOTAN_XMSS_PARAMETERS_H_
9
#define BOTAN_XMSS_PARAMETERS_H_
10
11
#include <botan/xmss_wots_parameters.h>
12
#include <string>
13
14
namespace Botan {
15
16
/**
17
 * Descibes a signature method for XMSS, as defined in:
18
 * [1] XMSS: Extended Hash-Based Signatures,
19
 *     Request for Comments: 8391
20
 *     Release: May 2018.
21
 *     https://datatracker.ietf.org/doc/rfc8391/
22
 **/
23
class BOTAN_PUBLIC_API(2,0) XMSS_Parameters
24
   {
25
   public:
26
      enum xmss_algorithm_t
27
         {
28
         XMSS_SHA2_10_256 = 0x00000001,
29
         XMSS_SHA2_16_256 = 0x00000002,
30
         XMSS_SHA2_20_256 = 0x00000003,
31
         XMSS_SHA2_10_512 = 0x00000004,
32
         XMSS_SHA2_16_512 = 0x00000005,
33
         XMSS_SHA2_20_512 = 0x00000006,
34
         XMSS_SHAKE_10_256 = 0x00000007,
35
         XMSS_SHAKE_16_256 = 0x00000008,
36
         XMSS_SHAKE_20_256 = 0x00000009,
37
         XMSS_SHAKE_10_512 = 0x0000000a,
38
         XMSS_SHAKE_16_512 = 0x0000000b,
39
         XMSS_SHAKE_20_512 = 0x0000000c
40
         };
41
42
      static xmss_algorithm_t xmss_id_from_string(const std::string& algo_name);
43
44
      XMSS_Parameters(const std::string& algo_name);
45
      XMSS_Parameters(xmss_algorithm_t oid);
46
47
      /**
48
       * @return XMSS registry name for the chosen parameter set.
49
       **/
50
      const std::string& name() const
51
0
         {
52
0
         return m_name;
53
0
         }
54
55
      const std::string& hash_function_name() const
56
0
         {
57
0
         return m_hash_name;
58
0
         }
59
60
      /**
61
       * Retrieves the uniform length of a message, and the size of
62
       * each node. This correlates to XMSS parameter "n" defined
63
       * in [1].
64
       *
65
       * @return element length in bytes.
66
       **/
67
0
      size_t element_size() const { return m_element_size; }
68
69
      /**
70
       * @returns The height (number of levels - 1) of the tree
71
       **/
72
0
      size_t tree_height() const { return m_tree_height; }
73
74
      /**
75
       * The Winternitz parameter.
76
       *
77
       * @return numeric base used for internal representation of
78
       *         data.
79
       **/
80
0
      size_t wots_parameter() const { return m_w; }
81
82
0
      size_t len() const { return m_len; }
83
84
0
      xmss_algorithm_t oid() const { return m_oid; }
85
86
      XMSS_WOTS_Parameters::ots_algorithm_t ots_oid() const
87
0
         {
88
0
         return m_wots_oid;
89
0
         }
90
91
      /**
92
       * Returns the estimated pre-quantum security level of
93
       * the chosen algorithm.
94
       **/
95
      size_t estimated_strength() const
96
0
         {
97
0
         return m_strength;
98
0
         }
99
100
      bool operator==(const XMSS_Parameters& p) const
101
0
         {
102
0
         return m_oid == p.m_oid;
103
0
         }
104
105
   private:
106
      xmss_algorithm_t m_oid;
107
      XMSS_WOTS_Parameters::ots_algorithm_t m_wots_oid;
108
      std::string m_name;
109
      std::string m_hash_name;
110
      size_t m_element_size;
111
      size_t m_tree_height;
112
      size_t m_w;
113
      size_t m_len;
114
      size_t m_strength;
115
   };
116
117
}
118
119
#endif