Botan  2.8.0
Crypto and TLS for C++11
Public Member Functions | List of all members
Botan::GF2m_Field Class Reference

#include <gf2m_small_m.h>

Public Member Functions

gf2m get_cardinality () const
 
gf2m get_extension_degree () const
 
 GF2m_Field (size_t extdeg)
 
gf2m gf_div (gf2m x, gf2m y) const
 
gf2m gf_div_nrr (gf2m a, gf2m b) const
 
gf2m gf_div_rnn (gf2m x, gf2m y) const
 
gf2m gf_div_rnr (gf2m x, gf2m b) const
 
gf2m gf_div_zzr (gf2m x, gf2m b) const
 
gf2m gf_exp (gf2m i) const
 
gf2m gf_inv (gf2m x) const
 
gf2m gf_inv_rn (gf2m x) const
 
gf2m gf_l_from_n (gf2m x) const
 
gf2m gf_log (gf2m i) const
 
gf2m gf_mul (gf2m x, gf2m y) const
 
gf2m gf_mul_fast (gf2m x, gf2m y) const
 
gf2m gf_mul_lll (gf2m a, gf2m b) const
 
gf2m gf_mul_lnn (gf2m x, gf2m y) const
 
gf2m gf_mul_nnr (gf2m y, gf2m a) const
 
gf2m gf_mul_nrn (gf2m a, gf2m y) const
 
gf2m gf_mul_nrr (gf2m a, gf2m b) const
 
gf2m gf_mul_rnn (gf2m x, gf2m y) const
 
gf2m gf_mul_rnr (gf2m y, gf2m a) const
 
gf2m gf_mul_rrn (gf2m a, gf2m y) const
 
gf2m gf_mul_rrr (gf2m a, gf2m b) const
 
gf2m gf_mul_zrz (gf2m a, gf2m y) const
 
gf2m gf_mul_zzr (gf2m a, gf2m y) const
 
gf2m gf_ord () const
 
gf2m gf_pow (gf2m x, int i) const
 
gf2m gf_sqrt (gf2m x) const
 
gf2m gf_square (gf2m x) const
 
gf2m gf_square_ln (gf2m x) const
 
gf2m gf_square_rr (gf2m a) const
 
gf2m square_rr (gf2m x) const
 

Detailed Description

GF(2^m) field for m = [2...16]

Definition at line 25 of file gf2m_small_m.h.

Constructor & Destructor Documentation

◆ GF2m_Field()

Botan::GF2m_Field::GF2m_Field ( size_t  extdeg)
explicit

Definition at line 112 of file gf2m_small_m.cpp.

112  : m_gf_extension_degree(extdeg),
113  m_gf_multiplicative_order((1 << extdeg) - 1),
114  m_gf_log_table(log_table(m_gf_extension_degree)),
115  m_gf_exp_table(exp_table(m_gf_extension_degree))
116  {
117  }

Member Function Documentation

◆ get_cardinality()

gf2m Botan::GF2m_Field::get_cardinality ( ) const
inline

Definition at line 193 of file gf2m_small_m.h.

194  {
195  return static_cast<gf2m>(1 << get_extension_degree());
196  }
uint16_t gf2m
Definition: gf2m_small_m.h:20
gf2m get_extension_degree() const
Definition: gf2m_small_m.h:188

◆ get_extension_degree()

gf2m Botan::GF2m_Field::get_extension_degree ( ) const
inline

Definition at line 188 of file gf2m_small_m.h.

Referenced by gf_pow().

189  {
190  return m_gf_extension_degree;
191  }

◆ gf_div()

gf2m Botan::GF2m_Field::gf_div ( gf2m  x,
gf2m  y 
) const

Definition at line 119 of file gf2m_small_m.cpp.

References gf_exp(), and gf_log().

120  {
121  const int32_t sub_res = static_cast<int32_t>(gf_log(x) - static_cast<int32_t>(gf_log(y)));
122  const int32_t modq_res = static_cast<int32_t>(_gf_modq_1(sub_res));
123  const int32_t div_res = static_cast<int32_t>(x) ? static_cast<int32_t>(gf_exp(modq_res)) : 0;
124  return static_cast<gf2m>(div_res);
125  }
gf2m gf_exp(gf2m i) const
Definition: gf2m_small_m.h:173
gf2m gf_log(gf2m i) const
Definition: gf2m_small_m.h:178
uint16_t gf2m
Definition: gf2m_small_m.h:20

◆ gf_div_nrr()

gf2m Botan::GF2m_Field::gf_div_nrr ( gf2m  a,
gf2m  b 
) const
inline

Definition at line 134 of file gf2m_small_m.h.

135  {
136  return gf_exp(_gf_modq_1(a - b));
137  }
gf2m gf_exp(gf2m i) const
Definition: gf2m_small_m.h:173

◆ gf_div_rnn()

gf2m Botan::GF2m_Field::gf_div_rnn ( gf2m  x,
gf2m  y 
) const
inline

Definition at line 124 of file gf2m_small_m.h.

125  {
126  return _gf_modq_1(gf_log(x) - gf_log(y));
127  }
gf2m gf_log(gf2m i) const
Definition: gf2m_small_m.h:178

◆ gf_div_rnr()

gf2m Botan::GF2m_Field::gf_div_rnr ( gf2m  x,
gf2m  b 
) const
inline

Definition at line 129 of file gf2m_small_m.h.

130  {
131  return _gf_modq_1(gf_log(x) - b);
132  }
gf2m gf_log(gf2m i) const
Definition: gf2m_small_m.h:178

◆ gf_div_zzr()

gf2m Botan::GF2m_Field::gf_div_zzr ( gf2m  x,
gf2m  b 
) const
inline

Definition at line 139 of file gf2m_small_m.h.

140  {
141  return ((x) ? gf_exp(_gf_modq_1(gf_log(x) - b)) : 0);
142  }
gf2m gf_exp(gf2m i) const
Definition: gf2m_small_m.h:173
gf2m gf_log(gf2m i) const
Definition: gf2m_small_m.h:178

◆ gf_exp()

gf2m Botan::GF2m_Field::gf_exp ( gf2m  i) const
inline

Definition at line 173 of file gf2m_small_m.h.

Referenced by gf_div(), and gf_pow().

174  {
175  return m_gf_exp_table.at(i); /* alpha^i */
176  }

◆ gf_inv()

gf2m Botan::GF2m_Field::gf_inv ( gf2m  x) const
inline

Definition at line 144 of file gf2m_small_m.h.

145  {
146  return gf_exp(gf_ord() - gf_log(x));
147  }
gf2m gf_exp(gf2m i) const
Definition: gf2m_small_m.h:173
gf2m gf_ord() const
Definition: gf2m_small_m.h:183
gf2m gf_log(gf2m i) const
Definition: gf2m_small_m.h:178

◆ gf_inv_rn()

gf2m Botan::GF2m_Field::gf_inv_rn ( gf2m  x) const
inline

Definition at line 149 of file gf2m_small_m.h.

150  {
151  return (gf_ord() - gf_log(x));
152  }
gf2m gf_ord() const
Definition: gf2m_small_m.h:183
gf2m gf_log(gf2m i) const
Definition: gf2m_small_m.h:178

◆ gf_l_from_n()

gf2m Botan::GF2m_Field::gf_l_from_n ( gf2m  x) const
inline

Definition at line 164 of file gf2m_small_m.h.

165  {
166  return gf_log(x);
167  }
gf2m gf_log(gf2m i) const
Definition: gf2m_small_m.h:178

◆ gf_log()

gf2m Botan::GF2m_Field::gf_log ( gf2m  i) const
inline

Definition at line 178 of file gf2m_small_m.h.

Referenced by gf_div(), and gf_pow().

179  {
180  return m_gf_log_table.at(i); /* return i when x=alpha^i */
181  }

◆ gf_mul()

gf2m Botan::GF2m_Field::gf_mul ( gf2m  x,
gf2m  y 
) const
inline

Definition at line 30 of file gf2m_small_m.h.

31  {
32  return ((x) ? gf_mul_fast(x, y) : 0);
33  }
gf2m gf_mul_fast(gf2m x, gf2m y) const
Definition: gf2m_small_m.h:45

◆ gf_mul_fast()

gf2m Botan::GF2m_Field::gf_mul_fast ( gf2m  x,
gf2m  y 
) const
inline

Definition at line 45 of file gf2m_small_m.h.

46  {
47  return ((y) ? gf_exp(_gf_modq_1(gf_log(x) + gf_log(y))) : 0);
48  }
gf2m gf_exp(gf2m i) const
Definition: gf2m_small_m.h:173
gf2m gf_log(gf2m i) const
Definition: gf2m_small_m.h:178

◆ gf_mul_lll()

gf2m Botan::GF2m_Field::gf_mul_lll ( gf2m  a,
gf2m  b 
) const
inline

Definition at line 58 of file gf2m_small_m.h.

59  {
60  return (a + b);
61  }

◆ gf_mul_lnn()

gf2m Botan::GF2m_Field::gf_mul_lnn ( gf2m  x,
gf2m  y 
) const
inline

Definition at line 83 of file gf2m_small_m.h.

84  {
85  return (gf_log(x) + gf_log(y));
86  }
gf2m gf_log(gf2m i) const
Definition: gf2m_small_m.h:178

◆ gf_mul_nnr()

gf2m Botan::GF2m_Field::gf_mul_nnr ( gf2m  y,
gf2m  a 
) const
inline

non-zero operand

Definition at line 114 of file gf2m_small_m.h.

115  {
116  return gf_mul_nrn(a, y);
117  }
gf2m gf_mul_nrn(gf2m a, gf2m y) const
Definition: gf2m_small_m.h:93

◆ gf_mul_nrn()

gf2m Botan::GF2m_Field::gf_mul_nrn ( gf2m  a,
gf2m  y 
) const
inline

Definition at line 93 of file gf2m_small_m.h.

94  {
95  return gf_exp(_gf_modq_1((a) + gf_log(y)));
96  }
gf2m gf_exp(gf2m i) const
Definition: gf2m_small_m.h:173
gf2m gf_log(gf2m i) const
Definition: gf2m_small_m.h:178

◆ gf_mul_nrr()

gf2m Botan::GF2m_Field::gf_mul_nrr ( gf2m  a,
gf2m  b 
) const
inline

Definition at line 68 of file gf2m_small_m.h.

69  {
70  return (gf_exp(gf_mul_rrr(a, b)));
71  }
gf2m gf_exp(gf2m i) const
Definition: gf2m_small_m.h:173
gf2m gf_mul_rrr(gf2m a, gf2m b) const
Definition: gf2m_small_m.h:63

◆ gf_mul_rnn()

gf2m Botan::GF2m_Field::gf_mul_rnn ( gf2m  x,
gf2m  y 
) const
inline

Definition at line 88 of file gf2m_small_m.h.

89  {
90  return _gf_modq_1(gf_mul_lnn(x, y));
91  }
gf2m gf_mul_lnn(gf2m x, gf2m y) const
Definition: gf2m_small_m.h:83

◆ gf_mul_rnr()

gf2m Botan::GF2m_Field::gf_mul_rnr ( gf2m  y,
gf2m  a 
) const
inline

Definition at line 78 of file gf2m_small_m.h.

79  {
80  return gf_mul_rrn(a, y);
81  }
gf2m gf_mul_rrn(gf2m a, gf2m y) const
Definition: gf2m_small_m.h:73

◆ gf_mul_rrn()

gf2m Botan::GF2m_Field::gf_mul_rrn ( gf2m  a,
gf2m  y 
) const
inline

Definition at line 73 of file gf2m_small_m.h.

74  {
75  return _gf_modq_1(gf_mul_lll(a, gf_log(y)));
76  }
gf2m gf_log(gf2m i) const
Definition: gf2m_small_m.h:178
gf2m gf_mul_lll(gf2m a, gf2m b) const
Definition: gf2m_small_m.h:58

◆ gf_mul_rrr()

gf2m Botan::GF2m_Field::gf_mul_rrr ( gf2m  a,
gf2m  b 
) const
inline

Definition at line 63 of file gf2m_small_m.h.

64  {
65  return (_gf_modq_1(gf_mul_lll(a, b)));
66  }
gf2m gf_mul_lll(gf2m a, gf2m b) const
Definition: gf2m_small_m.h:58

◆ gf_mul_zrz()

gf2m Botan::GF2m_Field::gf_mul_zrz ( gf2m  a,
gf2m  y 
) const
inline

zero operand allowed

Definition at line 101 of file gf2m_small_m.h.

102  {
103  return ( (y == 0) ? 0 : gf_mul_nrn(a, y) );
104  }
gf2m gf_mul_nrn(gf2m a, gf2m y) const
Definition: gf2m_small_m.h:93

◆ gf_mul_zzr()

gf2m Botan::GF2m_Field::gf_mul_zzr ( gf2m  a,
gf2m  y 
) const
inline

Definition at line 106 of file gf2m_small_m.h.

107  {
108  return gf_mul_zrz(y, a);
109  }
gf2m gf_mul_zrz(gf2m a, gf2m y) const
Definition: gf2m_small_m.h:101

◆ gf_ord()

gf2m Botan::GF2m_Field::gf_ord ( ) const
inline

Definition at line 183 of file gf2m_small_m.h.

Referenced by gf_pow().

184  {
185  return m_gf_multiplicative_order;
186  }

◆ gf_pow()

gf2m Botan::GF2m_Field::gf_pow ( gf2m  x,
int  i 
) const

Definition at line 128 of file gf2m_small_m.cpp.

References get_extension_degree(), gf_exp(), gf_log(), and gf_ord().

129  {
130  if (i == 0)
131  return 1;
132  else if (x == 0)
133  return 0;
134  else
135  {
136  // i mod (q-1)
137  while (i >> get_extension_degree())
138  i = (i & (gf_ord())) + (i >> get_extension_degree());
139  i *= gf_log(x);
140  while (i >> get_extension_degree())
141  i = (i & (gf_ord())) + (i >> get_extension_degree());
142  return gf_exp(i);
143  }
144  }
gf2m gf_exp(gf2m i) const
Definition: gf2m_small_m.h:173
gf2m gf_ord() const
Definition: gf2m_small_m.h:183
gf2m gf_log(gf2m i) const
Definition: gf2m_small_m.h:178
gf2m get_extension_degree() const
Definition: gf2m_small_m.h:188

◆ gf_sqrt()

gf2m Botan::GF2m_Field::gf_sqrt ( gf2m  x) const
inline

Definition at line 119 of file gf2m_small_m.h.

120  {
121  return ((x) ? gf_exp(_gf_modq_1(gf_log(x) << (get_extension_degree()-1))) : 0);
122  }
gf2m gf_exp(gf2m i) const
Definition: gf2m_small_m.h:173
gf2m gf_log(gf2m i) const
Definition: gf2m_small_m.h:178
gf2m get_extension_degree() const
Definition: gf2m_small_m.h:188

◆ gf_square()

gf2m Botan::GF2m_Field::gf_square ( gf2m  x) const
inline

Definition at line 35 of file gf2m_small_m.h.

36  {
37  return ((x) ? gf_exp(_gf_modq_1(gf_log(x) << 1)) : 0);
38  }
gf2m gf_exp(gf2m i) const
Definition: gf2m_small_m.h:173
gf2m gf_log(gf2m i) const
Definition: gf2m_small_m.h:178

◆ gf_square_ln()

gf2m Botan::GF2m_Field::gf_square_ln ( gf2m  x) const
inline

Definition at line 154 of file gf2m_small_m.h.

155  {
156  return gf_log(x) << 1;
157  }
gf2m gf_log(gf2m i) const
Definition: gf2m_small_m.h:178

◆ gf_square_rr()

gf2m Botan::GF2m_Field::gf_square_rr ( gf2m  a) const
inline

Definition at line 159 of file gf2m_small_m.h.

160  {
161  return a << 1;
162  }

◆ square_rr()

gf2m Botan::GF2m_Field::square_rr ( gf2m  x) const
inline

Definition at line 40 of file gf2m_small_m.h.

41  {
42  return _gf_modq_1(x << 1);
43  }

The documentation for this class was generated from the following files: