aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/mce
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/pubkey/mce')
-rw-r--r--src/lib/pubkey/mce/code_based_key_gen.cpp2
-rw-r--r--src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp2
-rw-r--r--src/lib/pubkey/mce/goppa_code.cpp6
-rw-r--r--src/lib/pubkey/mce/mce_kem.cpp6
-rw-r--r--src/lib/pubkey/mce/mce_kem.h2
-rw-r--r--src/lib/pubkey/mce/mceliece.cpp12
-rw-r--r--src/lib/pubkey/mce/mceliece.h18
-rw-r--r--src/lib/pubkey/mce/mceliece_key.cpp6
8 files changed, 27 insertions, 27 deletions
diff --git a/src/lib/pubkey/mce/code_based_key_gen.cpp b/src/lib/pubkey/mce/code_based_key_gen.cpp
index 150f9b2ee..7adf85112 100644
--- a/src/lib/pubkey/mce/code_based_key_gen.cpp
+++ b/src/lib/pubkey/mce/code_based_key_gen.cpp
@@ -149,7 +149,7 @@ McEliece_PrivateKey generate_mceliece_key( RandomNumberGenerator & rng, u32bit e
//
//
std::vector<u32bit> H(bit_size_to_32bit_size(codimension) * code_length );
- u32bit* sk = &H[0];
+ u32bit* sk = H.data();
for (i = 0; i < code_length; ++i)
{
for (l = 0; l < t; ++l)
diff --git a/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp b/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp
index 85da0ec1d..2d4f06130 100644
--- a/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp
+++ b/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp
@@ -312,7 +312,7 @@ secure_vector<gf2m> gf2m_decomp_rootfind_state::find_roots(const polyn_gf2m & si
}while(1);
// side channel / fault attack countermeasure:
- root_pos = patch_root_array(&result[0], result.size(), root_pos);
+ root_pos = patch_root_array(result.data(), result.size(), root_pos);
result.resize(root_pos);
return result;
}
diff --git a/src/lib/pubkey/mce/goppa_code.cpp b/src/lib/pubkey/mce/goppa_code.cpp
index 6f4b40226..175508eac 100644
--- a/src/lib/pubkey/mce/goppa_code.cpp
+++ b/src/lib/pubkey/mce/goppa_code.cpp
@@ -161,14 +161,14 @@ secure_vector<byte> mceliece_decrypt(
key.get_code_length(),
bit_size_to_32bit_size(codimension),
ciphertext,
- &syndrome_vec[0], syndrome_vec.size() );
+ syndrome_vec.data(), syndrome_vec.size() );
secure_vector<byte> syndrome_byte_vec(bit_size_to_byte_size(codimension));
u32bit syndrome_byte_vec_size = syndrome_byte_vec.size();
for(u32bit i = 0; i < syndrome_byte_vec_size; i++)
{
syndrome_byte_vec[i] = syndrome_vec[i/4] >> (8* (i % 4));
}
- syndrome_polyn = polyn_gf2m( t-1, &syndrome_byte_vec[0],bit_size_to_byte_size(codimension), key.get_goppa_polyn().get_sp_field());
+ syndrome_polyn = polyn_gf2m(t-1, syndrome_byte_vec.data(), bit_size_to_byte_size(codimension), key.get_goppa_polyn().get_sp_field());
@@ -179,7 +179,7 @@ secure_vector<byte> mceliece_decrypt(
secure_vector<byte> cleartext(cleartext_len);
- copy_mem(&cleartext[0], ciphertext, cleartext_len);
+ copy_mem(cleartext.data(), ciphertext, cleartext_len);
for(u32bit i = 0; i < nb_err; i++)
{
diff --git a/src/lib/pubkey/mce/mce_kem.cpp b/src/lib/pubkey/mce/mce_kem.cpp
index dd4af4acc..b24c42f85 100644
--- a/src/lib/pubkey/mce/mce_kem.cpp
+++ b/src/lib/pubkey/mce/mce_kem.cpp
@@ -21,7 +21,7 @@ McEliece_KEM_Encryptor::encrypt(RandomNumberGenerator& rng)
{
const McEliece_PublicKey& key = m_raw_pub_op.get_key();
secure_vector<Botan::byte> plaintext((key.get_message_word_bit_length()+7)/8);
- rng.randomize(&plaintext[0], plaintext.size() );
+ rng.randomize(plaintext.data(), plaintext.size());
// unset unused bits in the last plaintext byte
u32bit used = key.get_message_word_bit_length() % 8;
@@ -39,7 +39,7 @@ McEliece_KEM_Encryptor::encrypt(RandomNumberGenerator& rng)
SHA_512 hash;
hash.update(message_and_error_input);
secure_vector<byte> sym_key = hash.final();
- secure_vector<byte> ciphertext = m_raw_pub_op.encrypt(&message_and_error_input[0],
+ secure_vector<byte> ciphertext = m_raw_pub_op.encrypt(message_and_error_input.data(),
message_and_error_input.size(), rng);
return std::make_pair(ciphertext, sym_key);
@@ -53,7 +53,7 @@ McEliece_KEM_Decryptor::McEliece_KEM_Decryptor(const McEliece_PrivateKey& mce_ke
secure_vector<Botan::byte> McEliece_KEM_Decryptor::decrypt(const byte msg[], size_t msg_len)
{
- secure_vector<Botan::byte> message_and_error = m_raw_priv_op.decrypt(&msg[0], msg_len );
+ secure_vector<Botan::byte> message_and_error = m_raw_priv_op.decrypt(msg, msg_len);
SHA_512 hash;
hash.update(message_and_error);
diff --git a/src/lib/pubkey/mce/mce_kem.h b/src/lib/pubkey/mce/mce_kem.h
index cbb2fc553..7a8d2f7ff 100644
--- a/src/lib/pubkey/mce/mce_kem.h
+++ b/src/lib/pubkey/mce/mce_kem.h
@@ -44,7 +44,7 @@ class BOTAN_DLL McEliece_KEM_Decryptor
template<typename Alloc>
secure_vector<Botan::byte> decrypt_vec(const std::vector<byte, Alloc>& v)
{
- return decrypt(&v[0], v.size());
+ return decrypt(v.data(), v.size());
}
private:
diff --git a/src/lib/pubkey/mce/mceliece.cpp b/src/lib/pubkey/mce/mceliece.cpp
index ed4d24467..6bbe93ce3 100644
--- a/src/lib/pubkey/mce/mceliece.cpp
+++ b/src/lib/pubkey/mce/mceliece.cpp
@@ -60,7 +60,7 @@ std::vector<byte> mult_by_pubkey(const byte *cleartext,
u32bit dimension = code_length - codimension;
std::vector<byte> cR(bit_size_to_32bit_size(codimension)* sizeof(u32bit));
- const byte* pt = &public_matrix[0];
+ const byte* pt = public_matrix.data();
for(i = 0; i < dimension / 8; ++i)
{
@@ -68,7 +68,7 @@ std::vector<byte> mult_by_pubkey(const byte *cleartext,
{
if(cleartext[i] & (1 << j))
{
- xor_buf(&cR[0], pt, cR.size());
+ xor_buf(cR.data(), pt, cR.size());
}
pt += bit_size_to_32bit_size(codimension) * sizeof(u32bit);
}
@@ -78,12 +78,12 @@ std::vector<byte> mult_by_pubkey(const byte *cleartext,
{
if(cleartext[i] & (1 << j))
{
- xor_buf(&cR[0], pt, bit_size_to_byte_size(codimension));
+ xor_buf(cR.data(), pt, bit_size_to_byte_size(codimension));
}
pt += bit_size_to_32bit_size(codimension) * sizeof(u32bit);
}
- concat_vectors( &ciphertext[0], cleartext, &cR[0], dimension, codimension);
+ concat_vectors(ciphertext.data(), cleartext, cR.data(), dimension, codimension);
return ciphertext;
}
@@ -150,7 +150,7 @@ secure_vector<byte> McEliece_Public_Operation::encrypt(const byte msg[], size_t
std::vector<byte> ciphertext_tmp = mceliece_encrypt( message_word, m_pub_key.get_public_matrix(), err_pos, m_code_length);
- copy_mem(&ciphertext[0], &ciphertext_tmp[0], ciphertext.size());
+ copy_mem(ciphertext.data(), ciphertext_tmp.data(), ciphertext.size());
return ciphertext;
}
@@ -159,7 +159,7 @@ std::vector<byte> mceliece_encrypt(const secure_vector<byte> & cleartext,
const secure_vector<gf2m> & err_pos,
u32bit code_length)
{
- std::vector<byte> ciphertext = mult_by_pubkey(&cleartext[0], public_matrix, code_length, err_pos.size());
+ std::vector<byte> ciphertext = mult_by_pubkey(cleartext.data(), public_matrix, code_length, err_pos.size());
// flip t error positions
for(size_t i = 0; i < err_pos.size(); ++i)
diff --git a/src/lib/pubkey/mce/mceliece.h b/src/lib/pubkey/mce/mceliece.h
index 19de27d8e..b62afee3a 100644
--- a/src/lib/pubkey/mce/mceliece.h
+++ b/src/lib/pubkey/mce/mceliece.h
@@ -30,15 +30,15 @@ class mceliece_message_parts
public:
mceliece_message_parts(const secure_vector<gf2m>& err_pos, const byte* message, u32bit message_length, u32bit code_length) :
- m_error_vector(error_vector_from_error_positions(&err_pos[0], err_pos.size(), code_length)),
+ m_error_vector(error_vector_from_error_positions(err_pos.data(), err_pos.size(), code_length)),
m_code_length(code_length)
{
m_message_word.resize(message_length);
- copy_mem(&m_message_word[0], message, message_length);
+ copy_mem(m_message_word.data(), message, message_length);
}
mceliece_message_parts(const secure_vector<gf2m>& err_pos, const secure_vector<byte>& message, unsigned code_length) :
- m_error_vector(error_vector_from_error_positions(&err_pos[0], err_pos.size(), code_length)),
+ m_error_vector(error_vector_from_error_positions(err_pos.data(), err_pos.size(), code_length)),
m_message_word(message),
m_code_length(code_length)
{}
@@ -68,17 +68,17 @@ class mceliece_message_parts
throw Invalid_Argument("cannot split McEliece message parts");
}
size_t err_vec_start_pos = message_concat_errors_len - err_vec_len;
- m_message_word = secure_vector<byte>(err_vec_start_pos );
- copy_mem(&m_message_word[0], &message_concat_errors[0], err_vec_start_pos);
- m_error_vector = secure_vector<byte>(err_vec_len );
- copy_mem(&m_error_vector[0], &message_concat_errors[err_vec_start_pos], err_vec_len);
+ m_message_word = secure_vector<byte>(err_vec_start_pos);
+ copy_mem(m_message_word.data(), message_concat_errors, err_vec_start_pos);
+ m_error_vector = secure_vector<byte>(err_vec_len);
+ copy_mem(m_error_vector.data(), &message_concat_errors[err_vec_start_pos], err_vec_len);
}
secure_vector<byte> get_concat() const
{
secure_vector<byte> result(m_error_vector.size() + m_message_word.size());
- copy_mem(&result[0], &m_message_word[0], m_message_word.size());
- copy_mem(&result[m_message_word.size()], &m_error_vector[0], m_error_vector.size());
+ copy_mem(result.data(), m_message_word.data(), m_message_word.size());
+ copy_mem(&result[m_message_word.size()], m_error_vector.data(), m_error_vector.size());
return result;
}
diff --git a/src/lib/pubkey/mce/mceliece_key.cpp b/src/lib/pubkey/mce/mceliece_key.cpp
index e0f8b4cd6..41392f695 100644
--- a/src/lib/pubkey/mce/mceliece_key.cpp
+++ b/src/lib/pubkey/mce/mceliece_key.cpp
@@ -139,13 +139,13 @@ bool McEliece_PrivateKey::check_key(RandomNumberGenerator& rng, bool) const
McEliece_Public_Operation pub_op(*this, get_code_length());
secure_vector<byte> plaintext((this->get_message_word_bit_length()+7)/8);
- rng.randomize(&plaintext[0], plaintext.size() - 1);
+ rng.randomize(plaintext.data(), plaintext.size() - 1);
const secure_vector<gf2m> err_pos = create_random_error_positions(this->get_code_length(), this->get_t(), rng);
mceliece_message_parts parts(err_pos, plaintext, this->get_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> message_and_error_output = priv_op.decrypt(&ciphertext[0], ciphertext.size());
+ secure_vector<byte> ciphertext = pub_op.encrypt(message_and_error_input.data(), message_and_error_input.size(), rng);
+ secure_vector<byte> message_and_error_output = priv_op.decrypt(ciphertext.data(), ciphertext.size());
return (message_and_error_input == message_and_error_output);
}