aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/math
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-03-14 06:43:49 -0400
committerJack Lloyd <[email protected]>2018-03-14 06:43:49 -0400
commite3c05e70379f2ba593724a072aa3d6404eebbe81 (patch)
tree9f5ff539d9844fb679481ca424ca5a4462191efa /src/lib/math
parentdeb54a47d76a2de8bb9d1faae8f13a31429ba489 (diff)
Improve memory handling for PointGFp
Diffstat (limited to 'src/lib/math')
-rw-r--r--src/lib/math/bigint/bigint.h5
-rw-r--r--src/lib/math/mp/mp_karat.cpp2
-rw-r--r--src/lib/math/mp/mp_monty.cpp2
3 files changed, 3 insertions, 6 deletions
diff --git a/src/lib/math/bigint/bigint.h b/src/lib/math/bigint/bigint.h
index c397a7659..ba17d7ede 100644
--- a/src/lib/math/bigint/bigint.h
+++ b/src/lib/math/bigint/bigint.h
@@ -383,11 +383,6 @@ class BOTAN_PUBLIC_API(2,0) BigInt final
m_reg[i] = w;
}
- void ensure_capacity(size_t sz)
- {
- m_reg.reserve(sz);
- }
-
/**
* Tests if the sign of the integer is negative
* @result true, iff the integer has a negative sign
diff --git a/src/lib/math/mp/mp_karat.cpp b/src/lib/math/mp/mp_karat.cpp
index 6fb217668..e460aaac9 100644
--- a/src/lib/math/mp/mp_karat.cpp
+++ b/src/lib/math/mp/mp_karat.cpp
@@ -326,6 +326,8 @@ void bigint_sqr(word z[], size_t z_size,
const word x[], size_t x_size, size_t x_sw,
word workspace[], size_t ws_size)
{
+ clear_mem(z, z_size);
+
BOTAN_ASSERT(z_size/2 >= x_sw, "Output size is sufficient");
if(x_sw == 1)
diff --git a/src/lib/math/mp/mp_monty.cpp b/src/lib/math/mp/mp_monty.cpp
index 199475297..5a28526ff 100644
--- a/src/lib/math/mp/mp_monty.cpp
+++ b/src/lib/math/mp/mp_monty.cpp
@@ -109,7 +109,7 @@ void bigint_monty_redc(word z[],
ws[2*p_size+1] = word_sub(ws[p_size], 0, &borrow);
CT::conditional_copy_mem(borrow, z, ws, ws + (p_size + 1), (p_size + 1));
- clear_mem(z + p_size + 1, z_size - p_size - 1);
+ clear_mem(z + p_size, z_size - p_size - 2);
CT::unpoison(z, z_size);
CT::unpoison(p, p_size);