diff options
Diffstat (limited to 'src/math/gfpmath')
-rw-r--r-- | src/math/gfpmath/gfp_element.cpp | 5 | ||||
-rw-r--r-- | src/math/gfpmath/gfp_element.h | 40 | ||||
-rw-r--r-- | src/math/gfpmath/info.txt | 21 | ||||
-rw-r--r-- | src/math/gfpmath/point_gfp.cpp | 6 | ||||
-rw-r--r-- | src/math/gfpmath/point_gfp.h | 41 |
5 files changed, 61 insertions, 52 deletions
diff --git a/src/math/gfpmath/gfp_element.cpp b/src/math/gfpmath/gfp_element.cpp index 872000a58..1a48fdc92 100644 --- a/src/math/gfpmath/gfp_element.cpp +++ b/src/math/gfpmath/gfp_element.cpp @@ -9,9 +9,8 @@ #include <botan/gfp_element.h> #include <botan/numthry.h> #include <botan/def_powm.h> -#include <botan/mp_types.h> -#include <botan/mp_asm.h> -#include <botan/mp_asmi.h> +#include <botan/internal/mp_asm.h> +#include <botan/internal/mp_asmi.h> #include <ostream> #include <assert.h> diff --git a/src/math/gfpmath/gfp_element.h b/src/math/gfpmath/gfp_element.h index d340c77b1..c84806f9a 100644 --- a/src/math/gfpmath/gfp_element.h +++ b/src/math/gfpmath/gfp_element.h @@ -218,14 +218,6 @@ class BOTAN_DLL GFpElement //friend declarations for non-member functions - /** - * write a GFpElement to an output stream. - * @param output the output stream to write to - * @param elem the object to write - * @result the output stream - */ - friend std::ostream& operator<<(std::ostream& output, const GFpElement& elem); - friend class Point_Coords_GFp; /** @@ -252,31 +244,37 @@ class BOTAN_DLL GFpElement }; // relational operators -bool operator==(const GFpElement& lhs, const GFpElement& rhs); +bool BOTAN_DLL operator==(const GFpElement& lhs, const GFpElement& rhs); inline bool operator!=(const GFpElement& lhs, const GFpElement& rhs ) { return !operator==(lhs, rhs); } // arithmetic operators -GFpElement operator+(const GFpElement& lhs, const GFpElement& rhs); -GFpElement operator-(const GFpElement& lhs, const GFpElement& rhs); -GFpElement operator-(const GFpElement& lhs); +GFpElement BOTAN_DLL operator+(const GFpElement& lhs, const GFpElement& rhs); +GFpElement BOTAN_DLL operator-(const GFpElement& lhs, const GFpElement& rhs); +GFpElement BOTAN_DLL operator-(const GFpElement& lhs); -GFpElement operator*(const GFpElement& lhs, const GFpElement& rhs); -GFpElement operator/(const GFpElement& lhs, const GFpElement& rhs); -GFpElement operator* (const GFpElement& lhs, u32bit rhs); -GFpElement operator* (u32bit rhs, const GFpElement& lhs); +GFpElement BOTAN_DLL operator*(const GFpElement& lhs, const GFpElement& rhs); +GFpElement BOTAN_DLL operator/(const GFpElement& lhs, const GFpElement& rhs); +GFpElement BOTAN_DLL operator* (const GFpElement& lhs, u32bit rhs); +GFpElement BOTAN_DLL operator* (u32bit rhs, const GFpElement& lhs); -// io operators -std::ostream& operator<<(std::ostream& output, const GFpElement& elem); + +/** +* write a GFpElement to an output stream. +* @param output the output stream to write to +* @param elem the object to write +* @result the output stream +*/ +BOTAN_DLL std::ostream& operator<<(std::ostream& output, const GFpElement& elem); // return (*this)^(-1) -GFpElement inverse(const GFpElement& elem); +GFpElement BOTAN_DLL inverse(const GFpElement& elem); // encoding and decoding -SecureVector<byte> FE2OSP(const GFpElement& elem); -GFpElement OS2FEP(MemoryRegion<byte> const& os, BigInt p); +SecureVector<byte> BOTAN_DLL FE2OSP(const GFpElement& elem); +GFpElement BOTAN_DLL OS2FEP(MemoryRegion<byte> const& os, BigInt p); inline void swap(GFpElement& x, GFpElement& y) { diff --git a/src/math/gfpmath/info.txt b/src/math/gfpmath/info.txt index e1bf892c7..55ae8b5e6 100644 --- a/src/math/gfpmath/info.txt +++ b/src/math/gfpmath/info.txt @@ -1,16 +1,25 @@ define BIGINT_GFP -load_on auto +<header:public> +curve_gfp.h +gfp_element.h +gfp_modulus.h +point_gfp.h +</header:public> +<<<<<<< variant A +<source> +>>>>>>> variant B <add> +####### Ancestor +define BIGINT_GFP + +<add> +======= end curve_gfp.cpp -curve_gfp.h gfp_element.cpp -gfp_element.h -gfp_modulus.h point_gfp.cpp -point_gfp.h -</add> +</source> <requires> bigint diff --git a/src/math/gfpmath/point_gfp.cpp b/src/math/gfpmath/point_gfp.cpp index b19687537..4dae1afc8 100644 --- a/src/math/gfpmath/point_gfp.cpp +++ b/src/math/gfpmath/point_gfp.cpp @@ -839,7 +839,7 @@ void PointGFp::swap(PointGFp& other) std::swap<bool>(mAZpow4_set, other.mAZpow4_set); } -PointGFp const mult2(const PointGFp& point) +PointGFp mult2(const PointGFp& point) { return (PointGFp(point)).mult2_in_place(); } @@ -1114,8 +1114,8 @@ GFpElement PointGFp::decompress(bool yMod2, const GFpElement& x, return GFpElement(curve.get_p(),z); } -PointGFp const create_random_point(RandomNumberGenerator& rng, - const CurveGFp& curve) +PointGFp create_random_point(RandomNumberGenerator& rng, + const CurveGFp& curve) { // create a random point diff --git a/src/math/gfpmath/point_gfp.h b/src/math/gfpmath/point_gfp.h index ce2bf1626..10fc404bf 100644 --- a/src/math/gfpmath/point_gfp.h +++ b/src/math/gfpmath/point_gfp.h @@ -18,7 +18,7 @@ namespace Botan { -struct Illegal_Point : public Exception +struct BOTAN_DLL Illegal_Point : public Exception { Illegal_Point(const std::string& err = "") : Exception(err) {} }; @@ -260,36 +260,39 @@ class BOTAN_DLL PointGFp }; // relational operators -bool operator==(const PointGFp& lhs, const PointGFp& rhs); +bool BOTAN_DLL operator==(const PointGFp& lhs, const PointGFp& rhs); inline bool operator!=(const PointGFp& lhs, const PointGFp& rhs ) { return !operator==(lhs, rhs); } // arithmetic operators -PointGFp operator+(const PointGFp& lhs, const PointGFp& rhs); -PointGFp operator-(const PointGFp& lhs, const PointGFp& rhs); -PointGFp operator-(const PointGFp& lhs); +PointGFp BOTAN_DLL operator+(const PointGFp& lhs, const PointGFp& rhs); +PointGFp BOTAN_DLL operator-(const PointGFp& lhs, const PointGFp& rhs); +PointGFp BOTAN_DLL operator-(const PointGFp& lhs); -PointGFp operator*(const BigInt& scalar, const PointGFp& point); -PointGFp operator*(const PointGFp& point, const BigInt& scalar); -PointGFp mult_point_secure(const PointGFp& point, - const BigInt& scalar, - const BigInt& point_order, - const BigInt& max_secret); +PointGFp BOTAN_DLL operator*(const BigInt& scalar, const PointGFp& point); +PointGFp BOTAN_DLL operator*(const PointGFp& point, const BigInt& scalar); +PointGFp BOTAN_DLL mult_point_secure(const PointGFp& point, + const BigInt& scalar, + const BigInt& point_order, + const BigInt& max_secret); -PointGFp const mult2(const PointGFp& point); +PointGFp BOTAN_DLL mult2(const PointGFp& point); -PointGFp const create_random_point(RandomNumberGenerator& rng, - const CurveGFp& curve); +PointGFp BOTAN_DLL create_random_point(RandomNumberGenerator& rng, + const CurveGFp& curve); // encoding and decoding -SecureVector<byte> EC2OSP(const PointGFp& point, byte format); -PointGFp OS2ECP(MemoryRegion<byte> const& os, const CurveGFp& curve); +SecureVector<byte> BOTAN_DLL EC2OSP(const PointGFp& point, byte format); +PointGFp BOTAN_DLL OS2ECP(MemoryRegion<byte> const& os, const CurveGFp& curve); -SecureVector<byte> encode_uncompressed(const PointGFp& point); // maybe make private -SecureVector<byte> encode_hybrid(const PointGFp& point); // maybe make private -SecureVector<byte> encode_compressed(const PointGFp& point); // maybe make private +/* Should these be private? */ +SecureVector<byte> +BOTAN_DLL encode_uncompressed(const PointGFp& point); + +SecureVector<byte> BOTAN_DLL encode_hybrid(const PointGFp& point); +SecureVector<byte> BOTAN_DLL encode_compressed(const PointGFp& point); // swaps the states of point1 and point2, does not throw! // cf. Meyers, Item 25 |