diff options
author | liushuyu <liushuyu011@gmail.com> | 2022-09-11 01:38:36 +0200 |
---|---|---|
committer | Narr the Reg <juangerman-13@hotmail.com> | 2022-09-11 01:56:29 +0200 |
commit | aa11d73bba386076973010ba4c60d5b04ba828a3 (patch) | |
tree | 9d04e02b4384221b3f6567b193d587f980714ac7 /src/dedicated_room | |
parent | fix black icon (diff) | |
download | yuzu-aa11d73bba386076973010ba4c60d5b04ba828a3.tar yuzu-aa11d73bba386076973010ba4c60d5b04ba828a3.tar.gz yuzu-aa11d73bba386076973010ba4c60d5b04ba828a3.tar.bz2 yuzu-aa11d73bba386076973010ba4c60d5b04ba828a3.tar.lz yuzu-aa11d73bba386076973010ba4c60d5b04ba828a3.tar.xz yuzu-aa11d73bba386076973010ba4c60d5b04ba828a3.tar.zst yuzu-aa11d73bba386076973010ba4c60d5b04ba828a3.zip |
Diffstat (limited to 'src/dedicated_room')
-rw-r--r-- | src/dedicated_room/yuzu_room.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/dedicated_room/yuzu_room.cpp b/src/dedicated_room/yuzu_room.cpp index 8d8ac1ed7..359891883 100644 --- a/src/dedicated_room/yuzu_room.cpp +++ b/src/dedicated_room/yuzu_room.cpp @@ -76,8 +76,18 @@ static constexpr char BanListMagic[] = "YuzuRoom-BanList-1"; static constexpr char token_delimiter{':'}; static void PadToken(std::string& token) { - const auto remainder = token.size() % 3; - for (size_t i = 0; i < (3 - remainder); i++) { + std::size_t outlen = 0; + + std::array<unsigned char, 512> output{}; + std::array<unsigned char, 2048> roundtrip{}; + for (size_t i = 0; i < 3; i++) { + mbedtls_base64_decode(output.data(), output.size(), &outlen, + reinterpret_cast<const unsigned char*>(token.c_str()), + token.length()); + mbedtls_base64_encode(roundtrip.data(), roundtrip.size(), &outlen, output.data(), outlen); + if (memcmp(roundtrip.data(), token.data(), token.size()) == 0) { + break; + } token.push_back('='); } } |