aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/math
diff options
context:
space:
mode:
authorRenĂ© Korthaus <[email protected]>2015-12-23 11:52:19 +0100
committerJack Lloyd <[email protected]>2016-01-08 19:09:51 -0500
commitd22bc10cd4f67924acd82bcd46a31e3de3b20ce3 (patch)
tree58459585e6675cd799b6ef5900be026825cd6f9d /src/lib/math
parent2fbfdd7e5afb5e888fd8c0b56c6df09e2bdeaca7 (diff)
Mass-prefix member vars with m_
Diffstat (limited to 'src/lib/math')
-rw-r--r--src/lib/math/numbertheory/def_powm.h10
-rw-r--r--src/lib/math/numbertheory/dsa_gen.cpp10
-rw-r--r--src/lib/math/numbertheory/powm_fw.cpp30
-rw-r--r--src/lib/math/numbertheory/reducer.cpp38
-rw-r--r--src/lib/math/numbertheory/reducer.h10
5 files changed, 49 insertions, 49 deletions
diff --git a/src/lib/math/numbertheory/def_powm.h b/src/lib/math/numbertheory/def_powm.h
index ef5d6e39b..d60ca8173 100644
--- a/src/lib/math/numbertheory/def_powm.h
+++ b/src/lib/math/numbertheory/def_powm.h
@@ -29,11 +29,11 @@ class Fixed_Window_Exponentiator : public Modular_Exponentiator
Fixed_Window_Exponentiator(const BigInt&, Power_Mod::Usage_Hints);
private:
- Modular_Reducer reducer;
- BigInt exp;
- size_t window_bits;
- std::vector<BigInt> g;
- Power_Mod::Usage_Hints hints;
+ Modular_Reducer m_reducer;
+ BigInt m_exp;
+ size_t m_window_bits;
+ std::vector<BigInt> m_g;
+ Power_Mod::Usage_Hints m_hints;
};
/**
diff --git a/src/lib/math/numbertheory/dsa_gen.cpp b/src/lib/math/numbertheory/dsa_gen.cpp
index 60151355a..1f922fd49 100644
--- a/src/lib/math/numbertheory/dsa_gen.cpp
+++ b/src/lib/math/numbertheory/dsa_gen.cpp
@@ -61,19 +61,19 @@ bool generate_dsa_primes(RandomNumberGenerator& rng,
class Seed
{
public:
- Seed(const std::vector<byte>& s) : seed(s) {}
+ Seed(const std::vector<byte>& s) : m_seed(s) {}
- operator std::vector<byte>& () { return seed; }
+ operator std::vector<byte>& () { return m_seed; }
Seed& operator++()
{
- for(size_t j = seed.size(); j > 0; --j)
- if(++seed[j-1])
+ for(size_t j = m_seed.size(); j > 0; --j)
+ if(++m_seed[j-1])
break;
return (*this);
}
private:
- std::vector<byte> seed;
+ std::vector<byte> m_seed;
};
Seed seed(seed_c);
diff --git a/src/lib/math/numbertheory/powm_fw.cpp b/src/lib/math/numbertheory/powm_fw.cpp
index 14474104e..02e9bbe83 100644
--- a/src/lib/math/numbertheory/powm_fw.cpp
+++ b/src/lib/math/numbertheory/powm_fw.cpp
@@ -16,7 +16,7 @@ namespace Botan {
*/
void Fixed_Window_Exponentiator::set_exponent(const BigInt& e)
{
- exp = e;
+ m_exp = e;
}
/*
@@ -24,14 +24,14 @@ void Fixed_Window_Exponentiator::set_exponent(const BigInt& e)
*/
void Fixed_Window_Exponentiator::set_base(const BigInt& base)
{
- window_bits = Power_Mod::window_bits(exp.bits(), base.bits(), hints);
+ m_window_bits = Power_Mod::window_bits(m_exp.bits(), base.bits(), m_hints);
- g.resize((1 << window_bits));
- g[0] = 1;
- g[1] = base;
+ m_g.resize((1 << m_window_bits));
+ m_g[0] = 1;
+ m_g[1] = base;
- for(size_t i = 2; i != g.size(); ++i)
- g[i] = reducer.multiply(g[i-1], g[0]);
+ for(size_t i = 2; i != m_g.size(); ++i)
+ m_g[i] = m_reducer.multiply(m_g[i-1], m_g[0]);
}
/*
@@ -39,18 +39,18 @@ void Fixed_Window_Exponentiator::set_base(const BigInt& base)
*/
BigInt Fixed_Window_Exponentiator::execute() const
{
- const size_t exp_nibbles = (exp.bits() + window_bits - 1) / window_bits;
+ const size_t exp_nibbles = (m_exp.bits() + m_window_bits - 1) / m_window_bits;
BigInt x = 1;
for(size_t i = exp_nibbles; i > 0; --i)
{
- for(size_t j = 0; j != window_bits; ++j)
- x = reducer.square(x);
+ for(size_t j = 0; j != m_window_bits; ++j)
+ x = m_reducer.square(x);
- const u32bit nibble = exp.get_substring(window_bits*(i-1), window_bits);
+ const u32bit nibble = m_exp.get_substring(m_window_bits*(i-1), m_window_bits);
- x = reducer.multiply(x, g[nibble]);
+ x = m_reducer.multiply(x, m_g[nibble]);
}
return x;
}
@@ -61,9 +61,9 @@ BigInt Fixed_Window_Exponentiator::execute() const
Fixed_Window_Exponentiator::Fixed_Window_Exponentiator(const BigInt& n,
Power_Mod::Usage_Hints hints)
{
- reducer = Modular_Reducer(n);
- this->hints = hints;
- window_bits = 0;
+ m_reducer = Modular_Reducer(n);
+ m_hints = hints;
+ m_window_bits = 0;
}
}
diff --git a/src/lib/math/numbertheory/reducer.cpp b/src/lib/math/numbertheory/reducer.cpp
index 332895d63..d5f1666e1 100644
--- a/src/lib/math/numbertheory/reducer.cpp
+++ b/src/lib/math/numbertheory/reducer.cpp
@@ -18,12 +18,12 @@ Modular_Reducer::Modular_Reducer(const BigInt& mod)
if(mod <= 0)
throw Invalid_Argument("Modular_Reducer: modulus must be positive");
- modulus = mod;
- mod_words = modulus.sig_words();
+ m_modulus = mod;
+ m_mod_words = m_modulus.sig_words();
- modulus_2 = Botan::square(modulus);
+ m_modulus_2 = Botan::square(m_modulus);
- mu = BigInt::power_of_2(2 * MP_WORD_BITS * mod_words) / modulus;
+ m_mu = BigInt::power_of_2(2 * MP_WORD_BITS * m_mod_words) / m_modulus;
}
/*
@@ -31,50 +31,50 @@ Modular_Reducer::Modular_Reducer(const BigInt& mod)
*/
BigInt Modular_Reducer::reduce(const BigInt& x) const
{
- if(mod_words == 0)
+ if(m_mod_words == 0)
throw Invalid_State("Modular_Reducer: Never initalized");
- if(x.cmp(modulus, false) < 0)
+ if(x.cmp(m_modulus, false) < 0)
{
if(x.is_negative())
- return x + modulus; // make positive
+ return x + m_modulus; // make positive
return x;
}
- else if(x.cmp(modulus_2, false) < 0)
+ else if(x.cmp(m_modulus_2, false) < 0)
{
BigInt t1 = x;
t1.set_sign(BigInt::Positive);
- t1 >>= (MP_WORD_BITS * (mod_words - 1));
- t1 *= mu;
+ t1 >>= (MP_WORD_BITS * (m_mod_words - 1));
+ t1 *= m_mu;
- t1 >>= (MP_WORD_BITS * (mod_words + 1));
- t1 *= modulus;
+ t1 >>= (MP_WORD_BITS * (m_mod_words + 1));
+ t1 *= m_modulus;
- t1.mask_bits(MP_WORD_BITS * (mod_words + 1));
+ t1.mask_bits(MP_WORD_BITS * (m_mod_words + 1));
BigInt t2 = x;
t2.set_sign(BigInt::Positive);
- t2.mask_bits(MP_WORD_BITS * (mod_words + 1));
+ t2.mask_bits(MP_WORD_BITS * (m_mod_words + 1));
t2 -= t1;
if(t2.is_negative())
{
- t2 += BigInt::power_of_2(MP_WORD_BITS * (mod_words + 1));
+ t2 += BigInt::power_of_2(MP_WORD_BITS * (m_mod_words + 1));
}
- while(t2 >= modulus)
- t2 -= modulus;
+ while(t2 >= m_modulus)
+ t2 -= m_modulus;
if(x.is_positive())
return t2;
else
- return (modulus - t2);
+ return (m_modulus - t2);
}
else
{
// too big, fall back to normal division
- return (x % modulus);
+ return (x % m_modulus);
}
}
diff --git a/src/lib/math/numbertheory/reducer.h b/src/lib/math/numbertheory/reducer.h
index b45e0e186..248de3e2f 100644
--- a/src/lib/math/numbertheory/reducer.h
+++ b/src/lib/math/numbertheory/reducer.h
@@ -18,7 +18,7 @@ namespace Botan {
class BOTAN_DLL Modular_Reducer
{
public:
- const BigInt& get_modulus() const { return modulus; }
+ const BigInt& get_modulus() const { return m_modulus; }
BigInt reduce(const BigInt& x) const;
@@ -47,13 +47,13 @@ class BOTAN_DLL Modular_Reducer
BigInt cube(const BigInt& x) const
{ return multiply(x, this->square(x)); }
- bool initialized() const { return (mod_words != 0); }
+ bool initialized() const { return (m_mod_words != 0); }
- Modular_Reducer() { mod_words = 0; }
+ Modular_Reducer() { m_mod_words = 0; }
Modular_Reducer(const BigInt& mod);
private:
- BigInt modulus, modulus_2, mu;
- size_t mod_words;
+ BigInt m_modulus, m_modulus_2, m_mu;
+ size_t m_mod_words;
};
}