mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-06 09:22:35 +00:00
switch back to strings for simplicity
This commit is contained in:
parent
827214b237
commit
309fc59d16
@ -67,7 +67,7 @@ static int cursorHideTimeout = 5; // 5 seconds (default)
|
||||
static bool separateupdatefolder = false;
|
||||
static bool compatibilityData = false;
|
||||
static bool checkCompatibilityOnStartup = false;
|
||||
static std::vector<u8> trophyKey;
|
||||
static std::string trophyKey;
|
||||
|
||||
// Gui
|
||||
std::vector<std::filesystem::path> settings_install_dirs = {};
|
||||
@ -92,11 +92,11 @@ std::string emulator_language = "en";
|
||||
// Language
|
||||
u32 m_language = 1; // english
|
||||
|
||||
std::vector<u8> getTrophyKey() {
|
||||
std::string getTrophyKey() {
|
||||
return trophyKey;
|
||||
}
|
||||
|
||||
void setTrophyKey(std::vector<u8> key) {
|
||||
void setTrophyKey(std::string key) {
|
||||
trophyKey = key;
|
||||
}
|
||||
|
||||
@ -664,9 +664,7 @@ void load(const std::filesystem::path& path) {
|
||||
|
||||
if (data.contains("Keys")) {
|
||||
const toml::value& keys = data.at("Keys");
|
||||
if (keys.contains("TrophyKey") && keys.at("TrophyKey").is_array()) {
|
||||
trophyKey = toml::find<std::vector<u8>>(keys, "TrophyKey");
|
||||
}
|
||||
trophyKey = toml::find_or<std::string>(keys, "TrophyKey", "");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,8 +15,8 @@ void load(const std::filesystem::path& path);
|
||||
void save(const std::filesystem::path& path);
|
||||
void saveMainWindow(const std::filesystem::path& path);
|
||||
|
||||
std::vector<u8> getTrophyKey();
|
||||
void setTrophyKey(std::vector<u8> key);
|
||||
std::string getTrophyKey();
|
||||
void setTrophyKey(std::string key);
|
||||
|
||||
bool isNeoMode();
|
||||
bool isFullscreenMode();
|
||||
|
@ -34,6 +34,13 @@ static void removePadding(std::vector<u8>& vec) {
|
||||
}
|
||||
}
|
||||
|
||||
static void hexToBytes(const char* hex, unsigned char* dst) {
|
||||
for (size_t i = 0; hex[i] != 0; i++) {
|
||||
const unsigned char value = (hex[i] < 0x3A) ? (hex[i] - 0x30) : (hex[i] - 0x37);
|
||||
dst[i / 2] |= ((i % 2) == 0) ? (value << 4) : (value);
|
||||
}
|
||||
}
|
||||
|
||||
bool TRP::Extract(const std::filesystem::path& trophyPath, const std::string titleId) {
|
||||
std::filesystem::path gameSysDir = trophyPath / "sce_sys/trophy/";
|
||||
if (!std::filesystem::exists(gameSysDir)) {
|
||||
@ -41,13 +48,15 @@ bool TRP::Extract(const std::filesystem::path& trophyPath, const std::string tit
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto user_key = Config::getTrophyKey();
|
||||
if (user_key.size() != 16) {
|
||||
const auto user_key_str = Config::getTrophyKey();
|
||||
if (user_key_str.size() != 32) {
|
||||
LOG_CRITICAL(Common_Filesystem, "Trophy decryption key is not specified");
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::span<CryptoPP::byte, 16> key{(CryptoPP::byte*)user_key.data(), 16};
|
||||
std::array<CryptoPP::byte, 16> user_key{};
|
||||
hexToBytes(user_key_str.c_str(), user_key.data());
|
||||
const std::span<CryptoPP::byte, 16> key{user_key.data(), user_key.size()};
|
||||
|
||||
for (int index = 0; const auto& it : std::filesystem::directory_iterator(gameSysDir)) {
|
||||
if (it.is_regular_file()) {
|
||||
|
Loading…
Reference in New Issue
Block a user