summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorZach Hilman <zachhilman@gmail.com>2018-08-26 00:56:25 +0200
committerZach Hilman <zachhilman@gmail.com>2018-09-04 22:21:40 +0200
commit99fbcb3bf2ddeb0e95ee4b7ce891f46f44447af3 (patch)
tree1e33310cb59f8c6b8a0da38854d8581716453ad7 /src/core
parentMerge pull request #1178 from DarkLordZach/nsp (diff)
downloadyuzu-99fbcb3bf2ddeb0e95ee4b7ce891f46f44447af3.tar
yuzu-99fbcb3bf2ddeb0e95ee4b7ce891f46f44447af3.tar.gz
yuzu-99fbcb3bf2ddeb0e95ee4b7ce891f46f44447af3.tar.bz2
yuzu-99fbcb3bf2ddeb0e95ee4b7ce891f46f44447af3.tar.lz
yuzu-99fbcb3bf2ddeb0e95ee4b7ce891f46f44447af3.tar.xz
yuzu-99fbcb3bf2ddeb0e95ee4b7ce891f46f44447af3.tar.zst
yuzu-99fbcb3bf2ddeb0e95ee4b7ce891f46f44447af3.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/crypto/aes_util.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/core/crypto/aes_util.cpp b/src/core/crypto/aes_util.cpp
index 72e4bed67..89ade5000 100644
--- a/src/core/crypto/aes_util.cpp
+++ b/src/core/crypto/aes_util.cpp
@@ -82,11 +82,25 @@ void AESCipher<Key, KeySize>::Transcode(const u8* src, size_t size, u8* dest, Op
}
} else {
const auto block_size = mbedtls_cipher_get_block_size(context);
+ if (size < block_size) {
+ std::vector<u8> block(block_size);
+ std::memcpy(block.data(), src, size);
+ Transcode(block.data(), block.size(), block.data(), op);
+ std::memcpy(dest, block.data(), size);
+ return;
+ }
for (size_t offset = 0; offset < size; offset += block_size) {
auto length = std::min<size_t>(block_size, size - offset);
mbedtls_cipher_update(context, src + offset, length, dest + offset, &written);
if (written != length) {
+ if (length < block_size) {
+ std::vector<u8> block(block_size);
+ std::memcpy(block.data(), src + offset, length);
+ Transcode(block.data(), block.size(), block.data(), op);
+ std::memcpy(dest + offset, block.data(), length);
+ return;
+ }
LOG_WARNING(Crypto, "Not all data was decrypted requested={:016X}, actual={:016X}.",
length, written);
}