aboutsummaryrefslogtreecommitdiffstats
path: root/src/math/numbertheory
diff options
context:
space:
mode:
Diffstat (limited to 'src/math/numbertheory')
-rw-r--r--src/math/numbertheory/curve_gfp.h4
-rw-r--r--src/math/numbertheory/def_powm.h4
-rw-r--r--src/math/numbertheory/dsa_gen.cpp16
-rw-r--r--src/math/numbertheory/jacobi.cpp2
-rw-r--r--src/math/numbertheory/make_prm.cpp16
-rw-r--r--src/math/numbertheory/mp_numth.cpp12
-rw-r--r--src/math/numbertheory/numthry.cpp38
-rw-r--r--src/math/numbertheory/numthry.h16
-rw-r--r--src/math/numbertheory/point_gfp.cpp26
-rw-r--r--src/math/numbertheory/point_gfp.h4
-rw-r--r--src/math/numbertheory/pow_mod.cpp16
-rw-r--r--src/math/numbertheory/pow_mod.h2
-rw-r--r--src/math/numbertheory/powm_fw.cpp10
-rw-r--r--src/math/numbertheory/powm_mnt.cpp14
-rw-r--r--src/math/numbertheory/reducer.h2
-rw-r--r--src/math/numbertheory/ressol.cpp4
16 files changed, 93 insertions, 93 deletions
diff --git a/src/math/numbertheory/curve_gfp.h b/src/math/numbertheory/curve_gfp.h
index 3609ffd9d..f3c4dc1a1 100644
--- a/src/math/numbertheory/curve_gfp.h
+++ b/src/math/numbertheory/curve_gfp.h
@@ -91,7 +91,7 @@ class BOTAN_DLL CurveGFp
/**
* @return p.sig_words()
*/
- u32bit get_p_words() const { return p_words; }
+ size_t get_p_words() const { return p_words; }
/**
* @return modular reducer for p
@@ -128,7 +128,7 @@ class BOTAN_DLL CurveGFp
// Curve parameters
BigInt p, a, b;
- u32bit p_words; // cache of p.sig_words()
+ size_t p_words; // cache of p.sig_words()
// Montgomery parameters
BigInt r, r_inv, a_r;
diff --git a/src/math/numbertheory/def_powm.h b/src/math/numbertheory/def_powm.h
index ce128b965..a93db9b82 100644
--- a/src/math/numbertheory/def_powm.h
+++ b/src/math/numbertheory/def_powm.h
@@ -31,7 +31,7 @@ class Fixed_Window_Exponentiator : public Modular_Exponentiator
private:
Modular_Reducer reducer;
BigInt exp;
- u32bit window_bits;
+ size_t window_bits;
std::vector<BigInt> g;
Power_Mod::Usage_Hints hints;
};
@@ -55,7 +55,7 @@ class Montgomery_Exponentiator : public Modular_Exponentiator
BigInt R2, R_mod;
std::vector<BigInt> g;
word mod_prime;
- u32bit mod_words, exp_bits, window_bits;
+ size_t mod_words, exp_bits, window_bits;
Power_Mod::Usage_Hints hints;
};
diff --git a/src/math/numbertheory/dsa_gen.cpp b/src/math/numbertheory/dsa_gen.cpp
index e09de4b04..fcae7c619 100644
--- a/src/math/numbertheory/dsa_gen.cpp
+++ b/src/math/numbertheory/dsa_gen.cpp
@@ -19,7 +19,7 @@ namespace {
/*
* Check if this size is allowed by FIPS 186-3
*/
-bool fips186_3_valid_size(u32bit pbits, u32bit qbits)
+bool fips186_3_valid_size(size_t pbits, size_t qbits)
{
if(qbits == 160)
return (pbits == 512 || pbits == 768 || pbits == 1024);
@@ -41,7 +41,7 @@ bool fips186_3_valid_size(u32bit pbits, u32bit qbits)
bool generate_dsa_primes(RandomNumberGenerator& rng,
Algorithm_Factory& af,
BigInt& p, BigInt& q,
- u32bit pbits, u32bit qbits,
+ size_t pbits, size_t qbits,
const MemoryRegion<byte>& seed_c)
{
if(!fips186_3_valid_size(pbits, qbits))
@@ -57,7 +57,7 @@ bool generate_dsa_primes(RandomNumberGenerator& rng,
std::auto_ptr<HashFunction> hash(
af.make_hash_function("SHA-" + to_string(qbits)));
- const u32bit HASH_SIZE = hash->OUTPUT_LENGTH;
+ const size_t HASH_SIZE = hash->OUTPUT_LENGTH;
class Seed
{
@@ -68,7 +68,7 @@ bool generate_dsa_primes(RandomNumberGenerator& rng,
Seed& operator++()
{
- for(u32bit j = seed.size(); j > 0; --j)
+ for(size_t j = seed.size(); j > 0; --j)
if(++seed[j-1])
break;
return (*this);
@@ -86,15 +86,15 @@ bool generate_dsa_primes(RandomNumberGenerator& rng,
if(!check_prime(q, rng))
return false;
- const u32bit n = (pbits-1) / (HASH_SIZE * 8),
+ const size_t n = (pbits-1) / (HASH_SIZE * 8),
b = (pbits-1) % (HASH_SIZE * 8);
BigInt X;
SecureVector<byte> V(HASH_SIZE * (n+1));
- for(u32bit j = 0; j != 4096; ++j)
+ for(size_t j = 0; j != 4096; ++j)
{
- for(u32bit k = 0; k <= n; ++k)
+ for(size_t k = 0; k <= n; ++k)
{
++seed;
hash->update(seed);
@@ -119,7 +119,7 @@ bool generate_dsa_primes(RandomNumberGenerator& rng,
SecureVector<byte> generate_dsa_primes(RandomNumberGenerator& rng,
Algorithm_Factory& af,
BigInt& p, BigInt& q,
- u32bit pbits, u32bit qbits)
+ size_t pbits, size_t qbits)
{
while(true)
{
diff --git a/src/math/numbertheory/jacobi.cpp b/src/math/numbertheory/jacobi.cpp
index 2ad05ff71..fcccc80e5 100644
--- a/src/math/numbertheory/jacobi.cpp
+++ b/src/math/numbertheory/jacobi.cpp
@@ -34,7 +34,7 @@ s32bit jacobi(const BigInt& a, const BigInt& n)
if(x.is_zero())
return 0;
- u32bit shifts = low_zero_bits(x);
+ size_t shifts = low_zero_bits(x);
x >>= shifts;
if(shifts % 2)
{
diff --git a/src/math/numbertheory/make_prm.cpp b/src/math/numbertheory/make_prm.cpp
index 59a5c2635..4fb3f908c 100644
--- a/src/math/numbertheory/make_prm.cpp
+++ b/src/math/numbertheory/make_prm.cpp
@@ -15,8 +15,8 @@ namespace Botan {
* Generate a random prime
*/
BigInt random_prime(RandomNumberGenerator& rng,
- u32bit bits, const BigInt& coprime,
- u32bit equiv, u32bit modulo)
+ size_t bits, const BigInt& coprime,
+ size_t equiv, size_t modulo)
{
if(bits <= 1)
throw Invalid_Argument("random_prime: Can't make a prime of " +
@@ -47,13 +47,13 @@ BigInt random_prime(RandomNumberGenerator& rng,
if(p % modulo != equiv)
p += (modulo - p % modulo) + equiv;
- const u32bit sieve_size = std::min(bits / 2, PRIME_TABLE_SIZE);
- SecureVector<u32bit> sieve(sieve_size);
+ const size_t sieve_size = std::min(bits / 2, PRIME_TABLE_SIZE);
+ SecureVector<size_t> sieve(sieve_size);
- for(u32bit j = 0; j != sieve.size(); ++j)
+ for(size_t j = 0; j != sieve.size(); ++j)
sieve[j] = p % PRIMES[j];
- u32bit counter = 0;
+ size_t counter = 0;
while(true)
{
if(counter == 4096 || p.bits() > bits)
@@ -66,7 +66,7 @@ BigInt random_prime(RandomNumberGenerator& rng,
if(p.bits() > bits)
break;
- for(u32bit j = 0; j != sieve.size(); ++j)
+ for(size_t j = 0; j != sieve.size(); ++j)
{
sieve[j] = (sieve[j] + modulo) % PRIMES[j];
if(sieve[j] == 0)
@@ -84,7 +84,7 @@ BigInt random_prime(RandomNumberGenerator& rng,
/*
* Generate a random safe prime
*/
-BigInt random_safe_prime(RandomNumberGenerator& rng, u32bit bits)
+BigInt random_safe_prime(RandomNumberGenerator& rng, size_t bits)
{
if(bits <= 64)
throw Invalid_Argument("random_safe_prime: Can't make a prime of " +
diff --git a/src/math/numbertheory/mp_numth.cpp b/src/math/numbertheory/mp_numth.cpp
index 4edc694e5..23623b5f0 100644
--- a/src/math/numbertheory/mp_numth.cpp
+++ b/src/math/numbertheory/mp_numth.cpp
@@ -17,9 +17,9 @@ namespace Botan {
*/
BigInt square(const BigInt& x)
{
- const u32bit x_sw = x.sig_words();
+ const size_t x_sw = x.sig_words();
- BigInt z(BigInt::Positive, round_up<u32bit>(2*x_sw, 16));
+ BigInt z(BigInt::Positive, round_up<size_t>(2*x_sw, 16));
SecureVector<word> workspace(z.size());
bigint_sqr(z.get_reg(), z.size(), workspace,
@@ -39,9 +39,9 @@ BigInt mul_add(const BigInt& a, const BigInt& b, const BigInt& c)
if(a.sign() != b.sign())
sign = BigInt::Negative;
- const u32bit a_sw = a.sig_words();
- const u32bit b_sw = b.sig_words();
- const u32bit c_sw = c.sig_words();
+ const size_t a_sw = a.sig_words();
+ const size_t b_sw = b.sig_words();
+ const size_t c_sw = c.sig_words();
BigInt r(sign, std::max(a.size() + b.size(), c_sw) + 1);
SecureVector<word> workspace(r.size());
@@ -49,7 +49,7 @@ BigInt mul_add(const BigInt& a, const BigInt& b, const BigInt& c)
bigint_mul(r.get_reg(), r.size(), workspace,
a.data(), a.size(), a_sw,
b.data(), b.size(), b_sw);
- const u32bit r_size = std::max(r.sig_words(), c_sw);
+ const size_t r_size = std::max(r.sig_words(), c_sw);
bigint_add2(r.get_reg(), r_size, c.data(), c_sw);
return r;
}
diff --git a/src/math/numbertheory/numthry.cpp b/src/math/numbertheory/numthry.cpp
index 010a523ff..8018c1d2d 100644
--- a/src/math/numbertheory/numthry.cpp
+++ b/src/math/numbertheory/numthry.cpp
@@ -24,7 +24,7 @@ class MillerRabin_Test
MillerRabin_Test(const BigInt& num);
private:
BigInt n, r, n_minus_1;
- u32bit s;
+ size_t s;
Fixed_Exponent_Power_Mod pow_mod;
Modular_Reducer reducer;
};
@@ -41,7 +41,7 @@ bool MillerRabin_Test::passes_test(const BigInt& a)
if(y == 1 || y == n_minus_1)
return true;
- for(u32bit i = 1; i != s; ++i)
+ for(size_t i = 1; i != s; ++i)
{
y = reducer.square(y);
@@ -73,9 +73,9 @@ MillerRabin_Test::MillerRabin_Test(const BigInt& num)
/*
* Miller-Rabin Iterations
*/
-u32bit miller_rabin_test_iterations(u32bit bits, u32bit level)
+size_t miller_rabin_test_iterations(size_t bits, size_t level)
{
- struct mapping { u32bit bits; u32bit verify_iter; u32bit check_iter; };
+ struct mapping { size_t bits; size_t verify_iter; size_t check_iter; };
static const mapping tests[] = {
{ 50, 55, 25 },
@@ -113,7 +113,7 @@ u32bit miller_rabin_test_iterations(u32bit bits, u32bit level)
{ 0, 0, 0 }
};
- for(u32bit i = 0; tests[i].bits; ++i)
+ for(size_t i = 0; tests[i].bits; ++i)
{
if(bits <= tests[i].bits)
{
@@ -122,7 +122,7 @@ u32bit miller_rabin_test_iterations(u32bit bits, u32bit level)
else if(level == 1)
return tests[i].check_iter;
else if(level == 0)
- return std::max<u32bit>(tests[i].check_iter / 4, 1);
+ return std::max<size_t>(tests[i].check_iter / 4, 1);
}
}
@@ -134,13 +134,13 @@ u32bit miller_rabin_test_iterations(u32bit bits, u32bit level)
/*
* Return the number of 0 bits at the end of n
*/
-u32bit low_zero_bits(const BigInt& n)
+size_t low_zero_bits(const BigInt& n)
{
- u32bit low_zero = 0;
+ size_t low_zero = 0;
if(n.is_positive() && n.is_nonzero())
{
- for(u32bit i = 0; i != n.size(); ++i)
+ for(size_t i = 0; i != n.size(); ++i)
{
word x = n[i];
@@ -168,7 +168,7 @@ BigInt gcd(const BigInt& a, const BigInt& b)
BigInt x = a, y = b;
x.set_sign(BigInt::Positive);
y.set_sign(BigInt::Positive);
- u32bit shift = std::min(low_zero_bits(x), low_zero_bits(y));
+ size_t shift = std::min(low_zero_bits(x), low_zero_bits(y));
x >>= shift;
y >>= shift;
@@ -210,9 +210,9 @@ BigInt inverse_mod(const BigInt& n, const BigInt& mod)
while(u.is_nonzero())
{
- u32bit zero_bits = low_zero_bits(u);
+ size_t zero_bits = low_zero_bits(u);
u >>= zero_bits;
- for(u32bit i = 0; i != zero_bits; ++i)
+ for(size_t i = 0; i != zero_bits; ++i)
{
if(A.is_odd() || B.is_odd())
{ A += y; B -= x; }
@@ -221,7 +221,7 @@ BigInt inverse_mod(const BigInt& n, const BigInt& mod)
zero_bits = low_zero_bits(v);
v >>= zero_bits;
- for(u32bit i = 0; i != zero_bits; ++i)
+ for(size_t i = 0; i != zero_bits; ++i)
{
if(C.is_odd() || D.is_odd())
{ C += y; D -= x; }
@@ -257,9 +257,9 @@ BigInt power_mod(const BigInt& base, const BigInt& exp, const BigInt& mod)
*/
bool primality_test(const BigInt& n,
RandomNumberGenerator& rng,
- u32bit level)
+ size_t level)
{
- const u32bit PREF_NONCE_BITS = 64;
+ const size_t PREF_NONCE_BITS = 64;
if(n == 2)
return true;
@@ -271,7 +271,7 @@ bool primality_test(const BigInt& n,
{
const word num = n.word_at(0);
- for(u32bit i = 0; PRIMES[i]; ++i)
+ for(size_t i = 0; PRIMES[i]; ++i)
{
if(num == PRIMES[i])
return true;
@@ -285,14 +285,14 @@ bool primality_test(const BigInt& n,
if(level > 2)
level = 2;
- const u32bit NONCE_BITS = std::min(n.bits() - 2, PREF_NONCE_BITS);
+ const size_t NONCE_BITS = std::min(n.bits() - 2, PREF_NONCE_BITS);
MillerRabin_Test mr(n);
- const u32bit tests = miller_rabin_test_iterations(n.bits(), level);
+ const size_t tests = miller_rabin_test_iterations(n.bits(), level);
BigInt nonce;
- for(u32bit i = 0; i != tests; ++i)
+ for(size_t i = 0; i != tests; ++i)
{
while(nonce < 2 || nonce >= (n-1))
nonce.randomize(rng, NONCE_BITS);
diff --git a/src/math/numbertheory/numthry.h b/src/math/numbertheory/numthry.h
index 1ab64b038..750fbc78e 100644
--- a/src/math/numbertheory/numthry.h
+++ b/src/math/numbertheory/numthry.h
@@ -112,7 +112,7 @@ BigInt BOTAN_DLL ressol(const BigInt& x, const BigInt& p);
* @return count of the zero bits in x, or, equivalently, the largest
* value of n such that 2^n divides x evently
*/
-u32bit BOTAN_DLL low_zero_bits(const BigInt& x);
+size_t BOTAN_DLL low_zero_bits(const BigInt& x);
/**
* Primality Testing
@@ -123,7 +123,7 @@ u32bit BOTAN_DLL low_zero_bits(const BigInt& x);
*/
bool BOTAN_DLL primality_test(const BigInt& n,
RandomNumberGenerator& rng,
- u32bit level = 1);
+ size_t level = 1);
/**
* Quickly check for primality
@@ -165,8 +165,8 @@ inline bool verify_prime(const BigInt& n, RandomNumberGenerator& rng)
* @return random prime with the specified criteria
*/
BigInt BOTAN_DLL random_prime(RandomNumberGenerator& rng,
- u32bit bits, const BigInt& coprime = 1,
- u32bit equiv = 1, u32bit equiv_mod = 2);
+ size_t bits, const BigInt& coprime = 1,
+ size_t equiv = 1, size_t equiv_mod = 2);
/**
* Return a 'safe' prime, of the form p=2*q+1 with q prime
@@ -175,7 +175,7 @@ BigInt BOTAN_DLL random_prime(RandomNumberGenerator& rng,
* @return prime randomly chosen from safe primes of length bits
*/
BigInt BOTAN_DLL random_safe_prime(RandomNumberGenerator& rng,
- u32bit bits);
+ size_t bits);
class Algorithm_Factory;
@@ -193,7 +193,7 @@ SecureVector<byte> BOTAN_DLL
generate_dsa_primes(RandomNumberGenerator& rng,
Algorithm_Factory& af,
BigInt& p_out, BigInt& q_out,
- u32bit pbits, u32bit qbits);
+ size_t pbits, size_t qbits);
/**
* Generate DSA parameters using the FIPS 186 kosherizer
@@ -211,13 +211,13 @@ bool BOTAN_DLL
generate_dsa_primes(RandomNumberGenerator& rng,
Algorithm_Factory& af,
BigInt& p_out, BigInt& q_out,
- u32bit pbits, u32bit qbits,
+ size_t pbits, size_t qbits,
const MemoryRegion<byte>& seed);
/**
* The size of the PRIMES[] array
*/
-const u32bit PRIME_TABLE_SIZE = 6541;
+const size_t PRIME_TABLE_SIZE = 6541;
/**
* A const array of all primes less than 65535
diff --git a/src/math/numbertheory/point_gfp.cpp b/src/math/numbertheory/point_gfp.cpp
index 56d4a145a..5da1959bc 100644
--- a/src/math/numbertheory/point_gfp.cpp
+++ b/src/math/numbertheory/point_gfp.cpp
@@ -45,7 +45,7 @@ void PointGFp::monty_mult(BigInt& z,
}
const BigInt& p = curve.get_p();
- const u32bit p_size = curve.get_p_words();
+ const size_t p_size = curve.get_p_words();
const word p_dash = curve.get_p_dash();
SecureVector<word>& z_reg = z.get_reg();
@@ -75,7 +75,7 @@ void PointGFp::monty_sqr(BigInt& z, const BigInt& x,
}
const BigInt& p = curve.get_p();
- const u32bit p_size = curve.get_p_words();
+ const size_t p_size = curve.get_p_words();
const word p_dash = curve.get_p_dash();
SecureVector<word>& z_reg = z.get_reg();
@@ -289,7 +289,7 @@ PointGFp operator*(const BigInt& scalar, const PointGFp& point)
if(scalar.abs() <= 2) // special cases for small values
{
- u32bit value = scalar.abs().to_u32bit();
+ byte value = scalar.abs().byte_at(0);
PointGFp result = point;
@@ -302,14 +302,14 @@ PointGFp operator*(const BigInt& scalar, const PointGFp& point)
return result;
}
- const u32bit scalar_bits = scalar.bits();
+ const size_t scalar_bits = scalar.bits();
- const u32bit window_size = 4;
+ const size_t window_size = 4;
std::vector<PointGFp> Ps((1 << window_size) - 1);
Ps[0] = point;
- for(u32bit i = 1; i != Ps.size(); ++i)
+ for(size_t i = 1; i != Ps.size(); ++i)
{
Ps[i] = Ps[i-1];
@@ -320,14 +320,14 @@ PointGFp operator*(const BigInt& scalar, const PointGFp& point)
}
PointGFp H(curve); // create as zero
- u32bit bits_left = scalar_bits;
+ size_t bits_left = scalar_bits;
while(bits_left >= window_size)
{
- u32bit nibble = scalar.get_substring(bits_left - window_size,
+ size_t nibble = scalar.get_substring(bits_left - window_size,
window_size);
- for(u32bit i = 0; i != window_size; ++i)
+ for(size_t i = 0; i != window_size; ++i)
H.mult2(ws);
if(nibble)
@@ -469,7 +469,7 @@ SecureVector<byte> EC2OSP(const PointGFp& point, byte format)
if(point.is_zero())
return SecureVector<byte>(1); // single 0 byte
- const u32bit p_bytes = point.get_curve().get_p().bytes();
+ const size_t p_bytes = point.get_curve().get_p().bytes();
BigInt x = point.get_affine_x();
BigInt y = point.get_affine_y();
@@ -541,7 +541,7 @@ BigInt decompress_point(bool yMod2,
}
-PointGFp OS2ECP(const byte data[], u32bit data_len,
+PointGFp OS2ECP(const byte data[], size_t data_len,
const CurveGFp& curve)
{
if(data_len <= 1)
@@ -561,7 +561,7 @@ PointGFp OS2ECP(const byte data[], u32bit data_len,
}
else if(pc == 4)
{
- const u32bit l = (data_len - 1) / 2;
+ const size_t l = (data_len - 1) / 2;
// uncompressed form
x = BigInt::decode(&data[1], l);
@@ -569,7 +569,7 @@ PointGFp OS2ECP(const byte data[], u32bit data_len,
}
else if(pc == 6 || pc == 7)
{
- const u32bit l = (data_len - 1) / 2;
+ const size_t l = (data_len - 1) / 2;
// hybrid form
x = BigInt::decode(&data[1], l);
diff --git a/src/math/numbertheory/point_gfp.h b/src/math/numbertheory/point_gfp.h
index 42baa7d2c..35ec6d503 100644
--- a/src/math/numbertheory/point_gfp.h
+++ b/src/math/numbertheory/point_gfp.h
@@ -156,7 +156,7 @@ class BOTAN_DLL PointGFp
class Workspace
{
public:
- Workspace(u32bit p_words) :
+ Workspace(size_t p_words) :
ws_monty(2*(p_words+2)), ws_bn(12) {}
SecureVector<word> ws_monty;
@@ -259,7 +259,7 @@ inline PointGFp operator*(const PointGFp& point, const BigInt& scalar)
// encoding and decoding
SecureVector<byte> BOTAN_DLL EC2OSP(const PointGFp& point, byte format);
-PointGFp BOTAN_DLL OS2ECP(const byte data[], u32bit data_len,
+PointGFp BOTAN_DLL OS2ECP(const byte data[], size_t data_len,
const CurveGFp& curve);
inline PointGFp OS2ECP(const MemoryRegion<byte>& data, const CurveGFp& curve)
diff --git a/src/math/numbertheory/pow_mod.cpp b/src/math/numbertheory/pow_mod.cpp
index 5ab5638ea..a66a1f7df 100644
--- a/src/math/numbertheory/pow_mod.cpp
+++ b/src/math/numbertheory/pow_mod.cpp
@@ -114,18 +114,18 @@ BigInt Power_Mod::execute() const
/*
* Try to choose a good window size
*/
-u32bit Power_Mod::window_bits(u32bit exp_bits, u32bit,
+size_t Power_Mod::window_bits(size_t exp_bits, size_t,
Power_Mod::Usage_Hints hints)
{
- static const u32bit wsize[][2] = {
+ static const size_t wsize[][2] = {
{ 2048, 7 }, { 1024, 6 }, { 256, 5 }, { 128, 4 }, { 64, 3 }, { 0, 0 }
};
- u32bit window_bits = 1;
+ size_t window_bits = 1;
if(exp_bits)
{
- for(u32bit j = 0; wsize[j][0]; ++j)
+ for(size_t j = 0; wsize[j][0]; ++j)
{
if(exp_bits >= wsize[j][0])
{
@@ -154,8 +154,8 @@ Power_Mod::Usage_Hints choose_base_hints(const BigInt& b, const BigInt& n)
return Power_Mod::Usage_Hints(Power_Mod::BASE_IS_2 |
Power_Mod::BASE_IS_SMALL);
- const u32bit b_bits = b.bits();
- const u32bit n_bits = n.bits();
+ const size_t b_bits = b.bits();
+ const size_t n_bits = n.bits();
if(b_bits < n_bits / 32)
return Power_Mod::BASE_IS_SMALL;
@@ -170,8 +170,8 @@ Power_Mod::Usage_Hints choose_base_hints(const BigInt& b, const BigInt& n)
*/
Power_Mod::Usage_Hints choose_exp_hints(const BigInt& e, const BigInt& n)
{
- const u32bit e_bits = e.bits();
- const u32bit n_bits = n.bits();
+ const size_t e_bits = e.bits();
+ const size_t n_bits = n.bits();
if(e_bits < n_bits / 32)
return Power_Mod::BASE_IS_SMALL;
diff --git a/src/math/numbertheory/pow_mod.h b/src/math/numbertheory/pow_mod.h
index 1a60ca05f..7ec237d72 100644
--- a/src/math/numbertheory/pow_mod.h
+++ b/src/math/numbertheory/pow_mod.h
@@ -48,7 +48,7 @@ class BOTAN_DLL Power_Mod
/*
* Try to choose a good window size
*/
- static u32bit window_bits(u32bit exp_bits, u32bit base_bits,
+ static size_t window_bits(size_t exp_bits, size_t base_bits,
Power_Mod::Usage_Hints hints);
void set_modulus(const BigInt&, Usage_Hints = NO_HINTS) const;
diff --git a/src/math/numbertheory/powm_fw.cpp b/src/math/numbertheory/powm_fw.cpp
index 68dabc332..afc53f233 100644
--- a/src/math/numbertheory/powm_fw.cpp
+++ b/src/math/numbertheory/powm_fw.cpp
@@ -28,7 +28,7 @@ void Fixed_Window_Exponentiator::set_base(const BigInt& base)
g.resize((1 << window_bits) - 1);
g[0] = base;
- for(u32bit j = 1; j != g.size(); ++j)
+ for(size_t j = 1; j != g.size(); ++j)
g[j] = reducer.multiply(g[j-1], g[0]);
}
@@ -37,15 +37,15 @@ void Fixed_Window_Exponentiator::set_base(const BigInt& base)
*/
BigInt Fixed_Window_Exponentiator::execute() const
{
- const u32bit exp_nibbles = (exp.bits() + window_bits - 1) / window_bits;
+ const size_t exp_nibbles = (exp.bits() + window_bits - 1) / window_bits;
BigInt x = 1;
- for(u32bit j = exp_nibbles; j > 0; --j)
+ for(size_t j = exp_nibbles; j > 0; --j)
{
- for(u32bit k = 0; k != window_bits; ++k)
+ for(size_t k = 0; k != window_bits; ++k)
x = reducer.square(x);
- u32bit nibble = exp.get_substring(window_bits*(j-1), window_bits);
+ size_t nibble = exp.get_substring(window_bits*(j-1), window_bits);
if(nibble)
x = reducer.multiply(x, g[nibble-1]);
}
diff --git a/src/math/numbertheory/powm_mnt.cpp b/src/math/numbertheory/powm_mnt.cpp
index 8b915390c..038ce14da 100644
--- a/src/math/numbertheory/powm_mnt.cpp
+++ b/src/math/numbertheory/powm_mnt.cpp
@@ -44,12 +44,12 @@ void Montgomery_Exponentiator::set_base(const BigInt& base)
g[0].get_reg().set(&z[0], mod_words + 1);
const BigInt& x = g[0];
- const u32bit x_sig = x.sig_words();
+ const size_t x_sig = x.sig_words();
- for(u32bit i = 1; i != g.size(); ++i)
+ for(size_t i = 1; i != g.size(); ++i)
{
const BigInt& y = g[i-1];
- const u32bit y_sig = y.sig_words();
+ const size_t y_sig = y.sig_words();
zeroise(z);
bigint_mul(&z[0], z.size(), &workspace[0],
@@ -69,15 +69,15 @@ void Montgomery_Exponentiator::set_base(const BigInt& base)
*/
BigInt Montgomery_Exponentiator::execute() const
{
- const u32bit exp_nibbles = (exp_bits + window_bits - 1) / window_bits;
+ const size_t exp_nibbles = (exp_bits + window_bits - 1) / window_bits;
BigInt x = R_mod;
SecureVector<word> z(2 * (mod_words + 1));
SecureVector<word> workspace(2 * (mod_words + 1));
- for(u32bit i = exp_nibbles; i > 0; --i)
+ for(size_t i = exp_nibbles; i > 0; --i)
{
- for(u32bit k = 0; k != window_bits; ++k)
+ for(size_t k = 0; k != window_bits; ++k)
{
zeroise(z);
bigint_sqr(&z[0], z.size(), &workspace[0],
@@ -90,7 +90,7 @@ BigInt Montgomery_Exponentiator::execute() const
x.get_reg().set(&z[0], mod_words + 1);
}
- u32bit nibble = exp.get_substring(window_bits*(i-1), window_bits);
+ size_t nibble = exp.get_substring(window_bits*(i-1), window_bits);
if(nibble)
{
const BigInt& y = g[nibble-1];
diff --git a/src/math/numbertheory/reducer.h b/src/math/numbertheory/reducer.h
index 861983ef0..05c12a440 100644
--- a/src/math/numbertheory/reducer.h
+++ b/src/math/numbertheory/reducer.h
@@ -53,7 +53,7 @@ class BOTAN_DLL Modular_Reducer
Modular_Reducer(const BigInt& mod);
private:
BigInt modulus, modulus_2, mu;
- u32bit mod_words, mod2_words, mu_words;
+ size_t mod_words, mod2_words, mu_words;
};
}
diff --git a/src/math/numbertheory/ressol.cpp b/src/math/numbertheory/ressol.cpp
index 4696168b8..2e01406f8 100644
--- a/src/math/numbertheory/ressol.cpp
+++ b/src/math/numbertheory/ressol.cpp
@@ -32,7 +32,7 @@ BigInt ressol(const BigInt& a, const BigInt& p)
if(p % 4 == 3)
return power_mod(a, ((p+1) >> 2), p);
- u32bit s = low_zero_bits(p - 1);
+ size_t s = low_zero_bits(p - 1);
BigInt q = p >> s;
q -= 1;
@@ -58,7 +58,7 @@ BigInt ressol(const BigInt& a, const BigInt& p)
{
q = n;
- u32bit i = 0;
+ size_t i = 0;
while(q != 1)
{
q = mod_p.square(q);