diff options
Diffstat (limited to 'src/math')
-rw-r--r-- | src/math/bigint/bigint.cpp | 4 | ||||
-rw-r--r-- | src/math/bigint/bigint.h | 4 | ||||
-rw-r--r-- | src/math/numbertheory/point_gfp.cpp | 6 | ||||
-rw-r--r-- | src/math/numbertheory/powm_fw.cpp | 3 | ||||
-rw-r--r-- | src/math/numbertheory/powm_mnt.cpp | 3 |
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]; |