summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorricea@chromium.org <ricea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-10 11:55:10 +0000
committerricea@chromium.org <ricea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-10 11:55:10 +0000
commit0553072d237ad2b977e948591de3f87eee536a9c (patch)
tree58b462d22b2342db07c041ac8abaf061e671d1e5
parent9377d2ad77c6d7ee0190c90544eaed0ff0c7fc9c (diff)
downloadchromium_src-0553072d237ad2b977e948591de3f87eee536a9c.zip
chromium_src-0553072d237ad2b977e948591de3f87eee536a9c.tar.gz
chromium_src-0553072d237ad2b977e948591de3f87eee536a9c.tar.bz2
The comment in base64.h implies that base::Base64Encode() can return false, but
this cannot happen in practice. Fix the comment. The implementation of Base64Encode() attempts to check for the return value MODP_B64_ERROR as a failure, but modp_b64_encode() cannot return this value. Remove the check. Remove unneeded integer cast. Change the return type to void. BUG=323357 TEST=base_unittests, compile all TBR=jochen@chromium.org,miket@chromium.org,joi@chromium.org,akalin@chromium.org,sergeyu@chromium.org Review URL: https://codereview.chromium.org/86913002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239759 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/base64.cc10
-rw-r--r--base/base64.h5
-rw-r--r--base/base64_unittest.cc3
-rw-r--r--chrome/browser/bookmarks/bookmark_html_writer.cc7
-rw-r--r--chrome/browser/chromeos/settings/device_settings_cache.cc5
-rw-r--r--chrome/browser/devtools/adb/android_rsa.cc7
-rw-r--r--chrome/browser/extensions/api/developer_private/developer_private_api.cc3
-rw-r--r--chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api.cc12
-rw-r--r--chrome/browser/extensions/api/extension_action/extension_action_api.cc3
-rw-r--r--chrome/browser/extensions/api/identity/web_auth_flow.cc3
-rw-r--r--chrome/browser/extensions/api/networking_private/networking_private_service_client.cc5
-rw-r--r--chrome/browser/extensions/api/proxy/proxy_api_helpers.cc3
-rw-r--r--chrome/browser/extensions/extension_protocols.cc17
-rw-r--r--chrome/browser/extensions/install_signer.cc3
-rw-r--r--chrome/browser/internal_auth.cc5
-rw-r--r--chrome/browser/managed_mode/managed_user_registration_utility.cc4
-rw-r--r--chrome/browser/media/desktop_streams_registry.cc6
-rw-r--r--chrome/browser/metrics/metrics_log.cc4
-rw-r--r--chrome/browser/metrics/metrics_log_serializer.cc5
-rw-r--r--chrome/browser/metrics/variations/variations_http_header_provider.cc16
-rw-r--r--chrome/browser/metrics/variations/variations_service.cc6
-rw-r--r--chrome/browser/metrics/variations/variations_service_unittest.cc2
-rw-r--r--chrome/browser/policy/cloud/component_cloud_policy_browsertest.cc3
-rw-r--r--chrome/browser/sync/profile_sync_service_harness.cc9
-rw-r--r--chrome/browser/ui/ash/screenshot_taker.cc5
-rw-r--r--chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc3
-rw-r--r--chrome/browser/ui/certificate_dialogs.cc6
-rw-r--r--chrome/browser/ui/webui/print_preview/print_preview_handler.cc4
-rw-r--r--chrome/common/metrics/caching_permuted_entropy_provider.cc5
-rw-r--r--chrome/test/chromedriver/chrome_launcher.cc3
-rw-r--r--chrome/test/chromedriver/chrome_launcher_unittest.cc3
-rw-r--r--chrome/test/chromedriver/net/websocket.cc8
-rw-r--r--components/policy/core/common/cloud/resource_cache.cc3
-rw-r--r--content/browser/devtools/renderer_overrides_handler.cc26
-rw-r--r--content/common/page_state_serialization_unittest.cc2
-rw-r--r--content/shell/browser/webkit_test_controller.cc3
-rw-r--r--content/shell/renderer/webkit_test_runner.cc3
-rw-r--r--extensions/common/extension.cc5
-rw-r--r--google_apis/cup/client_update_protocol.cc4
-rw-r--r--google_apis/gaia/oauth_request_signer.cc10
-rw-r--r--jingle/notifier/listener/push_notifications_send_update_task.cc12
-rw-r--r--jingle/notifier/listener/push_notifications_send_update_task_unittest.cc2
-rw-r--r--net/base/keygen_handler_win.cc5
-rw-r--r--net/cert/x509_certificate.cc3
-rw-r--r--net/http/http_auth_gssapi_posix.cc6
-rw-r--r--net/http/http_auth_handler_basic.cc10
-rw-r--r--net/http/http_auth_handler_ntlm.cc6
-rw-r--r--net/http/http_auth_sspi_win.cc6
-rw-r--r--net/test/spawned_test_server/base_test_server.cc9
-rw-r--r--net/third_party/mozilla_security_manager/nsKeygenHandler.cpp10
-rw-r--r--net/websockets/websocket_basic_handshake_stream.cc3
-rw-r--r--net/websockets/websocket_handshake_handler.cc6
-rw-r--r--remoting/base/rsa_key_pair.cc4
-rw-r--r--remoting/host/pin_hash.cc4
-rw-r--r--remoting/host/token_validator_factory_impl.cc3
-rw-r--r--remoting/protocol/auth_util.cc4
-rw-r--r--remoting/protocol/authenticator_test_base.cc2
-rw-r--r--remoting/protocol/pairing_registry.cc6
-rw-r--r--remoting/protocol/v2_authenticator.cc9
-rw-r--r--sync/internal_api/public/base/unique_position_unittest.cc2
-rw-r--r--sync/internal_api/sync_encryption_handler_impl.cc3
-rw-r--r--sync/protocol/proto_value_conversions.cc4
-rw-r--r--sync/syncable/syncable_util.cc2
-rw-r--r--sync/test/fake_encryptor.cc3
-rw-r--r--sync/tools/null_invalidation_state_tracker.cc2
-rw-r--r--sync/util/cryptographer.cc6
-rw-r--r--sync/util/nigori.cc6
67 files changed, 125 insertions, 252 deletions
diff --git a/base/base64.cc b/base/base64.cc
index 9514b0a..8ed1249 100644
--- a/base/base64.cc
+++ b/base/base64.cc
@@ -8,21 +8,15 @@
namespace base {
-bool Base64Encode(const StringPiece& input, std::string* output) {
+void Base64Encode(const StringPiece& input, std::string* output) {
std::string temp;
temp.resize(modp_b64_encode_len(input.size())); // makes room for null byte
- // null terminates result since result is base64 text!
- int input_size = static_cast<int>(input.size());
-
// modp_b64_encode_len() returns at least 1, so temp[0] is safe to use.
- size_t output_size = modp_b64_encode(&(temp[0]), input.data(), input_size);
- if (output_size == MODP_B64_ERROR)
- return false;
+ size_t output_size = modp_b64_encode(&(temp[0]), input.data(), input.size());
temp.resize(output_size); // strips off null byte
output->swap(temp);
- return true;
}
bool Base64Decode(const StringPiece& input, std::string* output) {
diff --git a/base/base64.h b/base/base64.h
index cc78edc..43d8f76 100644
--- a/base/base64.h
+++ b/base/base64.h
@@ -12,9 +12,8 @@
namespace base {
-// Encodes the input string in base64. Returns true if successful and false
-// otherwise. The output string is only modified if successful.
-BASE_EXPORT bool Base64Encode(const StringPiece& input, std::string* output);
+// Encodes the input string in base64.
+BASE_EXPORT void Base64Encode(const StringPiece& input, std::string* output);
// Decodes the base64 input string. Returns true if successful and false
// otherwise. The output string is only modified if successful.
diff --git a/base/base64_unittest.cc b/base/base64_unittest.cc
index 9a5dd81..9b23194 100644
--- a/base/base64_unittest.cc
+++ b/base/base64_unittest.cc
@@ -16,8 +16,7 @@ TEST(Base64Test, Basic) {
std::string decoded;
bool ok;
- ok = Base64Encode(kText, &encoded);
- EXPECT_TRUE(ok);
+ Base64Encode(kText, &encoded);
EXPECT_EQ(kBase64Text, encoded);
ok = Base64Decode(encoded, &decoded);
diff --git a/chrome/browser/bookmarks/bookmark_html_writer.cc b/chrome/browser/bookmarks/bookmark_html_writer.cc
index 3096166..6de0259 100644
--- a/chrome/browser/bookmarks/bookmark_html_writer.cc
+++ b/chrome/browser/bookmarks/bookmark_html_writer.cc
@@ -270,10 +270,9 @@ class Writer : public base::RefCountedThreadSafe<Writer> {
favicon_data.assign(reinterpret_cast<const char*>(data->front()),
data->size());
std::string favicon_base64_encoded;
- if (base::Base64Encode(favicon_data, &favicon_base64_encoded)) {
- GURL favicon_url("data:image/png;base64," + favicon_base64_encoded);
- favicon_string = favicon_url.spec();
- }
+ base::Base64Encode(favicon_data, &favicon_base64_encoded);
+ GURL favicon_url("data:image/png;base64," + favicon_base64_encoded);
+ favicon_string = favicon_url.spec();
}
if (!WriteIndent() ||
diff --git a/chrome/browser/chromeos/settings/device_settings_cache.cc b/chrome/browser/chromeos/settings/device_settings_cache.cc
index 2ccc48b..6ffbb9f 100644
--- a/chrome/browser/chromeos/settings/device_settings_cache.cc
+++ b/chrome/browser/chromeos/settings/device_settings_cache.cc
@@ -28,10 +28,7 @@ bool Store(const em::PolicyData& policy, PrefService* local_state) {
if (local_state) {
std::string policy_string = policy.SerializeAsString();
std::string encoded;
- if (!base::Base64Encode(policy_string, &encoded)) {
- LOG(ERROR) << "Can't encode policy in base64.";
- return false;
- }
+ base::Base64Encode(policy_string, &encoded);
local_state->SetString(prefs::kDeviceSettingsCache, encoded);
return true;
}
diff --git a/chrome/browser/devtools/adb/android_rsa.cc b/chrome/browser/devtools/adb/android_rsa.cc
index 371c433..27a52b4 100644
--- a/chrome/browser/devtools/adb/android_rsa.cc
+++ b/chrome/browser/devtools/adb/android_rsa.cc
@@ -196,10 +196,9 @@ crypto::RSAPrivateKey* AndroidRSAPrivateKey(Profile* profile) {
return NULL;
std::string key_string(key_info.begin(), key_info.end());
- if (base::Base64Encode(key_string, &encoded_key)) {
- profile->GetPrefs()->SetString(prefs::kDevToolsAdbKey,
- encoded_key);
- }
+ base::Base64Encode(key_string, &encoded_key);
+ profile->GetPrefs()->SetString(prefs::kDevToolsAdbKey,
+ encoded_key);
}
return key.release();
}
diff --git a/chrome/browser/extensions/api/developer_private/developer_private_api.cc b/chrome/browser/extensions/api/developer_private/developer_private_api.cc
index db64c33..4037c53 100644
--- a/chrome/browser/extensions/api/developer_private/developer_private_api.cc
+++ b/chrome/browser/extensions/api/developer_private/developer_private_api.cc
@@ -88,8 +88,7 @@ ExtensionUpdater* GetExtensionUpdater(Profile* profile) {
GURL GetImageURLFromData(std::string contents) {
std::string contents_base64;
- if (!base::Base64Encode(contents, &contents_base64))
- return GURL();
+ base::Base64Encode(contents, &contents_base64);
// TODO(dvh): make use of chrome::kDataScheme. Filed as crbug/297301.
const char kDataURLPrefix[] = "data:image;base64,";
diff --git a/chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api.cc b/chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api.cc
index 57f0c7f..0d67501 100644
--- a/chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api.cc
+++ b/chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api.cc
@@ -371,11 +371,7 @@ void EPKPChallengeMachineKey::SignChallengeCallback(
}
std::string encoded_response;
- if (!base::Base64Encode(response, &encoded_response)) {
- SetError(kResponseBadBase64Error);
- SendResponse(false);
- return;
- }
+ base::Base64Encode(response, &encoded_response);
results_ = api_epkp::ChallengeMachineKey::Results::Create(encoded_response);
SendResponse(true);
@@ -544,11 +540,7 @@ void EPKPChallengeUserKey::RegisterKeyCallback(
}
std::string encoded_response;
- if (!base::Base64Encode(response, &encoded_response)) {
- SetError(kResponseBadBase64Error);
- SendResponse(false);
- return;
- }
+ base::Base64Encode(response, &encoded_response);
results_ = api_epkp::ChallengeUserKey::Results::Create(encoded_response);
SendResponse(true);
diff --git a/chrome/browser/extensions/api/extension_action/extension_action_api.cc b/chrome/browser/extensions/api/extension_action/extension_action_api.cc
index 5c7b068..08d8c3d 100644
--- a/chrome/browser/extensions/api/extension_action/extension_action_api.cc
+++ b/chrome/browser/extensions/api/extension_action/extension_action_api.cc
@@ -113,8 +113,7 @@ std::string RepresentationToString(const gfx::ImageSkia& image, float scale) {
std::string raw_str(static_cast<const char*>(bitmap_pickle.data()),
bitmap_pickle.size());
std::string base64_str;
- if (!base::Base64Encode(raw_str, &base64_str))
- return std::string();
+ base::Base64Encode(raw_str, &base64_str);
return base64_str;
}
diff --git a/chrome/browser/extensions/api/identity/web_auth_flow.cc b/chrome/browser/extensions/api/identity/web_auth_flow.cc
index 0ade81b..01a284c 100644
--- a/chrome/browser/extensions/api/identity/web_auth_flow.cc
+++ b/chrome/browser/extensions/api/identity/web_auth_flow.cc
@@ -76,8 +76,7 @@ void WebAuthFlow::Start() {
// in OnShellWindowAdded.
std::string random_bytes;
crypto::RandBytes(WriteInto(&random_bytes, 33), 32);
- bool success = base::Base64Encode(random_bytes, &shell_window_key_);
- DCHECK(success);
+ base::Base64Encode(random_bytes, &shell_window_key_);
// identityPrivate.onWebFlowRequest(shell_window_key, provider_url_, mode_)
scoped_ptr<base::ListValue> args(new base::ListValue());
diff --git a/chrome/browser/extensions/api/networking_private/networking_private_service_client.cc b/chrome/browser/extensions/api/networking_private/networking_private_service_client.cc
index 5d94bb3..1c1eb29 100644
--- a/chrome/browser/extensions/api/networking_private/networking_private_service_client.cc
+++ b/chrome/browser/extensions/api/networking_private/networking_private_service_client.cc
@@ -79,10 +79,7 @@ class CryptoVerifyImpl : public NetworkingPrivateServiceClient::CryptoVerify {
return;
}
- if (!base::Base64Encode(ciphertext, base64_encoded_ciphertext)) {
- *error = "EncodeError";
- return;
- }
+ base::Base64Encode(ciphertext, base64_encoded_ciphertext);
}
};
diff --git a/chrome/browser/extensions/api/proxy/proxy_api_helpers.cc b/chrome/browser/extensions/api/proxy/proxy_api_helpers.cc
index fa88fbd..69d9ccb 100644
--- a/chrome/browser/extensions/api/proxy/proxy_api_helpers.cc
+++ b/chrome/browser/extensions/api/proxy/proxy_api_helpers.cc
@@ -35,8 +35,7 @@ bool CreateDataURLFromPACScript(const std::string& pac_script,
std::string* pac_script_url_base64_encoded) {
// Encode pac_script in base64.
std::string pac_script_base64_encoded;
- if (!base::Base64Encode(pac_script, &pac_script_base64_encoded))
- return false;
+ base::Base64Encode(pac_script, &pac_script_base64_encoded);
// Make it a correct data url.
*pac_script_url_base64_encoded =
diff --git a/chrome/browser/extensions/extension_protocols.cc b/chrome/browser/extensions/extension_protocols.cc
index 30a0cf2..ae0a0fb 100644
--- a/chrome/browser/extensions/extension_protocols.cc
+++ b/chrome/browser/extensions/extension_protocols.cc
@@ -86,15 +86,14 @@ net::HttpResponseHeaders* BuildHttpHeaders(
last_modified_time.ToInternalValue());
hash = base::SHA1HashString(hash);
std::string etag;
- if (base::Base64Encode(hash, &etag)) {
- raw_headers.append(1, '\0');
- raw_headers.append("ETag: \"");
- raw_headers.append(etag);
- raw_headers.append("\"");
- // Also force revalidation.
- raw_headers.append(1, '\0');
- raw_headers.append("cache-control: no-cache");
- }
+ base::Base64Encode(hash, &etag);
+ raw_headers.append(1, '\0');
+ raw_headers.append("ETag: \"");
+ raw_headers.append(etag);
+ raw_headers.append("\"");
+ // Also force revalidation.
+ raw_headers.append(1, '\0');
+ raw_headers.append("cache-control: no-cache");
}
raw_headers.append(2, '\0');
diff --git a/chrome/browser/extensions/install_signer.cc b/chrome/browser/extensions/install_signer.cc
index a144b99..eb04fe7 100644
--- a/chrome/browser/extensions/install_signer.cc
+++ b/chrome/browser/extensions/install_signer.cc
@@ -115,7 +115,8 @@ bool HashWithMachineId(const std::string& salt, std::string* result) {
std::string result_bytes(crypto::kSHA256Length, 0);
hash->Finish(string_as_array(&result_bytes), result_bytes.size());
- return base::Base64Encode(result_bytes, result);
+ base::Base64Encode(result_bytes, result);
+ return true;
}
} // namespace
diff --git a/chrome/browser/internal_auth.cc b/chrome/browser/internal_auth.cc
index ed8ff26..984c954 100644
--- a/chrome/browser/internal_auth.cc
+++ b/chrome/browser/internal_auth.cc
@@ -166,10 +166,7 @@ void CreatePassport(const std::string& domain,
return;
}
std::string hmac_base64;
- if (!base::Base64Encode(hmac, &hmac_base64)) {
- NOTREACHED();
- return;
- }
+ base::Base64Encode(hmac, &hmac_base64);
if (hmac_base64.size() != BASE64_PER_RAW(kHMACSizeInBytes)) {
NOTREACHED();
return;
diff --git a/chrome/browser/managed_mode/managed_user_registration_utility.cc b/chrome/browser/managed_mode/managed_user_registration_utility.cc
index fc198ac..9b6d630 100644
--- a/chrome/browser/managed_mode/managed_user_registration_utility.cc
+++ b/chrome/browser/managed_mode/managed_user_registration_utility.cc
@@ -150,9 +150,7 @@ ManagedUserRegistrationUtility::Create(Profile* profile) {
// static
std::string ManagedUserRegistrationUtility::GenerateNewManagedUserId() {
std::string new_managed_user_id;
- bool success = base::Base64Encode(base::RandBytesAsString(8),
- &new_managed_user_id);
- DCHECK(success);
+ base::Base64Encode(base::RandBytesAsString(8), &new_managed_user_id);
return new_managed_user_id;
}
diff --git a/chrome/browser/media/desktop_streams_registry.cc b/chrome/browser/media/desktop_streams_registry.cc
index 64e4160..05c2ba0 100644
--- a/chrome/browser/media/desktop_streams_registry.cc
+++ b/chrome/browser/media/desktop_streams_registry.cc
@@ -20,10 +20,8 @@ std::string GenerateRandomStreamId() {
char buffer[kStreamIdLengthBytes];
crypto::RandBytes(buffer, arraysize(buffer));
std::string result;
- if (!base::Base64Encode(base::StringPiece(buffer, arraysize(buffer)),
- &result)) {
- LOG(FATAL) << "Base64Encode failed.";
- }
+ base::Base64Encode(base::StringPiece(buffer, arraysize(buffer)),
+ &result);
return result;
}
diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc
index 72d738b..9ebf3bc 100644
--- a/chrome/browser/metrics/metrics_log.cc
+++ b/chrome/browser/metrics/metrics_log.cc
@@ -803,8 +803,8 @@ void MetricsLog::RecordEnvironment(
std::string serialied_system_profile;
std::string base64_system_profile;
- if (system_profile->SerializeToString(&serialied_system_profile) &&
- base::Base64Encode(serialied_system_profile, &base64_system_profile)) {
+ if (system_profile->SerializeToString(&serialied_system_profile)) {
+ base::Base64Encode(serialied_system_profile, &base64_system_profile);
PrefService* local_state = GetPrefService();
local_state->SetString(prefs::kStabilitySavedSystemProfile,
base64_system_profile);
diff --git a/chrome/browser/metrics/metrics_log_serializer.cc b/chrome/browser/metrics/metrics_log_serializer.cc
index 8283ccd..e25b379 100644
--- a/chrome/browser/metrics/metrics_log_serializer.cc
+++ b/chrome/browser/metrics/metrics_log_serializer.cc
@@ -141,10 +141,7 @@ void MetricsLogSerializer::WriteLogsToPrefList(
it != local_list.end(); ++it) {
// We encode the compressed log as Value::CreateStringValue() expects to
// take a valid UTF8 string.
- if (!base::Base64Encode(it->log_text(), &encoded_log)) {
- list->Clear();
- return;
- }
+ base::Base64Encode(it->log_text(), &encoded_log);
base::MD5Update(&ctx, encoded_log);
list->Append(Value::CreateStringValue(encoded_log));
}
diff --git a/chrome/browser/metrics/variations/variations_http_header_provider.cc b/chrome/browser/metrics/variations/variations_http_header_provider.cc
index 909394a..08907f3 100644
--- a/chrome/browser/metrics/variations/variations_http_header_provider.cc
+++ b/chrome/browser/metrics/variations/variations_http_header_provider.cc
@@ -163,16 +163,12 @@ void VariationsHttpHeaderProvider::UpdateVariationIDsHeaderValue() {
proto.SerializeToString(&serialized);
std::string hashed;
- if (base::Base64Encode(serialized, &hashed)) {
- // If successful, swap the header value with the new one.
- // Note that the list of IDs and the header could be temporarily out of sync
- // if IDs are added as the header is recreated. The receiving servers are OK
- // with such discrepancies.
- variation_ids_header_ = hashed;
- } else {
- NOTREACHED() << "Failed to base64 encode Variation IDs value: "
- << serialized;
- }
+ base::Base64Encode(serialized, &hashed);
+ // If successful, swap the header value with the new one.
+ // Note that the list of IDs and the header could be temporarily out of sync
+ // if IDs are added as the header is recreated. The receiving servers are OK
+ // with such discrepancies.
+ variation_ids_header_ = hashed;
}
// static
diff --git a/chrome/browser/metrics/variations/variations_service.cc b/chrome/browser/metrics/variations/variations_service.cc
index 95e9905..d93c2f19 100644
--- a/chrome/browser/metrics/variations/variations_service.cc
+++ b/chrome/browser/metrics/variations/variations_service.cc
@@ -481,11 +481,7 @@ bool VariationsService::StoreSeedData(const std::string& seed_data,
}
std::string base64_seed_data;
- if (!base::Base64Encode(seed_data, &base64_seed_data)) {
- VLOG(1) << "Variations Seed data from server fails Base64Encode, rejecting "
- << "the seed.";
- return false;
- }
+ base::Base64Encode(seed_data, &base64_seed_data);
local_state_->SetString(prefs::kVariationsSeed, base64_seed_data);
local_state_->SetString(prefs::kVariationsSeedHash, HashSeed(seed_data));
diff --git a/chrome/browser/metrics/variations/variations_service_unittest.cc b/chrome/browser/metrics/variations/variations_service_unittest.cc
index bda76ac..f912ebe 100644
--- a/chrome/browser/metrics/variations/variations_service_unittest.cc
+++ b/chrome/browser/metrics/variations/variations_service_unittest.cc
@@ -91,7 +91,7 @@ std::string SerializeSeedBase64(const VariationsSeed& seed, std::string* hash) {
*hash = base::HexEncode(sha1.data(), sha1.size());
}
std::string base64_serialized_seed;
- EXPECT_TRUE(base::Base64Encode(serialized_seed, &base64_serialized_seed));
+ base::Base64Encode(serialized_seed, &base64_serialized_seed);
return base64_serialized_seed;
}
diff --git a/chrome/browser/policy/cloud/component_cloud_policy_browsertest.cc b/chrome/browser/policy/cloud/component_cloud_policy_browsertest.cc
index 41e65ea..8e7e164 100644
--- a/chrome/browser/policy/cloud/component_cloud_policy_browsertest.cc
+++ b/chrome/browser/policy/cloud/component_cloud_policy_browsertest.cc
@@ -87,8 +87,9 @@ const char kTestPolicy2JSON[] = "{\"Another\":\"turn_it_off\"}";
// Same encoding as ResourceCache does for its keys.
bool Base64Encode(const std::string& value, std::string* encoded) {
- if (value.empty() || !base::Base64Encode(value, encoded))
+ if (value.empty())
return false;
+ base::Base64Encode(value, encoded);
base::ReplaceChars(*encoded, "+", "-", encoded);
base::ReplaceChars(*encoded, "/", "_", encoded);
return true;
diff --git a/chrome/browser/sync/profile_sync_service_harness.cc b/chrome/browser/sync/profile_sync_service_harness.cc
index 695f277..3bb1763 100644
--- a/chrome/browser/sync/profile_sync_service_harness.cc
+++ b/chrome/browser/sync/profile_sync_service_harness.cc
@@ -929,13 +929,8 @@ bool ProfileSyncServiceHarness::MatchesOtherClient(
if (marker != partner_marker) {
if (VLOG_IS_ON(2)) {
std::string marker_base64, partner_marker_base64;
- if (!base::Base64Encode(marker, &marker_base64)) {
- NOTREACHED();
- }
- if (!base::Base64Encode(
- partner_marker, &partner_marker_base64)) {
- NOTREACHED();
- }
+ base::Base64Encode(marker, &marker_base64);
+ base::Base64Encode(partner_marker, &partner_marker_base64);
DVLOG(2) << syncer::ModelTypeToString(i.Get()) << ": "
<< profile_debug_name_ << " progress marker = "
<< marker_base64 << ", "
diff --git a/chrome/browser/ui/ash/screenshot_taker.cc b/chrome/browser/ui/ash/screenshot_taker.cc
index fa63be5..e5f9408 100644
--- a/chrome/browser/ui/ash/screenshot_taker.cc
+++ b/chrome/browser/ui/ash/screenshot_taker.cc
@@ -71,10 +71,7 @@ void CopyScreenshotToClipboard(scoped_refptr<base::RefCountedString> png_data) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
std::string encoded;
- if (!base::Base64Encode(png_data->data(), &encoded)) {
- LOG(ERROR) << "Failed to encode base64";
- return;
- }
+ base::Base64Encode(png_data->data(), &encoded);
// Only cares about HTML because ChromeOS doesn't need other formats.
// TODO(dcheng): Why don't we take advantage of the ability to write bitmaps
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
index 0d70405..1cfd4e7 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
@@ -2611,8 +2611,7 @@ void AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData(
std::string proto_data;
fingerprint->SerializeToString(&proto_data);
- bool success = base::Base64Encode(proto_data, &risk_data_);
- DCHECK(success);
+ base::Base64Encode(proto_data, &risk_data_);
SubmitWithWallet();
}
diff --git a/chrome/browser/ui/certificate_dialogs.cc b/chrome/browser/ui/certificate_dialogs.cc
index d200036..cb32713 100644
--- a/chrome/browser/ui/certificate_dialogs.cc
+++ b/chrome/browser/ui/certificate_dialogs.cc
@@ -49,11 +49,7 @@ std::string WrapAt64(const std::string &str) {
std::string GetBase64String(net::X509Certificate::OSCertHandle cert) {
std::string base64;
- if (!base::Base64Encode(
- x509_certificate_model::GetDerString(cert), &base64)) {
- LOG(ERROR) << "base64 encoding error";
- return std::string();
- }
+ base::Base64Encode(x509_certificate_model::GetDerString(cert), &base64);
return "-----BEGIN CERTIFICATE-----\r\n" +
WrapAt64(base64) +
"-----END CERTIFICATE-----\r\n";
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
index 3245c69..5af78f4 100644
--- a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
+++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
@@ -1172,9 +1172,7 @@ void PrintPreviewHandler::SendCloudPrintJob(const base::RefCountedBytes* data) {
std::string raw_data(reinterpret_cast<const char*>(data->front()),
data->size());
std::string base64_data;
- if (!base::Base64Encode(raw_data, &base64_data)) {
- NOTREACHED() << "Base64 encoding PDF data.";
- }
+ base::Base64Encode(raw_data, &base64_data);
StringValue data_value(base64_data);
web_ui()->CallJavascriptFunction("printToCloud", data_value);
diff --git a/chrome/common/metrics/caching_permuted_entropy_provider.cc b/chrome/common/metrics/caching_permuted_entropy_provider.cc
index f58dee8..2432f3f 100644
--- a/chrome/common/metrics/caching_permuted_entropy_provider.cc
+++ b/chrome/common/metrics/caching_permuted_entropy_provider.cc
@@ -66,10 +66,7 @@ void CachingPermutedEntropyProvider::UpdateLocalState() const {
cache_.SerializeToString(&serialized);
std::string base64_encoded;
- if (!base::Base64Encode(serialized, &base64_encoded)) {
- NOTREACHED();
- return;
- }
+ base::Base64Encode(serialized, &base64_encoded);
local_state_->SetString(prefs::kMetricsPermutedEntropyCache, base64_encoded);
}
diff --git a/chrome/test/chromedriver/chrome_launcher.cc b/chrome/test/chromedriver/chrome_launcher.cc
index 6ef3a57..d293d43 100644
--- a/chrome/test/chromedriver/chrome_launcher.cc
+++ b/chrome/test/chromedriver/chrome_launcher.cc
@@ -497,8 +497,7 @@ Status ProcessExtension(const std::string& extension,
if (key_len != public_key.size())
return Status(kUnknownError, "invalid public key length");
std::string public_key_base64;
- if (!base::Base64Encode(public_key, &public_key_base64))
- return Status(kUnknownError, "cannot base64 encode public key");
+ base::Base64Encode(public_key, &public_key_base64);
std::string id = GenerateExtensionId(public_key);
// Unzip the crx file.
diff --git a/chrome/test/chromedriver/chrome_launcher_unittest.cc b/chrome/test/chromedriver/chrome_launcher_unittest.cc
index 24714d6..e75051b 100644
--- a/chrome/test/chromedriver/chrome_launcher_unittest.cc
+++ b/chrome/test/chromedriver/chrome_launcher_unittest.cc
@@ -40,8 +40,7 @@ bool AddExtensionForInstall(const std::string& relative_path,
return false;
std::string crx_encoded;
- if (!base::Base64Encode(crx_contents, &crx_encoded))
- return false;
+ base::Base64Encode(crx_contents, &crx_encoded);
extensions->push_back(crx_encoded);
return true;
}
diff --git a/chrome/test/chromedriver/net/websocket.cc b/chrome/test/chromedriver/net/websocket.cc
index 76d17da..2c214f9 100644
--- a/chrome/test/chromedriver/net/websocket.cc
+++ b/chrome/test/chromedriver/net/websocket.cc
@@ -121,7 +121,7 @@ void WebSocket::OnSocketConnect(int code) {
return;
}
- CHECK(base::Base64Encode(base::RandBytesAsString(16), &sec_key_));
+ base::Base64Encode(base::RandBytesAsString(16), &sec_key_);
std::string handshake = base::StringPrintf(
"GET %s HTTP/1.1\r\n"
"Host: %s\r\n"
@@ -210,8 +210,8 @@ void WebSocket::OnReadDuringHandshake(const char* data, int len) {
const char kMagicKey[] = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
std::string websocket_accept;
- CHECK(base::Base64Encode(base::SHA1HashString(sec_key_ + kMagicKey),
- &websocket_accept));
+ base::Base64Encode(base::SHA1HashString(sec_key_ + kMagicKey),
+ &websocket_accept);
scoped_refptr<net::HttpResponseHeaders> headers(
new net::HttpResponseHeaders(
net::HttpUtil::AssembleRawHeaders(
@@ -262,5 +262,3 @@ void WebSocket::Close(int code) {
state_ = CLOSED;
}
-
-
diff --git a/components/policy/core/common/cloud/resource_cache.cc b/components/policy/core/common/cloud/resource_cache.cc
index e527679..7b9e327 100644
--- a/components/policy/core/common/cloud/resource_cache.cc
+++ b/components/policy/core/common/cloud/resource_cache.cc
@@ -21,8 +21,9 @@ namespace {
// which is safe to use as a file name on all platforms.
bool Base64Encode(const std::string& value, std::string* encoded) {
DCHECK(!value.empty());
- if (value.empty() || !base::Base64Encode(value, encoded))
+ if (value.empty())
return false;
+ base::Base64Encode(value, encoded);
base::ReplaceChars(*encoded, "+", "-", encoded);
base::ReplaceChars(*encoded, "/", "_", encoded);
return true;
diff --git a/content/browser/devtools/renderer_overrides_handler.cc b/content/browser/devtools/renderer_overrides_handler.cc
index 1bd487f..4901f34 100644
--- a/content/browser/devtools/renderer_overrides_handler.cc
+++ b/content/browser/devtools/renderer_overrides_handler.cc
@@ -443,16 +443,13 @@ RendererOverridesHandler::PageCaptureScreenshot(
&png,
gfx::Rect(snapshot_size))) {
std::string base64_data;
- bool success = base::Base64Encode(
+ base::Base64Encode(
base::StringPiece(reinterpret_cast<char*>(&*png.begin()), png.size()),
&base64_data);
- if (success) {
- base::DictionaryValue* result = new base::DictionaryValue();
- result->SetString(
- devtools::Page::captureScreenshot::kResponseData, base64_data);
- return command->SuccessResponse(result);
- }
- return command->InternalErrorResponse("Unable to base64encode screenshot");
+ base::DictionaryValue* result = new base::DictionaryValue();
+ result->SetString(
+ devtools::Page::captureScreenshot::kResponseData, base64_data);
+ return command->SuccessResponse(result);
}
// Fallback to copying from compositing surface.
@@ -553,16 +550,9 @@ void RendererOverridesHandler::ScreenshotCaptured(
}
std::string base_64_data;
- if (!base::Base64Encode(base::StringPiece(
- reinterpret_cast<char*>(&data[0]),
- data.size()),
- &base_64_data)) {
- if (command) {
- SendAsyncResponse(
- command->InternalErrorResponse("Unable to base64 encode"));
- }
- return;
- }
+ base::Base64Encode(
+ base::StringPiece(reinterpret_cast<char*>(&data[0]), data.size()),
+ &base_64_data);
base::DictionaryValue* response = new base::DictionaryValue();
response->SetString(devtools::Page::screencastFrame::kParamData,
diff --git a/content/common/page_state_serialization_unittest.cc b/content/common/page_state_serialization_unittest.cc
index c23a2fb..b7e5895 100644
--- a/content/common/page_state_serialization_unittest.cc
+++ b/content/common/page_state_serialization_unittest.cc
@@ -373,7 +373,7 @@ TEST_F(PageStateSerializationTest, DumpExpectedPageStateForBackwardsCompat) {
EXPECT_TRUE(EncodePageState(state, &encoded));
std::string base64;
- EXPECT_TRUE(base::Base64Encode(encoded, &base64));
+ base::Base64Encode(encoded, &base64);
base::FilePath path;
PathService::Get(base::DIR_TEMP, &path);
diff --git a/content/shell/browser/webkit_test_controller.cc b/content/shell/browser/webkit_test_controller.cc
index 8f458e7..3939669 100644
--- a/content/shell/browser/webkit_test_controller.cc
+++ b/content/shell/browser/webkit_test_controller.cc
@@ -170,10 +170,9 @@ void WebKitTestResultPrinter::PrintEncodedBinaryData(
*output_ << "Content-Transfer-Encoding: base64\n";
std::string data_base64;
- const bool success = base::Base64Encode(
+ base::Base64Encode(
base::StringPiece(reinterpret_cast<const char*>(&data[0]), data.size()),
&data_base64);
- DCHECK(success);
*output_ << "Content-Length: " << data_base64.length() << "\n";
output_->write(data_base64.c_str(), data_base64.length());
diff --git a/content/shell/renderer/webkit_test_runner.cc b/content/shell/renderer/webkit_test_runner.cc
index 91535fd..e9b96ae 100644
--- a/content/shell/renderer/webkit_test_runner.cc
+++ b/content/shell/renderer/webkit_test_runner.cc
@@ -292,8 +292,7 @@ WebURL WebKitTestRunner::localFileToDataURL(const WebURL& file_url) {
routing_id(), local_path, &contents));
std::string contents_base64;
- if (!base::Base64Encode(contents, &contents_base64))
- return WebURL();
+ base::Base64Encode(contents, &contents_base64);
const char data_url_prefix[] = "data:text/css:charset=utf-8;base64,";
return WebURL(GURL(data_url_prefix + contents_base64));
diff --git a/extensions/common/extension.cc b/extensions/common/extension.cc
index 10e065b..0a67983 100644
--- a/extensions/common/extension.cc
+++ b/extensions/common/extension.cc
@@ -248,7 +248,10 @@ bool Extension::ParsePEMKeyBytes(const std::string& input,
// static
bool Extension::ProducePEM(const std::string& input, std::string* output) {
DCHECK(output);
- return (input.length() == 0) ? false : base::Base64Encode(input, output);
+ if (input.empty())
+ return false;
+ base::Base64Encode(input, output);
+ return true;
}
// static
diff --git a/google_apis/cup/client_update_protocol.cc b/google_apis/cup/client_update_protocol.cc
index 0ff3d8f..afde3ab 100644
--- a/google_apis/cup/client_update_protocol.cc
+++ b/google_apis/cup/client_update_protocol.cc
@@ -122,8 +122,7 @@ std::vector<uint8> RsaPad(size_t rsa_key_size,
// needed. Call the standard Base64 encoder/decoder and then apply fixups.
std::string UrlSafeB64Encode(const std::vector<uint8>& data) {
std::string result;
- if (!base::Base64Encode(ByteVectorToSP(data), &result))
- return std::string();
+ base::Base64Encode(ByteVectorToSP(data), &result);
// Do an tr|+/|-_| on the output, and strip any '=' padding.
for (std::string::iterator it = result.begin(); it != result.end(); ++it) {
@@ -302,4 +301,3 @@ bool ClientUpdateProtocol::DeriveSharedKey(const std::vector<uint8>& source) {
return true;
}
-
diff --git a/google_apis/gaia/oauth_request_signer.cc b/google_apis/gaia/oauth_request_signer.cc
index fe65d4f..115c14d 100644
--- a/google_apis/gaia/oauth_request_signer.cc
+++ b/google_apis/gaia/oauth_request_signer.cc
@@ -204,10 +204,12 @@ bool SignHmacSha1(const std::string& text,
DCHECK(hmac.DigestLength() == kHmacDigestLength);
unsigned char digest[kHmacDigestLength];
bool result = hmac.Init(key) &&
- hmac.Sign(text, digest, kHmacDigestLength) &&
- base::Base64Encode(std::string(reinterpret_cast<const char*>(digest),
- kHmacDigestLength),
- signature_return);
+ hmac.Sign(text, digest, kHmacDigestLength);
+ if (result) {
+ base::Base64Encode(
+ std::string(reinterpret_cast<const char*>(digest), kHmacDigestLength),
+ signature_return);
+ }
return result;
}
diff --git a/jingle/notifier/listener/push_notifications_send_update_task.cc b/jingle/notifier/listener/push_notifications_send_update_task.cc
index 4e0c127..9b5abb6 100644
--- a/jingle/notifier/listener/push_notifications_send_update_task.cc
+++ b/jingle/notifier/listener/push_notifications_send_update_task.cc
@@ -71,20 +71,14 @@ buzz::XmlElement* PushNotificationsSendUpdateTask::MakeUpdateMessage(
recipient_element->AddAttr(buzz::QN_TO, recipient.to);
if (!recipient.user_specific_data.empty()) {
std::string base64_data;
- if (!base::Base64Encode(recipient.user_specific_data, &base64_data)) {
- DLOG(WARNING) << "Could not encode data "
- << recipient.user_specific_data;
- } else {
- recipient_element->SetBodyText(base64_data);
- }
+ base::Base64Encode(recipient.user_specific_data, &base64_data);
+ recipient_element->SetBodyText(base64_data);
}
}
buzz::XmlElement* data = new buzz::XmlElement(kQnData, true);
std::string base64_data;
- if (!base::Base64Encode(notification.data, &base64_data)) {
- DLOG(WARNING) << "Could not encode data " << notification.data;
- }
+ base::Base64Encode(notification.data, &base64_data);
data->SetBodyText(base64_data);
push->AddElement(data);
diff --git a/jingle/notifier/listener/push_notifications_send_update_task_unittest.cc b/jingle/notifier/listener/push_notifications_send_update_task_unittest.cc
index c57bd93..0395352 100644
--- a/jingle/notifier/listener/push_notifications_send_update_task_unittest.cc
+++ b/jingle/notifier/listener/push_notifications_send_update_task_unittest.cc
@@ -36,7 +36,7 @@ TEST_F(PushNotificationsSendUpdateTaskTest, MakeUpdateMessage) {
notification.data = "test_data";
std::string base64_data;
- EXPECT_TRUE(base::Base64Encode(notification.data, &base64_data));
+ base::Base64Encode(notification.data, &base64_data);
scoped_ptr<buzz::XmlElement> message(
PushNotificationsSendUpdateTask::MakeUpdateMessage(
diff --git a/net/base/keygen_handler_win.cc b/net/base/keygen_handler_win.cc
index e1d432c..59d90e8 100644
--- a/net/base/keygen_handler_win.cc
+++ b/net/base/keygen_handler_win.cc
@@ -211,10 +211,7 @@ std::string KeygenHandler::GenKeyAndSignChallenge() {
}
std::string result;
- if (!base::Base64Encode(spkac, &result)) {
- LOG(ERROR) << "Keygen failed: Couldn't convert signed key into base64";
- return std::string();
- }
+ base::Base64Encode(spkac, &result);
VLOG(1) << "Keygen succeeded";
return result;
diff --git a/net/cert/x509_certificate.cc b/net/cert/x509_certificate.cc
index 862a202..a095fdf 100644
--- a/net/cert/x509_certificate.cc
+++ b/net/cert/x509_certificate.cc
@@ -665,8 +665,7 @@ bool X509Certificate::GetPEMEncodedFromDER(const std::string& der_encoded,
if (der_encoded.empty())
return false;
std::string b64_encoded;
- if (!base::Base64Encode(der_encoded, &b64_encoded) || b64_encoded.empty())
- return false;
+ base::Base64Encode(der_encoded, &b64_encoded);
*pem_encoded = "-----BEGIN CERTIFICATE-----\n";
// Divide the Base-64 encoded data into 64-character chunks, as per
diff --git a/net/http/http_auth_gssapi_posix.cc b/net/http/http_auth_gssapi_posix.cc
index 4ea4bb9..41cbcdb 100644
--- a/net/http/http_auth_gssapi_posix.cc
+++ b/net/http/http_auth_gssapi_posix.cc
@@ -734,11 +734,7 @@ int HttpAuthGSSAPI::GenerateAuthToken(const AuthCredentials* credentials,
std::string encode_input(static_cast<char*>(output_token.value),
output_token.length);
std::string encode_output;
- bool base64_rv = base::Base64Encode(encode_input, &encode_output);
- if (!base64_rv) {
- LOG(ERROR) << "Base64 encoding of auth token failed.";
- return ERR_ENCODING_CONVERSION_FAILED;
- }
+ base::Base64Encode(encode_input, &encode_output);
*auth_token = scheme_ + " " + encode_output;
return OK;
}
diff --git a/net/http/http_auth_handler_basic.cc b/net/http/http_auth_handler_basic.cc
index af5f188..e445c93 100644
--- a/net/http/http_auth_handler_basic.cc
+++ b/net/http/http_auth_handler_basic.cc
@@ -91,13 +91,9 @@ int HttpAuthHandlerBasic::GenerateAuthTokenImpl(
DCHECK(credentials);
// TODO(eroman): is this the right encoding of username/password?
std::string base64_username_password;
- if (!base::Base64Encode(
- UTF16ToUTF8(credentials->username()) + ":" +
- UTF16ToUTF8(credentials->password()),
- &base64_username_password)) {
- LOG(ERROR) << "Unexpected problem Base64 encoding.";
- return ERR_UNEXPECTED;
- }
+ base::Base64Encode(UTF16ToUTF8(credentials->username()) + ":" +
+ UTF16ToUTF8(credentials->password()),
+ &base64_username_password);
*auth_token = "Basic " + base64_username_password;
return OK;
}
diff --git a/net/http/http_auth_handler_ntlm.cc b/net/http/http_auth_handler_ntlm.cc
index c0387d8..922800c 100644
--- a/net/http/http_auth_handler_ntlm.cc
+++ b/net/http/http_auth_handler_ntlm.cc
@@ -89,13 +89,9 @@ int HttpAuthHandlerNTLM::GenerateAuthTokenImpl(
// Base64 encode data in output buffer and prepend "NTLM ".
std::string encode_input(static_cast<char*>(out_buf), out_buf_len);
std::string encode_output;
- bool base64_rv = base::Base64Encode(encode_input, &encode_output);
+ base::Base64Encode(encode_input, &encode_output);
// OK, we are done with |out_buf|
free(out_buf);
- if (!base64_rv) {
- LOG(ERROR) << "Unexpected problem Base64 encoding.";
- return ERR_UNEXPECTED;
- }
*auth_token = std::string("NTLM ") + encode_output;
return OK;
#endif
diff --git a/net/http/http_auth_sspi_win.cc b/net/http/http_auth_sspi_win.cc
index 11d64dc..5718f9e 100644
--- a/net/http/http_auth_sspi_win.cc
+++ b/net/http/http_auth_sspi_win.cc
@@ -280,13 +280,9 @@ int HttpAuthSSPI::GenerateAuthToken(const AuthCredentials* credentials,
// Base64 encode data in output buffer and prepend the scheme.
std::string encode_input(static_cast<char*>(out_buf), out_buf_len);
std::string encode_output;
- bool base64_rv = base::Base64Encode(encode_input, &encode_output);
+ base::Base64Encode(encode_input, &encode_output);
// OK, we are done with |out_buf|
free(out_buf);
- if (!base64_rv) {
- LOG(ERROR) << "Base64 encoding of auth token failed.";
- return ERR_ENCODING_CONVERSION_FAILED;
- }
*auth_token = scheme_ + " " + encode_output;
return OK;
}
diff --git a/net/test/spawned_test_server/base_test_server.cc b/net/test/spawned_test_server/base_test_server.cc
index 775341b..7ef2aba 100644
--- a/net/test/spawned_test_server/base_test_server.cc
+++ b/net/test/spawned_test_server/base_test_server.cc
@@ -226,10 +226,8 @@ bool BaseTestServer::GetFilePathWithReplacements(
const std::string& new_text = it->second;
std::string base64_old;
std::string base64_new;
- if (!base::Base64Encode(old_text, &base64_old))
- return false;
- if (!base::Base64Encode(new_text, &base64_new))
- return false;
+ base::Base64Encode(old_text, &base64_old);
+ base::Base64Encode(new_text, &base64_new);
if (first_query_parameter) {
new_file_path += "?";
first_query_parameter = false;
@@ -400,8 +398,7 @@ bool BaseTestServer::GenerateArguments(base::DictionaryValue* arguments) const {
}
if (!ssl_options_.signed_cert_timestamps.empty()) {
std::string b64_scts;
- if (!base::Base64Encode(ssl_options_.signed_cert_timestamps, &b64_scts))
- return false;
+ base::Base64Encode(ssl_options_.signed_cert_timestamps, &b64_scts);
arguments->SetString("signed-cert-timestamps", b64_scts);
}
}
diff --git a/net/third_party/mozilla_security_manager/nsKeygenHandler.cpp b/net/third_party/mozilla_security_manager/nsKeygenHandler.cpp
index 4cf47c4..f239cc1 100644
--- a/net/third_party/mozilla_security_manager/nsKeygenHandler.cpp
+++ b/net/third_party/mozilla_security_manager/nsKeygenHandler.cpp
@@ -215,13 +215,9 @@ std::string GenKeyAndSignChallenge(int key_size_in_bits,
}
// Convert the signed public key and challenge into base64/ascii.
- if (!base::Base64Encode(std::string(reinterpret_cast<char*>(signedItem.data),
- signedItem.len),
- &result_blob)) {
- LOG(ERROR) << "Couldn't convert signed public key into base64";
- isSuccess = false;
- goto failure;
- }
+ base::Base64Encode(
+ std::string(reinterpret_cast<char*>(signedItem.data), signedItem.len),
+ &result_blob);
failure:
if (!isSuccess) {
diff --git a/net/websockets/websocket_basic_handshake_stream.cc b/net/websockets/websocket_basic_handshake_stream.cc
index 1a8154b..8c0e42e 100644
--- a/net/websockets/websocket_basic_handshake_stream.cc
+++ b/net/websockets/websocket_basic_handshake_stream.cc
@@ -33,8 +33,7 @@ std::string GenerateHandshakeChallenge() {
std::string raw_challenge(websockets::kRawChallengeLength, '\0');
crypto::RandBytes(string_as_array(&raw_challenge), raw_challenge.length());
std::string encoded_challenge;
- bool encode_success = base::Base64Encode(raw_challenge, &encoded_challenge);
- DCHECK(encode_success);
+ base::Base64Encode(raw_challenge, &encoded_challenge);
return encoded_challenge;
}
diff --git a/net/websockets/websocket_handshake_handler.cc b/net/websockets/websocket_handshake_handler.cc
index 641b196..787dde6 100644
--- a/net/websockets/websocket_handshake_handler.cc
+++ b/net/websockets/websocket_handshake_handler.cc
@@ -351,8 +351,7 @@ void ComputeSecWebSocketAccept(const std::string& key,
std::string hash =
base::SHA1HashString(key + websockets::kWebSocketGuid);
- bool encode_success = base::Base64Encode(hash, accept);
- DCHECK(encode_success);
+ base::Base64Encode(hash, accept);
}
bool WebSocketHandshakeResponseHandler::ParseResponseInfo(
@@ -405,8 +404,7 @@ bool WebSocketHandshakeResponseHandler::ParseResponseHeaderBlock(
std::string hash =
base::SHA1HashString(challenge + websockets::kWebSocketGuid);
std::string websocket_accept;
- bool encode_success = base::Base64Encode(hash, &websocket_accept);
- DCHECK(encode_success);
+ base::Base64Encode(hash, &websocket_accept);
std::string response_message = base::StringPrintf(
"%s %s\r\n", websockets::kHttpProtocolVersion, status->second.c_str());
diff --git a/remoting/base/rsa_key_pair.cc b/remoting/base/rsa_key_pair.cc
index 1cea077..28dd2ef 100644
--- a/remoting/base/rsa_key_pair.cc
+++ b/remoting/base/rsa_key_pair.cc
@@ -63,9 +63,7 @@ std::string RsaKeyPair::ToString() const {
CHECK(key_->ExportPrivateKey(&key_buf));
std::string key_str(key_buf.begin(), key_buf.end());
std::string key_base64;
- if (!base::Base64Encode(key_str, &key_base64)) {
- LOG(FATAL) << "Base64Encode failed";
- }
+ base::Base64Encode(key_str, &key_base64);
return key_base64;
}
diff --git a/remoting/host/pin_hash.cc b/remoting/host/pin_hash.cc
index fe17f38..c9b1ca3c 100644
--- a/remoting/host/pin_hash.cc
+++ b/remoting/host/pin_hash.cc
@@ -16,9 +16,7 @@ std::string MakeHostPinHash(const std::string& host_id,
std::string hash = protocol::AuthenticationMethod::ApplyHashFunction(
protocol::AuthenticationMethod::HMAC_SHA256, host_id, pin);
std::string hash_base64;
- if (!base::Base64Encode(hash, &hash_base64)) {
- LOG(FATAL) << "Base64Encode failed";
- }
+ base::Base64Encode(hash, &hash_base64);
return "hmac:" + hash_base64;
}
diff --git a/remoting/host/token_validator_factory_impl.cc b/remoting/host/token_validator_factory_impl.cc
index 3dd9245..d93df62 100644
--- a/remoting/host/token_validator_factory_impl.cc
+++ b/remoting/host/token_validator_factory_impl.cc
@@ -107,8 +107,7 @@ class TokenValidatorImpl
std::string nonce_bytes;
crypto::RandBytes(WriteInto(&nonce_bytes, kNonceLength + 1), kNonceLength);
std::string nonce;
- bool success = base::Base64Encode(nonce_bytes, &nonce);
- DCHECK(success);
+ base::Base64Encode(nonce_bytes, &nonce);
return "client:" + remote_jid + " host:" + local_jid + " nonce:" + nonce;
}
diff --git a/remoting/protocol/auth_util.cc b/remoting/protocol/auth_util.cc
index 4559636..17263bf 100644
--- a/remoting/protocol/auth_util.cc
+++ b/remoting/protocol/auth_util.cc
@@ -26,9 +26,7 @@ std::string GenerateSupportAuthToken(const std::string& jid,
const std::string& access_code) {
std::string sha256 = crypto::SHA256HashString(jid + " " + access_code);
std::string sha256_base64;
- if (!base::Base64Encode(sha256, &sha256_base64)) {
- LOG(FATAL) << "Failed to encode auth token";
- }
+ base::Base64Encode(sha256, &sha256_base64);
return sha256_base64;
}
diff --git a/remoting/protocol/authenticator_test_base.cc b/remoting/protocol/authenticator_test_base.cc
index 8311476..25b0efe 100644
--- a/remoting/protocol/authenticator_test_base.cc
+++ b/remoting/protocol/authenticator_test_base.cc
@@ -53,7 +53,7 @@ void AuthenticatorTestBase::SetUp() {
std::string key_string;
ASSERT_TRUE(base::ReadFileToString(key_path, &key_string));
std::string key_base64;
- ASSERT_TRUE(base::Base64Encode(key_string, &key_base64));
+ base::Base64Encode(key_string, &key_base64);
key_pair_ = RsaKeyPair::FromString(key_base64);
ASSERT_TRUE(key_pair_.get());
host_public_key_ = key_pair_->GetPublicKey();
diff --git a/remoting/protocol/pairing_registry.cc b/remoting/protocol/pairing_registry.cc
index c159ce6..f1ce333 100644
--- a/remoting/protocol/pairing_registry.cc
+++ b/remoting/protocol/pairing_registry.cc
@@ -49,10 +49,8 @@ PairingRegistry::Pairing PairingRegistry::Pairing::Create(
std::string shared_secret;
char buffer[kKeySize];
crypto::RandBytes(buffer, arraysize(buffer));
- if (!base::Base64Encode(base::StringPiece(buffer, arraysize(buffer)),
- &shared_secret)) {
- LOG(FATAL) << "Base64Encode failed.";
- }
+ base::Base64Encode(base::StringPiece(buffer, arraysize(buffer)),
+ &shared_secret);
return Pairing(created_time, client_name, client_id, shared_secret);
}
diff --git a/remoting/protocol/v2_authenticator.cc b/remoting/protocol/v2_authenticator.cc
index 80f7af3..ee5c9d1 100644
--- a/remoting/protocol/v2_authenticator.cc
+++ b/remoting/protocol/v2_authenticator.cc
@@ -156,10 +156,7 @@ scoped_ptr<buzz::XmlElement> V2Authenticator::GetNextMessage() {
while (!pending_messages_.empty()) {
const std::string& spake_message = pending_messages_.front();
std::string base64_message;
- if (!base::Base64Encode(spake_message, &base64_message)) {
- LOG(DFATAL) << "Cannot perform base64 encode on certificate";
- continue;
- }
+ base::Base64Encode(spake_message, &base64_message);
buzz::XmlElement* eke_tag = new buzz::XmlElement(kEkeTag);
eke_tag->SetBodyText(base64_message);
@@ -171,9 +168,7 @@ scoped_ptr<buzz::XmlElement> V2Authenticator::GetNextMessage() {
if (!local_cert_.empty() && !certificate_sent_) {
buzz::XmlElement* certificate_tag = new buzz::XmlElement(kCertificateTag);
std::string base64_cert;
- if (!base::Base64Encode(local_cert_, &base64_cert)) {
- LOG(DFATAL) << "Cannot perform base64 encode on certificate";
- }
+ base::Base64Encode(local_cert_, &base64_cert);
certificate_tag->SetBodyText(base64_cert);
message->AddElement(certificate_tag);
certificate_sent_ = true;
diff --git a/sync/internal_api/public/base/unique_position_unittest.cc b/sync/internal_api/public/base/unique_position_unittest.cc
index 371874a..4c0a660 100644
--- a/sync/internal_api/public/base/unique_position_unittest.cc
+++ b/sync/internal_api/public/base/unique_position_unittest.cc
@@ -392,7 +392,7 @@ class SuffixGenerator {
// random anyway.
std::string input = cache_guid_ + base::Int64ToString(next_id_--);
std::string output;
- CHECK(base::Base64Encode(base::SHA1HashString(input), &output));
+ base::Base64Encode(base::SHA1HashString(input), &output);
return output;
}
diff --git a/sync/internal_api/sync_encryption_handler_impl.cc b/sync/internal_api/sync_encryption_handler_impl.cc
index e468e6c..34bf0335 100644
--- a/sync/internal_api/sync_encryption_handler_impl.cc
+++ b/sync/internal_api/sync_encryption_handler_impl.cc
@@ -692,8 +692,7 @@ bool SyncEncryptionHandlerImpl::SetKeystoreKeys(
// Note: in order to Pack the keys, they must all be base64 encoded (else
// JSON serialization fails).
- if (!base::Base64Encode(raw_keystore_key, &keystore_key_))
- return false;
+ base::Base64Encode(raw_keystore_key, &keystore_key_);
// Go through and save the old keystore keys. We always persist all keystore
// keys the server sends us.
diff --git a/sync/protocol/proto_value_conversions.cc b/sync/protocol/proto_value_conversions.cc
index 0217c5c..cdb999e 100644
--- a/sync/protocol/proto_value_conversions.cc
+++ b/sync/protocol/proto_value_conversions.cc
@@ -54,9 +54,7 @@ base::StringValue* MakeInt64Value(int64 x) {
// that instead of a StringValue.
base::StringValue* MakeBytesValue(const std::string& bytes) {
std::string bytes_base64;
- if (!base::Base64Encode(bytes, &bytes_base64)) {
- NOTREACHED();
- }
+ base::Base64Encode(bytes, &bytes_base64);
return new base::StringValue(bytes_base64);
}
diff --git a/sync/syncable/syncable_util.cc b/sync/syncable/syncable_util.cc
index 74ae06a..d92aa47 100644
--- a/sync/syncable/syncable_util.cc
+++ b/sync/syncable/syncable_util.cc
@@ -101,7 +101,7 @@ std::string GenerateSyncableHash(
hash_input.append(client_tag);
std::string encode_output;
- CHECK(base::Base64Encode(base::SHA1HashString(hash_input), &encode_output));
+ base::Base64Encode(base::SHA1HashString(hash_input), &encode_output);
return encode_output;
}
diff --git a/sync/test/fake_encryptor.cc b/sync/test/fake_encryptor.cc
index 2a1b58c..1d53ea1 100644
--- a/sync/test/fake_encryptor.cc
+++ b/sync/test/fake_encryptor.cc
@@ -12,7 +12,8 @@ FakeEncryptor::~FakeEncryptor() {}
bool FakeEncryptor::EncryptString(const std::string& plaintext,
std::string* ciphertext) {
- return base::Base64Encode(plaintext, ciphertext);
+ base::Base64Encode(plaintext, ciphertext);
+ return true;
}
bool FakeEncryptor::DecryptString(const std::string& ciphertext,
diff --git a/sync/tools/null_invalidation_state_tracker.cc b/sync/tools/null_invalidation_state_tracker.cc
index ff21a6f..6823759 100644
--- a/sync/tools/null_invalidation_state_tracker.cc
+++ b/sync/tools/null_invalidation_state_tracker.cc
@@ -38,7 +38,7 @@ std::string NullInvalidationStateTracker::GetBootstrapData() const {
void NullInvalidationStateTracker::SetBootstrapData(const std::string& data) {
std::string base64_data;
- CHECK(base::Base64Encode(data, &base64_data));
+ base::Base64Encode(data, &base64_data);
LOG(INFO) << "Setting bootstrap data to: " << base64_data;
}
diff --git a/sync/util/cryptographer.cc b/sync/util/cryptographer.cc
index 0fed51e..29f3781 100644
--- a/sync/util/cryptographer.cc
+++ b/sync/util/cryptographer.cc
@@ -261,10 +261,8 @@ bool Cryptographer::GetBootstrapToken(std::string* token) const {
return false;
}
- if (!base::Base64Encode(encrypted_token, token)) {
- NOTREACHED();
- return false;
- }
+ base::Base64Encode(encrypted_token, token);
+
return true;
}
diff --git a/sync/util/nigori.cc b/sync/util/nigori.cc
index b0158f3..e74d81a91 100644
--- a/sync/util/nigori.cc
+++ b/sync/util/nigori.cc
@@ -150,7 +150,8 @@ bool Nigori::Permute(Type type, const std::string& name,
output.assign(ciphertext);
output.append(hash.begin(), hash.end());
- return Base64Encode(output, permuted);
+ Base64Encode(output, permuted);
+ return true;
}
// Enc[Kenc,Kmac](value)
@@ -186,7 +187,8 @@ bool Nigori::Encrypt(const std::string& value, std::string* encrypted) const {
output.append(ciphertext);
output.append(hash.begin(), hash.end());
- return Base64Encode(output, encrypted);
+ Base64Encode(output, encrypted);
+ return true;
}
bool Nigori::Decrypt(const std::string& encrypted, std::string* value) const {