diff options
author | Zach Hilman <zachhilman@gmail.com> | 2018-08-16 22:58:49 +0200 |
---|---|---|
committer | Zach Hilman <zachhilman@gmail.com> | 2018-08-23 17:52:44 +0200 |
commit | 6dd369ab88efa9f183104cf26304afc940b462cf (patch) | |
tree | 107ff7e41430300a4d05cf00f216e830b252087b /src | |
parent | xci: Fix error masking issue (diff) | |
download | yuzu-6dd369ab88efa9f183104cf26304afc940b462cf.tar yuzu-6dd369ab88efa9f183104cf26304afc940b462cf.tar.gz yuzu-6dd369ab88efa9f183104cf26304afc940b462cf.tar.bz2 yuzu-6dd369ab88efa9f183104cf26304afc940b462cf.tar.lz yuzu-6dd369ab88efa9f183104cf26304afc940b462cf.tar.xz yuzu-6dd369ab88efa9f183104cf26304afc940b462cf.tar.zst yuzu-6dd369ab88efa9f183104cf26304afc940b462cf.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/core/crypto/ctr_encryption_layer.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/core/crypto/ctr_encryption_layer.cpp b/src/core/crypto/ctr_encryption_layer.cpp index 106db02b3..3ea60dbd0 100644 --- a/src/core/crypto/ctr_encryption_layer.cpp +++ b/src/core/crypto/ctr_encryption_layer.cpp @@ -20,10 +20,8 @@ size_t CTREncryptionLayer::Read(u8* data, size_t length, size_t offset) const { if (sector_offset == 0) { UpdateIV(base_offset + offset); std::vector<u8> raw = base->ReadBytes(length, offset); - if (raw.size() != length) - return Read(data, raw.size(), offset); - cipher.Transcode(raw.data(), length, data, Op::Decrypt); - return length; + cipher.Transcode(raw.data(), raw.size(), data, Op::Decrypt); + return raw.size(); } // offset does not fall on block boundary (0x10) @@ -34,7 +32,7 @@ size_t CTREncryptionLayer::Read(u8* data, size_t length, size_t offset) const { if (length + sector_offset < 0x10) { std::memcpy(data, block.data() + sector_offset, std::min<u64>(length, read)); - return read; + return std::min<u64>(length, read); } std::memcpy(data, block.data() + sector_offset, read); return read + Read(data + read, length - read, offset + read); |