diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/ns/pl_u.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/core/hle/service/ns/pl_u.cpp b/src/core/hle/service/ns/pl_u.cpp index 71c7587db..b6ac0a81a 100644 --- a/src/core/hle/service/ns/pl_u.cpp +++ b/src/core/hle/service/ns/pl_u.cpp | |||
| @@ -65,13 +65,18 @@ static void DecryptSharedFont(const std::vector<u32>& input, Kernel::PhysicalMem | |||
| 65 | void DecryptSharedFontToTTF(const std::vector<u32>& input, std::vector<u8>& output) { | 65 | void DecryptSharedFontToTTF(const std::vector<u32>& input, std::vector<u8>& output) { |
| 66 | ASSERT_MSG(input[0] == EXPECTED_MAGIC, "Failed to derive key, unexpected magic number"); | 66 | ASSERT_MSG(input[0] == EXPECTED_MAGIC, "Failed to derive key, unexpected magic number"); |
| 67 | 67 | ||
| 68 | if (input.size() < 2) { | ||
| 69 | LOG_ERROR(Service_NS, "Input font is empty"); | ||
| 70 | return; | ||
| 71 | } | ||
| 72 | |||
| 68 | const u32 KEY = input[0] ^ EXPECTED_RESULT; // Derive key using an inverse xor | 73 | const u32 KEY = input[0] ^ EXPECTED_RESULT; // Derive key using an inverse xor |
| 69 | std::vector<u32> transformed_font(input.size()); | 74 | std::vector<u32> transformed_font(input.size()); |
| 70 | // TODO(ogniK): Figure out a better way to do this | 75 | // TODO(ogniK): Figure out a better way to do this |
| 71 | std::transform(input.begin(), input.end(), transformed_font.begin(), | 76 | std::transform(input.begin(), input.end(), transformed_font.begin(), |
| 72 | [&KEY](u32 font_data) { return Common::swap32(font_data ^ KEY); }); | 77 | [&KEY](u32 font_data) { return Common::swap32(font_data ^ KEY); }); |
| 73 | transformed_font[1] = Common::swap32(transformed_font[1]) ^ KEY; // "re-encrypt" the size | 78 | std::memcpy(output.data(), transformed_font.data() + 2, |
| 74 | std::memcpy(output.data(), transformed_font.data() + 2, transformed_font.size() * sizeof(u32)); | 79 | (transformed_font.size() - 2) * sizeof(u32)); |
| 75 | } | 80 | } |
| 76 | 81 | ||
| 77 | void EncryptSharedFont(const std::vector<u32>& input, std::vector<u8>& output, | 82 | void EncryptSharedFont(const std::vector<u32>& input, std::vector<u8>& output, |