diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/tests/test_gf2m.cpp | 12 | ||||
-rw-r--r-- | src/tests/test_octetstring.cpp | 40 | ||||
-rw-r--r-- | src/tests/tests.cpp | 4 | ||||
-rw-r--r-- | src/tests/tests.h | 6 |
4 files changed, 30 insertions, 32 deletions
diff --git a/src/tests/test_gf2m.cpp b/src/tests/test_gf2m.cpp index 9bb572c4e..d85f72e2e 100644 --- a/src/tests/test_gf2m.cpp +++ b/src/tests/test_gf2m.cpp @@ -41,11 +41,9 @@ class GF2m_Tests : public Test { Botan::GF2m_Field field(degree); - using Botan::gf2m; - for(size_t i = 0; i <= field.gf_ord(); ++i) { - gf2m a = static_cast<gf2m>(i); + Botan::gf2m a = static_cast<Botan::gf2m>(i); result.test_eq("square vs multiply", static_cast<size_t>(field.gf_square(a)), @@ -55,10 +53,10 @@ class GF2m_Tests : public Test * This sequence is from the start of gf2m_decomp_rootfind_state::calc_Fxj_j_neq_0 */ { - const gf2m jl_gray = field.gf_l_from_n(a); - const gf2m xl_j_tt_5 = field.gf_square_rr(jl_gray); - const gf2m xl_gray_tt_3 = field.gf_mul_rrr(xl_j_tt_5, jl_gray); - gf2m s = field.gf_mul_nrr(xl_gray_tt_3, field.gf_ord()); + const Botan::gf2m jl_gray = field.gf_l_from_n(a); + const Botan::gf2m xl_j_tt_5 = field.gf_square_rr(jl_gray); + const Botan::gf2m xl_gray_tt_3 = field.gf_mul_rrr(xl_j_tt_5, jl_gray); + Botan::gf2m s = field.gf_mul_nrr(xl_gray_tt_3, field.gf_ord()); result.test_gte("Value less than order", field.gf_ord(), s); } diff --git a/src/tests/test_octetstring.cpp b/src/tests/test_octetstring.cpp index ff689518e..ff9e179ac 100644 --- a/src/tests/test_octetstring.cpp +++ b/src/tests/test_octetstring.cpp @@ -12,13 +12,11 @@ namespace Botan_Tests { namespace { -using Botan::OctetString; - Test::Result test_from_rng() { Test::Result result("OctetString"); - OctetString os(Test::rng(), 32); + Botan::OctetString os(Test::rng(), 32); result.test_eq("length is 32 bytes", os.size(), 32); return result; @@ -28,7 +26,7 @@ Test::Result test_from_hex() { Test::Result result("OctetString"); - OctetString os("0123456789ABCDEF"); + Botan::OctetString os("0123456789ABCDEF"); result.test_eq("length is 8 bytes", os.size(), 8); return result; @@ -39,7 +37,7 @@ Test::Result test_from_byte() Test::Result result("OctetString"); auto rand_bytes = Test::rng().random_vec(8); - OctetString os(rand_bytes.data(), rand_bytes.size()); + Botan::OctetString os(rand_bytes.data(), rand_bytes.size()); result.test_eq("length is 8 bytes", os.size(), 8); return result; @@ -49,14 +47,14 @@ Test::Result test_odd_parity() { Test::Result result("OctetString"); - OctetString os("FFFFFFFFFFFFFFFF"); + Botan::OctetString os("FFFFFFFFFFFFFFFF"); os.set_odd_parity(); - OctetString expected("FEFEFEFEFEFEFEFE"); + Botan::OctetString expected("FEFEFEFEFEFEFEFE"); result.test_eq("odd parity set correctly", os, expected); - OctetString os2("EFCBDA4FAA997F63"); + Botan::OctetString os2("EFCBDA4FAA997F63"); os2.set_odd_parity(); - OctetString expected2("EFCBDA4FAB987F62"); + Botan::OctetString expected2("EFCBDA4FAB987F62"); result.test_eq("odd parity set correctly", os2, expected2); return result; @@ -66,7 +64,7 @@ Test::Result test_as_string() { Test::Result result("OctetString"); - OctetString os("0123456789ABCDEF"); + Botan::OctetString os("0123456789ABCDEF"); result.test_eq("OctetString::as_string() returns correct string", os.as_string(), "0123456789ABCDEF"); return result; @@ -76,10 +74,10 @@ Test::Result test_xor() { Test::Result result("OctetString"); - OctetString os1("0000000000000000"); - OctetString os2("FFFFFFFFFFFFFFFF"); + Botan::OctetString os1("0000000000000000"); + Botan::OctetString os2("FFFFFFFFFFFFFFFF"); - OctetString xor_result = os1 ^ os2; + Botan::OctetString xor_result = os1 ^ os2; result.test_eq("OctetString XOR operations works as expected", xor_result, os2); xor_result = os1; @@ -89,9 +87,9 @@ Test::Result test_xor() xor_result = os2 ^ os2; result.test_eq("OctetString XOR operations works as expected", xor_result, os1); - OctetString os3("0123456789ABCDEF"); + Botan::OctetString os3("0123456789ABCDEF"); xor_result = os3 ^ os2; - OctetString expected("FEDCBA9876543210"); + Botan::OctetString expected("FEDCBA9876543210"); result.test_eq("OctetString XOR operations works as expected", xor_result, expected); return result; @@ -101,8 +99,8 @@ Test::Result test_equality() { Test::Result result("OctetString"); - OctetString os1("0000000000000000"); - OctetString os2("FFFFFFFFFFFFFFFF"); + Botan::OctetString os1("0000000000000000"); + Botan::OctetString os2("FFFFFFFFFFFFFFFF"); result.confirm("OctetString equality operations works as expected", os1 == os1); result.confirm("OctetString equality operations works as expected", os2 == os2); @@ -115,11 +113,11 @@ Test::Result test_append() { Test::Result result("OctetString"); - OctetString os1("0000"); - OctetString os2("FFFF"); - OctetString expected("0000FFFF"); + Botan::OctetString os1("0000"); + Botan::OctetString os2("FFFF"); + Botan::OctetString expected("0000FFFF"); - OctetString append_result = os1 + os2; + Botan::OctetString append_result = os1 + os2; result.test_eq("OctetString append operations works as expected", append_result, expected); diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp index 243878bcd..a89899885 100644 --- a/src/tests/tests.cpp +++ b/src/tests/tests.cpp @@ -239,7 +239,9 @@ bool Test::Result::test_eq_sz(const std::string& what, size_t produced, size_t e return test_is_eq(what, produced, expected); } -bool Test::Result::test_eq(const std::string& what, OctetString produced, OctetString expected) +bool Test::Result::test_eq(const std::string& what, + Botan::OctetString produced, + Botan::OctetString expected) { std::ostringstream out; out << m_who << " " << what; diff --git a/src/tests/tests.h b/src/tests/tests.h index 32b654bbd..104ab43da 100644 --- a/src/tests/tests.h +++ b/src/tests/tests.h @@ -38,8 +38,6 @@ namespace Botan_Tests { using Botan::BigInt; #endif -using Botan::OctetString; - class Test_Error : public Botan::Exception { public: @@ -205,7 +203,9 @@ class Test bool test_eq(const std::string& what, size_t produced, size_t expected); bool test_eq_sz(const std::string& what, size_t produced, size_t expected); - bool test_eq(const std::string& what, OctetString produced, OctetString expected); + bool test_eq(const std::string& what, + Botan::OctetString produced, + Botan::OctetString expected); template<typename I1, typename I2> bool test_int_eq(I1 x, I2 y, const char* what) |