summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-04-23 20:37:17 +0200
committerGitHub <noreply@github.com>2021-04-23 20:37:17 +0200
commit51c787bfc1741b737a02266e9d0176945f0193f4 (patch)
tree7fb1b4ceb464b32bd21b28a0ac2c7f57e28f2ae7 /src/core
parentMerge pull request #6232 from lioncash/alias2 (diff)
parentaes_util: Make use of std::span (diff)
downloadyuzu-51c787bfc1741b737a02266e9d0176945f0193f4.tar
yuzu-51c787bfc1741b737a02266e9d0176945f0193f4.tar.gz
yuzu-51c787bfc1741b737a02266e9d0176945f0193f4.tar.bz2
yuzu-51c787bfc1741b737a02266e9d0176945f0193f4.tar.lz
yuzu-51c787bfc1741b737a02266e9d0176945f0193f4.tar.xz
yuzu-51c787bfc1741b737a02266e9d0176945f0193f4.tar.zst
yuzu-51c787bfc1741b737a02266e9d0176945f0193f4.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/crypto/aes_util.cpp6
-rw-r--r--src/core/crypto/aes_util.h8
2 files changed, 5 insertions, 9 deletions
diff --git a/src/core/crypto/aes_util.cpp b/src/core/crypto/aes_util.cpp
index cb7506241..85a666de9 100644
--- a/src/core/crypto/aes_util.cpp
+++ b/src/core/crypto/aes_util.cpp
@@ -119,9 +119,9 @@ void AESCipher<Key, KeySize>::XTSTranscode(const u8* src, std::size_t size, u8*
}
template <typename Key, std::size_t KeySize>
-void AESCipher<Key, KeySize>::SetIVImpl(const u8* data, std::size_t size) {
- ASSERT_MSG((mbedtls_cipher_set_iv(&ctx->encryption_context, data, size) ||
- mbedtls_cipher_set_iv(&ctx->decryption_context, data, size)) == 0,
+void AESCipher<Key, KeySize>::SetIV(std::span<const u8> data) {
+ ASSERT_MSG((mbedtls_cipher_set_iv(&ctx->encryption_context, data.data(), data.size()) ||
+ mbedtls_cipher_set_iv(&ctx->decryption_context, data.data(), data.size())) == 0,
"Failed to set IV on mbedtls ciphers.");
}
diff --git a/src/core/crypto/aes_util.h b/src/core/crypto/aes_util.h
index e2a304186..230451b8f 100644
--- a/src/core/crypto/aes_util.h
+++ b/src/core/crypto/aes_util.h
@@ -5,6 +5,7 @@
#pragma once
#include <memory>
+#include <span>
#include <type_traits>
#include "common/common_types.h"
#include "core/file_sys/vfs.h"
@@ -33,10 +34,7 @@ public:
AESCipher(Key key, Mode mode);
~AESCipher();
- template <typename ContiguousContainer>
- void SetIV(const ContiguousContainer& container) {
- SetIVImpl(std::data(container), std::size(container));
- }
+ void SetIV(std::span<const u8> data);
template <typename Source, typename Dest>
void Transcode(const Source* src, std::size_t size, Dest* dest, Op op) const {
@@ -60,8 +58,6 @@ public:
std::size_t sector_size, Op op);
private:
- void SetIVImpl(const u8* data, std::size_t size);
-
std::unique_ptr<CipherContext> ctx;
};
} // namespace Core::Crypto