diff options
author | lloyd <[email protected]> | 2010-02-25 20:15:54 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-02-25 20:15:54 +0000 |
commit | 790bf7561888953c34b2f5264a326bdb46b1174a (patch) | |
tree | 8932eb965bb93899f9ec221ac8bb97822782dcfe /checks | |
parent | f39241bf20dc6781be576f17b264ee1a6bf7d58b (diff) |
create_random_point was used in one tests though, so add it back in ec_tests.cpp
Diffstat (limited to 'checks')
-rw-r--r-- | checks/ec_tests.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/checks/ec_tests.cpp b/checks/ec_tests.cpp index 4115a84f1..2915eb2da 100644 --- a/checks/ec_tests.cpp +++ b/checks/ec_tests.cpp @@ -35,6 +35,31 @@ using namespace Botan; namespace { +PointGFp create_random_point(RandomNumberGenerator& rng, + const CurveGFp& curve) + { + const BigInt& p = curve.get_p(); + + while(true) + { + BigInt r(rng, p.bits()); + + GFpElement x = GFpElement(p, r); + GFpElement x3 = x * x * x; + + GFpElement ax(curve.get_p(), curve.get_a()); + ax *= x; + + GFpElement bx3(curve.get_p(), curve.get_b()); + bx3 *= x3; + + GFpElement y = ax + bx3; + + if(ressol(y.get_value(), p) > 0) + return PointGFp(curve, x.get_value(), y.get_value()); + } + } + void test_point_turn_on_sp_red_mul() { std::cout << "." << std::flush; |