diff options
author | Jack Lloyd <[email protected]> | 2018-02-18 12:01:43 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-02-18 13:37:42 -0500 |
commit | 9772e10e3112f9b14669d372574bcc01981028f2 (patch) | |
tree | db1a4c6aa745ff73dd52da6dcc57a812901d3e8a /src/lib/pubkey/ec_group/ec_group.h | |
parent | 292c32bd73b3c114621ac2e4a668f6aca02c0cea (diff) |
Add functions to reduce integers mod the order to EC_Group
This allows calculating the Barett reduction params just once,
when the group is initialized, then sharing them across all
operations which use that group.
Diffstat (limited to 'src/lib/pubkey/ec_group/ec_group.h')
-rw-r--r-- | src/lib/pubkey/ec_group/ec_group.h | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/lib/pubkey/ec_group/ec_group.h b/src/lib/pubkey/ec_group/ec_group.h index 1dc839540..b4b0ec9b3 100644 --- a/src/lib/pubkey/ec_group/ec_group.h +++ b/src/lib/pubkey/ec_group/ec_group.h @@ -133,6 +133,16 @@ class BOTAN_PUBLIC_API(2,0) EC_Group final size_t get_p_bytes() const; /** + * Return the size of group order in bits (same as get_order().bits()) + */ + size_t get_order_bits() const; + + /** + * Return the size of p in bytes (same as get_order().bytes()) + */ + size_t get_order_bytes() const; + + /** * Return the prime modulus of the field */ const BigInt& get_p() const; @@ -159,6 +169,22 @@ class BOTAN_PUBLIC_API(2,0) EC_Group final */ const BigInt& get_order() const; + /* + * Reduce x modulo the order + */ + BigInt mod_order(const BigInt& x) const; + + /* + * Reduce (x*y) modulo the order + */ + BigInt multiply_mod_order(const BigInt& x, const BigInt& y) const; + + /** + * Return the cofactor + * @result the cofactor + */ + const BigInt& get_cofactor() const; + /** * Return the OID of these domain parameters * @result the OID as a string @@ -172,12 +198,6 @@ class BOTAN_PUBLIC_API(2,0) EC_Group final const OID& get_curve_oid() const; /** - * Return the cofactor - * @result the cofactor - */ - const BigInt& get_cofactor() const; - - /** * Return a point on this curve with the affine values x, y */ PointGFp point(const BigInt& x, const BigInt& y) const; |