aboutsummaryrefslogtreecommitdiffstats
path: root/src/math
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-10-28 20:05:21 +0000
committerlloyd <[email protected]>2010-10-28 20:05:21 +0000
commit7c2ac02f29fd4b5d629e187381baa783b53bd2e4 (patch)
tree9d07a452f0a7bd44a2b9d3aaac16f9d9e692fde5 /src/math
parentb502cefaf0f9396354d58c4c18a78ac7870f6168 (diff)
parent7e4c62045c8216138dbed1c586139a1de7cd7f27 (diff)
propagate from branch 'net.randombit.botan' (head 2841fb518e20d2fe0a374e4f6b08bdbb14d5d158)
to branch 'net.randombit.botan.c++0x' (head 0b9275139d6346bd3aa28d63bf8b8a03851d853d)
Diffstat (limited to 'src/math')
-rw-r--r--src/math/bigint/bigint.cpp4
-rw-r--r--src/math/bigint/bigint.h4
-rw-r--r--src/math/numbertheory/point_gfp.cpp6
-rw-r--r--src/math/numbertheory/powm_fw.cpp3
-rw-r--r--src/math/numbertheory/powm_mnt.cpp3
5 files changed, 9 insertions, 11 deletions
diff --git a/src/math/bigint/bigint.cpp b/src/math/bigint/bigint.cpp
index a13c4f234..a49335e75 100644
--- a/src/math/bigint/bigint.cpp
+++ b/src/math/bigint/bigint.cpp
@@ -184,7 +184,7 @@ bool BigInt::get_bit(size_t n) const
/*
* Return bits {offset...offset+length}
*/
-size_t BigInt::get_substring(size_t offset, size_t length) const
+u32bit BigInt::get_substring(size_t offset, size_t length) const
{
if(length > 32)
throw Invalid_Argument("BigInt::get_substring: Substring size too big");
@@ -196,7 +196,7 @@ size_t BigInt::get_substring(size_t offset, size_t length) const
u64bit mask = (1 << length) - 1;
size_t shift = (offset % 8);
- return static_cast<size_t>((piece >> shift) & mask);
+ return static_cast<u32bit>((piece >> shift) & mask);
}
/*
diff --git a/src/math/bigint/bigint.h b/src/math/bigint/bigint.h
index 0c01d56c1..fc2e58073 100644
--- a/src/math/bigint/bigint.h
+++ b/src/math/bigint/bigint.h
@@ -135,7 +135,7 @@ class BOTAN_DLL BigInt
* @param i a word index
* @return the word at index i
*/
- word operator[](size_t i) const { return reg[i]; }
+ const word& operator[](size_t i) const { return reg[i]; }
/**
* Zeroize the BigInt
@@ -215,7 +215,7 @@ class BOTAN_DLL BigInt
* @result the integer extracted from the register starting at
* offset with specified length
*/
- size_t get_substring(size_t offset, size_t length) const;
+ u32bit get_substring(size_t offset, size_t length) const;
/**
* @param n the offset to get a byte from
diff --git a/src/math/numbertheory/point_gfp.cpp b/src/math/numbertheory/point_gfp.cpp
index 5da1959bc..8cb40270c 100644
--- a/src/math/numbertheory/point_gfp.cpp
+++ b/src/math/numbertheory/point_gfp.cpp
@@ -324,12 +324,12 @@ PointGFp operator*(const BigInt& scalar, const PointGFp& point)
while(bits_left >= window_size)
{
- size_t nibble = scalar.get_substring(bits_left - window_size,
- window_size);
-
for(size_t i = 0; i != window_size; ++i)
H.mult2(ws);
+ const u32bit nibble = scalar.get_substring(bits_left - window_size,
+ window_size);
+
if(nibble)
H.add(Ps[nibble-1], ws);
diff --git a/src/math/numbertheory/powm_fw.cpp b/src/math/numbertheory/powm_fw.cpp
index afc53f233..3348e55cd 100644
--- a/src/math/numbertheory/powm_fw.cpp
+++ b/src/math/numbertheory/powm_fw.cpp
@@ -45,8 +45,7 @@ BigInt Fixed_Window_Exponentiator::execute() const
for(size_t k = 0; k != window_bits; ++k)
x = reducer.square(x);
- size_t nibble = exp.get_substring(window_bits*(j-1), window_bits);
- if(nibble)
+ if(u32bit nibble = exp.get_substring(window_bits*(j-1), window_bits))
x = reducer.multiply(x, g[nibble-1]);
}
return x;
diff --git a/src/math/numbertheory/powm_mnt.cpp b/src/math/numbertheory/powm_mnt.cpp
index 038ce14da..4f626ac9d 100644
--- a/src/math/numbertheory/powm_mnt.cpp
+++ b/src/math/numbertheory/powm_mnt.cpp
@@ -90,8 +90,7 @@ BigInt Montgomery_Exponentiator::execute() const
x.get_reg().set(&z[0], mod_words + 1);
}
- size_t nibble = exp.get_substring(window_bits*(i-1), window_bits);
- if(nibble)
+ if(u32bit nibble = exp.get_substring(window_bits*(i-1), window_bits))
{
const BigInt& y = g[nibble-1];