aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_mceliece.cpp
diff options
context:
space:
mode:
authorSimon Warta <[email protected]>2015-06-29 13:11:23 +0200
committerSimon Warta <[email protected]>2015-06-30 10:38:23 +0200
commit8668ce8753b10e944bdc72b6e66d752759c7e710 (patch)
tree787e9829c871748b34594d35f3a5e6569ccdbb31 /src/tests/test_mceliece.cpp
parentb90187419f64b6d38d19c888985d58f902336677 (diff)
tests: Convert &vec[0] to vec.data()
Diffstat (limited to 'src/tests/test_mceliece.cpp')
-rw-r--r--src/tests/test_mceliece.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/tests/test_mceliece.cpp b/src/tests/test_mceliece.cpp
index f55492e95..8f1d3b6a3 100644
--- a/src/tests/test_mceliece.cpp
+++ b/src/tests/test_mceliece.cpp
@@ -36,13 +36,13 @@ size_t test_mceliece_message_parts(RandomNumberGenerator& rng, size_t code_lengt
{
secure_vector<gf2m> err_pos1 = create_random_error_positions(code_length, error_weight, rng);
secure_vector<byte> message1((code_length+7)/8);
- rng.randomize(&message1[0], message1.size() - 1);
+ rng.randomize(message1.data(), message1.size() - 1);
mceliece_message_parts parts1(err_pos1, message1, code_length);
secure_vector<byte> err_vec1 = parts1.get_error_vector();
secure_vector<byte> concat1 = parts1.get_concat();
- mceliece_message_parts parts2( &concat1[0], concat1.size(), code_length);
+ mceliece_message_parts parts2( concat1.data(), concat1.size(), code_length);
secure_vector<byte> err_vec2 = parts2.get_error_vector();
if(err_vec1 != err_vec2)
@@ -76,7 +76,7 @@ size_t test_mceliece_kem(const McEliece_PrivateKey& sk,
const secure_vector<byte>& ciphertext = ciphertext__sym_key.first;
const secure_vector<byte>& sym_key_encr = ciphertext__sym_key.second;
- const secure_vector<byte> sym_key_decr = priv_op.decrypt(&ciphertext[0], ciphertext.size());
+ const secure_vector<byte> sym_key_decr = priv_op.decrypt(ciphertext.data(), ciphertext.size());
if(sym_key_encr != sym_key_decr)
{
@@ -95,7 +95,7 @@ size_t test_mceliece_kem(const McEliece_PrivateKey& sk,
wrong_ct[byte_pos] ^= 1 << bit_pos;
try
{
- secure_vector<byte> decrypted = priv_op.decrypt(&wrong_ct[0], wrong_ct.size());
+ secure_vector<byte> decrypted = priv_op.decrypt(wrong_ct.data(), wrong_ct.size());
}
catch(const Integrity_Failure)
{
@@ -123,22 +123,22 @@ size_t test_mceliece_raw(const McEliece_PrivateKey& sk,
for(size_t i = 0; i != MCE_RUNS; i++)
{
secure_vector<byte> plaintext((pk.get_message_word_bit_length()+7)/8);
- rng.randomize(&plaintext[0], plaintext.size() - 1);
+ rng.randomize(plaintext.data(), plaintext.size() - 1);
secure_vector<gf2m> err_pos = create_random_error_positions(code_length, pk.get_t(), rng);
mceliece_message_parts parts(err_pos, plaintext, code_length);
secure_vector<byte> message_and_error_input = parts.get_concat();
- secure_vector<byte> ciphertext = pub_op.encrypt(&message_and_error_input[0], message_and_error_input.size(), rng);
+ secure_vector<byte> ciphertext = pub_op.encrypt(message_and_error_input.data(), message_and_error_input.size(), rng);
//std::cout << "ciphertext byte length = " << ciphertext.size() << std::endl;
- secure_vector<byte> message_and_error_output = priv_op.decrypt(&ciphertext[0], ciphertext.size() );
+ secure_vector<byte> message_and_error_output = priv_op.decrypt(ciphertext.data(), ciphertext.size() );
if(message_and_error_input != message_and_error_output)
{
- mceliece_message_parts combined(&message_and_error_input[0], message_and_error_input.size(), code_length);
+ mceliece_message_parts combined(message_and_error_input.data(), message_and_error_input.size(), code_length);
secure_vector<byte> orig_pt = combined.get_message_word();
secure_vector<byte> orig_ev = combined.get_error_vector();
- mceliece_message_parts decr_combined(&message_and_error_output[0], message_and_error_output.size(), code_length);
+ mceliece_message_parts decr_combined(message_and_error_output.data(), message_and_error_output.size(), code_length);
secure_vector<byte> decr_pt = decr_combined.get_message_word();
secure_vector<byte> decr_ev = decr_combined.get_error_vector();
std::cout << "ciphertext = " << hex_encode(ciphertext) << std::endl;