diff options
author | Simon Warta <simon@warta.it> | 2015-06-29 13:11:23 +0200 |
---|---|---|
committer | Simon Warta <simon@warta.it> | 2015-06-30 10:38:23 +0200 |
commit | 8668ce8753b10e944bdc72b6e66d752759c7e710 (patch) | |
tree | 787e9829c871748b34594d35f3a5e6569ccdbb31 /src/tests/unit_ecc.cpp | |
parent | b90187419f64b6d38d19c888985d58f902336677 (diff) |
tests: Convert &vec[0] to vec.data()
Diffstat (limited to 'src/tests/unit_ecc.cpp')
-rw-r--r-- | src/tests/unit_ecc.cpp | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/src/tests/unit_ecc.cpp b/src/tests/unit_ecc.cpp index 2bae63936..4c35caa48 100644 --- a/src/tests/unit_ecc.cpp +++ b/src/tests/unit_ecc.cpp @@ -75,9 +75,9 @@ size_t test_point_turn_on_sp_red_mul() std::vector<byte> sv_a_secp = hex_decode(a_secp); std::vector<byte> sv_b_secp = hex_decode(b_secp); std::vector<byte> sv_G_secp_comp = hex_decode(G_secp_comp); - BigInt bi_p_secp = BigInt::decode(&sv_p_secp[0], sv_p_secp.size()); - BigInt bi_a_secp = BigInt::decode(&sv_a_secp[0], sv_a_secp.size()); - BigInt bi_b_secp = BigInt::decode(&sv_b_secp[0], sv_b_secp.size()); + BigInt bi_p_secp = BigInt::decode(sv_p_secp.data(), sv_p_secp.size()); + BigInt bi_a_secp = BigInt::decode(sv_a_secp.data(), sv_a_secp.size()); + BigInt bi_b_secp = BigInt::decode(sv_b_secp.data(), sv_b_secp.size()); CurveGFp secp160r1(bi_p_secp, bi_a_secp, bi_b_secp); PointGFp p_G = OS2ECP(sv_G_secp_comp, secp160r1); @@ -140,9 +140,9 @@ size_t test_coordinates() std::vector<byte> sv_b_secp = hex_decode ( b_secp ); std::vector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp ); - BigInt bi_p_secp = BigInt::decode ( &sv_p_secp[0], sv_p_secp.size() ); - BigInt bi_a_secp = BigInt::decode ( &sv_a_secp[0], sv_a_secp.size() ); - BigInt bi_b_secp = BigInt::decode ( &sv_b_secp[0], sv_b_secp.size() ); + BigInt bi_p_secp = BigInt::decode ( sv_p_secp.data(), sv_p_secp.size() ); + BigInt bi_a_secp = BigInt::decode ( sv_a_secp.data(), sv_a_secp.size() ); + BigInt bi_b_secp = BigInt::decode ( sv_b_secp.data(), sv_b_secp.size() ); CurveGFp secp160r1 (bi_p_secp, bi_a_secp, bi_b_secp); PointGFp p_G = OS2ECP ( sv_G_secp_comp, secp160r1 ); PointGFp p0 = p_G; @@ -218,9 +218,9 @@ size_t test_point_negative() std::vector<byte> sv_a_secp = hex_decode ( a_secp ); std::vector<byte> sv_b_secp = hex_decode ( b_secp ); std::vector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp ); - BigInt bi_p_secp = BigInt::decode ( &sv_p_secp[0], sv_p_secp.size() ); - BigInt bi_a_secp = BigInt::decode ( &sv_a_secp[0], sv_a_secp.size() ); - BigInt bi_b_secp = BigInt::decode ( &sv_b_secp[0], sv_b_secp.size() ); + BigInt bi_p_secp = BigInt::decode ( sv_p_secp.data(), sv_p_secp.size() ); + BigInt bi_a_secp = BigInt::decode ( sv_a_secp.data(), sv_a_secp.size() ); + BigInt bi_b_secp = BigInt::decode ( sv_b_secp.data(), sv_b_secp.size() ); CurveGFp secp160r1(bi_p_secp, bi_a_secp, bi_b_secp); PointGFp p_G = OS2ECP ( sv_G_secp_comp, secp160r1 ); @@ -332,9 +332,9 @@ size_t test_add_point() std::vector<byte> sv_a_secp = hex_decode ( a_secp ); std::vector<byte> sv_b_secp = hex_decode ( b_secp ); std::vector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp ); - BigInt bi_p_secp = BigInt::decode ( &sv_p_secp[0], sv_p_secp.size() ); - BigInt bi_a_secp = BigInt::decode ( &sv_a_secp[0], sv_a_secp.size() ); - BigInt bi_b_secp = BigInt::decode ( &sv_b_secp[0], sv_b_secp.size() ); + BigInt bi_p_secp = BigInt::decode ( sv_p_secp.data(), sv_p_secp.size() ); + BigInt bi_a_secp = BigInt::decode ( sv_a_secp.data(), sv_a_secp.size() ); + BigInt bi_b_secp = BigInt::decode ( sv_b_secp.data(), sv_b_secp.size() ); CurveGFp secp160r1(bi_p_secp, bi_a_secp, bi_b_secp); PointGFp p_G = OS2ECP ( sv_G_secp_comp, secp160r1 ); @@ -369,9 +369,9 @@ size_t test_sub_point() std::vector<byte> sv_a_secp = hex_decode ( a_secp ); std::vector<byte> sv_b_secp = hex_decode ( b_secp ); std::vector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp ); - BigInt bi_p_secp = BigInt::decode ( &sv_p_secp[0], sv_p_secp.size() ); - BigInt bi_a_secp = BigInt::decode ( &sv_a_secp[0], sv_a_secp.size() ); - BigInt bi_b_secp = BigInt::decode ( &sv_b_secp[0], sv_b_secp.size() ); + BigInt bi_p_secp = BigInt::decode ( sv_p_secp.data(), sv_p_secp.size() ); + BigInt bi_a_secp = BigInt::decode ( sv_a_secp.data(), sv_a_secp.size() ); + BigInt bi_b_secp = BigInt::decode ( sv_b_secp.data(), sv_b_secp.size() ); CurveGFp secp160r1(bi_p_secp, bi_a_secp, bi_b_secp); PointGFp p_G = OS2ECP ( sv_G_secp_comp, secp160r1 ); @@ -405,9 +405,9 @@ size_t test_mult_point() std::vector<byte> sv_a_secp = hex_decode ( a_secp ); std::vector<byte> sv_b_secp = hex_decode ( b_secp ); std::vector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp ); - BigInt bi_p_secp = BigInt::decode ( &sv_p_secp[0], sv_p_secp.size() ); - BigInt bi_a_secp = BigInt::decode ( &sv_a_secp[0], sv_a_secp.size() ); - BigInt bi_b_secp = BigInt::decode ( &sv_b_secp[0], sv_b_secp.size() ); + BigInt bi_p_secp = BigInt::decode ( sv_p_secp.data(), sv_p_secp.size() ); + BigInt bi_a_secp = BigInt::decode ( sv_a_secp.data(), sv_a_secp.size() ); + BigInt bi_b_secp = BigInt::decode ( sv_b_secp.data(), sv_b_secp.size() ); CurveGFp secp160r1(bi_p_secp, bi_a_secp, bi_b_secp); PointGFp p_G = OS2ECP ( sv_G_secp_comp, secp160r1 ); @@ -435,9 +435,9 @@ size_t test_basic_operations() std::vector<byte> sv_a_secp = hex_decode ( a_secp ); std::vector<byte> sv_b_secp = hex_decode ( b_secp ); std::vector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp ); - BigInt bi_p_secp = BigInt::decode ( &sv_p_secp[0], sv_p_secp.size() ); - BigInt bi_a_secp = BigInt::decode ( &sv_a_secp[0], sv_a_secp.size() ); - BigInt bi_b_secp = BigInt::decode ( &sv_b_secp[0], sv_b_secp.size() ); + BigInt bi_p_secp = BigInt::decode ( sv_p_secp.data(), sv_p_secp.size() ); + BigInt bi_a_secp = BigInt::decode ( sv_a_secp.data(), sv_a_secp.size() ); + BigInt bi_b_secp = BigInt::decode ( sv_b_secp.data(), sv_b_secp.size() ); CurveGFp secp160r1(bi_p_secp, bi_a_secp, bi_b_secp); PointGFp p_G = OS2ECP ( sv_G_secp_comp, secp160r1 ); @@ -499,9 +499,9 @@ size_t test_enc_dec_compressed_160() std::vector<byte> sv_b_secp = hex_decode ( b_secp ); std::vector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp ); - BigInt bi_p_secp = BigInt::decode ( &sv_p_secp[0], sv_p_secp.size() ); - BigInt bi_a_secp = BigInt::decode ( &sv_a_secp[0], sv_a_secp.size() ); - BigInt bi_b_secp = BigInt::decode ( &sv_b_secp[0], sv_b_secp.size() ); + BigInt bi_p_secp = BigInt::decode ( sv_p_secp.data(), sv_p_secp.size() ); + BigInt bi_a_secp = BigInt::decode ( sv_a_secp.data(), sv_a_secp.size() ); + BigInt bi_b_secp = BigInt::decode ( sv_b_secp.data(), sv_b_secp.size() ); CurveGFp secp160r1(bi_p_secp, bi_a_secp, bi_b_secp); @@ -528,9 +528,9 @@ size_t test_enc_dec_compressed_256() std::vector<byte> sv_b_secp = hex_decode ( b_secp ); std::vector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp ); - BigInt bi_p_secp = BigInt::decode ( &sv_p_secp[0], sv_p_secp.size() ); - BigInt bi_a_secp = BigInt::decode ( &sv_a_secp[0], sv_a_secp.size() ); - BigInt bi_b_secp = BigInt::decode ( &sv_b_secp[0], sv_b_secp.size() ); + BigInt bi_p_secp = BigInt::decode ( sv_p_secp.data(), sv_p_secp.size() ); + BigInt bi_a_secp = BigInt::decode ( sv_a_secp.data(), sv_a_secp.size() ); + BigInt bi_b_secp = BigInt::decode ( sv_b_secp.data(), sv_b_secp.size() ); CurveGFp curve(bi_p_secp, bi_a_secp, bi_b_secp); @@ -559,9 +559,9 @@ size_t test_enc_dec_uncompressed_112() std::vector<byte> sv_b_secp = hex_decode ( b_secp ); std::vector<byte> sv_G_secp_uncomp = hex_decode ( G_secp_uncomp ); - BigInt bi_p_secp = BigInt::decode ( &sv_p_secp[0], sv_p_secp.size() ); - BigInt bi_a_secp = BigInt::decode ( &sv_a_secp[0], sv_a_secp.size() ); - BigInt bi_b_secp = BigInt::decode ( &sv_b_secp[0], sv_b_secp.size() ); + BigInt bi_p_secp = BigInt::decode ( sv_p_secp.data(), sv_p_secp.size() ); + BigInt bi_a_secp = BigInt::decode ( sv_a_secp.data(), sv_a_secp.size() ); + BigInt bi_b_secp = BigInt::decode ( sv_b_secp.data(), sv_b_secp.size() ); CurveGFp curve(bi_p_secp, bi_a_secp, bi_b_secp); @@ -588,17 +588,17 @@ size_t test_enc_dec_uncompressed_521() std::vector<byte> sv_b_secp = hex_decode ( b_secp ); std::vector<byte> sv_G_secp_uncomp = hex_decode ( G_secp_uncomp ); - BigInt bi_p_secp = BigInt::decode ( &sv_p_secp[0], sv_p_secp.size() ); - BigInt bi_a_secp = BigInt::decode ( &sv_a_secp[0], sv_a_secp.size() ); - BigInt bi_b_secp = BigInt::decode ( &sv_b_secp[0], sv_b_secp.size() ); + BigInt bi_p_secp = BigInt::decode ( sv_p_secp.data(), sv_p_secp.size() ); + BigInt bi_a_secp = BigInt::decode ( sv_a_secp.data(), sv_a_secp.size() ); + BigInt bi_b_secp = BigInt::decode ( sv_b_secp.data(), sv_b_secp.size() ); CurveGFp curve(bi_p_secp, bi_a_secp, bi_b_secp); PointGFp p_G = OS2ECP ( sv_G_secp_uncomp, curve ); std::vector<byte> sv_result = unlock(EC2OSP(p_G, PointGFp::UNCOMPRESSED)); - std::string result = hex_encode(&sv_result[0], sv_result.size()); - std::string exp_result = hex_encode(&sv_G_secp_uncomp[0], sv_G_secp_uncomp.size()); + std::string result = hex_encode(sv_result.data(), sv_result.size()); + std::string exp_result = hex_encode(sv_G_secp_uncomp.data(), sv_G_secp_uncomp.size()); CHECK_MESSAGE(sv_result == sv_G_secp_uncomp, "calc. result = " << result << "\nexp. result = " << exp_result); return fails; @@ -620,9 +620,9 @@ size_t test_enc_dec_uncompressed_521_prime_too_large() std::vector<byte> sv_b_secp = hex_decode ( b_secp ); std::vector<byte> sv_G_secp_uncomp = hex_decode ( G_secp_uncomp ); - BigInt bi_p_secp = BigInt::decode ( &sv_p_secp[0], sv_p_secp.size() ); - BigInt bi_a_secp = BigInt::decode ( &sv_a_secp[0], sv_a_secp.size() ); - BigInt bi_b_secp = BigInt::decode ( &sv_b_secp[0], sv_b_secp.size() ); + BigInt bi_p_secp = BigInt::decode ( sv_p_secp.data(), sv_p_secp.size() ); + BigInt bi_a_secp = BigInt::decode ( sv_a_secp.data(), sv_a_secp.size() ); + BigInt bi_b_secp = BigInt::decode ( sv_b_secp.data(), sv_b_secp.size() ); CurveGFp secp521r1 (bi_p_secp, bi_a_secp, bi_b_secp); std::unique_ptr<PointGFp> p_G; |