diff options
Diffstat (limited to 'src/core/crypto')
| -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 { | |||
| 20 | if (sector_offset == 0) { | 20 | if (sector_offset == 0) { |
| 21 | UpdateIV(base_offset + offset); | 21 | UpdateIV(base_offset + offset); |
| 22 | std::vector<u8> raw = base->ReadBytes(length, offset); | 22 | std::vector<u8> raw = base->ReadBytes(length, offset); |
| 23 | if (raw.size() != length) | 23 | cipher.Transcode(raw.data(), raw.size(), data, Op::Decrypt); |
| 24 | return Read(data, raw.size(), offset); | 24 | return raw.size(); |
| 25 | cipher.Transcode(raw.data(), length, data, Op::Decrypt); | ||
| 26 | return length; | ||
| 27 | } | 25 | } |
| 28 | 26 | ||
| 29 | // offset does not fall on block boundary (0x10) | 27 | // 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 { | |||
| 34 | 32 | ||
| 35 | if (length + sector_offset < 0x10) { | 33 | if (length + sector_offset < 0x10) { |
| 36 | std::memcpy(data, block.data() + sector_offset, std::min<u64>(length, read)); | 34 | std::memcpy(data, block.data() + sector_offset, std::min<u64>(length, read)); |
| 37 | return read; | 35 | return std::min<u64>(length, read); |
| 38 | } | 36 | } |
| 39 | std::memcpy(data, block.data() + sector_offset, read); | 37 | std::memcpy(data, block.data() + sector_offset, read); |
| 40 | return read + Read(data + read, length - read, offset + read); | 38 | return read + Read(data + read, length - read, offset + read); |