Avoid two-arg base::HexEncode() and RandBytes() calls.
Force the compiler to deduce the correct size, thus vastly simplifying the code. -- fix else-after-return as noticed. Change-Id: I50a5c3387e0ec7693e1d9a4f72f03e2a980e01da Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5241357 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: danakj <danakj@chromium.org> Owners-Override: danakj <danakj@chromium.org> Cr-Commit-Position: refs/heads/main@{#1254884}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
268d673d53
commit
80e9e6e546
ash
components
quick_pair
common
fast_pair
repository
chrome
browser
android
history_report
ash
arc
enterprise
cert_store
attestation
bruschetta
crosapi
net
dns_over_https
policy
enrollment
settings
smb_client
component_updater
device_api
download
extensions
nearby_sharing
printing
safe_browsing
download_protection
ui
installer
services
file_util
test
chromedriver
updater
chromecast/media/cma/pipeline
chromeos
ash
components
dbus
fwupd
login
auth
challenge_response
network
report
utils
sync_wifi
services
components
onc
printing
components
autofill
core
browser
data_model
client_update_protocol
crx_file
device_signals
core
system_signals
download
invalidation
public
metrics
optimization_guide
password_manager
core
browser
leak_detection
policy
core
pwg_encoder
safe_browsing
sync
viz
service
display_embedder
webcrypto
algorithms
content/browser
crypto
device
extensions/browser/api/networking_private
google_apis/gcm/engine
ios/chrome/browser/credential_provider/model
media
base
capture
video
chromeos
cdm
filters
midi
net
cert
http
quic
crypto
test
tools
cert_verify_tool
root_store_tool
sandbox
services
cert_verifier
network
shared_dictionary
preferences
tracked
resource_coordinator
public
cpp
memory_instrumentation
third_party/blink/common/unique_name
@ -60,9 +60,9 @@ constexpr int kClassify8GbDeviceInKb = 7500000;
|
||||
constexpr int kClassify16GbDeviceInKb = 15500000;
|
||||
|
||||
std::string GenerateRandomToken() {
|
||||
char random_bytes[16];
|
||||
base::RandBytes(random_bytes, 16);
|
||||
return base::HexEncode(random_bytes, 16);
|
||||
uint8_t random_bytes[16];
|
||||
base::RandBytes(random_bytes);
|
||||
return base::HexEncode(random_bytes);
|
||||
}
|
||||
|
||||
// Waits until |raw_socket_fd| is readable.
|
||||
|
@ -41,8 +41,7 @@ std::string GenerateFakeSerialNumber(std::string_view chromeos_user,
|
||||
std::string input(chromeos_user);
|
||||
input.append(salt.begin(), salt.end());
|
||||
const std::string hash(crypto::SHA256HashString(input));
|
||||
return base::HexEncode(hash.data(), hash.length())
|
||||
.substr(0, kMaxHardwareIdLen);
|
||||
return base::HexEncode(hash).substr(0, kMaxHardwareIdLen);
|
||||
}
|
||||
|
||||
std::string GetOrCreateSerialNumber(PrefService* local_state,
|
||||
@ -59,14 +58,13 @@ std::string GetOrCreateSerialNumber(PrefService* local_state,
|
||||
if (arc_salt_on_disk.empty()) {
|
||||
// The device doesn't have the salt file for ARC container. Create it from
|
||||
// scratch in the same way as ARC container.
|
||||
char rand_value[kArcSaltFileSize];
|
||||
crypto::RandBytes(rand_value, kArcSaltFileSize);
|
||||
hex_salt = base::HexEncode(rand_value, kArcSaltFileSize);
|
||||
uint8_t rand_value[kArcSaltFileSize];
|
||||
crypto::RandBytes(rand_value);
|
||||
hex_salt = base::HexEncode(rand_value);
|
||||
} else {
|
||||
// The device has the one for container. Reuse it for ARCVM.
|
||||
DCHECK_EQ(kArcSaltFileSize, arc_salt_on_disk.size());
|
||||
hex_salt =
|
||||
base::HexEncode(arc_salt_on_disk.data(), arc_salt_on_disk.size());
|
||||
hex_salt = base::HexEncode(arc_salt_on_disk);
|
||||
}
|
||||
local_state->SetString(prefs::kArcSerialNumberSalt, hex_salt);
|
||||
}
|
||||
|
@ -134,8 +134,7 @@ TEST_F(SerialNumberUtilTest, GetOrCreateSerialNumber) {
|
||||
// in local state.
|
||||
using std::literals::string_literals::operator""s;
|
||||
const std::string salt_on_disk = "BAADDECAFC0\0FFEE"s;
|
||||
const std::string salt_on_disk_hex =
|
||||
base::HexEncode(salt_on_disk.data(), salt_on_disk.size());
|
||||
const std::string salt_on_disk_hex = base::HexEncode(salt_on_disk);
|
||||
const std::string serialno_4 =
|
||||
GetOrCreateSerialNumber(test_local_state(), chromeos_user, salt_on_disk);
|
||||
EXPECT_FALSE(serialno_4.empty());
|
||||
@ -223,8 +222,7 @@ TEST_F(SerialNumberUtilTest, GetOrCreateSerialNumber_SerialNumberComputation) {
|
||||
const std::string chromeos_user = "user@gmail.com";
|
||||
|
||||
// Set the |hex_salt| in local state.
|
||||
const std::string hex_salt =
|
||||
base::HexEncode(std::string(kSaltLen, 'x').data(), kSaltLen);
|
||||
const std::string hex_salt = base::HexEncode(std::string(kSaltLen, 'x'));
|
||||
test_local_state()->SetString(prefs::kArcSerialNumberSalt, hex_salt);
|
||||
|
||||
// Get a serial number based on the hex salt.
|
||||
|
@ -57,31 +57,33 @@ bool HasModelId(const std::vector<uint8_t>* service_data) {
|
||||
|
||||
std::optional<std::string> GetHexModelIdFromServiceData(
|
||||
const std::vector<uint8_t>* service_data) {
|
||||
if (service_data == nullptr || service_data->size() < kMinModelIdLength)
|
||||
if (service_data == nullptr || service_data->size() < kMinModelIdLength) {
|
||||
return std::nullopt;
|
||||
else if (service_data->size() == kMinModelIdLength)
|
||||
// If the size is 3, all the bytes are the ID,
|
||||
return base::HexEncode(service_data->data(), kMinModelIdLength);
|
||||
else {
|
||||
// Otherwise, the first byte is a header which contains the length of the
|
||||
// big-endian model ID that follows. The model ID will be trimmed if it
|
||||
// contains leading zeros.
|
||||
int id_index = 1;
|
||||
int end = id_index + GetIdLength(service_data);
|
||||
|
||||
// Ignore leading zeros.
|
||||
while ((*service_data)[id_index] == 0 && end - id_index > kMinModelIdLength)
|
||||
id_index++;
|
||||
|
||||
// Copy appropriate bytes to new array.
|
||||
int bytes_size = end - id_index;
|
||||
uint8_t bytes[bytes_size];
|
||||
|
||||
for (int i = 0; i < bytes_size; i++)
|
||||
bytes[i] = (*service_data)[i + id_index];
|
||||
|
||||
return base::HexEncode(bytes, bytes_size);
|
||||
}
|
||||
if (service_data->size() == kMinModelIdLength) {
|
||||
// If the size is 3, all the bytes are the ID,
|
||||
return base::HexEncode(*service_data);
|
||||
}
|
||||
// Otherwise, the first byte is a header which contains the length of the
|
||||
// big-endian model ID that follows. The model ID will be trimmed if it
|
||||
// contains leading zeros.
|
||||
int id_index = 1;
|
||||
int end = id_index + GetIdLength(service_data);
|
||||
|
||||
// Ignore leading zeros.
|
||||
while ((*service_data)[id_index] == 0 && end - id_index > kMinModelIdLength) {
|
||||
id_index++;
|
||||
}
|
||||
|
||||
// Copy appropriate bytes to new array.
|
||||
int bytes_size = end - id_index;
|
||||
uint8_t bytes[bytes_size];
|
||||
|
||||
for (int i = 0; i < bytes_size; i++) {
|
||||
bytes[i] = (*service_data)[i + id_index];
|
||||
}
|
||||
|
||||
return base::HexEncode(bytes, bytes_size);
|
||||
}
|
||||
|
||||
} // namespace fast_pair_decoder
|
||||
|
@ -118,9 +118,7 @@ void FakeFastPairRepository::DeleteAssociatedDeviceByAccountKey(
|
||||
DeleteAssociatedDeviceByAccountKeyCallback callback) {
|
||||
for (auto it = devices_.begin(); it != devices_.end(); it++) {
|
||||
if (it->has_account_key() &&
|
||||
base::HexEncode(std::vector<uint8_t>(it->account_key().begin(),
|
||||
it->account_key().end())) ==
|
||||
base::HexEncode(account_key)) {
|
||||
base::HexEncode(it->account_key()) == base::HexEncode(account_key)) {
|
||||
devices_.erase(it);
|
||||
std::move(callback).Run(/*success=*/true);
|
||||
return;
|
||||
|
@ -781,8 +781,7 @@ void FastPairRepositoryImpl::RetryPendingDeletes(
|
||||
DCHECK(device.has_account_key());
|
||||
|
||||
const std::string saved_account_key =
|
||||
base::HexEncode(std::vector<uint8_t>(device.account_key().begin(),
|
||||
device.account_key().end()));
|
||||
base::HexEncode(device.account_key());
|
||||
found_in_saved_devices =
|
||||
saved_account_key == pending_delete.hex_account_key;
|
||||
if (found_in_saved_devices) {
|
||||
|
@ -97,7 +97,7 @@ std::string DeltaFileEntryWithData::UrlToId(const std::string& url) {
|
||||
// 2. SHA-256 of URL.
|
||||
uint8_t hash[kSHA256ByteSize];
|
||||
crypto::SHA256HashString(url, hash, sizeof(hash));
|
||||
id << base::HexEncode(hash, sizeof(hash));
|
||||
id << base::HexEncode(hash);
|
||||
|
||||
// 3. Prefix of URL to fill rest of the space.
|
||||
id << url.substr(0, kIdLengthLimit - 2 * kSHA256ByteSize - kUrlLengthWidth);
|
||||
|
@ -602,8 +602,7 @@ void CertStoreServiceTest::CheckInstalledCerts(
|
||||
std::string cert_id = installer_->cert_ids()[cert_name];
|
||||
// Check CKA_ID and slot.
|
||||
int slot_id;
|
||||
std::string hex_encoded_id =
|
||||
base::HexEncode(cert_id.data(), cert_id.size());
|
||||
std::string hex_encoded_id = base::HexEncode(cert_id);
|
||||
EXPECT_EQ(hex_encoded_id,
|
||||
ash::NetworkCertLoader::GetPkcs11IdAndSlotForCert(
|
||||
nss_cert.get(), &slot_id));
|
||||
|
@ -186,8 +186,8 @@ void EnrollmentIdUploadManager::RescheduleGetEnrollmentId() {
|
||||
void EnrollmentIdUploadManager::OnUploadComplete(
|
||||
const std::string& enrollment_id,
|
||||
policy::CloudPolicyClient::Result result) {
|
||||
const std::string& printable_enrollment_id = base::ToLowerASCII(
|
||||
base::HexEncode(enrollment_id.data(), enrollment_id.size()));
|
||||
const std::string printable_enrollment_id =
|
||||
base::ToLowerASCII(base::HexEncode(enrollment_id));
|
||||
|
||||
if (!result.IsSuccess()) {
|
||||
LOG(ERROR) << "Failed to upload Enrollment Identifier \""
|
||||
|
@ -84,10 +84,9 @@ std::string Sha256File(const base::FilePath& path) {
|
||||
ctx->Update(buffer, count);
|
||||
}
|
||||
|
||||
char digest_bytes[crypto::kSHA256Length];
|
||||
uint8_t digest_bytes[crypto::kSHA256Length];
|
||||
ctx->Finish(digest_bytes, crypto::kSHA256Length);
|
||||
|
||||
return base::HexEncode(digest_bytes, crypto::kSHA256Length);
|
||||
return base::HexEncode(digest_bytes);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -481,7 +481,7 @@ std::string VpnServiceForExtensionAsh::GetKey(
|
||||
const std::string& configuration_name) {
|
||||
const std::string key =
|
||||
crypto::SHA256HashString(extension_id + configuration_name);
|
||||
return base::HexEncode(key.data(), key.size());
|
||||
return base::HexEncode(key);
|
||||
}
|
||||
|
||||
VpnServiceForExtensionAsh::VpnConfiguration*
|
||||
|
@ -71,8 +71,7 @@ std::string FormatVariable(const std::string& input,
|
||||
if (!hash_variable) {
|
||||
return "${" + input + "}";
|
||||
}
|
||||
std::string hash = crypto::SHA256HashString(salt + input);
|
||||
return base::HexEncode(hash);
|
||||
return base::HexEncode(crypto::SHA256HashString(salt + input));
|
||||
}
|
||||
|
||||
// Returns a copy of `template` where the identifier placeholders are replaced
|
||||
|
@ -56,8 +56,7 @@ RlwePlaintextId ConstructPlainttextId(const std::string& rlz_brand_code,
|
||||
const std::string& serial_number) {
|
||||
RlwePlaintextId rlwe_id;
|
||||
// See http://shortn/_tkT6f7xV0F for format specification.
|
||||
const std::string rlz_brand_code_hex =
|
||||
base::HexEncode(rlz_brand_code.data(), rlz_brand_code.size());
|
||||
const std::string rlz_brand_code_hex = base::HexEncode(rlz_brand_code);
|
||||
const std::string id = rlz_brand_code_hex + "/" + serial_number;
|
||||
// The PSM client library, which consumes this proto, will hash non-sensitive
|
||||
// identifier and truncate to a few bits before sending it to the server,
|
||||
|
@ -70,9 +70,8 @@ std::string CryptohomeTokenEncryptor::EncryptWithSystemSalt(
|
||||
|
||||
// Return a concatenation of the nonce (counter) and the encrypted data, both
|
||||
// hex-encoded.
|
||||
return base::ToLowerASCII(
|
||||
base::HexEncode(nonce) +
|
||||
base::HexEncode(encoded_token.data(), encoded_token.size()));
|
||||
return base::ToLowerASCII(base::HexEncode(nonce) +
|
||||
base::HexEncode(encoded_token));
|
||||
}
|
||||
|
||||
std::string CryptohomeTokenEncryptor::DecryptWithSystemSalt(
|
||||
@ -150,8 +149,7 @@ std::string CryptohomeTokenEncryptor::WeakEncryptWithSystemSalt(
|
||||
return std::string();
|
||||
}
|
||||
|
||||
return base::ToLowerASCII(
|
||||
base::HexEncode(encoded_token.data(), encoded_token.size()));
|
||||
return base::ToLowerASCII(base::HexEncode(encoded_token));
|
||||
}
|
||||
|
||||
std::string CryptohomeTokenEncryptor::WeakDecryptWithSystemSalt(
|
||||
|
@ -36,11 +36,11 @@ std::vector<std::string> GetComponents(const std::string& file_system_id) {
|
||||
}
|
||||
|
||||
std::string GenerateRandomId() {
|
||||
char rand_bytes[kRandomIdBytes];
|
||||
base::RandBytes(rand_bytes, sizeof(rand_bytes));
|
||||
uint8_t rand_bytes[kRandomIdBytes];
|
||||
base::RandBytes(rand_bytes);
|
||||
// Encoding to hex ensure that there are no non-alpha characters in the id
|
||||
// (i.e. no @ delimiters).
|
||||
return base::HexEncode(rand_bytes, sizeof(rand_bytes));
|
||||
return base::HexEncode(rand_bytes);
|
||||
}
|
||||
|
||||
} // namespace.
|
||||
|
@ -61,7 +61,7 @@ std::string HashUsername(const std::string& username) {
|
||||
std::vector<uint8_t> data;
|
||||
base::ranges::copy(lowercase, std::back_inserter(data));
|
||||
base::SHA1HashBytes(data.data(), data.size(), binmd);
|
||||
std::string result = base::HexEncode(binmd, sizeof(binmd));
|
||||
std::string result = base::HexEncode(binmd);
|
||||
// Stay compatible with CryptoLib::HexEncodeToBuffer()
|
||||
base::ranges::transform(result, result.begin(), ::tolower);
|
||||
return result;
|
||||
|
@ -65,8 +65,7 @@ constexpr net::NetworkTrafficAnnotationTag kTrafficAnnotation =
|
||||
// Converts url::Origin into the key that can be used for filenames/dictionary
|
||||
// keys.
|
||||
std::string GetOriginEncoded(const url::Origin& origin) {
|
||||
std::string serialized = origin.Serialize();
|
||||
return base::HexEncode(serialized.data(), serialized.size());
|
||||
return base::HexEncode(origin.Serialize());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -410,9 +410,9 @@ void MaybeReportDangerousDownloadBlocked(
|
||||
}
|
||||
router->OnDangerousDownloadEvent(
|
||||
download->GetURL(), download->GetTabUrl(), download_path,
|
||||
base::HexEncode(raw_digest_sha256.data(), raw_digest_sha256.size()),
|
||||
danger_type, download->GetMimeType(), /*scan_id*/ "",
|
||||
download->GetTotalBytes(), safe_browsing::EventResult::BLOCKED);
|
||||
base::HexEncode(raw_digest_sha256), danger_type,
|
||||
download->GetMimeType(), /*scan_id*/ "", download->GetTotalBytes(),
|
||||
safe_browsing::EventResult::BLOCKED);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -165,10 +165,10 @@ std::string GetPageTextContent(content::WebContents* web_contents) {
|
||||
}
|
||||
|
||||
std::string GetCertFingerprint1(const net::X509Certificate& cert) {
|
||||
unsigned char hash[base::kSHA1Length];
|
||||
uint8_t hash[base::kSHA1Length];
|
||||
base::SHA1HashBytes(CRYPTO_BUFFER_data(cert.cert_buffer()),
|
||||
CRYPTO_BUFFER_len(cert.cert_buffer()), hash);
|
||||
return base::ToLowerASCII(base::HexEncode(hash, base::kSHA1Length));
|
||||
return base::ToLowerASCII(base::HexEncode(hash));
|
||||
}
|
||||
|
||||
// Generates a gtest failure whenever extension JS reports failure.
|
||||
|
@ -86,8 +86,7 @@ class LocalExtensionCacheTest : public testing::Test {
|
||||
hash->Update(data.c_str(), size);
|
||||
uint8_t output[crypto::kSHA256Length];
|
||||
hash->Finish(output, sizeof(output));
|
||||
const std::string hex_hash =
|
||||
base::ToLowerASCII(base::HexEncode(output, sizeof(output)));
|
||||
const std::string hex_hash = base::ToLowerASCII(base::HexEncode(output));
|
||||
|
||||
const base::FilePath file =
|
||||
GetExtensionFileName(dir, id, version, hex_hash);
|
||||
|
@ -86,10 +86,9 @@ std::optional<nearby_share::mojom::TransferStatus> GetTransferStatus(
|
||||
}
|
||||
|
||||
std::string GetDeviceIdForLogs(const ShareTarget& share_target) {
|
||||
return (share_target.device_id
|
||||
? base::HexEncode(share_target.device_id.value().data(),
|
||||
share_target.device_id.value().size())
|
||||
: "[null]");
|
||||
return share_target.device_id
|
||||
? base::HexEncode(share_target.device_id.value())
|
||||
: "[null]";
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -55,10 +55,9 @@ void GetPdfData(const char* file_name,
|
||||
}
|
||||
|
||||
std::string HashData(const char* data, size_t len) {
|
||||
char hash[base::kSHA1Length];
|
||||
base::SHA1HashBytes(reinterpret_cast<const unsigned char*>(data), len,
|
||||
reinterpret_cast<unsigned char*>(hash));
|
||||
return base::HexEncode(hash, base::kSHA1Length);
|
||||
uint8_t hash[base::kSHA1Length];
|
||||
base::SHA1HashBytes(reinterpret_cast<const uint8_t*>(data), len, hash);
|
||||
return base::HexEncode(hash);
|
||||
}
|
||||
|
||||
void ComparePwgOutput(const base::FilePath& expected_file,
|
||||
|
@ -446,9 +446,7 @@ void DeepScanningRequest::StartSingleFileScan() {
|
||||
weak_ptr_factory_.GetWeakPtr(), item_->GetFullPath()));
|
||||
request->set_filename(item_->GetTargetFilePath().AsUTF8Unsafe());
|
||||
|
||||
std::string raw_digest_sha256 = item_->GetHash();
|
||||
std::string sha256 =
|
||||
base::HexEncode(raw_digest_sha256.data(), raw_digest_sha256.size());
|
||||
std::string sha256 = base::HexEncode(item_->GetHash());
|
||||
request->set_digest(sha256);
|
||||
|
||||
if (password_) {
|
||||
|
@ -62,13 +62,12 @@ void MaybeReportDangerousDownloadWarning(download::DownloadItem* download) {
|
||||
if (!router)
|
||||
return;
|
||||
|
||||
std::string raw_digest_sha256 = download->GetHash();
|
||||
router->OnDangerousDownloadEvent(
|
||||
download->GetURL(), download->GetTabUrl(),
|
||||
download->GetTargetFilePath().AsUTF8Unsafe(),
|
||||
base::HexEncode(raw_digest_sha256.data(), raw_digest_sha256.size()),
|
||||
download->GetDangerType(), download->GetMimeType(), /*scan_id*/ "",
|
||||
download->GetTotalBytes(), EventResult::WARNED);
|
||||
base::HexEncode(download->GetHash()), download->GetDangerType(),
|
||||
download->GetMimeType(), /*scan_id*/ "", download->GetTotalBytes(),
|
||||
EventResult::WARNED);
|
||||
}
|
||||
|
||||
void ReportDangerousDownloadWarningBypassed(
|
||||
@ -96,12 +95,11 @@ void ReportDangerousDownloadWarningBypassed(
|
||||
metadata.scan_response.request_token(), metadata.size);
|
||||
}
|
||||
} else {
|
||||
std::string raw_digest_sha256 = download->GetHash();
|
||||
router->OnDangerousDownloadWarningBypassed(
|
||||
download->GetURL(), download->GetTabUrl(),
|
||||
download->GetTargetFilePath().AsUTF8Unsafe(),
|
||||
base::HexEncode(raw_digest_sha256.data(), raw_digest_sha256.size()),
|
||||
original_danger_type, download->GetMimeType(),
|
||||
base::HexEncode(download->GetHash()), original_danger_type,
|
||||
download->GetMimeType(),
|
||||
/*scan_id*/ "", download->GetTotalBytes());
|
||||
}
|
||||
}
|
||||
@ -127,12 +125,10 @@ void ReportAnalysisConnectorWarningBypassed(download::DownloadItem* download) {
|
||||
stored_result->user_justification);
|
||||
}
|
||||
} else {
|
||||
std::string raw_digest_sha256 = download->GetHash();
|
||||
ReportAnalysisConnectorWarningBypass(
|
||||
profile, download->GetURL(), download->GetTabUrl(), "", "",
|
||||
download->GetTargetFilePath().AsUTF8Unsafe(),
|
||||
base::HexEncode(raw_digest_sha256.data(), raw_digest_sha256.size()),
|
||||
download->GetMimeType(),
|
||||
base::HexEncode(download->GetHash()), download->GetMimeType(),
|
||||
extensions::SafeBrowsingPrivateEventRouter::kTriggerFileDownload, "",
|
||||
DeepScanAccessPoint::DOWNLOAD, download->GetTotalBytes(),
|
||||
enterprise_connectors::ContentAnalysisResponse(),
|
||||
|
@ -759,9 +759,8 @@ void DownloadProtectionService::OnDangerousDownloadOpened(
|
||||
router->OnDangerousDownloadOpened(
|
||||
item->GetURL(), item->GetTabUrl(),
|
||||
item->GetTargetFilePath().AsUTF8Unsafe(),
|
||||
base::HexEncode(raw_digest_sha256.data(), raw_digest_sha256.size()),
|
||||
item->GetMimeType(), /*scan_id*/ "", item->GetDangerType(),
|
||||
item->GetTotalBytes());
|
||||
base::HexEncode(raw_digest_sha256), item->GetMimeType(), /*scan_id*/ "",
|
||||
item->GetDangerType(), item->GetTotalBytes());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3243,7 +3243,7 @@ TEST_F(DownloadProtectionServiceTest, VerifyDangerousDownloadOpenedAPICall) {
|
||||
const auto captured_args =
|
||||
std::move(event_observer.PassEventArgs().GetList()[0].GetDict());
|
||||
EXPECT_EQ("http://example.com/a.exe", *captured_args.FindString("url"));
|
||||
EXPECT_EQ(base::HexEncode(hash.data(), hash.size()),
|
||||
EXPECT_EQ(base::HexEncode(hash),
|
||||
*captured_args.FindString("downloadDigestSha256"));
|
||||
EXPECT_EQ(target_path.MaybeAsASCII(), *captured_args.FindString("fileName"));
|
||||
|
||||
|
@ -674,7 +674,7 @@ TEST_F(DownloadRequestMakerTest, UsesPassword) {
|
||||
ASSERT_EQ(request_future.Get()->archived_binary_size(), 1);
|
||||
std::string sha256 =
|
||||
request_future.Get()->archived_binary(0).digests().sha256();
|
||||
EXPECT_EQ(base::HexEncode(sha256.data(), sha256.size()),
|
||||
EXPECT_EQ(base::HexEncode(sha256),
|
||||
"E11FFA0C9F25234453A9EDD1CB251D46107F34B536AD74642A8584ACA8C1A8CE");
|
||||
}
|
||||
|
||||
|
@ -112,8 +112,7 @@ void DownloadUrlSBClient::CheckDone(SBThreatType threat_type) {
|
||||
void DownloadUrlSBClient::ReportMalware(SBThreatType threat_type) {
|
||||
std::string post_data;
|
||||
if (!sha256_hash_.empty()) {
|
||||
post_data +=
|
||||
base::HexEncode(sha256_hash_.data(), sha256_hash_.size()) + "\n";
|
||||
post_data += base::HexEncode(sha256_hash_) + "\n";
|
||||
}
|
||||
for (size_t i = 0; i < url_chain_.size(); ++i) {
|
||||
post_data += url_chain_[i].spec() + "\n";
|
||||
|
@ -113,7 +113,7 @@ std::string HashWallpaperFilesIdStr(const std::string& files_id_unhashed) {
|
||||
std::vector<uint8_t> data = *salt;
|
||||
base::ranges::copy(files_id_unhashed, std::back_inserter(data));
|
||||
base::SHA1HashBytes(data.data(), data.size(), binmd);
|
||||
std::string result = base::HexEncode(binmd, sizeof(binmd));
|
||||
std::string result = base::HexEncode(binmd);
|
||||
base::ranges::transform(result, result.begin(), ::tolower);
|
||||
return result;
|
||||
}
|
||||
|
@ -674,9 +674,8 @@ class HotspotConfigMessageHandler : public content::WebUIMessageHandler {
|
||||
const std::string* ssid =
|
||||
value->GetDict().FindString(shill::kTetheringConfSSIDProperty);
|
||||
if (ssid) {
|
||||
value->GetDict().Set(
|
||||
shill::kTetheringConfSSIDProperty,
|
||||
base::Value(base::HexEncode(ssid->c_str(), ssid->size())));
|
||||
value->GetDict().Set(shill::kTetheringConfSSIDProperty,
|
||||
base::Value(base::HexEncode(*ssid)));
|
||||
}
|
||||
|
||||
ShillManagerClient::Get()->SetProperty(
|
||||
|
@ -44,8 +44,7 @@ std::wstring GetAutoLaunchKeyName() {
|
||||
uint8_t hash[16];
|
||||
crypto::SHA256HashString(input, hash, std::size(hash));
|
||||
return base::StrCat(
|
||||
{kAutolaunchKeyValue, L"_",
|
||||
base::ASCIIToWide(base::HexEncode(hash, std::size(hash)))});
|
||||
{kAutolaunchKeyValue, L"_", base::ASCIIToWide(base::HexEncode(hash))});
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -29,7 +29,7 @@ std::string GetRandomFilename() {
|
||||
EXPECT_NE(FALSE, CryptReleaseContext(crypt_ctx, 0));
|
||||
|
||||
// Hexify the value.
|
||||
std::string result(base::HexEncode(&data[0], std::size(data)));
|
||||
std::string result = base::HexEncode(data);
|
||||
EXPECT_EQ(8u, result.size());
|
||||
|
||||
// Replace the first digit with the letter 'R' (for "random", get it?).
|
||||
|
@ -23,10 +23,6 @@ namespace {
|
||||
|
||||
using ::testing::_;
|
||||
|
||||
std::string ToHex(const std::string& s) {
|
||||
return base::HexEncode(s.data(), s.size());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
class SandboxedSevenZipAnalyzerTest : public ::testing::Test {
|
||||
@ -117,7 +113,7 @@ TEST_F(SandboxedSevenZipAnalyzerTest, OneBinary) {
|
||||
EXPECT_EQ(ClientDownloadRequest::WIN_EXECUTABLE,
|
||||
results.archived_binary[0].download_type());
|
||||
EXPECT_EQ("B32E028F9B83C5FFB806CA7DFE7A3ECE5F1AED5A0368B0A140B35A67F5B000B3",
|
||||
ToHex(results.archived_binary[0].digests().sha256()));
|
||||
base::HexEncode(results.archived_binary[0].digests().sha256()));
|
||||
EXPECT_EQ(19, results.archived_binary[0].length());
|
||||
EXPECT_FALSE(results.archived_binary[0].is_encrypted());
|
||||
EXPECT_TRUE(results.archived_binary[0].is_executable());
|
||||
@ -139,7 +135,7 @@ TEST_F(SandboxedSevenZipAnalyzerTest, TwoBinariesAndFolder) {
|
||||
EXPECT_EQ(ClientDownloadRequest::WIN_EXECUTABLE,
|
||||
results.archived_binary[0].download_type());
|
||||
EXPECT_EQ("E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855",
|
||||
ToHex(results.archived_binary[0].digests().sha256()));
|
||||
base::HexEncode(results.archived_binary[0].digests().sha256()));
|
||||
EXPECT_EQ(0, results.archived_binary[0].length());
|
||||
EXPECT_FALSE(results.archived_binary[0].is_encrypted());
|
||||
EXPECT_FALSE(results.archived_binary[0].is_executable());
|
||||
@ -149,7 +145,7 @@ TEST_F(SandboxedSevenZipAnalyzerTest, TwoBinariesAndFolder) {
|
||||
EXPECT_EQ(ClientDownloadRequest::WIN_EXECUTABLE,
|
||||
results.archived_binary[1].download_type());
|
||||
EXPECT_EQ("B32E028F9B83C5FFB806CA7DFE7A3ECE5F1AED5A0368B0A140B35A67F5B000B3",
|
||||
ToHex(results.archived_binary[1].digests().sha256()));
|
||||
base::HexEncode(results.archived_binary[1].digests().sha256()));
|
||||
EXPECT_EQ(19, results.archived_binary[1].length());
|
||||
EXPECT_FALSE(results.archived_binary[1].is_encrypted());
|
||||
EXPECT_TRUE(results.archived_binary[1].is_executable());
|
||||
@ -159,7 +155,7 @@ TEST_F(SandboxedSevenZipAnalyzerTest, TwoBinariesAndFolder) {
|
||||
EXPECT_EQ(ClientDownloadRequest::WIN_EXECUTABLE,
|
||||
results.archived_binary[2].download_type());
|
||||
EXPECT_EQ("B32E028F9B83C5FFB806CA7DFE7A3ECE5F1AED5A0368B0A140B35A67F5B000B3",
|
||||
ToHex(results.archived_binary[2].digests().sha256()));
|
||||
base::HexEncode(results.archived_binary[2].digests().sha256()));
|
||||
EXPECT_EQ(19, results.archived_binary[2].length());
|
||||
EXPECT_FALSE(results.archived_binary[2].is_encrypted());
|
||||
EXPECT_TRUE(results.archived_binary[2].is_executable());
|
||||
@ -181,7 +177,7 @@ TEST_F(SandboxedSevenZipAnalyzerTest, NestedArchive) {
|
||||
EXPECT_EQ(ClientDownloadRequest::ARCHIVE,
|
||||
results.archived_binary[0].download_type());
|
||||
EXPECT_EQ("DFD138681A2BE04D4E97A4CF839C08042A1A9F7541B4DE0EDEC4422A4D881045",
|
||||
ToHex(results.archived_binary[0].digests().sha256()));
|
||||
base::HexEncode(results.archived_binary[0].digests().sha256()));
|
||||
EXPECT_EQ(10, results.archived_binary[0].length());
|
||||
EXPECT_FALSE(results.archived_binary[0].is_encrypted());
|
||||
EXPECT_FALSE(results.archived_binary[0].is_executable());
|
||||
|
@ -972,7 +972,7 @@ void ConvertHexadecimalToIDAlphabet(std::string& id) {
|
||||
std::string GenerateExtensionId(const std::string& input) {
|
||||
uint8_t hash[16];
|
||||
crypto::SHA256HashString(input, hash, sizeof(hash));
|
||||
std::string output = base::ToLowerASCII(base::HexEncode(hash, sizeof(hash)));
|
||||
std::string output = base::ToLowerASCII(base::HexEncode(hash));
|
||||
ConvertHexadecimalToIDAlphabet(output);
|
||||
return output;
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ std::string GetHashHex(const base::FilePath& file) {
|
||||
hasher->Update(mmfile.data(), mmfile.length());
|
||||
uint8_t actual_hash[crypto::kSHA256Length] = {0};
|
||||
hasher->Finish(actual_hash, sizeof(actual_hash));
|
||||
return base::HexEncode(actual_hash, sizeof(actual_hash));
|
||||
return base::HexEncode(actual_hash);
|
||||
}
|
||||
|
||||
std::string GetUpdateResponseForApp(
|
||||
|
@ -218,8 +218,7 @@ void AvPipelineImpl::ProcessPendingBuffer() {
|
||||
key_id, GetEncryptionScheme(pending_buffer_->stream_id()));
|
||||
if (!decrypt_context) {
|
||||
LOG(INFO) << "frame(pts=" << pending_buffer_->timestamp()
|
||||
<< "): waiting for key id "
|
||||
<< base::HexEncode(&key_id[0], key_id.size());
|
||||
<< "): waiting for key id " << base::HexEncode(key_id);
|
||||
if (!client_.waiting_cb.is_null())
|
||||
client_.waiting_cb.Run(::media::WaitingReason::kNoDecryptionKey);
|
||||
return;
|
||||
|
@ -48,8 +48,9 @@ std::string GetHexSSID(const base::Value::Dict& service_properties) {
|
||||
if (hex_ssid)
|
||||
return *hex_ssid;
|
||||
const std::string* ssid = service_properties.FindString(shill::kSSIDProperty);
|
||||
if (ssid)
|
||||
return base::HexEncode(ssid->c_str(), ssid->size());
|
||||
if (ssid) {
|
||||
return base::HexEncode(*ssid);
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
|
||||
|
@ -121,8 +121,8 @@ base::File VerifyChecksum(base::File file, const std::string& checksum) {
|
||||
|
||||
const std::string sha_contents = crypto::SHA256HashString(contents);
|
||||
|
||||
const std::string encoded_sha = base::ToLowerASCII(
|
||||
base::HexEncode(sha_contents.data(), sha_contents.size()));
|
||||
const std::string encoded_sha =
|
||||
base::ToLowerASCII(base::HexEncode(sha_contents));
|
||||
|
||||
if (encoded_sha != checksum) {
|
||||
LOG(ERROR) << "Wrong checksum, expected: " << checksum
|
||||
|
@ -22,8 +22,7 @@ constexpr char kKeyLabelPrefix[] = "challenge-response-";
|
||||
// label built this way is, practically, unique (short of a SHA-256 collision).
|
||||
std::string GenerateLabelSpkiPart(const std::string& public_key_spki_der) {
|
||||
DCHECK(!public_key_spki_der.empty());
|
||||
const std::string hash = crypto::SHA256HashString(public_key_spki_der);
|
||||
return base::HexEncode(hash.data(), hash.size());
|
||||
return base::HexEncode(crypto::SHA256HashString(public_key_spki_der));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -180,8 +180,7 @@ TEST_F(NetworkStateTest, SsidNonUtf8) {
|
||||
std::vector<uint8_t> non_utf8_ssid_bytes;
|
||||
non_utf8_ssid_bytes.push_back(static_cast<uint8_t>(non_utf8_ssid.data()[0]));
|
||||
|
||||
std::string wifi_hex =
|
||||
base::HexEncode(non_utf8_ssid.data(), non_utf8_ssid.size());
|
||||
std::string wifi_hex = base::HexEncode(non_utf8_ssid);
|
||||
EXPECT_TRUE(SetStringProperty(shill::kWifiHexSsid, wifi_hex));
|
||||
EXPECT_TRUE(SignalInitialPropertiesReceived());
|
||||
EXPECT_EQ(network_state_->raw_ssid(), non_utf8_ssid_bytes);
|
||||
|
@ -23,7 +23,7 @@ std::string GetDigestString(const std::string& key,
|
||||
if (!hmac.Init(key) || !hmac.Sign(message, &digest[0], digest.size())) {
|
||||
return std::string();
|
||||
}
|
||||
return base::HexEncode(&digest[0], digest.size());
|
||||
return base::HexEncode(digest);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -11,8 +11,7 @@
|
||||
namespace ash::sync_wifi {
|
||||
|
||||
NetworkIdentifier GeneratePskNetworkId(const std::string& ssid) {
|
||||
return NetworkIdentifier(base::HexEncode(ssid.data(), ssid.size()),
|
||||
shill::kSecurityClassPsk);
|
||||
return NetworkIdentifier(base::HexEncode(ssid), shill::kSecurityClassPsk);
|
||||
}
|
||||
|
||||
NetworkIdentifier GenerateInvalidPskNetworkId(const std::string& ssid) {
|
||||
|
@ -119,9 +119,7 @@ std::string BackgroundEidGenerator::IdentifyRemoteDeviceByAdvertisement(
|
||||
ss << "BackgroundEidGenerator::IdentifyRemoteDeviceByAdvertisement: "
|
||||
<< (success ? "Identified " : "Failed to identify ")
|
||||
<< "the following remote device from advertisement service data 0x"
|
||||
<< base::HexEncode(service_data_without_flags.data(),
|
||||
service_data_without_flags.size())
|
||||
<< ": "
|
||||
<< base::HexEncode(service_data_without_flags) << ": "
|
||||
<< "\n device_name: " << remote_device.name()
|
||||
<< "\n device_id: " << remote_device.GetDeviceId()
|
||||
<< "\n beacon seeds: ";
|
||||
|
@ -366,8 +366,8 @@ void BleScannerImpl::HandlePotentialScanResult(
|
||||
}
|
||||
|
||||
// Prepare a hex string of |service_data|.
|
||||
std::string hex_service_data = base::StrCat(
|
||||
{"0x", base::HexEncode(service_data.data(), service_data.size())});
|
||||
std::string hex_service_data =
|
||||
base::StrCat({"0x", base::HexEncode(service_data)});
|
||||
|
||||
if (results.empty()) {
|
||||
PA_LOG(WARNING) << "BleScannerImpl::HandleDeviceUpdated(): Received scan "
|
||||
|
@ -57,7 +57,7 @@ bool DataWithTimestamp::ContainsTime(const int64_t timestamp_ms) const {
|
||||
}
|
||||
|
||||
std::string DataWithTimestamp::DataInHex() const {
|
||||
return "0x" + base::HexEncode(data.data(), data.size());
|
||||
return "0x" + base::HexEncode(data);
|
||||
}
|
||||
|
||||
bool DataWithTimestamp::operator==(const DataWithTimestamp& other) const {
|
||||
|
@ -559,8 +559,7 @@ void FillInHexSSIDField(base::Value::Dict& wifi_fields) {
|
||||
NET_LOG(ERROR) << "Found empty SSID field.";
|
||||
return;
|
||||
}
|
||||
wifi_fields.Set(::onc::wifi::kHexSSID,
|
||||
base::HexEncode(ssid->c_str(), ssid->size()));
|
||||
wifi_fields.Set(::onc::wifi::kHexSSID, base::HexEncode(*ssid));
|
||||
}
|
||||
|
||||
void SetHiddenSSIDFieldInOncObject(const OncValueSignature& signature,
|
||||
|
@ -30,8 +30,7 @@ namespace {
|
||||
// Return the (full) path to the file we expect to find the given key at.
|
||||
base::FilePath FilePathForKey(const base::FilePath& base_dir,
|
||||
const std::string& key) {
|
||||
std::string hashed_key = crypto::SHA256HashString(key);
|
||||
return base_dir.Append(base::HexEncode(hashed_key.data(), hashed_key.size()));
|
||||
return base_dir.Append(base::HexEncode(crypto::SHA256HashString(key)));
|
||||
}
|
||||
|
||||
// If the cache doesn't already exist, create it.
|
||||
|
@ -1358,8 +1358,7 @@ std::ostream& operator<<(std::ostream& os, const CreditCard& credit_card) {
|
||||
return os << base::UTF16ToUTF8(credit_card.Label()) << " "
|
||||
<< (credit_card.record_type() == CreditCard::RecordType::kLocalCard
|
||||
? credit_card.guid()
|
||||
: base::HexEncode(credit_card.server_id().data(),
|
||||
credit_card.server_id().size()))
|
||||
: base::HexEncode(credit_card.server_id()))
|
||||
<< " " << credit_card.origin() << " "
|
||||
<< base::UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_NAME_FULL))
|
||||
<< " "
|
||||
|
@ -138,8 +138,7 @@ Ecdsa::RequestParameters Ecdsa::SignRequest(
|
||||
request_hash_ = SHA256HashStr(request_body);
|
||||
|
||||
// Return the query string for the user to send with the request.
|
||||
std::string request_hash_hex =
|
||||
base::HexEncode(&request_hash_.front(), request_hash_.size());
|
||||
std::string request_hash_hex = base::HexEncode(request_hash_);
|
||||
request_hash_hex = base::ToLowerASCII(request_hash_hex);
|
||||
|
||||
RequestParameters request_parameters;
|
||||
|
@ -142,8 +142,8 @@ VerifierResult VerifyCrx3(
|
||||
if (!signed_header_data.ParseFromString(signed_header_data_str))
|
||||
return VerifierResult::ERROR_HEADER_INVALID;
|
||||
const std::string& crx_id_encoded = signed_header_data.crx_id();
|
||||
const std::string declared_crx_id = id_util::GenerateIdFromHex(
|
||||
base::HexEncode(crx_id_encoded.data(), crx_id_encoded.size()));
|
||||
const std::string declared_crx_id =
|
||||
id_util::GenerateIdFromHex(base::HexEncode(crx_id_encoded));
|
||||
|
||||
// Create a little-endian representation of [signed-header-size].
|
||||
const int signed_header_size = signed_header_data_str.size();
|
||||
|
@ -40,8 +40,7 @@ GetFileSystemInfoOptions CreateOptions(const base::FilePath& path,
|
||||
}
|
||||
|
||||
std::string HexEncodeHash(const std::string& hashed_data) {
|
||||
return base::ToLowerASCII(
|
||||
base::HexEncode(std::data(hashed_data), hashed_data.size()));
|
||||
return base::ToLowerASCII(base::HexEncode(hashed_data));
|
||||
}
|
||||
|
||||
std::optional<size_t> FindItemIndexByFilePath(
|
||||
|
@ -110,8 +110,9 @@ DriverEntry DownloadDriverImpl::CreateDriverEntry(
|
||||
|
||||
if (item->GetState() == DownloadItem::DownloadState::COMPLETE) {
|
||||
std::string hash = item->GetHash();
|
||||
if (!hash.empty())
|
||||
entry.hash256 = base::HexEncode(hash.data(), hash.size());
|
||||
if (!hash.empty()) {
|
||||
entry.hash256 = base::HexEncode(hash);
|
||||
}
|
||||
}
|
||||
|
||||
return entry;
|
||||
|
@ -66,9 +66,9 @@ int64_t GetBuffersLength(const char** buffers, size_t num_buffer) {
|
||||
std::string GetHexEncodedHashValue(crypto::SecureHash* hash_state) {
|
||||
if (!hash_state)
|
||||
return std::string();
|
||||
std::vector<char> hash_value(hash_state->GetHashLength());
|
||||
std::vector<uint8_t> hash_value(hash_state->GetHashLength());
|
||||
hash_state->Finish(&hash_value.front(), hash_value.size());
|
||||
return base::HexEncode(&hash_value.front(), hash_value.size());
|
||||
return base::HexEncode(hash_value);
|
||||
}
|
||||
|
||||
class MockDownloadDestinationObserver : public DownloadDestinationObserver {
|
||||
|
@ -19,9 +19,8 @@ std::string GetRandomId() {
|
||||
|
||||
// This isn't a valid UUID, so we don't attempt to format it like one.
|
||||
uint8_t random_bytes[kBytesInHandle];
|
||||
base::RandBytes(random_bytes, sizeof(random_bytes));
|
||||
|
||||
return base::HexEncode(random_bytes, sizeof(random_bytes));
|
||||
base::RandBytes(random_bytes);
|
||||
return base::HexEncode(random_bytes);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
@ -168,7 +168,7 @@ bool MetricsServiceObserver::ExportLogsAsJson(bool include_log_proto_data,
|
||||
DCHECK_EQ(service_type_, MetricsServiceType::UMA);
|
||||
log_dict.Set("type", LogTypeToString(log->type.value()));
|
||||
}
|
||||
log_dict.Set("hash", base::HexEncode(log->hash.data(), log->hash.length()));
|
||||
log_dict.Set("hash", base::HexEncode(log->hash));
|
||||
log_dict.Set("timestamp", log->timestamp);
|
||||
|
||||
if (include_log_proto_data) {
|
||||
|
@ -177,9 +177,8 @@ void ReportingService::SendStagedLog() {
|
||||
|
||||
reporting_info_.set_attempt_count(reporting_info_.attempt_count() + 1);
|
||||
|
||||
const std::string hash =
|
||||
base::HexEncode(log_store()->staged_log_hash().data(),
|
||||
log_store()->staged_log_hash().size());
|
||||
const std::string hash = base::HexEncode(log_store()->staged_log_hash());
|
||||
|
||||
std::string signature =
|
||||
base::Base64Encode(log_store()->staged_log_signature());
|
||||
|
||||
|
@ -43,8 +43,7 @@ bool MatchesRegexp(const GURL& url, const RegexpList& regexps) {
|
||||
std::string SHA256(base::StringPiece input) {
|
||||
uint8_t result[crypto::kSHA256Length];
|
||||
crypto::SHA256HashString(input, result, std::size(result));
|
||||
std::string sha256hex = base::HexEncode(result, std::size(result));
|
||||
return sha256hex;
|
||||
return base::HexEncode(result);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -216,8 +216,7 @@ void LeakDetectionRequest::OnLookupSingleLeakResponse(
|
||||
LookupSingleLeakResponse leak_response;
|
||||
if (!leak_response.ParseFromString(*response)) {
|
||||
RecordLookupResponseResult(LeakLookupResponseResult::kParseError);
|
||||
DLOG(ERROR) << "Could not parse response: "
|
||||
<< base::HexEncode(response->data(), response->size());
|
||||
DLOG(ERROR) << "Could not parse response: " << base::HexEncode(*response);
|
||||
std::move(callback).Run(nullptr,
|
||||
LeakDetectionError::kInvalidServerResponse);
|
||||
return;
|
||||
|
@ -34,8 +34,8 @@ std::string GenerateDeviceLocalAccountUserId(std::string_view account_id,
|
||||
const auto* it = kDomainPrefixMap.find(type);
|
||||
CHECK(it != kDomainPrefixMap.end());
|
||||
return gaia::CanonicalizeEmail(
|
||||
base::StrCat({base::HexEncode(account_id.data(), account_id.size()), "@",
|
||||
it->second, kDeviceLocalAccountDomainSuffix}));
|
||||
base::StrCat({base::HexEncode(account_id), "@", it->second,
|
||||
kDeviceLocalAccountDomainSuffix}));
|
||||
}
|
||||
|
||||
base::expected<DeviceLocalAccountType, GetDeviceLocalAccountTypeError>
|
||||
|
@ -65,8 +65,7 @@ TEST(PwgRasterTest, Encode) {
|
||||
EXPECT_EQ(2970U, output.size());
|
||||
|
||||
std::string sha1 = base::SHA1HashString(output);
|
||||
EXPECT_EQ("4AD7442998C8FEAE94BC9C8B177A7C94766CC9FB",
|
||||
base::HexEncode(sha1.data(), sha1.size()));
|
||||
EXPECT_EQ("4AD7442998C8FEAE94BC9C8B177A7C94766CC9FB", base::HexEncode(sha1));
|
||||
|
||||
// Encode again in monochrome.
|
||||
header_info.color_space = PwgHeaderInfo::SGRAY;
|
||||
@ -76,8 +75,7 @@ TEST(PwgRasterTest, Encode) {
|
||||
EXPECT_EQ(2388U, output.size());
|
||||
|
||||
sha1 = base::SHA1HashString(output);
|
||||
EXPECT_EQ("4E718B0A69AC26A366A2E23AE1ECA6055079A1FF",
|
||||
base::HexEncode(sha1.data(), sha1.size()));
|
||||
EXPECT_EQ("4E718B0A69AC26A366A2E23AE1ECA6055079A1FF", base::HexEncode(sha1));
|
||||
}
|
||||
|
||||
} // namespace pwg_encoder
|
||||
|
@ -98,11 +98,9 @@ std::string ShortOriginForReporting(const std::string& url) {
|
||||
GURL gurl(url);
|
||||
if (gurl.SchemeIsLocal()) {
|
||||
std::string sha_url = crypto::SHA256HashString(url);
|
||||
return gurl.scheme() + "://" +
|
||||
base::HexEncode(sha_url.data(), sha_url.size());
|
||||
} else {
|
||||
return gurl.DeprecatedGetOriginAsURL().spec();
|
||||
return gurl.scheme() + "://" + base::HexEncode(sha_url);
|
||||
}
|
||||
return gurl.DeprecatedGetOriginAsURL().spec();
|
||||
}
|
||||
|
||||
base::TimeDelta GetNavigationFootprintTTL() {
|
||||
|
@ -46,7 +46,7 @@ std::string ShortURLForReporting(const GURL& url) {
|
||||
if (comma_pos != std::string::npos && comma_pos != spec.size() - 1) {
|
||||
std::string hash_value = crypto::SHA256HashString(spec);
|
||||
spec.erase(comma_pos + 1);
|
||||
spec += base::HexEncode(hash_value.data(), hash_value.size());
|
||||
spec += base::HexEncode(hash_value);
|
||||
}
|
||||
}
|
||||
return spec;
|
||||
|
@ -169,13 +169,12 @@ std::string UniquePosition::ToDebugString() const {
|
||||
if (bytes.empty())
|
||||
return std::string("INVALID[]");
|
||||
|
||||
std::string debug_string = base::HexEncode(bytes.data(), bytes.length());
|
||||
std::string debug_string = base::HexEncode(bytes);
|
||||
if (!IsValid()) {
|
||||
debug_string = "INVALID[" + debug_string + "]";
|
||||
}
|
||||
|
||||
std::string compressed_string =
|
||||
base::HexEncode(compressed_.data(), compressed_.length());
|
||||
std::string compressed_string = base::HexEncode(compressed_);
|
||||
debug_string.append(", compressed: " + compressed_string);
|
||||
return debug_string;
|
||||
}
|
||||
|
@ -1974,8 +1974,7 @@ TEST(ModelTypeWorkerPopulateUpdateResponseDataTest,
|
||||
*entity.mutable_specifics()
|
||||
->mutable_webauthn_credential()
|
||||
->mutable_sync_id() = sync_id;
|
||||
*entity.mutable_client_tag_hash() =
|
||||
base::HexEncode(sync_id.data(), sync_id.size());
|
||||
*entity.mutable_client_tag_hash() = base::HexEncode(sync_id);
|
||||
|
||||
ASSERT_EQ(
|
||||
ModelTypeWorker::SUCCESS,
|
||||
|
@ -240,15 +240,12 @@ TEST(SyncNigoriTest, CreateByDerivationShouldDeriveCorrectKeyUsingPbkdf2) {
|
||||
nigori->ExportKeys(&user_key, &encryption_key, &mac_key);
|
||||
// These are reference values obtained by running PBKDF2 with Nigori's
|
||||
// parameters and the input values given above.
|
||||
EXPECT_EQ(
|
||||
"025599e143c4923d77f65b99d97019a3",
|
||||
base::ToLowerASCII(base::HexEncode(user_key.data(), user_key.size())));
|
||||
EXPECT_EQ("025599e143c4923d77f65b99d97019a3",
|
||||
base::ToLowerASCII(base::HexEncode(user_key)));
|
||||
EXPECT_EQ("4596bf346572497d92b2a0e2146d93c1",
|
||||
base::ToLowerASCII(
|
||||
base::HexEncode(encryption_key.data(), encryption_key.size())));
|
||||
EXPECT_EQ(
|
||||
"2292ad9db96fe590b22a58db50f6f545",
|
||||
base::ToLowerASCII(base::HexEncode(mac_key.data(), mac_key.size())));
|
||||
base::ToLowerASCII(base::HexEncode(encryption_key)));
|
||||
EXPECT_EQ("2292ad9db96fe590b22a58db50f6f545",
|
||||
base::ToLowerASCII(base::HexEncode(mac_key)));
|
||||
}
|
||||
|
||||
TEST(SyncNigoriTest, CreateByDerivationShouldDeriveCorrectKeyUsingScrypt) {
|
||||
@ -266,17 +263,14 @@ TEST(SyncNigoriTest, CreateByDerivationShouldDeriveCorrectKeyUsingScrypt) {
|
||||
// user_key is not used anymore, but is being set for backwards compatibility
|
||||
// (because legacy clients cannot import a Nigori node without one).
|
||||
// Therefore, we just initialize it to all zeroes.
|
||||
EXPECT_EQ(
|
||||
"00000000000000000000000000000000",
|
||||
base::ToLowerASCII(base::HexEncode(user_key.data(), user_key.size())));
|
||||
EXPECT_EQ("00000000000000000000000000000000",
|
||||
base::ToLowerASCII(base::HexEncode(user_key)));
|
||||
// These are reference values obtained by running scrypt with Nigori's
|
||||
// parameters and the input values given above.
|
||||
EXPECT_EQ("8aa735e0091339a5e51da3b3dd1b328a",
|
||||
base::ToLowerASCII(
|
||||
base::HexEncode(encryption_key.data(), encryption_key.size())));
|
||||
EXPECT_EQ(
|
||||
"a7e73611968dfd2bca5b3382aed451ba",
|
||||
base::ToLowerASCII(base::HexEncode(mac_key.data(), mac_key.size())));
|
||||
base::ToLowerASCII(base::HexEncode(encryption_key)));
|
||||
EXPECT_EQ("a7e73611968dfd2bca5b3382aed451ba",
|
||||
base::ToLowerASCII(base::HexEncode(mac_key)));
|
||||
}
|
||||
|
||||
TEST(SyncNigoriTest, CreateByDerivationShouldReportPbkdf2DurationInHistogram) {
|
||||
|
@ -195,7 +195,8 @@ bool ServerSharedBitmapManager::OnMemoryDump(
|
||||
BitmapData* data = pair.second.get();
|
||||
|
||||
std::string dump_str = base::StringPrintf(
|
||||
"sharedbitmap/%s", base::HexEncode(id.name, sizeof(id.name)).c_str());
|
||||
"sharedbitmap/%s",
|
||||
base::HexEncode(base::as_byte_span(id.name)).c_str());
|
||||
base::trace_event::MemoryAllocatorDump* dump =
|
||||
pmd->CreateAllocatorDump(dump_str);
|
||||
if (!dump)
|
||||
|
@ -390,8 +390,8 @@ std::optional<base::Value::Dict> GetJwkDictionary(
|
||||
std::string k_value;
|
||||
if (!Base64DecodeUrlSafe(*value_string, &k_value))
|
||||
return ::testing::AssertionFailure() << "Base64DecodeUrlSafe(k) failed";
|
||||
if (!base::EqualsCaseInsensitiveASCII(
|
||||
base::HexEncode(k_value.data(), k_value.size()), k_expected_hex)) {
|
||||
if (!base::EqualsCaseInsensitiveASCII(base::HexEncode(k_value),
|
||||
k_expected_hex)) {
|
||||
return ::testing::AssertionFailure()
|
||||
<< "Expected 'k' to be " << k_expected_hex
|
||||
<< " but found something different";
|
||||
@ -417,7 +417,7 @@ std::optional<base::Value::Dict> GetJwkDictionary(
|
||||
std::string n_value;
|
||||
if (!Base64DecodeUrlSafe(*value_string, &n_value))
|
||||
return ::testing::AssertionFailure() << "Base64DecodeUrlSafe(n) failed";
|
||||
if (base::HexEncode(n_value.data(), n_value.size()) != n_expected_hex) {
|
||||
if (base::HexEncode(n_value) != n_expected_hex) {
|
||||
return ::testing::AssertionFailure() << "'n' does not match the expected "
|
||||
"value";
|
||||
}
|
||||
@ -430,8 +430,8 @@ std::optional<base::Value::Dict> GetJwkDictionary(
|
||||
std::string e_value;
|
||||
if (!Base64DecodeUrlSafe(*value_string, &e_value))
|
||||
return ::testing::AssertionFailure() << "Base64DecodeUrlSafe(e) failed";
|
||||
if (!base::EqualsCaseInsensitiveASCII(
|
||||
base::HexEncode(e_value.data(), e_value.size()), e_expected_hex)) {
|
||||
if (!base::EqualsCaseInsensitiveASCII(base::HexEncode(e_value),
|
||||
e_expected_hex)) {
|
||||
return ::testing::AssertionFailure()
|
||||
<< "Expected 'e' to be " << e_expected_hex
|
||||
<< " but found something different";
|
||||
|
@ -473,7 +473,7 @@ void GeneratedCodeCache::WriteEntry(const GURL& url,
|
||||
crypto::SHA256HashString(
|
||||
base::StringPiece(reinterpret_cast<char*>(copy.data()), copy.size()),
|
||||
result, std::size(result));
|
||||
std::string checksum_key = base::HexEncode(result, std::size(result));
|
||||
std::string checksum_key = base::HexEncode(result);
|
||||
small_buffer = base::MakeRefCounted<net::IOBufferWithSize>(
|
||||
kHeaderSizeInBytes + kSHAKeySizeInBytes);
|
||||
// Copy |checksum_key| into the small buffer.
|
||||
|
@ -2628,7 +2628,7 @@ void NetworkHandler::OnSignedExchangeReceived(
|
||||
std::unique_ptr<Network::SignedExchangeSignature> signature =
|
||||
Network::SignedExchangeSignature::Create()
|
||||
.SetLabel(sig.label)
|
||||
.SetSignature(base::HexEncode(sig.sig.data(), sig.sig.size()))
|
||||
.SetSignature(base::HexEncode(sig.sig))
|
||||
.SetIntegrity(sig.integrity)
|
||||
.SetCertUrl(sig.cert_url.spec())
|
||||
.SetValidityUrl(sig.validity_url.url.spec())
|
||||
@ -2636,8 +2636,7 @@ void NetworkHandler::OnSignedExchangeReceived(
|
||||
.SetExpires(sig.expires)
|
||||
.Build();
|
||||
if (sig.cert_sha256) {
|
||||
signature->SetCertSha256(base::HexEncode(sig.cert_sha256->data,
|
||||
sizeof(sig.cert_sha256->data)));
|
||||
signature->SetCertSha256(base::HexEncode(sig.cert_sha256->data));
|
||||
}
|
||||
if (certificate) {
|
||||
auto encoded_certificates = std::make_unique<protocol::Array<String>>();
|
||||
|
@ -103,7 +103,7 @@ ValueStore* LockScreenStorageHelper::GetValueStoreForOrigin(
|
||||
std::string serialized_origin = origin.Serialize();
|
||||
uint8_t hash[crypto::kSHA256Length];
|
||||
crypto::SHA256HashString(serialized_origin, hash, sizeof(hash));
|
||||
std::string filename = base::HexEncode(hash, crypto::kSHA256Length);
|
||||
std::string filename = base::HexEncode(hash);
|
||||
|
||||
auto iter = storage_map_.find(filename);
|
||||
if (iter != storage_map_.end())
|
||||
|
@ -258,7 +258,7 @@ std::string GetHMACForRawMediaDeviceID(
|
||||
: salt_and_origin.device_id_salt()),
|
||||
&digest[0], digest.size());
|
||||
DCHECK(result);
|
||||
return base::ToLowerASCII(base::HexEncode(&digest[0], digest.size()));
|
||||
return base::ToLowerASCII(base::HexEncode(digest));
|
||||
}
|
||||
|
||||
bool DoesRawMediaDeviceIDMatchHMAC(
|
||||
|
@ -304,10 +304,9 @@ base::FilePath StoragePartitionImplMap::GetStoragePartitionPath(
|
||||
if (!partition_name.empty()) {
|
||||
// For analysis of why we can ignore collisions, see the comment above
|
||||
// kPartitionNameHashBytes.
|
||||
char buffer[kPartitionNameHashBytes];
|
||||
crypto::SHA256HashString(partition_name, &buffer[0],
|
||||
sizeof(buffer));
|
||||
return path.AppendASCII(base::HexEncode(buffer, sizeof(buffer)));
|
||||
uint8_t buffer[kPartitionNameHashBytes];
|
||||
crypto::SHA256HashString(partition_name, buffer, sizeof(buffer));
|
||||
return path.AppendASCII(base::HexEncode(buffer));
|
||||
}
|
||||
|
||||
return path.Append(kDefaultPartitionDirname);
|
||||
|
@ -6724,8 +6724,8 @@ class ResidentKeyTestAuthenticatorRequestDelegate
|
||||
[](const device::AuthenticatorGetAssertionResponse& response) {
|
||||
const device::PublicKeyCredentialUserEntity& user =
|
||||
response.user_entity.value();
|
||||
return base::HexEncode(user.id.data(), user.id.size()) + ":" +
|
||||
user.name.value_or("") + ":" + user.display_name.value_or("");
|
||||
return base::HexEncode(user.id) + ":" + user.name.value_or("") + ":" +
|
||||
user.display_name.value_or("");
|
||||
});
|
||||
|
||||
EXPECT_EQ(config_.expected_accounts, base::JoinString(string_reps, "/"));
|
||||
|
@ -432,8 +432,7 @@ TEST(EncryptorTest, EncryptAES128CBCRegression) {
|
||||
|
||||
std::string ciphertext;
|
||||
EXPECT_TRUE(encryptor.Encrypt(plaintext, &ciphertext));
|
||||
EXPECT_EQ(expected_ciphertext_hex, base::HexEncode(ciphertext.data(),
|
||||
ciphertext.size()));
|
||||
EXPECT_EQ(expected_ciphertext_hex, base::HexEncode(ciphertext));
|
||||
|
||||
std::string decrypted;
|
||||
EXPECT_TRUE(encryptor.Decrypt(ciphertext, &decrypted));
|
||||
@ -484,8 +483,7 @@ TEST(EncryptorTest, EmptyEncryptCBC) {
|
||||
|
||||
std::string ciphertext;
|
||||
EXPECT_TRUE(encryptor.Encrypt(plaintext, &ciphertext));
|
||||
EXPECT_EQ(expected_ciphertext_hex, base::HexEncode(ciphertext.data(),
|
||||
ciphertext.size()));
|
||||
EXPECT_EQ(expected_ciphertext_hex, base::HexEncode(ciphertext));
|
||||
|
||||
std::string decrypted;
|
||||
EXPECT_TRUE(encryptor.Decrypt(ciphertext, &decrypted));
|
||||
|
@ -88,9 +88,7 @@ TEST_P(SymmetricKeyDeriveKeyFromPasswordUsingPbkdf2Test,
|
||||
|
||||
const std::string& raw_key = key->key();
|
||||
EXPECT_EQ(test_data.key_size_in_bits / 8, raw_key.size());
|
||||
EXPECT_EQ(test_data.expected,
|
||||
base::ToLowerASCII(base::HexEncode(raw_key.data(),
|
||||
raw_key.size())));
|
||||
EXPECT_EQ(test_data.expected, base::ToLowerASCII(base::HexEncode(raw_key)));
|
||||
}
|
||||
|
||||
TEST_P(SymmetricKeyDeriveKeyFromPasswordUsingScryptTest,
|
||||
|
@ -409,9 +409,9 @@ std::string BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(
|
||||
std::string BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(
|
||||
std::string_view device_identifier) {
|
||||
const size_t kCanonicalAddressNumberOfBytes = 6;
|
||||
char raw[kCanonicalAddressNumberOfBytes];
|
||||
uint8_t raw[kCanonicalAddressNumberOfBytes];
|
||||
crypto::SHA256HashString(device_identifier, raw, sizeof(raw));
|
||||
return CanonicalizeBluetoothAddress(base::HexEncode(raw, sizeof(raw)));
|
||||
return CanonicalizeBluetoothAddress(base::HexEncode(raw));
|
||||
}
|
||||
|
||||
void BluetoothLowEnergyDeviceMac::DidConnectPeripheral() {
|
||||
|
@ -161,9 +161,7 @@ class Ctap2DeviceOperation : public DeviceOperation<Request, Response> {
|
||||
FIDO_LOG(ERROR) << "-> (CBOR parse error '"
|
||||
<< cbor::Reader::ErrorCodeToString(error)
|
||||
<< "' from raw message "
|
||||
<< base::HexEncode(device_response->data(),
|
||||
device_response->size())
|
||||
<< ")";
|
||||
<< base::HexEncode(device_response.value()) << ")";
|
||||
std::move(this->callback())
|
||||
.Run(CtapDeviceResponseCode::kCtap2ErrInvalidCBOR, absl::nullopt);
|
||||
return;
|
||||
@ -174,9 +172,7 @@ class Ctap2DeviceOperation : public DeviceOperation<Request, Response> {
|
||||
if (!cbor) {
|
||||
FIDO_LOG(ERROR)
|
||||
<< "-> (CBOR with unfixable UTF-8 errors from raw message "
|
||||
<< base::HexEncode(device_response->data(),
|
||||
device_response->size())
|
||||
<< ")";
|
||||
<< base::HexEncode(device_response.value()) << ")";
|
||||
std::move(this->callback())
|
||||
.Run(CtapDeviceResponseCode::kCtap2ErrInvalidCBOR, absl::nullopt);
|
||||
return;
|
||||
|
@ -159,13 +159,11 @@ class NetworkingPrivateApiTest : public ApiUnitTest {
|
||||
base::Value::Dict()
|
||||
.Set("GUID", kManagedUserWifiGuid)
|
||||
.Set("Type", "WiFi")
|
||||
.Set("WiFi",
|
||||
base::Value::Dict()
|
||||
.Set("Passphrase", "fake")
|
||||
.Set("SSID", user_policy_ssid)
|
||||
.Set("HexSSID", base::HexEncode(user_policy_ssid.c_str(),
|
||||
user_policy_ssid.size()))
|
||||
.Set("Security", "WPA-PSK")));
|
||||
.Set("WiFi", base::Value::Dict()
|
||||
.Set("Passphrase", "fake")
|
||||
.Set("SSID", user_policy_ssid)
|
||||
.Set("HexSSID", base::HexEncode(user_policy_ssid))
|
||||
.Set("Security", "WPA-PSK")));
|
||||
|
||||
config_handler->SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUserHash,
|
||||
user_policy_onc,
|
||||
@ -179,8 +177,7 @@ class NetworkingPrivateApiTest : public ApiUnitTest {
|
||||
.Set("WiFi",
|
||||
base::Value::Dict()
|
||||
.Set("SSID", device_policy_ssid)
|
||||
.Set("HexSSID", base::HexEncode(device_policy_ssid.c_str(),
|
||||
device_policy_ssid.size()))
|
||||
.Set("HexSSID", base::HexEncode(device_policy_ssid))
|
||||
.Set("Security", "None")));
|
||||
config_handler->SetPolicy(::onc::ONC_SOURCE_DEVICE_POLICY, "",
|
||||
device_policy_onc,
|
||||
|
@ -182,7 +182,6 @@ const base::TimeDelta GServicesSettings::MinimumCheckinInterval() {
|
||||
|
||||
// static
|
||||
std::string GServicesSettings::CalculateDigest(const SettingsMap& settings) {
|
||||
unsigned char hash[base::kSHA1Length];
|
||||
std::string data;
|
||||
for (SettingsMap::const_iterator iter = settings.begin();
|
||||
iter != settings.end();
|
||||
@ -192,10 +191,10 @@ std::string GServicesSettings::CalculateDigest(const SettingsMap& settings) {
|
||||
data += iter->second;
|
||||
data += '\0';
|
||||
}
|
||||
uint8_t hash[base::kSHA1Length];
|
||||
base::SHA1HashBytes(
|
||||
reinterpret_cast<const unsigned char*>(&data[0]), data.size(), hash);
|
||||
std::string digest =
|
||||
kDigestVersionPrefix + base::HexEncode(hash, base::kSHA1Length);
|
||||
std::string digest = kDigestVersionPrefix + base::HexEncode(hash);
|
||||
digest = base::ToLowerASCII(digest);
|
||||
return digest;
|
||||
}
|
||||
|
@ -55,8 +55,7 @@ NSString* GetFaviconFileKey(const GURL& url) {
|
||||
// a URL (including the scheme and ://) isn't a valid file name).
|
||||
unsigned char result[CC_SHA256_DIGEST_LENGTH];
|
||||
CC_SHA256(url.spec().data(), url.spec().length(), result);
|
||||
return base::SysUTF8ToNSString(
|
||||
base::HexEncode(result, CC_SHA256_DIGEST_LENGTH));
|
||||
return base::SysUTF8ToNSString(base::HexEncode(result));
|
||||
}
|
||||
|
||||
void SaveFaviconToSharedAppContainer(FaviconAttributes* attributes,
|
||||
|
@ -876,9 +876,8 @@ void MediaDrmBridge::OnSessionKeysChange(
|
||||
CdmKeyInformation::KeyStatus key_status =
|
||||
ConvertKeyStatus(static_cast<KeyStatus>(j_status_code), is_key_release);
|
||||
|
||||
DVLOG(2) << __func__ << "Key status change: "
|
||||
<< base::HexEncode(&key_id[0], key_id.size()) << ", "
|
||||
<< key_status;
|
||||
DVLOG(2) << __func__ << "Key status change: " << base::HexEncode(key_id)
|
||||
<< ", " << key_status;
|
||||
|
||||
cdm_keys_info.push_back(
|
||||
std::make_unique<CdmKeyInformation>(key_id, key_status, 0));
|
||||
|
@ -91,9 +91,8 @@ bool DecryptConfig::Matches(const DecryptConfig& config) const {
|
||||
}
|
||||
|
||||
std::ostream& DecryptConfig::Print(std::ostream& os) const {
|
||||
os << "key_id:'" << base::HexEncode(key_id_.data(), key_id_.size()) << "'"
|
||||
<< " iv:'" << base::HexEncode(iv_.data(), iv_.size()) << "'"
|
||||
<< " scheme:" << encryption_scheme_;
|
||||
os << "key_id:'" << base::HexEncode(key_id_) << "'" << " iv:'"
|
||||
<< base::HexEncode(iv_) << "'" << " scheme:" << encryption_scheme_;
|
||||
|
||||
if (encryption_pattern_) {
|
||||
os << " pattern:" << encryption_pattern_->crypt_byte_block() << ":"
|
||||
|
@ -99,9 +99,9 @@ void CreateEnableDisableFile(const std::string& enable_path,
|
||||
}
|
||||
|
||||
std::string GenerateRandomToken() {
|
||||
char random_bytes[16];
|
||||
base::RandBytes(random_bytes, 16);
|
||||
return base::HexEncode(random_bytes, 16);
|
||||
uint8_t random_bytes[16];
|
||||
base::RandBytes(random_bytes);
|
||||
return base::HexEncode(random_bytes);
|
||||
}
|
||||
|
||||
// Waits until |raw_socket_fd| is readable. We signal |raw_cancel_fd| when we
|
||||
|
@ -119,8 +119,8 @@ int GetHdcpValue(HdcpVersion hdcp_version) {
|
||||
// the generated session ID is `DUMMY_9F656F4D76BE30D4`.
|
||||
std::string GenerateDummySessionId() {
|
||||
uint8_t random_bytes[8];
|
||||
base::RandBytes(random_bytes, sizeof(random_bytes));
|
||||
return "DUMMY_" + base::HexEncode(random_bytes, sizeof(random_bytes));
|
||||
base::RandBytes(random_bytes);
|
||||
return "DUMMY_" + base::HexEncode(random_bytes);
|
||||
}
|
||||
|
||||
class CdmProxyImpl : public MediaFoundationCdmProxy {
|
||||
|
@ -281,7 +281,7 @@ void DecryptingAudioDecoder::DeliverFrame(
|
||||
std::string key_id =
|
||||
scoped_pending_buffer_to_decode->decrypt_config()->key_id();
|
||||
std::string log_message =
|
||||
"no key for key ID " + base::HexEncode(key_id.data(), key_id.size()) +
|
||||
"no key for key ID " + base::HexEncode(key_id) +
|
||||
"; will resume decoding after new usable key is available";
|
||||
DVLOG(1) << __func__ << ": " << log_message;
|
||||
MEDIA_LOG(INFO, media_log_) << GetDecoderType() << ": " << log_message;
|
||||
|
@ -323,7 +323,7 @@ void DecryptingDemuxerStream::OnBufferDecrypted(
|
||||
std::string key_id = pending_buffer_to_decrypt_->decrypt_config()->key_id();
|
||||
|
||||
std::string log_message =
|
||||
"no key for key ID " + base::HexEncode(key_id.data(), key_id.size()) +
|
||||
"no key for key ID " + base::HexEncode(key_id) +
|
||||
"; will resume decrypting after new usable key is available";
|
||||
DVLOG(1) << __func__ << ": " << log_message;
|
||||
MEDIA_LOG(INFO, media_log_) << GetDisplayName() << ": " << log_message;
|
||||
|
@ -290,7 +290,7 @@ void DecryptingVideoDecoder::DeliverFrame(Decryptor::Status status,
|
||||
std::string key_id =
|
||||
scoped_pending_buffer_to_decode->decrypt_config()->key_id();
|
||||
std::string log_message =
|
||||
"no key for key ID " + base::HexEncode(key_id.data(), key_id.size()) +
|
||||
"no key for key ID " + base::HexEncode(key_id) +
|
||||
"; will resume decoding after new usable key is available";
|
||||
DVLOG(1) << __func__ << ": " << log_message;
|
||||
MEDIA_LOG(INFO, media_log_) << GetDecoderType() << ": " << log_message;
|
||||
|
@ -393,8 +393,8 @@ std::string MidiManagerAlsa::MidiPort::JSONValue() const {
|
||||
// http://crbug.com/465320
|
||||
std::string MidiManagerAlsa::MidiPort::OpaqueKey() const {
|
||||
uint8_t hash[crypto::kSHA256Length];
|
||||
crypto::SHA256HashString(JSONValue(), &hash, sizeof(hash));
|
||||
return base::HexEncode(&hash, sizeof(hash));
|
||||
crypto::SHA256HashString(JSONValue(), hash, sizeof(hash));
|
||||
return base::HexEncode(hash);
|
||||
}
|
||||
|
||||
bool MidiManagerAlsa::MidiPort::MatchConnected(const MidiPort& query) const {
|
||||
|
@ -92,11 +92,9 @@ std::unique_ptr<test_server::HttpResponse> ServeResponse(
|
||||
}
|
||||
|
||||
std::string MakeRandomHexString(size_t num_bytes) {
|
||||
std::vector<char> rand_bytes;
|
||||
rand_bytes.resize(num_bytes);
|
||||
|
||||
base::RandBytes(rand_bytes.data(), rand_bytes.size());
|
||||
return base::HexEncode(rand_bytes.data(), rand_bytes.size());
|
||||
std::vector<uint8_t> rand_bytes(num_bytes);
|
||||
base::RandBytes(rand_bytes);
|
||||
return base::HexEncode(rand_bytes);
|
||||
}
|
||||
|
||||
static std::string MakeRandomPath(std::string_view suffix) {
|
||||
|
@ -279,11 +279,9 @@ bool ScopedTestRootCanTrustIntermediateCert(
|
||||
}
|
||||
|
||||
std::string MakeRandomHexString(size_t num_bytes) {
|
||||
std::vector<char> rand_bytes;
|
||||
rand_bytes.resize(num_bytes);
|
||||
|
||||
base::RandBytes(rand_bytes.data(), rand_bytes.size());
|
||||
return base::HexEncode(rand_bytes.data(), rand_bytes.size());
|
||||
std::vector<uint8_t> rand_bytes(num_bytes);
|
||||
base::RandBytes(rand_bytes);
|
||||
return base::HexEncode(rand_bytes);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -308,7 +308,7 @@ TEST_P(TrustStoreMacImplTest, SystemCerts) {
|
||||
std::back_inserter(all_certs));
|
||||
for (const std::string& cert_der : all_certs) {
|
||||
std::string hash = crypto::SHA256HashString(cert_der);
|
||||
std::string hash_text = base::HexEncode(hash.data(), hash.size());
|
||||
std::string hash_text = base::HexEncode(hash);
|
||||
SCOPED_TRACE(hash_text);
|
||||
|
||||
bssl::CertErrors errors;
|
||||
|
@ -39,8 +39,7 @@ void PrintTo(const SignedTreeHead& sth, std::ostream* os) {
|
||||
<< "\t\"tree_size\": " << sth.tree_size << ",\n"
|
||||
<< "\t\"sha256_root_hash\": \""
|
||||
<< base::HexEncode(sth.sha256_root_hash, kSthRootHashLength)
|
||||
<< "\",\n\t\"log_id\": \""
|
||||
<< base::HexEncode(sth.log_id.data(), sth.log_id.size()) << "\"\n"
|
||||
<< "\",\n\t\"log_id\": \"" << base::HexEncode(sth.log_id) << "\"\n"
|
||||
<< "}";
|
||||
}
|
||||
|
||||
|
@ -376,8 +376,8 @@ class HttpAuthHandlerDigest::DigestContext {
|
||||
uint8_t md_value[EVP_MAX_MD_SIZE] = {};
|
||||
unsigned int md_len = sizeof(md_value);
|
||||
CHECK(EVP_DigestFinal_ex(md_ctx_.get(), md_value, &md_len));
|
||||
CHECK_LE(out_len_, md_len);
|
||||
return base::ToLowerASCII(base::HexEncode(md_value, out_len_));
|
||||
return base::ToLowerASCII(
|
||||
base::HexEncode(base::span(md_value).first(out_len_)));
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -44,8 +44,7 @@ base::Value::Dict NetLogParameterChannelBindings(
|
||||
if (!NetLogCaptureIncludesSocketBytes(capture_mode))
|
||||
return dict;
|
||||
|
||||
dict.Set("token", base::HexEncode(channel_binding_token.data(),
|
||||
channel_binding_token.size()));
|
||||
dict.Set("token", base::HexEncode(channel_binding_token));
|
||||
return dict;
|
||||
}
|
||||
|
||||
|
@ -122,8 +122,7 @@ bool ProofSourceChromium::GetProofInner(
|
||||
proof->signature.assign(reinterpret_cast<const char*>(signature.data()),
|
||||
signature.size());
|
||||
*out_chain = chain_;
|
||||
VLOG(1) << "signature: "
|
||||
<< base::HexEncode(proof->signature.data(), proof->signature.size());
|
||||
VLOG(1) << "signature: " << base::HexEncode(proof->signature);
|
||||
proof->leaf_cert_scts = signed_certificate_timestamp_;
|
||||
return true;
|
||||
}
|
||||
|
@ -364,11 +364,9 @@ std::string CertBuilder::SignatureAlgorithmToDer(
|
||||
|
||||
// static
|
||||
std::string CertBuilder::MakeRandomHexString(size_t num_bytes) {
|
||||
std::vector<char> rand_bytes;
|
||||
rand_bytes.resize(num_bytes);
|
||||
|
||||
base::RandBytes(rand_bytes.data(), rand_bytes.size());
|
||||
return base::HexEncode(rand_bytes.data(), rand_bytes.size());
|
||||
std::vector<uint8_t> rand_bytes(num_bytes);
|
||||
base::RandBytes(rand_bytes);
|
||||
return base::HexEncode(rand_bytes);
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -122,7 +122,7 @@ void PrintCertError(const std::string& error, const CertInput& cert) {
|
||||
std::string FingerPrintCryptoBuffer(const CRYPTO_BUFFER* cert_handle) {
|
||||
net::SHA256HashValue hash =
|
||||
net::X509Certificate::CalculateFingerprint256(cert_handle);
|
||||
return base::HexEncode(hash.data, std::size(hash.data));
|
||||
return base::HexEncode(hash.data);
|
||||
}
|
||||
|
||||
std::string SubjectFromX509Certificate(const net::X509Certificate* cert) {
|
||||
|
@ -57,7 +57,7 @@ bool DumpParsedCertificateChain(const base::FilePath& file_path,
|
||||
// Returns a hex-encoded sha256 of the DER-encoding of |cert|.
|
||||
std::string FingerPrintParsedCertificate(const bssl::ParsedCertificate* cert) {
|
||||
std::string hash = crypto::SHA256HashString(cert->der_cert().AsStringView());
|
||||
return base::HexEncode(hash.data(), hash.size());
|
||||
return base::HexEncode(hash);
|
||||
}
|
||||
|
||||
std::string SubjectToString(const bssl::RDNSequence& parsed_subject) {
|
||||
|
@ -240,8 +240,7 @@ bool WriteEvCppFile(const RootStore& root_store,
|
||||
// Chrome Root Store textprotos.
|
||||
const int kMaxPolicyOids = 2;
|
||||
int oids_size = anchor.ev_policy_oids_size();
|
||||
std::string hexencode_hash =
|
||||
base::HexEncode(sha256_hash.data(), sha256_hash.size());
|
||||
std::string hexencode_hash = base::HexEncode(sha256_hash);
|
||||
if (oids_size > kMaxPolicyOids) {
|
||||
PLOG(ERROR) << hexencode_hash << " has too many OIDs!";
|
||||
return false;
|
||||
|
@ -450,8 +450,8 @@ std::wstring GetAppContainerProfileName(const std::string& appcontainer_id,
|
||||
}
|
||||
|
||||
auto sha1 = base::SHA1HashString(appcontainer_id);
|
||||
std::string profile_name = base::StrCat(
|
||||
{sandbox_base_name, base::HexEncode(sha1.data(), sha1.size())});
|
||||
std::string profile_name =
|
||||
base::StrCat({sandbox_base_name, base::HexEncode(sha1)});
|
||||
// CreateAppContainerProfile requires that the profile name is at most 64
|
||||
// characters but 50 on WCOS systems. The size of sha1 is a constant 40,
|
||||
// so validate that the base names are sufficiently short that the total
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user