aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/math
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-02-23 08:31:25 -0500
committerJack Lloyd <[email protected]>2018-02-23 08:31:25 -0500
commitcad1e719dae651022f9fc3da9e431c2442d3827b (patch)
tree134f61fb20b9a9d4e04e2f100407a4e05fe3748f /src/lib/math
parent6fbe80af97d6788f82ae3e570e7279801ca6d9bf (diff)
Inline NIST normalize function, use bigint_sub3
Diffstat (limited to 'src/lib/math')
-rw-r--r--src/lib/math/ec_gfp/curve_nistp.cpp15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/lib/math/ec_gfp/curve_nistp.cpp b/src/lib/math/ec_gfp/curve_nistp.cpp
index 62d11d4a9..7990c541c 100644
--- a/src/lib/math/ec_gfp/curve_nistp.cpp
+++ b/src/lib/math/ec_gfp/curve_nistp.cpp
@@ -13,29 +13,20 @@ namespace Botan {
namespace {
-void normalize(const BigInt& p, BigInt& x, secure_vector<word>& ws, size_t bound)
+inline void normalize(const BigInt& p, BigInt& x, secure_vector<word>& ws, size_t bound)
{
const word* prime = p.data();
const size_t p_words = p.sig_words();
- // TODO: provide a high level function for this compare-and-sub operation
if(x.size() < p_words + 1)
x.grow_to(p_words + 1);
if(ws.size() < p_words + 1)
ws.resize(p_words + 1);
- for(size_t i = 0; bound == 0 || i < bound; ++i)
+ for(size_t i = 0; i < bound; ++i)
{
- const word* xd = x.data();
- word borrow = 0;
-
- for(size_t j = 0; j != p_words; ++j)
- {
- ws[j] = word_sub(xd[j], prime[j], &borrow);
- }
-
- ws[p_words] = word_sub(xd[p_words], 0, &borrow);
+ word borrow = bigint_sub3(ws.data(), x.data(), p_words + 1, prime, p_words);
if(borrow)
break;