summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorShawn Hoffman <godisgovernment@gmail.com>2022-07-27 18:47:52 -0700
committerShawn Hoffman <godisgovernment@gmail.com>2022-08-02 22:25:05 -0700
commit403f3693da03f6211a9c04f947f22aed34bdb8a5 (patch)
tree9f2d15416134ff25571935af7d849048f12a3ebc /Source/Core
parentc7ce035a7f13879e1c429d76fe5e3d6242a43c4c (diff)
NetPlay: use sha1 instead of md5
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/NetPlayClient.cpp16
-rw-r--r--Source/Core/DolphinQt/NetPlay/GameDigestDialog.cpp2
2 files changed, 7 insertions, 11 deletions
diff --git a/Source/Core/Core/NetPlayClient.cpp b/Source/Core/Core/NetPlayClient.cpp
index 9bc0ff5e2f..1ee76e21f0 100644
--- a/Source/Core/Core/NetPlayClient.cpp
+++ b/Source/Core/Core/NetPlayClient.cpp
@@ -16,11 +16,11 @@
#include <vector>
#include <fmt/format.h>
-#include <mbedtls/md5.h>
#include "Common/Assert.h"
#include "Common/CommonPaths.h"
#include "Common/CommonTypes.h"
+#include "Common/Crypto/SHA1.h"
#include "Common/ENetUtil.h"
#include "Common/FileUtil.h"
#include "Common/Logging/Log.h"
@@ -2436,16 +2436,15 @@ bool NetPlayClient::DoAllPlayersHaveGame()
});
}
-static std::string MD5Sum(const std::string& file_path, std::function<bool(int)> report_progress)
+static std::string SHA1Sum(const std::string& file_path, std::function<bool(int)> report_progress)
{
std::vector<u8> data(8 * 1024 * 1024);
u64 read_offset = 0;
- mbedtls_md5_context ctx;
std::unique_ptr<DiscIO::BlobReader> file(DiscIO::CreateBlobReader(file_path));
u64 game_size = file->GetDataSize();
- mbedtls_md5_starts_ret(&ctx);
+ auto ctx = Common::SHA1::CreateContext();
while (read_offset < game_size)
{
@@ -2453,7 +2452,7 @@ static std::string MD5Sum(const std::string& file_path, std::function<bool(int)>
if (!file->Read(read_offset, read_size, data.data()))
return "";
- mbedtls_md5_update_ret(&ctx, data.data(), read_size);
+ ctx->Update(data.data(), read_size);
read_offset += read_size;
int progress =
@@ -2462,11 +2461,8 @@ static std::string MD5Sum(const std::string& file_path, std::function<bool(int)>
return "";
}
- std::array<u8, 16> output;
- mbedtls_md5_finish_ret(&ctx, output.data());
-
// Convert to hex
- return fmt::format("{:02x}", fmt::join(output, ""));
+ return fmt::format("{:02x}", fmt::join(ctx->Finish(), ""));
}
void NetPlayClient::ComputeGameDigest(const SyncIdentifier& sync_identifier)
@@ -2495,7 +2491,7 @@ void NetPlayClient::ComputeGameDigest(const SyncIdentifier& sync_identifier)
if (m_game_digest_thread.joinable())
m_game_digest_thread.join();
m_game_digest_thread = std::thread([this, file]() {
- std::string sum = MD5Sum(file, [&](int progress) {
+ std::string sum = SHA1Sum(file, [&](int progress) {
sf::Packet packet;
packet << MessageID::GameDigestProgress;
packet << progress;
diff --git a/Source/Core/DolphinQt/NetPlay/GameDigestDialog.cpp b/Source/Core/DolphinQt/NetPlay/GameDigestDialog.cpp
index 8144514c74..6a91e4bbde 100644
--- a/Source/Core/DolphinQt/NetPlay/GameDigestDialog.cpp
+++ b/Source/Core/DolphinQt/NetPlay/GameDigestDialog.cpp
@@ -40,7 +40,7 @@ GameDigestDialog::GameDigestDialog(QWidget* parent) : QDialog(parent)
{
CreateWidgets();
ConnectWidgets();
- setWindowTitle(tr("MD5 Checksum"));
+ setWindowTitle(tr("SHA1 Digest"));
setWindowFlags(Qt::Sheet | Qt::Dialog);
setWindowModality(Qt::WindowModal);
}