From 65e5a8826f4240fd0b21ad99ab9daa9da862fc29 Mon Sep 17 00:00:00 2001 From: lloyd Date: Mon, 15 Mar 2010 16:39:10 +0000 Subject: Use bigint_{mul,sqr} in PointGFp monty ops --- src/math/numbertheory/point_gfp.cpp | 15 +++++++-------- src/math/numbertheory/point_gfp.h | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'src/math/numbertheory') 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& 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 ws_monty; std::vector ws_bn; -- cgit v1.2.3