diff options
author | lloyd <[email protected]> | 2014-11-15 14:35:19 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2014-11-15 14:35:19 +0000 |
commit | 1518c30f1c90c2d0e5e06731e3dffe21353b34db (patch) | |
tree | c2f819f2a2011a7af6052ede3b32638412b546d0 /src/lib/math/ec_gfp/curve_gfp.h | |
parent | 17349a1fc49d604f8160f2077538fdf397b702c6 (diff) |
Add specialized reduction for P-521 along with 9x9 Comba routines.
Roughly 35-50% faster on my laptop (depending on if mlock is enabled,
the overhead in that allocator is becoming much more of a hotspot).
Diffstat (limited to 'src/lib/math/ec_gfp/curve_gfp.h')
-rw-r--r-- | src/lib/math/ec_gfp/curve_gfp.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/lib/math/ec_gfp/curve_gfp.h b/src/lib/math/ec_gfp/curve_gfp.h index 67fb3d2cf..59639d537 100644 --- a/src/lib/math/ec_gfp/curve_gfp.h +++ b/src/lib/math/ec_gfp/curve_gfp.h @@ -24,6 +24,8 @@ class CurveGFp_Repr virtual const BigInt& get_a() const = 0; virtual const BigInt& get_b() const = 0; + virtual size_t get_p_words() const = 0; + /* * Returns to_curve_rep(get_a()) */ @@ -43,6 +45,10 @@ class CurveGFp_Repr virtual void curve_sqr(BigInt& z, const BigInt& x, secure_vector<word>& ws) const = 0; + + virtual void normalize(BigInt& x, + secure_vector<word>& ws, + size_t bound) const; }; /** @@ -109,6 +115,8 @@ class BOTAN_DLL CurveGFp return xt; } + // TODO: from_rep taking && ref + void mul(BigInt& z, const BigInt& x, const BigInt& y, secure_vector<word>& ws) const { m_repr->curve_mul(z, x, y, ws); @@ -133,6 +141,16 @@ class BOTAN_DLL CurveGFp return z; } + /** + * Adjust x to be in [0,p) + * @param bound if greater than zero, assume that no more than bound + * additions or subtractions are required to move x into range. + */ + void normalize(BigInt& x, secure_vector<word>& ws, size_t bound = 0) const + { + m_repr->normalize(x, ws, bound); + } + void swap(CurveGFp& other) { std::swap(m_repr, other.m_repr); |