summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2021-04-23 11:37:17 -0700
committerGravatar GitHub2021-04-23 11:37:17 -0700
commit51c787bfc1741b737a02266e9d0176945f0193f4 (patch)
tree7fb1b4ceb464b32bd21b28a0ac2c7f57e28f2ae7
parentMerge pull request #6232 from lioncash/alias2 (diff)
parentaes_util: Make use of std::span (diff)
downloadyuzu-51c787bfc1741b737a02266e9d0176945f0193f4.tar.gz
yuzu-51c787bfc1741b737a02266e9d0176945f0193f4.tar.xz
yuzu-51c787bfc1741b737a02266e9d0176945f0193f4.zip
Merge pull request #6231 from lioncash/aes
aes_util: Make use of std::span
Diffstat (limited to '')
-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*
119} 119}
120 120
121template <typename Key, std::size_t KeySize> 121template <typename Key, std::size_t KeySize>
122void AESCipher<Key, KeySize>::SetIVImpl(const u8* data, std::size_t size) { 122void AESCipher<Key, KeySize>::SetIV(std::span<const u8> data) {
123 ASSERT_MSG((mbedtls_cipher_set_iv(&ctx->encryption_context, data, size) || 123 ASSERT_MSG((mbedtls_cipher_set_iv(&ctx->encryption_context, data.data(), data.size()) ||
124 mbedtls_cipher_set_iv(&ctx->decryption_context, data, size)) == 0, 124 mbedtls_cipher_set_iv(&ctx->decryption_context, data.data(), data.size())) == 0,
125 "Failed to set IV on mbedtls ciphers."); 125 "Failed to set IV on mbedtls ciphers.");
126} 126}
127 127
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 @@
5#pragma once 5#pragma once
6 6
7#include <memory> 7#include <memory>
8#include <span>
8#include <type_traits> 9#include <type_traits>
9#include "common/common_types.h" 10#include "common/common_types.h"
10#include "core/file_sys/vfs.h" 11#include "core/file_sys/vfs.h"
@@ -33,10 +34,7 @@ public:
33 AESCipher(Key key, Mode mode); 34 AESCipher(Key key, Mode mode);
34 ~AESCipher(); 35 ~AESCipher();
35 36
36 template <typename ContiguousContainer> 37 void SetIV(std::span<const u8> data);
37 void SetIV(const ContiguousContainer& container) {
38 SetIVImpl(std::data(container), std::size(container));
39 }
40 38
41 template <typename Source, typename Dest> 39 template <typename Source, typename Dest>
42 void Transcode(const Source* src, std::size_t size, Dest* dest, Op op) const { 40 void Transcode(const Source* src, std::size_t size, Dest* dest, Op op) const {
@@ -60,8 +58,6 @@ public:
60 std::size_t sector_size, Op op); 58 std::size_t sector_size, Op op);
61 59
62private: 60private:
63 void SetIVImpl(const u8* data, std::size_t size);
64
65 std::unique_ptr<CipherContext> ctx; 61 std::unique_ptr<CipherContext> ctx;
66}; 62};
67} // namespace Core::Crypto 63} // namespace Core::Crypto