aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/misc/aont/package.cpp16
-rw-r--r--src/lib/misc/benchmark/benchmark.cpp2
-rw-r--r--src/lib/misc/cryptobox/cryptobox.cpp12
-rw-r--r--src/lib/misc/fpe_fe1/fpe_fe1.cpp8
-rw-r--r--src/lib/misc/pbes2/pbes2.cpp4
-rw-r--r--src/lib/misc/pem/pem.cpp2
-rw-r--r--src/lib/misc/pem/pem.h4
-rw-r--r--src/lib/misc/rfc3394/rfc3394.cpp16
-rw-r--r--src/lib/misc/tss/tss.cpp10
9 files changed, 37 insertions, 37 deletions
diff --git a/src/lib/misc/aont/package.cpp b/src/lib/misc/aont/package.cpp
index 731cae408..125b3842e 100644
--- a/src/lib/misc/aont/package.cpp
+++ b/src/lib/misc/aont/package.cpp
@@ -52,18 +52,18 @@ void aont_package(RandomNumberGenerator& rng,
input_len - BLOCK_SIZE * i);
zeroise(buf);
- copy_mem(&buf[0], output + (BLOCK_SIZE * i), left);
+ copy_mem(buf.data(), output + (BLOCK_SIZE * i), left);
for(size_t j = 0; j != sizeof(i); ++j)
buf[BLOCK_SIZE - 1 - j] ^= get_byte(sizeof(i)-1-j, i);
- cipher->encrypt(&buf[0]);
+ cipher->encrypt(buf.data());
- xor_buf(&final_block[0], &buf[0], BLOCK_SIZE);
+ xor_buf(final_block, buf.data(), BLOCK_SIZE);
}
// XOR the random package key into the final block
- xor_buf(&final_block[0], package_key.begin(), BLOCK_SIZE);
+ xor_buf(final_block, package_key.begin(), BLOCK_SIZE);
}
void aont_unpackage(BlockCipher* cipher,
@@ -87,7 +87,7 @@ void aont_unpackage(BlockCipher* cipher,
secure_vector<byte> buf(BLOCK_SIZE);
// Copy the package key (masked with the block hashes)
- copy_mem(&package_key[0],
+ copy_mem(package_key.data(),
input + (input_len - BLOCK_SIZE),
BLOCK_SIZE);
@@ -100,14 +100,14 @@ void aont_unpackage(BlockCipher* cipher,
input_len - BLOCK_SIZE * (i+1));
zeroise(buf);
- copy_mem(&buf[0], input + (BLOCK_SIZE * i), left);
+ copy_mem(buf.data(), input + (BLOCK_SIZE * i), left);
for(size_t j = 0; j != sizeof(i); ++j)
buf[BLOCK_SIZE - 1 - j] ^= get_byte(sizeof(i)-1-j, i);
- cipher->encrypt(&buf[0]);
+ cipher->encrypt(buf.data());
- xor_buf(&package_key[0], &buf[0], BLOCK_SIZE);
+ xor_buf(package_key.data(), buf.data(), BLOCK_SIZE);
}
Pipe pipe(new StreamCipher_Filter(new CTR_BE(cipher), package_key));
diff --git a/src/lib/misc/benchmark/benchmark.cpp b/src/lib/misc/benchmark/benchmark.cpp
index c30b20698..90d8b1aca 100644
--- a/src/lib/misc/benchmark/benchmark.cpp
+++ b/src/lib/misc/benchmark/benchmark.cpp
@@ -51,7 +51,7 @@ time_algorithm_ops(const std::string& name,
const size_t Mebibyte = 1024*1024;
secure_vector<byte> buffer(buf_size * 1024);
- rng.randomize(&buffer[0], buffer.size());
+ rng.randomize(buffer.data(), buffer.size());
const double mb_mult = buffer.size() / static_cast<double>(Mebibyte);
diff --git a/src/lib/misc/cryptobox/cryptobox.cpp b/src/lib/misc/cryptobox/cryptobox.cpp
index fb210bc0b..d7e7bb72b 100644
--- a/src/lib/misc/cryptobox/cryptobox.cpp
+++ b/src/lib/misc/cryptobox/cryptobox.cpp
@@ -45,20 +45,20 @@ std::string encrypt(const byte input[], size_t input_len,
RandomNumberGenerator& rng)
{
secure_vector<byte> pbkdf_salt(PBKDF_SALT_LEN);
- rng.randomize(&pbkdf_salt[0], pbkdf_salt.size());
+ rng.randomize(pbkdf_salt.data(), pbkdf_salt.size());
PKCS5_PBKDF2 pbkdf(new HMAC(new SHA_512));
OctetString master_key = pbkdf.derive_key(
PBKDF_OUTPUT_LEN,
passphrase,
- &pbkdf_salt[0],
+ pbkdf_salt.data(),
pbkdf_salt.size(),
PBKDF_ITERATIONS);
const byte* mk = master_key.begin();
- SymmetricKey cipher_key(&mk[0], CIPHER_KEY_LEN);
+ SymmetricKey cipher_key(mk, CIPHER_KEY_LEN);
SymmetricKey mac_key(&mk[CIPHER_KEY_LEN], MAC_KEY_LEN);
InitializationVector iv(&mk[CIPHER_KEY_LEN + MAC_KEY_LEN], CIPHER_IV_LEN);
@@ -87,7 +87,7 @@ std::string encrypt(const byte input[], size_t input_len,
for(size_t i = 0; i != VERSION_CODE_LEN; ++i)
out_buf[i] = get_byte(i, CRYPTOBOX_VERSION_CODE);
- copy_mem(&out_buf[VERSION_CODE_LEN], &pbkdf_salt[0], PBKDF_SALT_LEN);
+ copy_mem(&out_buf[VERSION_CODE_LEN], pbkdf_salt.data(), PBKDF_SALT_LEN);
pipe.read(&out_buf[VERSION_CODE_LEN + PBKDF_SALT_LEN], MAC_OUTPUT_LEN, 1);
pipe.read(&out_buf[VERSION_CODE_LEN + PBKDF_SALT_LEN + MAC_OUTPUT_LEN],
@@ -124,7 +124,7 @@ std::string decrypt(const byte input[], size_t input_len,
const byte* mk = master_key.begin();
- SymmetricKey cipher_key(&mk[0], CIPHER_KEY_LEN);
+ SymmetricKey cipher_key(mk, CIPHER_KEY_LEN);
SymmetricKey mac_key(&mk[CIPHER_KEY_LEN], MAC_KEY_LEN);
InitializationVector iv(&mk[CIPHER_KEY_LEN + MAC_KEY_LEN], CIPHER_IV_LEN);
@@ -153,7 +153,7 @@ std::string decrypt(const byte input[], size_t input_len,
std::string decrypt(const std::string& input,
const std::string& passphrase)
{
- return decrypt(reinterpret_cast<const byte*>(&input[0]),
+ return decrypt(reinterpret_cast<const byte*>(input.data()),
input.size(),
passphrase);
}
diff --git a/src/lib/misc/fpe_fe1/fpe_fe1.cpp b/src/lib/misc/fpe_fe1/fpe_fe1.cpp
index c0a29519a..f2502014b 100644
--- a/src/lib/misc/fpe_fe1/fpe_fe1.cpp
+++ b/src/lib/misc/fpe_fe1/fpe_fe1.cpp
@@ -103,10 +103,10 @@ FPE_Encryptor::FPE_Encryptor(const SymmetricKey& key,
throw std::runtime_error("N is too large for FPE encryption");
mac->update_be(static_cast<u32bit>(n_bin.size()));
- mac->update(&n_bin[0], n_bin.size());
+ mac->update(n_bin.data(), n_bin.size());
mac->update_be(static_cast<u32bit>(tweak.size()));
- mac->update(&tweak[0], tweak.size());
+ mac->update(tweak.data(), tweak.size());
mac_n_t = unlock(mac->final());
}
@@ -119,10 +119,10 @@ BigInt FPE_Encryptor::operator()(size_t round_no, const BigInt& R)
mac->update_be(static_cast<u32bit>(round_no));
mac->update_be(static_cast<u32bit>(r_bin.size()));
- mac->update(&r_bin[0], r_bin.size());
+ mac->update(r_bin.data(), r_bin.size());
secure_vector<byte> X = mac->final();
- return BigInt(&X[0], X.size());
+ return BigInt(X.data(), X.size());
}
}
diff --git a/src/lib/misc/pbes2/pbes2.cpp b/src/lib/misc/pbes2/pbes2.cpp
index 435caaab1..89af01e9d 100644
--- a/src/lib/misc/pbes2/pbes2.cpp
+++ b/src/lib/misc/pbes2/pbes2.cpp
@@ -89,7 +89,7 @@ pbes2_encrypt(const secure_vector<byte>& key_bits,
secure_vector<byte> iv = rng.random_vec(enc->default_nonce_length());
- enc->set_key(pbkdf->derive_key(key_length, passphrase, &salt[0], salt.size(),
+ enc->set_key(pbkdf->derive_key(key_length, passphrase, salt.data(), salt.size(),
msec, iterations).bits_of());
enc->start(iv);
@@ -159,7 +159,7 @@ pbes2_decrypt(const secure_vector<byte>& key_bits,
if(key_length == 0)
key_length = dec->key_spec().maximum_keylength();
- dec->set_key(pbkdf->pbkdf_iterations(key_length, passphrase, &salt[0], salt.size(), iterations));
+ dec->set_key(pbkdf->pbkdf_iterations(key_length, passphrase, salt.data(), salt.size(), iterations));
dec->start(iv);
diff --git a/src/lib/misc/pem/pem.cpp b/src/lib/misc/pem/pem.cpp
index 9b57c1531..f33016c70 100644
--- a/src/lib/misc/pem/pem.cpp
+++ b/src/lib/misc/pem/pem.cpp
@@ -123,7 +123,7 @@ bool matches(DataSource& source, const std::string& extra,
const std::string PEM_HEADER = "-----BEGIN " + extra;
secure_vector<byte> search_buf(search_range);
- size_t got = source.peek(&search_buf[0], search_buf.size(), 0);
+ size_t got = source.peek(search_buf.data(), search_buf.size(), 0);
if(got < PEM_HEADER.length())
return false;
diff --git a/src/lib/misc/pem/pem.h b/src/lib/misc/pem/pem.h
index 3b3fec32e..aaae5ee35 100644
--- a/src/lib/misc/pem/pem.h
+++ b/src/lib/misc/pem/pem.h
@@ -29,7 +29,7 @@ inline std::string encode(const std::vector<byte>& data,
const std::string& label,
size_t line_width = 64)
{
- return encode(&data[0], data.size(), label, line_width);
+ return encode(data.data(), data.size(), label, line_width);
}
/**
@@ -39,7 +39,7 @@ inline std::string encode(const secure_vector<byte>& data,
const std::string& label,
size_t line_width = 64)
{
- return encode(&data[0], data.size(), label, line_width);
+ return encode(data.data(), data.size(), label, line_width);
}
/**
diff --git a/src/lib/misc/rfc3394/rfc3394.cpp b/src/lib/misc/rfc3394/rfc3394.cpp
index 11791418b..a199cc599 100644
--- a/src/lib/misc/rfc3394/rfc3394.cpp
+++ b/src/lib/misc/rfc3394/rfc3394.cpp
@@ -34,7 +34,7 @@ secure_vector<byte> rfc3394_keywrap(const secure_vector<byte>& key,
for(size_t i = 0; i != 8; ++i)
A[i] = 0xA6;
- copy_mem(&R[8], &key[0], key.size());
+ copy_mem(&R[8], key.data(), key.size());
for(size_t j = 0; j <= 5; ++j)
{
@@ -44,16 +44,16 @@ secure_vector<byte> rfc3394_keywrap(const secure_vector<byte>& key,
copy_mem(&A[8], &R[8*i], 8);
- aes->encrypt(&A[0]);
+ aes->encrypt(A.data());
copy_mem(&R[8*i], &A[8], 8);
byte t_buf[4] = { 0 };
store_be(t, t_buf);
- xor_buf(&A[4], &t_buf[0], 4);
+ xor_buf(&A[4], t_buf, 4);
}
}
- copy_mem(&R[0], &A[0], 8);
+ copy_mem(R.data(), A.data(), 8);
return R;
}
@@ -78,7 +78,7 @@ secure_vector<byte> rfc3394_keyunwrap(const secure_vector<byte>& key,
for(size_t i = 0; i != 8; ++i)
A[i] = key[i];
- copy_mem(&R[0], &key[8], key.size() - 8);
+ copy_mem(R.data(), &key[8], key.size() - 8);
for(size_t j = 0; j <= 5; ++j)
{
@@ -89,17 +89,17 @@ secure_vector<byte> rfc3394_keyunwrap(const secure_vector<byte>& key,
byte t_buf[4] = { 0 };
store_be(t, t_buf);
- xor_buf(&A[4], &t_buf[0], 4);
+ xor_buf(&A[4], t_buf, 4);
copy_mem(&A[8], &R[8*(i-1)], 8);
- aes->decrypt(&A[0]);
+ aes->decrypt(A.data());
copy_mem(&R[8*(i-1)], &A[8], 8);
}
}
- if(load_be<u64bit>(&A[0], 0) != 0xA6A6A6A6A6A6A6A6)
+ if(load_be<u64bit>(A.data(), 0) != 0xA6A6A6A6A6A6A6A6)
throw Integrity_Failure("NIST key unwrap failed");
return R;
diff --git a/src/lib/misc/tss/tss.cpp b/src/lib/misc/tss/tss.cpp
index c021bff7b..6904f9f0a 100644
--- a/src/lib/misc/tss/tss.cpp
+++ b/src/lib/misc/tss/tss.cpp
@@ -118,7 +118,7 @@ byte RTSS_Share::share_id() const
std::string RTSS_Share::to_string() const
{
- return hex_encode(&contents[0], contents.size());
+ return hex_encode(contents.data(), contents.size());
}
std::vector<RTSS_Share>
@@ -155,7 +155,7 @@ RTSS_Share::split(byte M, byte N,
for(size_t i = 0; i != secret.size(); ++i)
{
std::vector<byte> coefficients(M-1);
- rng.randomize(&coefficients[0], coefficients.size());
+ rng.randomize(coefficients.data(), coefficients.size());
for(byte j = 0; j != N; ++j)
{
@@ -248,14 +248,14 @@ RTSS_Share::reconstruct(const std::vector<RTSS_Share>& shares)
if(secret.size() != secret_len + hash->output_length())
throw Decoding_Error("Bad length in RTSS output");
- hash->update(&secret[0], secret_len);
+ hash->update(secret.data(), secret_len);
secure_vector<byte> hash_check = hash->final();
- if(!same_mem(&hash_check[0],
+ if(!same_mem(hash_check.data(),
&secret[secret_len], hash->output_length()))
throw Decoding_Error("RTSS hash check failed");
- return secure_vector<byte>(&secret[0], &secret[secret_len]);
+ return secure_vector<byte>(secret.cbegin(), secret.cbegin() + secret_len);
}
}