diff options
author | Simon Warta <[email protected]> | 2015-06-24 20:18:56 +0200 |
---|---|---|
committer | Simon Warta <[email protected]> | 2015-06-25 01:50:52 +0200 |
commit | 1033054c1495d4a10afc33f2747d24d9c32b6907 (patch) | |
tree | 776c291a37b5d86d82739591d62e3602ee294f38 /src/lib/misc/cryptobox/cryptobox.cpp | |
parent | f3e2ba1c8273e439f4d18dabc253d6aad47ac622 (diff) |
lib/misc: Convert &vec[0] to vec.data()
Diffstat (limited to 'src/lib/misc/cryptobox/cryptobox.cpp')
-rw-r--r-- | src/lib/misc/cryptobox/cryptobox.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
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); } |