[cr144] Migrate MD5 usage in default protocol handler to crypto/obsolete/md5.h
Chromium changes: https://chromium.googlesource.com/chromium/src/+/30e187d7d78b64c59c52a747b5373cc21b389871 commit 30e187d7d78b64c59c52a747b5373cc21b389871 Author: Giovanni Ortuño Urquidi <ortuno@chromium.org> Date: Tue Nov 4 09:44:08 2025 -0800 Remove base/hash/md5.h All usages have been migrated to crypto/obsolete/md5.h or upgraded to SHA-256. Fixed: 406729261 Change-Id: Ie643451d670c0ab701cddf2b3e820d50debd571e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7113738 Reviewed-by: Elly FJ <ellyjones@chromium.org> Commit-Queue: Giovanni Ortuno Urquidi <ortuno@chromium.org> Reviewed-by: Nico Weber <thakis@chromium.org> Owners-Override: Nico Weber <thakis@chromium.org> Cr-Commit-Position: refs/heads/main@{#1540135}
This commit is contained in:
@@ -21,7 +21,6 @@
|
||||
#include "base/containers/span.h"
|
||||
#include "base/containers/span_reader.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/hash/md5.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/notreached.h"
|
||||
#include "base/numerics/byte_conversions.h"
|
||||
@@ -40,11 +39,19 @@
|
||||
#include "base/win/windows_version.h"
|
||||
#include "chrome/install_static/install_util.h"
|
||||
#include "chrome/installer/util/shell_util.h"
|
||||
#include "crypto/obsolete/md5.h"
|
||||
#include "third_party/abseil-cpp/absl/strings/str_format.h"
|
||||
|
||||
// Most of source code in this file comes from firefox's SetDefaultBrowser -
|
||||
// https://github.com/mozilla/gecko-dev/blob/master/toolkit/mozapps/defaultagent/SetDefaultBrowser.cpp
|
||||
|
||||
namespace brave {
|
||||
std::array<uint8_t, crypto::obsolete::kMd5Size> Md5ForDefaultProtocolHandler(
|
||||
base::span<const uint8_t> data) {
|
||||
return crypto::obsolete::Md5::Hash(data);
|
||||
}
|
||||
} // namespace brave
|
||||
|
||||
namespace protocol_handler_utils {
|
||||
|
||||
namespace {
|
||||
@@ -67,9 +74,9 @@ std::wstring HashString(base::wcstring_view input) {
|
||||
|
||||
// Compute an MD5 hash. md5[0] and md5[1] will be used as constant multipliers
|
||||
// in the scramble below.
|
||||
base::MD5Digest digest;
|
||||
base::MD5Sum(bytes, &digest);
|
||||
auto md5 = base::as_byte_span(digest.a).first<8u>();
|
||||
std::array<uint8_t, crypto::obsolete::kMd5Size> digest =
|
||||
brave::Md5ForDefaultProtocolHandler(bytes);
|
||||
auto md5 = base::as_byte_span(digest).first<8u>();
|
||||
|
||||
// The following loop effectively computes two checksums, scrambled like a
|
||||
// hash after every DWORD is added.
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/* Copyright (c) 2025 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef BRAVE_CHROMIUM_SRC_CRYPTO_OBSOLETE_MD5_H_
|
||||
#define BRAVE_CHROMIUM_SRC_CRYPTO_OBSOLETE_MD5_H_
|
||||
|
||||
// In order to continue using MD5 (which has now moved to //crypto/obsolete) for
|
||||
// our default protocol handler, we must mark our helper function as a friend of
|
||||
// Md5. This is a standard pattern used by upstream code that wishes to continue
|
||||
// using Md5.
|
||||
#define KnownAnswer \
|
||||
KnownAnswer); friend std::array<uint8_t, crypto::obsolete::kMd5Size> \
|
||||
brave::Md5ForDefaultProtocolHandler(base::span<const uint8_t> data
|
||||
|
||||
#define BRAVE_CRYPTO_OBSOLETE_MD5 \
|
||||
namespace brave { \
|
||||
std::array<uint8_t, crypto::obsolete::kMd5Size> \
|
||||
Md5ForDefaultProtocolHandler(base::span<const uint8_t> data); \
|
||||
}
|
||||
|
||||
#include <crypto/obsolete/md5.h> // IWYU pragma: export
|
||||
|
||||
#undef BRAVE_CRYPTO_OBSOLETE_MD5
|
||||
#undef KnownAnswer
|
||||
|
||||
#endif // BRAVE_CHROMIUM_SRC_CRYPTO_OBSOLETE_MD5_H_
|
||||
@@ -0,0 +1,12 @@
|
||||
diff --git a/crypto/obsolete/md5.h b/crypto/obsolete/md5.h
|
||||
index 3c8cc67a081f04b4526e2b0e5a4984fa0f73ff9c..7a463946d2613dc5928ee279bcca74d84ed380e7 100644
|
||||
--- a/crypto/obsolete/md5.h
|
||||
+++ b/crypto/obsolete/md5.h
|
||||
@@ -152,6 +152,7 @@ namespace web_app::internals {
|
||||
crypto::obsolete::Md5 MakeMd5HasherForWebAppShortcutIcon();
|
||||
std::wstring Md5AsHexForUninstall(const std::wstring& data);
|
||||
}
|
||||
+BRAVE_CRYPTO_OBSOLETE_MD5
|
||||
|
||||
namespace crypto::obsolete {
|
||||
|
||||
Reference in New Issue
Block a user