Botan 2.19.1
Crypto and TLS for C&
Public Member Functions | List of all members
Botan::GF2m_Field Class Reference

#include <gf2m_small_m.h>

Public Member Functions

gf2m get_cardinality () const
 
size_t 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_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 27 of file gf2m_small_m.h.

Constructor & Destructor Documentation

◆ GF2m_Field()

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

Definition at line 111 of file gf2m_small_m.cpp.

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

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 }
size_t get_extension_degree() const
Definition: gf2m_small_m.h:188
uint16_t gf2m
Definition: gf2m_small_m.h:22

◆ get_extension_degree()

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

Definition at line 188 of file gf2m_small_m.h.

189 {
190 return m_gf_extension_degree;
191 }

◆ gf_div()

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

Definition at line 118 of file gf2m_small_m.cpp.

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

References gf_exp(), and gf_log().

◆ gf_div_nrr()

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

Definition at line 136 of file gf2m_small_m.h.

137 {
138 return gf_exp(_gf_modq_1(a - b));
139 }

◆ gf_div_rnn()

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

Definition at line 126 of file gf2m_small_m.h.

127 {
128 return _gf_modq_1(gf_log(x) - gf_log(y));
129 }

◆ gf_div_rnr()

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

Definition at line 131 of file gf2m_small_m.h.

132 {
133 return _gf_modq_1(gf_log(x) - b);
134 }

◆ gf_div_zzr()

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

Definition at line 141 of file gf2m_small_m.h.

142 {
143 return ((x) ? gf_exp(_gf_modq_1(gf_log(x) - b)) : 0);
144 }

◆ gf_exp()

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

Definition at line 173 of file gf2m_small_m.h.

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

Referenced by gf_div().

◆ gf_inv()

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

Definition at line 146 of file gf2m_small_m.h.

147 {
148 return gf_exp(gf_ord() - gf_log(x));
149 }
gf2m gf_ord() const
Definition: gf2m_small_m.h:183

◆ gf_inv_rn()

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

Definition at line 151 of file gf2m_small_m.h.

152 {
153 return (gf_ord() - gf_log(x));
154 }

◆ gf_l_from_n()

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

Definition at line 166 of file gf2m_small_m.h.

167 {
168 return gf_log(x);
169 }

◆ gf_log()

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

Definition at line 178 of file gf2m_small_m.h.

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

Referenced by gf_div().

◆ gf_mul()

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

Definition at line 32 of file gf2m_small_m.h.

33 {
34 return ((x) ? gf_mul_fast(x, y) : 0);
35 }
gf2m gf_mul_fast(gf2m x, gf2m y) const
Definition: gf2m_small_m.h:47

◆ gf_mul_fast()

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

Definition at line 47 of file gf2m_small_m.h.

48 {
49 return ((y) ? gf_exp(_gf_modq_1(gf_log(x) + gf_log(y))) : 0);
50 }

◆ gf_mul_lll()

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

Definition at line 60 of file gf2m_small_m.h.

61 {
62 return (a + b);
63 }

◆ gf_mul_lnn()

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

Definition at line 85 of file gf2m_small_m.h.

86 {
87 return (gf_log(x) + gf_log(y));
88 }

◆ gf_mul_nnr()

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

non-zero operand

Definition at line 116 of file gf2m_small_m.h.

117 {
118 return gf_mul_nrn(a, y);
119 }
gf2m gf_mul_nrn(gf2m a, gf2m y) const
Definition: gf2m_small_m.h:95

◆ gf_mul_nrn()

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

Definition at line 95 of file gf2m_small_m.h.

96 {
97 return gf_exp(_gf_modq_1((a) + gf_log(y)));
98 }

◆ gf_mul_nrr()

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

Definition at line 70 of file gf2m_small_m.h.

71 {
72 return (gf_exp(gf_mul_rrr(a, b)));
73 }
gf2m gf_mul_rrr(gf2m a, gf2m b) const
Definition: gf2m_small_m.h:65

◆ gf_mul_rnn()

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

Definition at line 90 of file gf2m_small_m.h.

91 {
92 return _gf_modq_1(gf_mul_lnn(x, y));
93 }
gf2m gf_mul_lnn(gf2m x, gf2m y) const
Definition: gf2m_small_m.h:85

◆ gf_mul_rnr()

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

Definition at line 80 of file gf2m_small_m.h.

81 {
82 return gf_mul_rrn(a, y);
83 }
gf2m gf_mul_rrn(gf2m a, gf2m y) const
Definition: gf2m_small_m.h:75

◆ gf_mul_rrn()

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

Definition at line 75 of file gf2m_small_m.h.

76 {
77 return _gf_modq_1(gf_mul_lll(a, gf_log(y)));
78 }
gf2m gf_mul_lll(gf2m a, gf2m b) const
Definition: gf2m_small_m.h:60

◆ gf_mul_rrr()

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

Definition at line 65 of file gf2m_small_m.h.

66 {
67 return (_gf_modq_1(gf_mul_lll(a, b)));
68 }

◆ gf_mul_zrz()

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

zero operand allowed

Definition at line 103 of file gf2m_small_m.h.

104 {
105 return ( (y == 0) ? 0 : gf_mul_nrn(a, y) );
106 }

◆ gf_mul_zzr()

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

Definition at line 108 of file gf2m_small_m.h.

109 {
110 return gf_mul_zrz(y, a);
111 }
gf2m gf_mul_zrz(gf2m a, gf2m y) const
Definition: gf2m_small_m.h:103

◆ gf_ord()

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

Definition at line 183 of file gf2m_small_m.h.

184 {
185 return m_gf_multiplicative_order;
186 }

◆ gf_sqrt()

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

Definition at line 121 of file gf2m_small_m.h.

122 {
123 return ((x) ? gf_exp(_gf_modq_1(gf_log(x) << (get_extension_degree()-1))) : 0);
124 }

◆ gf_square()

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

Definition at line 37 of file gf2m_small_m.h.

38 {
39 return ((x) ? gf_exp(_gf_modq_1(gf_log(x) << 1)) : 0);
40 }

◆ gf_square_ln()

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

Definition at line 156 of file gf2m_small_m.h.

157 {
158 return gf_log(x) << 1;
159 }

◆ gf_square_rr()

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

Definition at line 161 of file gf2m_small_m.h.

162 {
163 return a << 1;
164 }

◆ square_rr()

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

Definition at line 42 of file gf2m_small_m.h.

43 {
44 return _gf_modq_1(x << 1);
45 }

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