summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorBrett Wilson <brettw@chromium.org>2015-07-07 16:38:09 -0700
committerBrett Wilson <brettw@chromium.org>2015-07-07 23:39:16 +0000
commite3c4d1a1228e00b190ad743a83f88a2266f45238 (patch)
tree3923b42b43c9b7a8a689d0468688b30bf9ea8f83 /crypto
parent1c33a26e56880fbf058fd796aa004e097e07b691 (diff)
downloadchromium_src-e3c4d1a1228e00b190ad743a83f88a2266f45238.zip
chromium_src-e3c4d1a1228e00b190ad743a83f88a2266f45238.tar.gz
chromium_src-e3c4d1a1228e00b190ad743a83f88a2266f45238.tar.bz2
Move WriteInto to base namespace.
Update all callers. De-inlines the template. For some reason touching the namespaces started givin errors about DCHECK not being defined. Indeed, this header does not include logging.h. Rather than include logging in this very common header, it seems preferable to move the implementation to the .cc file. This removes support for the wstring variant and updates the callers that used it. R=ben@chromium.org, ben TBR=jschuh (sandbox_win.cc) NOPRESUBMIT=true (this patch touches code using legacy wstrings) Review URL: https://codereview.chromium.org/1223983002. Cr-Commit-Position: refs/heads/master@{#337703}
Diffstat (limited to 'crypto')
-rw-r--r--crypto/aead_openssl.cc4
-rw-r--r--crypto/aes_128_gcm_helpers_nss_unittest.cc6
-rw-r--r--crypto/encryptor_openssl.cc7
-rw-r--r--crypto/random_unittest.cc2
-rw-r--r--crypto/symmetric_key_openssl.cc8
5 files changed, 14 insertions, 13 deletions
diff --git a/crypto/aead_openssl.cc b/crypto/aead_openssl.cc
index e32168a..54795b8 100644
--- a/crypto/aead_openssl.cc
+++ b/crypto/aead_openssl.cc
@@ -53,7 +53,7 @@ bool Aead::Seal(const base::StringPiece& plaintext,
EVP_AEAD_max_overhead(aead_) + plaintext.size();
size_t output_length;
uint8* out_ptr =
- reinterpret_cast<uint8*>(WriteInto(&result, max_output_length + 1));
+ reinterpret_cast<uint8*>(base::WriteInto(&result, max_output_length + 1));
if (!EVP_AEAD_CTX_seal(
&ctx, out_ptr, &output_length, max_output_length,
@@ -91,7 +91,7 @@ bool Aead::Open(const base::StringPiece& ciphertext,
const size_t max_output_length = ciphertext.size();
size_t output_length;
uint8* out_ptr =
- reinterpret_cast<uint8*>(WriteInto(&result, max_output_length + 1));
+ reinterpret_cast<uint8*>(base::WriteInto(&result, max_output_length + 1));
if (!EVP_AEAD_CTX_open(
&ctx, out_ptr, &output_length, max_output_length,
diff --git a/crypto/aes_128_gcm_helpers_nss_unittest.cc b/crypto/aes_128_gcm_helpers_nss_unittest.cc
index 938e909..d741b2f 100644
--- a/crypto/aes_128_gcm_helpers_nss_unittest.cc
+++ b/crypto/aes_128_gcm_helpers_nss_unittest.cc
@@ -425,7 +425,7 @@ class Aes128GcmHelpersTest : public ::testing::Test {
unsigned char* raw_input = const_cast<unsigned char*>(
reinterpret_cast<const unsigned char*>(input.data()));
unsigned char* raw_output = reinterpret_cast<unsigned char*>(
- WriteInto(output, maximum_output_length + 1 /* null */));
+ base::WriteInto(output, maximum_output_length + 1 /* null */));
PK11Helper_TransformFunction* transform_function =
mode == DECRYPT ? PK11DecryptHelper : PK11EncryptHelper;
@@ -468,8 +468,8 @@ TEST_F(Aes128GcmHelpersTest, RoundTrip) {
const size_t kNonceSize = 16;
std::string key, nonce;
- RandBytes(WriteInto(&key, kKeySize + 1), kKeySize);
- RandBytes(WriteInto(&nonce, kNonceSize + 1), kNonceSize);
+ RandBytes(base::WriteInto(&key, kKeySize + 1), kKeySize);
+ RandBytes(base::WriteInto(&nonce, kNonceSize + 1), kNonceSize);
// AEAD_AES_128_GCM is defined with a default authentication tag size of 16,
// but RFC 5282 extends this to authentication tag sizes of 8 and 12 as well.
diff --git a/crypto/encryptor_openssl.cc b/crypto/encryptor_openssl.cc
index 0504adb..4f0e511 100644
--- a/crypto/encryptor_openssl.cc
+++ b/crypto/encryptor_openssl.cc
@@ -113,8 +113,8 @@ bool Encryptor::Crypt(bool do_encrypt,
const size_t output_size = input.size() + (do_encrypt ? iv_.size() : 0);
CHECK_GT(output_size, 0u);
CHECK_GT(output_size + 1, input.size());
- uint8* out_ptr = reinterpret_cast<uint8*>(WriteInto(&result,
- output_size + 1));
+ uint8* out_ptr =
+ reinterpret_cast<uint8*>(base::WriteInto(&result, output_size + 1));
int out_len;
if (!EVP_CipherUpdate(ctx.get(), out_ptr, &out_len,
reinterpret_cast<const uint8*>(input.data()),
@@ -154,7 +154,8 @@ bool Encryptor::CryptCTR(bool do_encrypt,
CHECK_GT(out_size + 1, input.size());
std::string result;
- uint8* out_ptr = reinterpret_cast<uint8*>(WriteInto(&result, out_size + 1));
+ uint8* out_ptr =
+ reinterpret_cast<uint8*>(base::WriteInto(&result, out_size + 1));
uint8_t ivec[AES_BLOCK_SIZE] = { 0 };
uint8_t ecount_buf[AES_BLOCK_SIZE] = { 0 };
diff --git a/crypto/random_unittest.cc b/crypto/random_unittest.cc
index 846d9b6..00d4b2b 100644
--- a/crypto/random_unittest.cc
+++ b/crypto/random_unittest.cc
@@ -22,6 +22,6 @@ bool IsTrivial(const std::string& bytes) {
TEST(RandBytes, RandBytes) {
std::string bytes(16, '\0');
- crypto::RandBytes(WriteInto(&bytes, bytes.size()), bytes.size());
+ crypto::RandBytes(base::WriteInto(&bytes, bytes.size()), bytes.size());
EXPECT_TRUE(!IsTrivial(bytes));
}
diff --git a/crypto/symmetric_key_openssl.cc b/crypto/symmetric_key_openssl.cc
index e268a1d0..912c9b4 100644
--- a/crypto/symmetric_key_openssl.cc
+++ b/crypto/symmetric_key_openssl.cc
@@ -39,8 +39,8 @@ SymmetricKey* SymmetricKey::GenerateRandomKey(Algorithm algorithm,
OpenSSLErrStackTracer err_tracer(FROM_HERE);
scoped_ptr<SymmetricKey> key(new SymmetricKey);
- uint8* key_data =
- reinterpret_cast<uint8*>(WriteInto(&key->key_, key_size_in_bytes + 1));
+ uint8* key_data = reinterpret_cast<uint8*>(
+ base::WriteInto(&key->key_, key_size_in_bytes + 1));
int rv = RAND_bytes(key_data, static_cast<int>(key_size_in_bytes));
return rv == 1 ? key.release() : NULL;
@@ -70,8 +70,8 @@ SymmetricKey* SymmetricKey::DeriveKeyFromPassword(Algorithm algorithm,
OpenSSLErrStackTracer err_tracer(FROM_HERE);
scoped_ptr<SymmetricKey> key(new SymmetricKey);
- uint8* key_data =
- reinterpret_cast<uint8*>(WriteInto(&key->key_, key_size_in_bytes + 1));
+ uint8* key_data = reinterpret_cast<uint8*>(
+ base::WriteInto(&key->key_, key_size_in_bytes + 1));
int rv = PKCS5_PBKDF2_HMAC_SHA1(password.data(), password.length(),
reinterpret_cast<const uint8*>(salt.data()),
salt.length(), iterations,