diff options
author | lloyd <[email protected]> | 2010-03-15 16:39:10 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-03-15 16:39:10 +0000 |
commit | 65e5a8826f4240fd0b21ad99ab9daa9da862fc29 (patch) | |
tree | 615a95eb20c87b01f5427bc9fba7c87f8c4dfe04 | |
parent | b44cd1b0e15da99561d6d1f1dfc927c5ee8d53ee (diff) |
Use bigint_{mul,sqr} in PointGFp monty ops
-rw-r--r-- | src/math/numbertheory/point_gfp.cpp | 15 | ||||
-rw-r--r-- | src/math/numbertheory/point_gfp.h | 2 |
2 files changed, 8 insertions, 9 deletions
diff --git a/src/math/numbertheory/point_gfp.cpp b/src/math/numbertheory/point_gfp.cpp index d4c68d1dc..2e4f99796 100644 --- a/src/math/numbertheory/point_gfp.cpp +++ b/src/math/numbertheory/point_gfp.cpp @@ -38,15 +38,15 @@ BigInt PointGFp::monty_mult(const BigInt& a, const BigInt& b, return 0; const BigInt& p = curve.get_p(); - const u32bit p_size = (workspace.size() - 1) / 2; + const u32bit p_size = p.sig_words(); const word p_dash = curve.get_p_dash(); workspace.clear(); - bigint_simple_mul(workspace, - a.data(), a.sig_words(), - b.data(), b.sig_words()); + bigint_mul(workspace, workspace.size(), 0, + a.data(), a.size(), a.sig_words(), + b.data(), b.size(), b.sig_words()); bigint_monty_redc(workspace, workspace.size(), p.data(), p_size, p_dash); @@ -61,19 +61,18 @@ BigInt PointGFp::monty_mult(const BigInt& a, const BigInt& b, BigInt PointGFp::monty_sqr(const BigInt& x, MemoryRegion<word>& workspace) { - //return monty_mult(x, x, workspace); - if(x.is_zero()) return 0; const BigInt& p = curve.get_p(); - const u32bit p_size = (workspace.size() - 1) / 2; + const u32bit p_size = p.sig_words(); const word p_dash = curve.get_p_dash(); workspace.clear(); - bigint_simple_sqr(workspace, x.data(), x.sig_words()); + bigint_sqr(workspace, workspace.size(), 0, + x.data(), x.size(), x.sig_words()); bigint_monty_redc(workspace, workspace.size(), p.data(), p_size, p_dash); diff --git a/src/math/numbertheory/point_gfp.h b/src/math/numbertheory/point_gfp.h index e4cf6f7d5..c7da6995c 100644 --- a/src/math/numbertheory/point_gfp.h +++ b/src/math/numbertheory/point_gfp.h @@ -145,7 +145,7 @@ class BOTAN_DLL PointGFp { public: Workspace(u32bit p_words) : - ws_monty(2*p_words+1), ws_bn(12) {} + ws_monty(2*(p_words+2)), ws_bn(12) {} SecureVector<word> ws_monty; std::vector<BigInt> ws_bn; |