diff options
author | bunnei <bunneidev@gmail.com> | 2020-08-06 04:35:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-06 04:35:41 +0200 |
commit | 35c1607f231cab060305e79f434ef15442c162f1 (patch) | |
tree | 0a2af713d7f5ca2b0c0bbe45176c112ae9ba2b03 /src/core/crypto/ctr_encryption_layer.cpp | |
parent | Merge pull request #4477 from lioncash/log-desig (diff) | |
parent | aes_util: Allow SetIV to be non-allocating (diff) | |
download | yuzu-35c1607f231cab060305e79f434ef15442c162f1.tar yuzu-35c1607f231cab060305e79f434ef15442c162f1.tar.gz yuzu-35c1607f231cab060305e79f434ef15442c162f1.tar.bz2 yuzu-35c1607f231cab060305e79f434ef15442c162f1.tar.lz yuzu-35c1607f231cab060305e79f434ef15442c162f1.tar.xz yuzu-35c1607f231cab060305e79f434ef15442c162f1.tar.zst yuzu-35c1607f231cab060305e79f434ef15442c162f1.zip |
Diffstat (limited to 'src/core/crypto/ctr_encryption_layer.cpp')
-rw-r--r-- | src/core/crypto/ctr_encryption_layer.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/core/crypto/ctr_encryption_layer.cpp b/src/core/crypto/ctr_encryption_layer.cpp index 902841c77..5c84bb0a4 100644 --- a/src/core/crypto/ctr_encryption_layer.cpp +++ b/src/core/crypto/ctr_encryption_layer.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <algorithm> #include <cstring> #include "common/assert.h" #include "core/crypto/ctr_encryption_layer.h" @@ -10,8 +11,7 @@ namespace Core::Crypto { CTREncryptionLayer::CTREncryptionLayer(FileSys::VirtualFile base_, Key128 key_, std::size_t base_offset) - : EncryptionLayer(std::move(base_)), base_offset(base_offset), cipher(key_, Mode::CTR), - iv(16, 0) {} + : EncryptionLayer(std::move(base_)), base_offset(base_offset), cipher(key_, Mode::CTR) {} std::size_t CTREncryptionLayer::Read(u8* data, std::size_t length, std::size_t offset) const { if (length == 0) @@ -39,9 +39,8 @@ std::size_t CTREncryptionLayer::Read(u8* data, std::size_t length, std::size_t o return read + Read(data + read, length - read, offset + read); } -void CTREncryptionLayer::SetIV(const std::vector<u8>& iv_) { - const auto length = std::min(iv_.size(), iv.size()); - iv.assign(iv_.cbegin(), iv_.cbegin() + length); +void CTREncryptionLayer::SetIV(const IVData& iv_) { + iv = iv_; } void CTREncryptionLayer::UpdateIV(std::size_t offset) const { |