summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2018-08-04 22:49:39 +0200
committerLioncash <mathew1800@gmail.com>2018-08-04 22:49:42 +0200
commitb25468b4980d2e57c5e94808130196542e568282 (patch)
treeeb504e6526e1a9dcc44af7d5f8631b51669975fc
parentcore/crypto: Remove unnecessary includes (diff)
downloadyuzu-b25468b4980d2e57c5e94808130196542e568282.tar
yuzu-b25468b4980d2e57c5e94808130196542e568282.tar.gz
yuzu-b25468b4980d2e57c5e94808130196542e568282.tar.bz2
yuzu-b25468b4980d2e57c5e94808130196542e568282.tar.lz
yuzu-b25468b4980d2e57c5e94808130196542e568282.tar.xz
yuzu-b25468b4980d2e57c5e94808130196542e568282.tar.zst
yuzu-b25468b4980d2e57c5e94808130196542e568282.zip
-rw-r--r--src/core/crypto/aes_util.cpp13
-rw-r--r--src/core/crypto/aes_util.h4
2 files changed, 9 insertions, 8 deletions
diff --git a/src/core/crypto/aes_util.cpp b/src/core/crypto/aes_util.cpp
index 3d939da15..e2dc4acb3 100644
--- a/src/core/crypto/aes_util.cpp
+++ b/src/core/crypto/aes_util.cpp
@@ -58,27 +58,28 @@ void AESCipher<Key, KeySize>::SetIV(std::vector<u8> iv) {
}
template <typename Key, size_t KeySize>
-void AESCipher<Key, KeySize>::Transcode(const u8* src, size_t size, u8* dest, Op op) {
- size_t written = 0;
-
- const auto context = op == Op::Encrypt ? &ctx->encryption_context : &ctx->decryption_context;
+void AESCipher<Key, KeySize>::Transcode(const u8* src, size_t size, u8* dest, Op op) const {
+ auto* const context = op == Op::Encrypt ? &ctx->encryption_context : &ctx->decryption_context;
mbedtls_cipher_reset(context);
+ size_t written = 0;
if (mbedtls_cipher_get_cipher_mode(context) == MBEDTLS_MODE_XTS) {
mbedtls_cipher_update(context, src, size, dest, &written);
- if (written != size)
+ if (written != size) {
LOG_WARNING(Crypto, "Not all data was decrypted requested={:016X}, actual={:016X}.",
size, written);
+ }
} else {
const auto block_size = mbedtls_cipher_get_block_size(context);
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 (written != length) {
LOG_WARNING(Crypto, "Not all data was decrypted requested={:016X}, actual={:016X}.",
length, written);
+ }
}
}
diff --git a/src/core/crypto/aes_util.h b/src/core/crypto/aes_util.h
index 81fa0d73f..bda41b144 100644
--- a/src/core/crypto/aes_util.h
+++ b/src/core/crypto/aes_util.h
@@ -38,11 +38,11 @@ public:
void SetIV(std::vector<u8> iv);
template <typename Source, typename Dest>
- void Transcode(const Source* src, size_t size, Dest* dest, Op op) {
+ void Transcode(const Source* src, size_t size, Dest* dest, Op op) const {
Transcode(reinterpret_cast<const u8*>(src), size, reinterpret_cast<u8*>(dest), op);
}
- void Transcode(const u8* src, size_t size, u8* dest, Op op);
+ void Transcode(const u8* src, size_t size, u8* dest, Op op) const;
template <typename Source, typename Dest>
void XTSTranscode(const Source* src, size_t size, Dest* dest, size_t sector_id,